YesNoOk
avatar

Change State if enemy is alive or Back to idle state if Enemy is not alive  (Read 1770 times)

Started by Lucastyle, April 24, 2024, 09:12:16 am
Share this topic:
Change State if enemy is alive or Back to idle state if Enemy is not alive
#1  April 24, 2024, 09:12:16 am
  • avatar
    • Australia
So This is my first post but i need help on how to do this part where if the attack is sucessful in defeating the enemy it must return to its idle state or 0 when animation is finished or if the enemy is still alive then it will change its state to the next attack that it will execute. This is the code:
Code:
[Statedef 2100, Final Attack]
type    = S
movetype= A
physics = S
juggle  = 0
velset = 0,0
ctrl = 0
sprpriority = 4
anim=2100
hitdefpersist=1
movehitpersist=1


[State 0, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT,AA,AP,AT
;ignorehitpause =
;persistent =

[state ]
type=playsnd
trigger1=animelem=2
value=7000,0

[state ]
type=playsnd
trigger1=animelem=6
value=7000,0

[state ]
type=playsnd
trigger1=animelem=9
value=7000,0

[state ]
type=playsnd
trigger1=animelem=9
value=7000,1

[state ]
type=playsnd
trigger1=animelem=16
value=7000,2

[State 0, Explod]
type = Explod
trigger1 = AnimElem = 15
anim = 16933
ID = 16933
pos = 0,-40
postype = P1  ;P2, Front, Back, Left, Right
facing = 1
vfacing = 1
bindtime = -1
removetime = -2
supermovetime = 99999
pausemovetime = 99999
scale = 1,1
sprpriority = 999
ontop = 1
ownpal = 1
;ignorehitpause =
;persistent =

[State 0, Explod]
type = Explod
trigger1 = AnimElem = 15
anim = 7070
ID = 7070
pos = 6,-40
postype = P1  ;P2, Front, Back, Left, Right
bindtime = -1
removetime = -2
supermovetime = 99999
pausemovetime = 99999
scale = .5,.5
sprpriority = 0
ontop = 1
ownpal = 1
;ignorehitpause =
;persistent =

[State 0, EnvShake]
type = EnvShake
trigger1 = AnimElem = 15
time = 160
freq =500
ampl=50
;ignorehitpause =
;persistent =


[State 2OS, Fade to White]
type=allpalfx
trigger1=AnimElem = 2
time=10 ;; 2 actual seconds
sinadd=256,256,256,-10 ;; 1st value red, 2nd green, 3rd blue, 4th fade speed time, 10 is slow, raise it to be faster if desired
add = 256,256,256
invertall=0
color=256
ignorehitpause=1
persistent=1




[State 2OS, Fade to White]
type=allpalfx
trigger1=AnimElem = 4
time=10 ;; 2 actual seconds
sinadd=256,256,256,-10 ;; 1st value red, 2nd green, 3rd blue, 4th fade speed time, 10 is slow, raise it to be faster if desired
add = 256,256,256
invertall=0
color=256
ignorehitpause=1
persistent=1



[State 2OS, Fade to White]
type=allpalfx
trigger1=AnimElem = 6
time=10 ;; 2 actual seconds
sinadd=256,256,256,-10 ;; 1st value red, 2nd green, 3rd blue, 4th fade speed time, 10 is slow, raise it to be faster if desired
add = 256,256,256
invertall=0
color=256
ignorehitpause=1
persistent=1

[State 2OS, Fade to White]
type=allpalfx
trigger1=AnimElem = 9
time=10 ;; 2 actual seconds
sinadd=256,256,256,-10 ;; 1st value red, 2nd green, 3rd blue, 4th fade speed time, 10 is slow, raise it to be faster if desired
add = 256,256,256
invertall=0
color=256
ignorehitpause=1
persistent=1

[State 24123, 2]
type = Projectile
trigger1 = AnimElem = 16
priority = 999, Hit
projremove = 10
projremovetime = 425
projhits = 999999
projmisstime = 0
projanim = 88888
projhitanim = 88888
projid = 88888
projpriority = 999999
projshadow = 0,0,0
projremanim = -1
projedgebound = 999999
projstagebound = 999999
projheightbound = -240, 1
supermovetime = 999999
pausemovetime = 999999
offset = 0,0
velocity = 0,0         ;????????
attr = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT,AA,AP,AT
damage   = 999999
animtype = Hard
sparkno = -1
hitflag = MAFDPLH
guardflag = HA
hitsound   = -1
pausetime = 0, 200            ;??????????????????(??,??)
sparkxy = 35,-15
numhits = 1
ground.type = High
ground.slidetime = 10
ground.hittime  = 10
ground.velocity = 0.0
getpower = 0, 0
givepower = -9999999999,-99999999
fall = 100
fall.damage = 99999999999
projpriority = 5
projshadow = 0,0,0
projremovetime = -1


[State 2100, Change State]
type=changestate
triggerall=animtime=0
trigger1=enemy,alive<0
value=0
ctrl=1

[State 2100, Change State]
type=changestate
triggerall=animtime=0
trigger1=enemy,alive>=1
value=2220
ctrl=1

The main problem is that it keeps repeating the animation if the enemy is dead or not and tried solving multiple times
Im hoping i would get an answer and see if i can figure it out or i have to change my plans otherwise thanks.
Last Edit: April 24, 2024, 01:37:12 pm by Lucastyle
Re: Change State if enemy is alive or Back to idle state if Enemy is not alive
#2  April 24, 2024, 01:06:14 pm
  • *****
  • Shame on you!
    • USA

  • Online
have you tried adding
target,life = 0
as an additional trigger?
You may also want to add a changestate where if the target has less health than the hitdef is going to cause it'll switch over.

You might be dealing with roundstate also. The match could be considered over by the time the changestates happen?
vVv Ryuko718 Updated 10/31/22 vVv
Re: Change State if enemy is alive or Back to idle state if Enemy is not alive
#3  April 24, 2024, 01:36:29 pm
  • avatar
    • Australia
Thanks alot i was able to execute it perfectly, should have known to add roundstate instead.

[State 2100, Change State]
type=changestate
triggerall=roundstate = 3
trigger1=enemy,alive = 0
value=0
ctrl=1

[State 2100, Change State]
type=changestate
triggerall=animtime=0
trigger1=enemy,alive >= 1
value=2220
ctrl=1