Revive code

Started by Seravy, November 15, 2008, 02:36:34 PM

Previous topic - Next topic

Seravy

I want to make a character have multiple lives. Meaning when it reaches 0 life, he goes back to maximum a set number of times. I use this code, and it is working, but sometimes, seemingly at random, the character gets KO-d anyway, before he could revive.
So my questions are :
Where to put the minus state part, state -1 or -2, and when exactly is KO checked by the game engine/ how am I supposed to modify the code to make it work for sure/ what causes the KOs when they aren't supposed to happen with NoKo asserted?

[State -1]
Type=Assertspecial
trigger1=var(21)< Number of lives here
trigger1=P2Life !=0
Flag=NoKo
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1
time=20

[State -1]
Type=ChangeState
Trigger1=Life=0
Trigger1=StateNo!=7500
Trigger1=var(21)< Number of lives here
Value=7500
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1

[Statedef 7500]
type     = S                     
movetype = A                     
physics  = S                     
velset   = 0,0                   
ctrl     = 0                     
anim     = 7500

[State 7500]
Type=VarAdd
trigger1=time=0
v=21
value=1
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1

[State 7500]
Type=Lifeadd
Value=25
Trigger1=1
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1

[State 7500]
type = Pause
trigger1 = time = 0
time = 100
movetime = 100
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1

[State 7500]
Type=ChangeState
Trigger1= time>100
Value = 50
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1



Seravy

That...can't be working. That code uses the same state # (9000) for the helper and the player. Besides how is making a helper preventing ko? Anyway I moved my minus triggers to Statedef -2, added a nothitby for life=0, and also added a changestate to 5150 just in case (Though it being in -2 is supposed to be enough), and now it seems to be working. Probably moving it to -2 was what actually mattered.
It looks like this now :
[State -2]
Type=Assertspecial
trigger1=var(21)<11
trigger1=P2Life !=0
Flag=NoKo
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1
time=100

[State -2]
Type=NotHitBy
trigger1=life=0
value= SCA

[State -2]
Type=SelfState
Trigger1=Life=0
Trigger1=StateNo!=7500
Trigger1=var(21)<11
Value=7500
PauseMoveTime=9999
SuperMoveTime=9999
ignorehitpause=1