YesNoOk
avatar

Getting a Helper or Projectile to Aim At Other Helpers? (Read 20819 times)

Started by Afterthought, March 16, 2018, 04:44:33 am
Share this topic:
Getting a Helper or Projectile to Aim At Other Helpers?
#1  March 16, 2018, 04:44:33 am
  • avatar
  • **
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.
Last Edit: March 16, 2018, 02:35:13 pm by Afterthought
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#2  March 16, 2018, 05:19:43 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
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

Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#3  March 16, 2018, 08:53:50 am
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#4  March 16, 2018, 12:11:20 pm
  • avatar
  • **
@Odb718: 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.

@altoiddealer: 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.
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#5  March 16, 2018, 12:48:34 pm
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#6  March 16, 2018, 12:48:50 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
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.
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)

Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#7  March 16, 2018, 01:12:37 pm
  • avatar
  • **
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.
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#8  March 16, 2018, 01:52:49 pm
  • *****
  • Shame on you!
    • USA
This goes in your missile
Spoiler, click to toggle visibilty
This goes in statedef -2
Spoiler, click to toggle visibilty

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 Ryuko718 Updated 10/31/22 vVv
Last Edit: March 16, 2018, 02:04:48 pm by Odb718
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#9  March 16, 2018, 02:07:48 pm
  • avatar
  • **
@Odb718: 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.
Last Edit: March 16, 2018, 02:30:45 pm by Afterthought
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#10  March 16, 2018, 02:13:19 pm
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Limiting Multiple Helpers, and Other Helpers/Projectiles Homing In On Them
#11  March 16, 2018, 02:14:39 pm
  • avatar
  • **
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.
Last Edit: March 16, 2018, 02:30:12 pm by Afterthought
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#12  March 16, 2018, 02:45:38 pm
  • ******
    • www.justnopoint.com/
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.
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#13  March 16, 2018, 02:59:41 pm
  • avatar
  • **
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.
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#14  March 16, 2018, 03:10:12 pm
  • *****
  • Shame on you!
    • USA
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 toggle visibilty
Edit the actual values of var(10) and var(16) to be the aiming equations.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#15  March 16, 2018, 03:59:53 pm
  • avatar
  • **
@Odb718: 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.
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#16  March 16, 2018, 04:08:01 pm
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#17  March 16, 2018, 04:46:18 pm
  • avatar
  • **
This is the current code in its entirety.
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
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 toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty

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.
Last Edit: March 16, 2018, 04:49:14 pm by Odb718
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#18  March 16, 2018, 04:51:17 pm
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#19  March 16, 2018, 04:58:25 pm
  • avatar
  • **
Code:
[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.
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#20  March 16, 2018, 05:09:33 pm
  • *****
  • Shame on you!
    • USA
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 Ryuko718 Updated 10/31/22 vVv
Last Edit: March 16, 2018, 05:22:51 pm by Odb718