I snagged the Miraclo code from the Hero file forum and decided that I wanted to try to make it applicable to heroes with attributes other than a speed and strength of 3. I started looking at the superspeed code and made some simple substitutions in the code. But it seems that Hourman loses his enhanced attributes sooner than he should with the timer. I was wondering if there should be a line to tell the computer to check every so often and see if the attribute should still be active. Another solution I was thinking of in place of this code was to write a boost function for speed, energy, strength, jumper and low grade invulnerability. That way, I could have use of the power consume a hero point which is what I would like to use to simulate Hourman's supply of Miraclo pills. Unfortunately, I took a look at the Boost code and I don't understand it at all so I have no idea how to do this.
[spoiler]def initmiraclo(char,update=0):
#combines FFX increased strength, speed and superjumper.
if isMP():
return
if update==0:
#give him the command to take a miraclo pill
Mission_CustomAction('CUSTOM_MIRACLOON',char,char,'hourofpower',5,0)
FFX_ObjectSetAttr(char,'boosted',0)
RegTimer('countdowntimer',1,0,char)
#3600 seconds or 60 minutes.
time=3600
FFX_ObjectSetAttr(char,'hourcount',time)
def hourofpower(dummy,char):
state=FFX_ObjectGetAttr(char,'boosted')
if state==0:
FFX_ObjectSetAttr(char,'boosted',1)
energy=Object_GetAttr(char,'energyPoints')
#energy cost for Miraclo boost
Object_SetAttr(char,'energyPoints',energy-25)
#increase health
FFX_FactorHealth(char,2) # doubles health
Object_SetAttr(char,'strength',Object_GetAttr(char,'strength')+4)
Object_SetAttr(char,'energy',Object_GetAttr(char,'energy')+10)
FFX_ObjectSetAttr(char,'jumpdist',20+Object_GetAttr(char,'baseStrength')*4)
RegTimer('hmupdatejumper',1,0,char)
Mission_RemoveCustomAction('CUSTOM_MIRACLOON',char,char)
#set speed
Object_SetAttr(char,'speed',Object_GetAttr(char,'speed')+4)
# if Hourman is boosted - drop the counter, and when it hits zero return to normal.
def countdowntimer(event):
char=event.object
#check again in one second
RegTimer('countdowntimer',1,0,char)
#if Hourman is boosted, decrement the counter
if FFX_ObjectGetAttr(char,'boosted'):
count=FFX_ObjectGetAttr(char,'hourcount')-1
FFX_ObjectSetAttr(char,'hourcount',count)
if count<=0:
timeisup('',char)
#this then stops him popping another pill - he's done
FFX_ObjectSetAttr(char,'hourcount',0)
#the hour is over, set all stats back to normal
def timeisup(dummy,char):
state=FFX_ObjectGetAttr(char,'boosted')
if state==1:
FFX_ObjectSetAttr(char,'boosted',0)
Object_SetAttr(char,'speed',Object_GetAttr(char,'speed')-4)
Object_SetAttr(char,'strength',Object_GetAttr(char,'strength')-4)
Object_SetAttr(char,'energy',Object_GetAttr(char,'energy')-10)
FFX_ObjectSetAttr(char,'jumpdist',0+Object_GetAttr(char,'baseStrength')*0)
RegTimer('hmupdatejumperoff',1,0,char)
removeCommand('CUSTOM_MIGHTYJUMP',char)
def hmupdatejumper(event):
char=event.object
update=event.user
radius=FFX_ObjectGetAttr(char,'jumpdist',30)
addCommand('CUSTOM_MIGHTYJUMP',char,'onhmjumpto',radius,update)
def hmupdatejumperoff(event):
char=event.object
removeCommand('CUSTOM_MIGHTYJUMP',char)
def onhmjumpto(target,char):
pos=GetTargetPos(char,target)
FFX_TP(char,(pos[0],pos[1],500),'FFR_TP2DY',0)
#controls energy cost for Mighty jump
def FFR_TP2DY(event):
char=event.object
# print 'ffx_tp2:char=%s'%(char)
Object_SetAttr(char,'strength',FFX_ObjectGetAttr(char,'jumpStrength'))
Object_SetAttr(char,'speed',FFX_ObjectGetAttr(char,'jumpSpeed'))
energy=Object_GetAttr(char,'energyPoints')
#energy cost
Object_SetAttr(char,'energyPoints',energy-50)
pos=Get_ObjectPos(char)
FFX_ObjectSetAttr(char,'lastY',pos[1])
FFX_ObjectSetAttr(char,'lastX',pos[0])
[/spoiler]
Hmmm, I've never set a timer to one hour, but the check every single second might be unneeded (those timers leech resources, so if we can avoid the without undue pain...) Example (not tested):
initmiraclo(char,update=0):
#combines FFX increased strength, speed and superjumper.
#give him the command to take a miraclo pill
Mission_CustomAction('CUSTOM_MIRACLOON',char,char,'hourofpower',5,1)
def hourofpower(dummy,char):
energy=Object_GetAttr(char,'energyPoints')
#energy cost for Miraclo boost
Object_SetAttr(char,'energyPoints',energy-25)
#increase health
FFX_FactorHealth(char,2) # doubles health
Object_SetAttr(char,'strength',Object_GetAttr(char,'strength')+4)
Object_SetAttr(char,'energy',Object_GetAttr(char,'energy')+10)
FFX_ObjectSetAttr(char,'jumpdist',20+Object_GetAttr(char,'baseStrength')*4)
RegTimer('hmupdatejumper',1,0,char)
#set speed
Object_SetAttr(char,'speed',Object_GetAttr(char,'speed')+4)
#3600 seconds or 60 minutes.
RegTimer('timeisup',3600,0,char)
#the hour is over, set all stats back to normal
def timeisup(event):
char=event.object
Object_SetAttr(char,'speed',Object_GetAttr(char,'speed')-4)
Object_SetAttr(char,'strength',Object_GetAttr(char,'strength')-4)
Object_SetAttr(char,'energy',Object_GetAttr(char,'energy')-10)
FFX_ObjectSetAttr(char,'jumpdist',0+Object_GetAttr(char,'baseStrength')*0)
removeCommand('CUSTOM_MIGHTYJUMP',char)
def hmupdatejumper(event):
char=event.object
update=event.user
radius=FFX_ObjectGetAttr(char,'jumpdist',30)
addCommand('CUSTOM_MIGHTYJUMP',char,'onhmjumpto',radius,update)
def onhmjumpto(target,char):
pos=GetTargetPos(char,target)
FFX_TP(char,(pos[0],pos[1],500),'FFR_TP2DY',0)
#controls energy cost for Mighty jump
def FFR_TP2DY(event):
char=event.object
Object_SetAttr(char,'strength',FFX_ObjectGetAttr(char,'jumpStrength'))
Object_SetAttr(char,'speed',FFX_ObjectGetAttr(char,'jumpSpeed'))
energy=Object_GetAttr(char,'energyPoints')
#energy cost
Object_SetAttr(char,'energyPoints',energy-50)
pos=Get_ObjectPos(char)
FFX_ObjectSetAttr(char,'lastY',pos[1])
FFX_ObjectSetAttr(char,'lastX',pos[0])
There are a few other problems with that code, though, such as not checking the validity of the values in the new stats. A better method, as you point out, would be to use a Boost attribute or, better yet, Accidental Change/Accidental Form. Using that last method, you could add the relevant attributes ans stats directly to the template. The only code needed would be to duplicate the isMinuteUp() code to last 3600 seconds (which is a tad excessive in gameplay terms, IMHO, but that's strictly a personal viewpoint):
In ffx.py:
def isHourUp(obj,char=''):
t=1+FFX_ObjectGetAttr(obj,'acctime')
FFX_ObjectSetAttr(obj,'acctime',t)
t=3600-t
if t % 60 == 0:
Mission_StatusText('%d mins.'% int(t/60))
elif t < 6:
Mission_StatusText('%d'%t)
return t<0
In ffxdefault.py, under FFX_TRIGGERS=[, after
["isMinuteUp"], add the line:
["isHourUp"],
And run the character thourgh the Control Centre to select isHourUp
Hmm... I think a Boost function would be more what I'm looking for. Could anyone explain how the boost functions are written? I've looked at them a few times and they don't make much sense to me.