News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Getting a Helper or Projectile to Aim At Other Helpers?

Started by Afterthought, March 16, 2018, 04:44:33 AM

Previous topic - Next topic

Afterthought

This should be a bit easier than my previous venture (keyword should). This is split into two parts:

1. I'm aware that using NumHelper can limit the amount of helpers with a set ID that are visible onscreen at a time. What I'd like to know is if there's a way to make it so, if there are X amount of helpers on screen, regardless of ID, a character would no longer be able to create another helper until an existing one is destroyed; or better yet, making it so activating a new helper after the limit would automatically destroy an existing one. Would it be as easy as using NumHelper < X without specifying an ID? (Pretty sure that is the solution but it doesn't hurt to ask.)

2. I am also aware helpers have ID that we, the coders, assign to them. And creating projectiles or helpers that can home in on characters is also possible - something I'm still struggling with at the moment, but I need it for what I'm attempting: how would one code a helper or projectile that can home in on another helper? Optimally I'd like to make it so the proj/helper in questions moves directly toward the nearest existing helper, and depending on how many are on screen, it would move in sequence and contact each; when there aren't anymore, it would set course for P2. I have no doubt IDs would play a strong part, but as for targeting and VelSetting, AngleSetting, etc. I'm a bit shaky.

Hopefully this isn't more difficult to pull off than what I'm imagining. Any help is appreciated.

altoiddealer

1.  NumHelper does not require an ID, and it works like you stated.  In the destroyself, the trigger would have to be root,numhelper > X OR parent,numhelper > X
2. The Vel values would be calculated by comparing current Pos against the target helper's Pos, using trigger redirection.  Although I think nearby enemy helpers will also trigger P2Dist (instead of a specific target).  If you have existing homing code I could probably help adjust the equation


Odb718

I think Team Z's Piccolo has a move that works similarly. The orbs/balls are put out. If one's close to another it moves. Pretty sure there was a LOT involved with that. I think JNP may have simplified it though.

My Samus has tracking missiles. They're a little different. They aim for the mid-chest and once they go past P2 they stop tracking. I used multiple images and multiple angles for my missiles combining them into 1 moving homing missile. Basically You set the values based on P2's pos y compared to helper's pos y. and the 2 Xs if you want it to turn around.


Getting the helpers to not spawn is 1 line of code in the CMD.
Getting them to go toward the original one that's spawned should be easy enough. But I'm not sure what you mean by
"....and depending on how many are on screen, it would move in sequence and contact each; when there aren't anymore, it would set course for P2. "
How would the game know/decide that enough were there? Do you need more than 1 to track/attack P2?
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

@[user id=10719]Odb718[/user]: I need just one to track P2. It'd just make a few pit stops along the way. I'm banking on using NumHelper to actually set a limit; I'm not entirely sure, after the fact, if there IS a way to tell the game that there's enough on screen. That's why I asked in the first place. Maybe I can use a variable or two and even more NumHelper triggers? When the moving proj/helper contacts an already existing helper it would add to a variable and then when said variable hits a limit and there are no more helpers on screen, it would go toward P2.

@[user id=81778]altoiddealer[/user]: I don't have anything aside from the handful of homing codes I've seen floating around MFG. I should clarify, though: I don't need the proj/helper to HOME so much as I need it to AIM. The helpers it is targeting would be stationary; P2 obviously wouldn't be, but aiming at them afterward would suffice.

Odb718

This is the concept you're not clarifying;
".... when said variable hits a limit and there are no more helpers on screen, it would go toward P2."
If there are 0 helpers on the screen, 0 helpers will move towards P2. Are you meaning to say the helpers who are grouped up dont count and are outside of the 0 helpers? so
4 helpers, 3 are grouped, the 3 don't move. 4th helper touches the group, they all move??

TriggerAll = NumHelper(718) = 187
Would fire off once 187 missiles were on the screen. (Which probably wouldn't work)


If you're only trying to aim, you only need to adjust a velset/veladd based off of the P2 dist X and P2 Dist Y. If it goes off on a tangent you only adjust it once. If you want it to home in on P2 add a renewing trigger like time%6 = 0 so it homes in on P2 ten times a second using the same aiming equations. 
vVv Gouken718 vVv SabreTooth718 vVv


altoiddealer

Quote from: Afterthought on March 16, 2018, 12:11:20 PMI should clarify, though: I don't need the proj/helper to HOME so much as I need it to AIM. The helpers it is targeting would be stationary; P2 obviously wouldn't be, but aiming at them afterward would suffice.
So it would just get a one-time VelSet, based on p2 helper's position compared to p1 helper.
Offhand I don't know the formula for that but it should be simple.
But I imagine you would need to either use a Var to simplify the formula, or you would need to use a big chain of nested Cond statements like:

x = Cond(enemy(0),IsHelper,(enemy(0),Pos X - Pos X),(Cond(enemy(1),IsHelper,(enemy(1),Pos X - Pos X),Cond(enemy(2),IsHelper,(enemy(2),Pos X - Pos X))))))
^ NOT the correct formula, but you would do this to find the nearest enemy helper.  You would also need to factor in "numenemy(*)" to prevent errors.

So probably better off with something like

Type = Null
trigger1 = numenemy(10)
trigger1 = enemy(10),IsHelper
trigger1 = var(10) := 10
trigger2 = numenemy(9)
trigger2 = enemy(9),IsHelper
trigger2 = var(10) := 9
trigger3 = numenemy(8)
trigger3 = enemy(8),IsHelper
trigger3 = var(10) := 8
...etc. Note its higher to lower because the lower ones will trigger last.

x = enemy(var(10)),Pos X - Pos X
(not the correct formula just the concept again)


Afterthought

But what if the helpers are generated by P1? That's what's going on currently; I should have specified that as well. It'll have no effect on any helper aside from the ones P1 has created.

Odb718

This goes in your missile
Spoiler (click to show)
[State 718, ParentVarSet]
type = ParentVarSet
triggerall = parent,fvar(23) = 0
trigger1 = time = 1
fv = 23
value = pos x
;[State 0, VarSet]
;type = VarSet
;triggerall = fvar(10) != fvar(23)+1000.0
;trigger1 = time = 2
;fv = 10    ;fv = 10
;value = parent,fvar(23)+1000.0
;^^^^Dont mind this for now^^^^
[State 0, VelAdd]
type = Velset
trigger1 = parent,fvar(23) != 0
trigger1 = pos x != parent,fvar(23)
trigger1 = time%3 = 0
x = floor((parent,fvar(23)-pos x)/10)
y = 0
ignorehitpause = 1
;persistent =
This goes in statedef -2
Spoiler (click to show)

[State -2, VarSet]
type = VarSet
trigger1 = fvar(23) != 0 ;this is going to keep track of things
trigger1 = numhelper(7050) <= 0  ;this is your missile
fv = 23   
value = 0
ignorehitpause = 1

Right now this has 2 big flaws.
If the screen moves everything kinda messes up.
&
There has to be 0 missiles on the stage for it to start over.
I'm not sure if the "Original" missile, the one that set's it's pos x to fvar(23), can be destroyed, but all of them will go there if it's gone or not if another missile is on screen when it's destroyed.

I was trying to think of a way to determine if the missiles could sort themselves out. Maybe gametime. Like you have an additional parent,fvar that's 0 when there are 0. When the first missile's spawned it sets an internal var to gametime. If parent,fvar = 0 it sets it to it's fvar(10). If parent,fvar is less than fvar(10) do nothing.
If parent fvar is greater than fvar(10) set it's pos x to parent,fvar(23). Still kinda confusing myself.
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

@[user id=10719]Odb718[/user]: Yeah, it's confusing to me as well, haha.

In layman's terms, I need what I'm trying to do to work like Doctor Strange's Grace of Hoggoth/Flames of the Faltine. That might give a better idea of what I'm attempting.

EDIT: Three helpers: two stationary, one that moves. The moving one will aim at and move toward the stationary ones, then go in P2's direction after contacting the last existing helper.

Odb718

Did you try my code? I'm like 70% done with coming up with how to keep track of which missile is the oldest.
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

I did. Seems bound to P1 and moves BEHIND P1 whenever P2 gets closer.

EDIT: Revised my previous post to be a bit more specific. This sounds doable, all I need is a solid way for one helper (projectile?) to track the existence of the other helpers and move toward them. Not entirely sure which triggers to use.

JustNoPoint

I find it easiest to have the helpers spawned from a helper maker.

So all 3 of these helpers would come from a helper attached to the root that fires them. I did this for Piccolo trap shot interaction and for all 5 ghosts in Gotenks so they know which is oldest of 5 and know where the other ghosts are in position of conga line.

This way you can set vars using their positions and have them communicate to each other through the maker helper.

Afterthought

I'd be willing to try it this way. Currently in the process of having each type of helper load through a master helper.

Would you be willing to help outline this method further? It sounds a lot less convoluted than trying to make it work between entirely different statedefs.

Odb718

Ok I imagined something different. I thought they were all the same helper for some reason. 
Helper S is stationary
Helper T is stationary
Helper M moves.

helper S and T are out. Helper M is just spawned. In M You're going to want something like
Spoiler (click to show)

[State 0, VarSet]
type = VarSet
triggerall = numhelper(7050)
trigger1 = time = 0
v = 10    ;fv = 10
value = pos x - helper(7050),pos x
[State 0, VarSet]
type = VarSet
triggerall = numhelper(6161)
trigger1 = time = 0
v = 16   ;fv = 10
value = pos x - helper(6161),pos x


[State 0, VelSet]
type = VelSet
triggerall = numhelper(7050)
triggerall = numhelper(6161)
trigger1 = time = 0
x =  ifelse(var(10)>var(16), var(10),var(16))
y = 0
;ignorehitpause =
;persistent =

[State 0, VelSet]
type = VelSet
triggerall = numhelper(7050)
triggerall = !numhelper(6161)
trigger1 = time = 0
x = var(10)
y = 0
;ignorehitpause =
;persistent =

[State 0, VelSet]
type = VelSet
triggerall = !numhelper(7050)
triggerall = numhelper(6161)
trigger1 = time = 0
x = var(16)
y = 0
;ignorehitpause =
;persistent =
Edit the actual values of var(10) and var(16) to be the aiming equations.
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

@[user id=10719]Odb718[/user]: Yeah, they are all separate. I will attempt this code,  just waiting for JNP to input further; right now I'm attempting to have the three helpers summon from a master helper but I'm not having any luck.

Odb718

Are you spawning all 3 at the same time? I honestly dont think you need to do that method. What I posted should be enough. You'll have to tweak it a bit. I doubt it's completely perfect but it's there. It's just 1 helper comparing it's distance x to 2 other helpers. Then it sees which one is better.

I dont see a lot that could mess it up. The only thing I can think of is which side of the screen they're on. So you may need to use screenpos x or something.

Remember to set up displaytoclipboard inside the helpers for debugging. Monitor each and everything you can.
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

This is the current code in its entirety.
Spoiler (click to show)

[code][Statedef 1200]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(32) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = AnimElem = 5
helpertype = normal
name = "Blast Effect"
ID = 1206
stateno = 1206
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1201]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(33) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = AnimElem = 5
helpertype = normal
name = "Blast Effect"
ID = 1207
stateno = 1207
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1202]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(34) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = AnimElem = 5
helpertype = normal
name = "Blast Effect"
ID = 1208
stateno = 1208
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1206]
type = A
movetype = A
physics = N
anim = 4018
velset = 0,0
sprpriority = 99

[State 1201, DestroySelf]
type = DestroySelf
trigger1 =  time > 500
trigger2 = NumHelper > 3

[Statedef 1207]
type = A
movetype = A
physics = N
anim = 4019
velset = 0,0
sprpriority = 99

[State 1201, DestroySelf]
type = DestroySelf
trigger1 =  time > 500
trigger2 = NumHelper > 3
Spoiler (click to show)

[Statedef 1208]
type = A
movetype = A
physics = N
anim = 1301

[State 0]
type = VarSet
triggerall = numhelper (1206)
trigger1 = time = 0
v = 32
value = pos x - helper(1206), pos x

[State 0]
type = VarSet
triggerall = numhelper (1207)
trigger1 = time = 0
v = 33
value = pos x - helper(1207), pos x

[State 0]
type = VelSet
triggerall = numhelper (1206)
triggerall = numhelper (1207)
trigger1 = time = 0
x = ifelse (var(32) > var(33), var(32), var(33))
y = 0
ignorehitpause = 1

[State 0]
type = VelSet
triggerall = numhelper (1206)
triggerall = !numhelper (1207)
trigger1 = time = 0
x = var(32)
y = 0

[State 0]
type = VelSet
triggerall = !numhelper (1206)
triggerall = numhelper (1207)
trigger1 = time = 0
x = var(33)
y = 0


[State 1300, 2]
type = HitDef
trigger1 = time = 0
attr = S,SP
hitflag = MAF
guardflag = MA
animtype = low
priority = 4,Hit
damage = 65,10
pausetime = 18,8
sparkno = -1
guard.sparkno = -1
hitsound = S15,7
guardsound = S15,7
ground.type = Low
ground.slidetime = 18
ground.hittime  = 8
ground.velocity = -18,7
air.velocity = -8,4

[State 0]
type = DestroySelf
trigger1 = movecontact
trigger1 = time > 200

[/code]
Helper 1208 will not spawn with those VelSets if 1206 or 1207 are onscreen. If they aren't on screen, 1208 will appear but not move obviously.

I also have the code attempting to make a master helper that could call the other three helpers depending on command:
Spoiler (click to show)
[code][Statedef 1200]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(32) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = time = 0
helpertype = normal
name = "Blast Effect"
ID = 1205
stateno = 1205
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1201]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(33) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = time = 0
helpertype = normal
name = "Blast Effect"
ID = 1205
stateno = 1205
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1202]
type    = S
movetype= A
physics = S
juggle  = 4
poweradd= 50
ctrl = 0
velset = 0,0
anim = 1200
sprpriority = 0

[State 0]
type = VarSet
trigger1 = time = 0
var(34) = 1

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 2
value = 1000,6

[State 1200, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S1200,0
volume = 255
channel = 5

[State 1200, Helper]
type = Helper
trigger1 = time = 0
helpertype = normal
name = "Blast Effect"
ID = 1205
stateno = 1205
pos = 40,-50
size.xscale = 0.8
size.yscale = 0.8
postype = p1
bindtime = -1

[State 1200, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1205]
type    = S
movetype= H
physics = S

[State 1200, Helper]
type = Helper
trigger1 = root, var(32) = 1
helpertype = normal
name = "Blast Effect"
ID = 1206
stateno = 1206
pos = 0,0
size.xscale = 0.3
size.yscale = 0.3
postype = p1
bindtime = -1

[State 1200, Helper]
type = Helper
trigger1 = root, var(33) = 1
helpertype = normal
name = "Blast Effect"
ID = 1207
stateno = 1207
pos = 0,0
size.xscale = 0.3
size.yscale = 0.3
postype = p1
bindtime = -1

[State 1200, Helper]
type = Helper
trigger1 = root, var(34) = 1
helpertype = normal
name = "Blast Effect"
ID = 1208
stateno = 1208
pos = 0,0
size.xscale = 0.3
size.yscale = 0.3
postype = p1
bindtime = -1

[State 1200, 5]
type = DestroySelf
trigger1 = stateno != 1206 || stateno != 1207 || stateno != 1208
value = 0
ctrl = 1
Spoiler (click to show)

[Statedef 1206]
type = A
movetype = A
physics = N
anim = 4018
velset = 0,0
sprpriority = 99

[State 1201, DestroySelf]
type = DestroySelf
trigger1 =  time > 500
trigger2 = NumHelper > 3
Spoiler (click to show)

[Statedef 1207]
type = A
movetype = A
physics = N
anim = 4019
velset = 0,0
sprpriority = 99

[State 1201, DestroySelf]
type = DestroySelf
trigger1 =  time > 500
trigger2 = NumHelper > 3
Spoiler (click to show)

[Statedef 1208]
type = A
movetype = A
physics = N
anim = 1301

[State 0]
type = Null
triggerall = parent, fvar(23) = 0
trigger1 = time = 1
fv = 23
value = pos x

[State 0]
type = Null
trigger1 = parent, fvar(23) !=0
trigger1 = pos x != parent, fvar(23)
trigger1 = time%3 = 0
x = floor ((parent, fvar(23)-pos x)/10)
y = 0
ignorehitpause =1

[State 0]
type = VelSet
trigger1 = time = 0
x = 2
y = 0

[State 1300, 2]
type = HitDef
trigger1 = time = 0
attr = S,SP
hitflag = MAF
guardflag = MA
animtype = low
priority = 4,Hit
damage = 65,10
pausetime = 18,8
sparkno = -1
guard.sparkno = -1
hitsound = S15,7
guardsound = S15,7
ground.type = Low
ground.slidetime = 18
ground.hittime  = 8
ground.velocity = -18,7
air.velocity = -8,4

[State 0]
type = DestroySelf
trigger1 = movecontact
trigger1 = time > 200
[/code]

Bear in mind I'll also need to have 1208 move on Y as well as X, but I'm sure once I can get it moving in the first place Y won't be a big issue. I know for a fact I'm doing something wrong, just need help sorting it out.

Odb718

replace
numhelper (1206)
with
numhelper(1206)
and all the variations. Just use notepad or wordpad and the replace function and change
numhelper (
to
numhelper(

And if you can label each of those states I code/spoiled that'd help a lot.
vVv Gouken718 vVv SabreTooth718 vVv


Afterthought

[Statedef 1208]
type = A
movetype = A
physics = N
anim = 1301

;----ODB's Code-----
[State 0]
type = VarSet
triggerall = numhelper(1206)
trigger1 = time = 0
v = 32
value = pos x - helper(1206), pos x

[State 0]
type = VarSet
triggerall = numhelper(1207)
trigger1 = time = 0
v = 33
value = pos x - helper(1207), pos x

[State 0]
type = VelSet
triggerall = numhelper(1206)
triggerall = numhelper(1207)
trigger1 = time = 0
x = ifelse (var(32) > var(33), var(32), var(33))
y = 0
ignorehitpause = 1

[State 0]
type = VelSet
triggerall = numhelper(1206)
triggerall = !numhelper(1207)
trigger1 = time = 0
x = var(32)
y = 0

[State 0]
type = VelSet
triggerall = !numhelper(1206)
triggerall = numhelper(1207)
trigger1 = time = 0
x = var(33)
y = 0
;----ODB's Code----


[State 1300, 2]
type = HitDef
trigger1 = time = 0
attr = S,SP
hitflag = MAF
guardflag = MA
animtype = low
priority = 4,Hit
damage = 65,10
pausetime = 18,8
sparkno = -1
guard.sparkno = -1
hitsound = S15,7
guardsound = S15,7
ground.type = Low
ground.slidetime = 18
ground.hittime  = 8
ground.velocity = -18,7
air.velocity = -8,4

[State 0]
type = DestroySelf
trigger1 = movecontact
trigger1 = time > 200


Revisions made; nothing changed. Everything of yours that I'm using currently is in this state.

Odb718

So are you looking at the positions of the values? Like what do var(32) and var(33) equal and does the math make sense?
Have you tried to set a standard number instead of the var for the velset to see if it moves?
One very slim possibility is that the two pos x are exactly the same so the > doesn't work but there's no real way.
You may need to use fvars but I dont think it'd matter. You'd only get debug flood.

----
I get movement on my end so I'm not sure what's going on. I do get debug flood if none of the helpers are out. If one is out it works fine. I haven't set up a second helper to test it 100% but I know it'll move.

---- ----
If I'm parting everything together correctly, you shouldn't set var(10) or var(16), 32 or 33, anywhere except the helper that moves. I think you set them to 1 for some reason?
vVv Gouken718 vVv SabreTooth718 vVv