YesNoOk
avatar

Coding: Helper-Type Projectile spawning another Helper-Type Projectile (Read 6552 times)

Started by Redash, March 11, 2018, 09:48:28 am
Share this topic:
Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#1  March 11, 2018, 09:48:28 am
  • avatar
  • **
    • Singapore
Hi,

I coding a rocket with 9 sprite frames that is seperated into 2 anims (1010 & 1011)

State:1010 to play Anim:1010
= will first go to sky move horizontally towards enemy Pos X a random distance

On 5th frame, there is a VelAdd:
Trigger = AnimElem = 5
X = 1 + (random % 9)

Then 1010 ChangeState to 1011 when AnimTime = 0

State:1011 to play Anim:1011
= dive down and creates an small AOE explosion (this explosion is coded as a stationary Helper-type projectile)
= the Helper-type projectile is called in State:1011

Problem:
Anim:1011 sprites all play on where Anim:1010 is launched (which also happens to be ontop on my char), instead of the suppose new location "travelled" by anim:1010 final sprite frame (the 5th anim Elem)...

Then the helper-type explosion also appear where my char is instead of the "supposed" travelled position...

What am i missing?
Last Edit: March 14, 2018, 05:22:45 am by Redash
Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#2  March 11, 2018, 02:37:03 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Have the helper create the helper.

Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#3  March 12, 2018, 07:45:52 am
  • avatar
  • **
    • Singapore
Hi altoiddealer,

Am i creating the helper-type projectile (small aoe explosion) from the helper-type projectile (rocket) correctly?

State:1010 (rocket 1st half anim with vel X > 0) ==(changestate)==> State:1011(rocket 2nd half anim with vel X = 0, calls state:1012 for explosion helper, destroyself when animtime = 0)
Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#4  March 12, 2018, 09:50:00 am
  • *****
  • Shame on you!
    • USA
So what I am imagining seems to be possible all from with in 1 state.
Are you using multiple sprites for the explosion? If the missile disappears and becomes only an explosion, you can just change animations.

It sounds as if your 1010 animation isn't reaching the ground. Because it's animation time = 0 it switches to 1011 too early. You may want to add a trigger to monitor where the missile is in the air. This way it MUST be on the ground to switch.
trigger1 = pos y >= 0
Because your speed can be 2 through 10 you may get to the floor before the animation time = 0. You may want to add the pos y as trigger1 along with AnimTime = 0, AND have a pos y trigger by itself in case vel = 10 reaches the floor too fast.

Post your  type = Helper code here. You may be using P1 as the spawn point. You could probably just use rootdist as the adjustment. I'm not positive.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#5  March 12, 2018, 12:48:25 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Spawning stuff is, by default, Postype = p1 --- which is, at the location of whatever player has the code.

So from your description it sounds like Player creates a helper, the helper flies off and travels somewhere, but then you make a second helper from the Players state.  Meaning it will spawn at player location, not at the location of the helper.

You can do it the former but then you need to calculate the position like
X = helper(**),Pos X - Pos X

Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#6  March 14, 2018, 05:22:36 am
  • avatar
  • **
    • Singapore
Thanks.both.
I manage to solve the issue now.

Now the visuals are all correct.

I will post the code to share once i clean it up a bit. Sorta messy :^p
Re: Coding: Helper-Type Projectile spawning another Helper-Type Projectile
#7  March 15, 2018, 09:45:53 am
  • avatar
  • **
    • Singapore
The cleaned up code:
Code:

;---------------------------------------------------------------------------
[Statedef 1279, Rocket_Part1_UpAcross]
type = A
movetype = A
physics = N
juggle = 0
poweradd = 0
velset = 0,0
anim = 1265  ; Rocket_Part1_UpAcross
ctrl = 0
sprpriority = 2
;facep2 = 0

[State 1279, AssertSpecial]
type = AssertSpecial
trigger1 = (Time >= 0)
flag = NoShadow
;ignorehitpause =
persistent = 1

[State 1279, Explod_Effect]
type = Explod
trigger1 = (AnimElemTime(1) = 0)
anim = 1264
;id = 1264
pos = -10,0
postype = p1
;facing = 1
;vfacing = 1
bindtime = -1
;vel = 0,0
;accel = 0,0
;random = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
;scale = 1,1
sprpriority = 3
;ontop =
;under =
shadow = 0,0,0
ownpal = 1
removeongethit = 1
ignorehitpause = 0
;trans =
persistent = 0
;supermove =

[State 1279, HitDef]
type = HitDef
trigger1 = (AnimElem = 1)
trigger2 = (AnimElem = 2)
trigger3 = (AnimElem = 3)
trigger4 = (AnimElem = 4)
trigger5 = (AnimElem = 5) ; last frame with 8 ticks
attr = A,SP
hitflag = MAFP
guardflag = MA
;affectteam = E
animtype = Back
air.animtype = Back
fall.animtype = Back
priority = 21,Hit
damage = 1,3
pausetime = 2,2
guard.pausetime = 0,15
;sparkno =
;guard.sparkno =
;sparkxy = 0,0
hitsound = S1,0
guardsound = S2,0
ground.type = High
air.type = Low
;ground.slidetime = 20
guard.slidetime = 20
ground.hittime = 20
guard.hittime = 20
air.hittime = 20
guard.ctrltime = 20
guard.dist = 200
yaccel = 0.5
ground.velocity = -2,-2
guard.velocity = -2
air.velocity = -2,-2
airguard.velocity = -2,-2
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
down.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
airguard.ctrltime = 20
;air.juggle = 0
;mindist = 0,0
;maxdist = 0,0
;snap = 0,0
;p1facing =
p1getp2facing = 0
;p2facing =
;p1stateno =
;p2stateno =
;p2getp1state = 1
;forcestand = 0
fall = 1
;fall.xvelocity =
;fall.yvelocity = -4.5
fall.recover = 1
fall.recovertime = 60
;fall.damage = 0
air.fall = 1
down.velocity = -2,-2
down.hittime = 20
down.bounce = 1
;id =
;chainID = -1
;nochainID =
hitonce = 0
;kill = 1
;guard.kill = 1
;fall.kill = 1
;numhits = 1
getpower = 0,0
givepower = 0,0
;palfx.time = 0
;palfx.mul =
;palfx.add =
envshake.time = 0
;envshake.freq =
;envshake.ampl =
;envshake.phase =
fall.envshake.time = 0
;fall.envshake.freq =
;fall.envshake.ampl =
;fall.envshake.phase =
ignorehitpause = 0
persistent = 1

[State 1279, VelAdd]
type = VelAdd
trigger1 = (AnimElemTime(5) >= 0)
x = 1 + (Random % 60) ; for 8 ticks then animtime = 0
y = 0
;ignorehitpause =
;persistent =

[State 1279, ChangeState]
type = ChangeState
trigger1 = (AnimTime = 0)
value = 1280
ctrl = 0
;anim =
;ignorehitpause =
;persistent =

;---------------------------------------------------------------------------
[Statedef 1280, Rocket_Part2_DiveDown]
type = A
movetype = A
physics = N
juggle = 0
poweradd = 0
velset = 0,0
anim = 1266  ; Rocket_Part2_DiveDown
ctrl = 0
sprpriority = 2
;facep2 = 0

[State 1280, AssertSpecial]
type = AssertSpecial
trigger1 = (Time >= 0)
flag = NoShadow
;ignorehitpause =
persistent = 1

[State 1280, HitDef]
type = HitDef
trigger1 = (AnimElem = 1)
trigger2 = (AnimElem = 2)
trigger3 = (AnimElem = 3)
trigger4 = (AnimElem = 4)
trigger5 = (AnimElem = 5) ; 2nd last frame
attr = A,SP
hitflag = MAFP
guardflag = MA
;affectteam = E
animtype = Back
air.animtype = Back
fall.animtype = Back
priority = 21,Hit
damage = 1,3
pausetime = 2,2
guard.pausetime = 0,15
;sparkno =
;guard.sparkno =
;sparkxy = 0,0
hitsound = S1,0
guardsound = S2,0
ground.type = High
air.type = Low
;ground.slidetime = 20
guard.slidetime = 20
ground.hittime = 20
guard.hittime = 20
air.hittime = 20
guard.ctrltime = 20
guard.dist = 200
yaccel = 0.5
ground.velocity = -2,-2
guard.velocity = -2
air.velocity = -2,-2
airguard.velocity = -2,-2
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
down.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
airguard.ctrltime = 20
;air.juggle = 0
;mindist = 0,0
;maxdist = 0,0
;snap = 0,0
;p1facing =
p1getp2facing = 0
;p2facing =
;p1stateno =
;p2stateno =
;p2getp1state = 1
;forcestand = 0
fall = 1
;fall.xvelocity =
;fall.yvelocity = -4.5
fall.recover = 1
fall.recovertime = 60
;fall.damage = 0
air.fall = 1
down.velocity = -2,-2
down.hittime = 20
down.bounce = 1
;id =
;chainID = -1
;nochainID =
hitonce = 0
;kill = 1
;guard.kill = 1
;fall.kill = 1
;numhits = 1
getpower = 0,0
givepower = 0,0
;palfx.time = 0
;palfx.mul =
;palfx.add =
envshake.time = 0
;envshake.freq =
;envshake.ampl =
;envshake.phase =
fall.envshake.time = 0
;fall.envshake.freq =
;fall.envshake.ampl =
;fall.envshake.phase =
ignorehitpause = 0
persistent = 1

[State 1280, Explosion]
type = Helper
trigger1 = (AnimElem = 6) ; last frame
;helpertype = normal ;player
name = "Explosion"
id = 1293
stateno = 1293
pos = 0,5
postype = p1
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0
;size.xscale =
;size.yscale =
;size.ground.back =
;size.ground.front =
;size.air.back =
;size.air.front =
;size.height =
;size.proj.doscale =
;size.head.pos = ,
;size.mid.pos = ,
;size.shadowoffset =
ignorehitpause = 1
persistent = 0

[State 1280, DestroySelf]
type = DestroySelf
trigger1 = (AnimTime = 0)
;ignorehitpause =
;persistent =

;---------------------------------------------------------------------------
[Statedef 1293, Explosion]
type = A
movetype = A
physics = N
juggle = 0
poweradd = 0
velset = 0,0
anim = 1267  ; Explosion
ctrl = 0
sprpriority = 2 ; front of Character
;facep2 = 0

[State 1293, PosAdd]
type = PosAdd
trigger1 = (AnimElemTime(1) = 0)
x = 130
y = 0
;ignorehitpause =
persistent = 0

[State 1293, AssertSpecial]
type = AssertSpecial
trigger1 = (Time >= 0)
flag = NoShadow
;ignorehitpause =
persistent = 1

[State 1293, HitDef]
type = HitDef
trigger1 = (HitCount < 1) ; allow only 1 hit, all frames has CLSN1
attr = A,SP
hitflag = MAFDP
guardflag = MA
;affectteam = E
animtype = Up
air.animtype = Up
fall.animtype = Up
priority = 9,Hit
damage = 1,3
pausetime = 2,2
guard.pausetime = 0,20
;sparkno =
;guard.sparkno =
;sparkxy = 0,0
hitsound = S1,0
guardsound = S2,0
ground.type = High
air.type = Low
ground.slidetime = 20
guard.slidetime = 20
ground.hittime = 20
guard.hittime = 20
air.hittime = 20
guard.ctrltime = 20
guard.dist = 200
yaccel = 0.5
ground.velocity = 0,-12
guard.velocity = -12
air.velocity = 0,-12
airguard.velocity = -12,-12
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
down.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
airguard.ctrltime = 20
;air.juggle = 0
;mindist = 0,0
;maxdist = 0,0
;snap = 0,0
;p1facing =
p1getp2facing = 0
;p2facing =
;p1stateno =
;p2stateno =
;p2getp1state = 1
;forcestand = 0
fall = 1
;fall.xvelocity =
;fall.yvelocity = -4.5
fall.recover = 0
;fall.recovertime = 60
;fall.damage = 0
air.fall = 1
down.velocity = 0,-12
down.hittime = 20
down.bounce = 1
;id =
;chainID = -1
;nochainID =
hitonce = 0
;kill = 1
;guard.kill = 1
;fall.kill = 1
;numhits = 1
getpower = 0,0
givepower = 0,0
;palfx.time = 0
;palfx.mul =
;palfx.add =
envshake.time = 0
;envshake.freq = 90
;envshake.ampl = -3
;envshake.phase = 60
fall.envshake.time = 0
;fall.envshake.freq =
;fall.envshake.ampl =
;fall.envshake.phase =
ignorehitpause = 0
persistent = 1

[State 1293, EnvShake]
type = EnvShake
trigger1 = (AnimElem = 1) ; only shake once upon activation, not upon hit
time = 4
freq = 80
ampl = -4
phase = 80
;ignorehitpause =
;persistent =

[State 1293, DestroySelf]
type = DestroySelf
trigger1 = (AnimTime = 0)
;ignorehitpause =
;persistent =

[\code]