YesNoOk
avatar

Rebounding Helpers and Variables (Read 7681 times)

Started by Afterthought, February 15, 2018, 09:07:46 pm
Share this topic:
Rebounding Helpers and Variables
#1  February 15, 2018, 09:07:46 pm
  • avatar
  • **
This is a weird one. Bear with me.

So I'm trying to code an attack with a helper that moves horizontally and can rebound when it hits a wall, and if it returns to the character who sent it out, it will disappear and a value will be added to a variable (var(5) in this case, which is not currently being used). For each value that's added, the command that executed the first helper can then send out a stronger helper, which rebounds, returns, adds a value.

The rebounding bit works, but there's two issues on the actual rebound.

1. When it returns to the character (using time >999 && RootDist X <0), the helper actually doesn't DestroySelf as I intended it to, but keeps moving past the character.

2. Same issue with actually adding to the variable; the variable value will never increase past 0.

I can actually supply the code later on (tried making a post earlier with everything but it got lost and I'm not in front of my work at the moment), but if anyone has a similar approach, maybe if they've done what I'm trying to do, I'd love to hear your thoughts. Much appreciated.
Last Edit: February 16, 2018, 02:16:09 am by Afterthought
Re: Rebounding Helpers and Variables
#2  February 16, 2018, 02:15:19 am
  • avatar
  • **
Code for attack:
Code:
[Statedef 510]
type    = S
movetype= A
physics = S
ctrl = 0
anim = 1000

[State 0]
type = VarSet
trigger1 = time = 0
v = 5
value = 0

[State 0]
type = Helper
trigger1 = animelem = 5
helpertype = normal
name = "Helper" 
ID =  513
stateno = 513
pos = 20,-50
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermove
pausemove

[State 0]
type = ChangeState
trigger1 = animtime = 0
value = 0
ctrl = 1

Code for helper:
Code:
[Statedef 513]
type = A
movetype = A
physics = N
ctrl = 0
anim = 510
sprpriority = 5
velset = 5,0

[State 0]
type = HitDef
trigger1 = time = 0
attr = A,SP
damage = 10,5
animtype = Hard
guardflag = A
hitflag = MAF
priority = 4, Hit
pausetime = 2,2
sparkno = s8253+random%2
hitsound = s8250,0
sparkxy = 0,0
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime = 12
ground.velocity = 1,-5
air.type = Low
air.hittime = 5
air.velocity = 1,-6
fall=1
fall.recover=0

[State 513,3]
type = Velset
trigger1 = FrontEdgeDist <1
x = -5
y = 0

[State 513]
type = VarAdd
trigger1 = time > 999 && RootDist X < 0
v = 5
value = 1

[State 513]
type = DestroySelf
trigger1 = (MoveContact) || time > 999 && RootDist X < 0


Re: Rebounding Helpers and Variables
#3  February 16, 2018, 04:42:36 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Time > 999?

Also, you could use Turn instead of Velset.

Re: Rebounding Helpers and Variables
#4  February 16, 2018, 07:28:06 am
  • avatar
  • **
Re: Rebounding Helpers and Variables
#5  February 16, 2018, 01:34:23 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
ParentVarAdd :)

Also some triggers don't play nice with && or ||, without extra parenthesis.  May be the issue there

[State 513]
type = ParentVarAdd
trigger1 = time > 10
trigger1 = RootDist X < 0
v = 5
value = 1
 
[State 513]
type = DestroySelf
trigger1 = MoveContact
trigger2 = time > 10
trigger2 = RootDist X < 0

Re: Rebounding Helpers and Variables
#6  February 16, 2018, 03:18:18 pm
  • avatar
  • **
ParentVarAdd. That's genius. If I had looked everything over just a bit more I would have probably noticed that.

I'll try everything you shared. I appreciate the help!

EDIT: Logically, that code makes sense, but it still won't work. I'm not sure what I would need to change at this point, if anyone else has further ideas I'd love to hear them.
Last Edit: February 17, 2018, 01:31:55 pm by Afterthought
Re: Rebounding Helpers and Variables
#7  February 20, 2018, 06:13:46 pm
  • avatar
  • **
Bumping just in case anyone else has any ideas or alternative solutions.
Re: Rebounding Helpers and Variables
#8  February 20, 2018, 06:51:43 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
If you don't have a DisplayToClipboard controller already (Use Search function to check), make sure you use one in State -2 like so

Code:
[State -2, 2]
type = DisplayToClipboard
trigger1 = 1
text="The value of var(5) %d"
params = var(5)

Enable debug with Ctrl+D and see if the var(5) value behaves as expected.
If not, try making drastic adjustments to at least pinpoint the problem code.

If the Var is behaving as expected, test out RootDist similarly, like so:

Code:
trigger1 = numhelper(153)
text="Distance from helper to root is %f"
params = Helper(513),rootdist X

Re: Rebounding Helpers and Variables
#9  February 21, 2018, 04:06:02 am
  • avatar
  • **
DisplayToClipboard

This singlehandedly helped me immensely, more than you know. I appreciate your assistance, thank you again.

Oddly enough, var(5) now will not extend past 1, using the same exact ParentVarAdd SCTRL and everything, nor will the helper in State 516 disappear when meeting the same conditions as in 513. I'm not immediately sure why that is; I even used a VarSet, var(5) = 1 in 511, which calls 516, and that got me no results.

I'm close to a breakthrough, but maybe I need to rewrite some code? Or maybe use a new variable?

EDIT: As it would seem, any X velocity past 5 for the second helper causes the VarAdd and DestroySelf to not terminate unless I'm holding Back, and even then it takes a few tries until they register. Not entirely sure why this is, so its velocity will remain 5.
Last Edit: February 21, 2018, 04:45:17 am by Afterthought
Re: Rebounding Helpers and Variables
#10  February 21, 2018, 04:25:58 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Post all the code :P

Re: Rebounding Helpers and Variables
#11  February 21, 2018, 04:47:12 am
  • avatar
  • **
Amended my previous post, but my current code is here:

Code:
[Statedef 510]
type    = S
movetype= A
physics = S
ctrl = 0
anim = 1000

[State 0]
type = VarSet
trigger1 = time = 0
v = 5
value = 0

[State 0]
type = Helper
trigger1 = animelem = 5
helpertype = normal
name = "H1"
ID =  513
stateno = 513
pos = 20,-50
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermove
pausemove



[State 0]
type = ChangeState
trigger1 = animtime = 0
value = 0
ctrl = 1

[Statedef 511]
type    = S
movetype= A
physics = S
ctrl = 0
anim = 1000


[State 0]
type = Helper
trigger1 = animelem = 5
helpertype = normal
name = "H2"
ID =  514
stateno = 514
pos = 20,-50
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermove
pausemove



[State 0]
type = ChangeState
trigger1 = animtime = 0
value = 0
ctrl = 1

[Statedef 512]
type    = S
movetype= A
physics = S
ctrl = 0
anim = 1000

[State 0]
type = Helper
trigger1 = animelem = 5
helpertype = normal
name = "H3"
ID =  515
stateno = 515
pos = 20,-50
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermove
pausemove



[State 0]
type = ChangeState
trigger1 = animtime = 0
value = 0
ctrl = 1


[Statedef 513]
type = A
movetype = A
physics = N
ctrl = 0
anim = 510
sprpriority = 5
velset = 5,0

[State 0]
type = HitDef
trigger1 = time = 0
attr = A,SP
damage = 10,5
animtype = Hard
guardflag = A
hitflag = MAF
priority = 4, Hit
pausetime = 2,2
sparkno = s8253+random%2
hitsound = s8250,0
sparkxy = 0,0
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime = 12
ground.velocity = 1,-5
air.type = Low
air.hittime = 5
air.velocity = 1,-6
fall=1
fall.recover=0

[State 513,3]
type = Velset
trigger1 = FrontEdgeDist <1
x = -5
y = 0

[State 513]
type = ParentVarAdd
trigger1 = abs(RootDist X) <= 1
v = 5
value = 1

[State 513]
type = DestroySelf
trigger1 = (MoveContact)
trigger2 = time > 10
trigger2 = abs (RootDist X) <= 1

[Statedef 514]
type = A
movetype = A
physics = N
ctrl = 0
anim = 510
sprpriority = 5
velset = 5,0

[State 0]
type = HitDef
trigger1 = time = 0
attr = A,SP
damage = 10,5
animtype = Hard
guardflag = A
hitflag = MAF
priority = 4, Hit
pausetime = 2,2
sparkno = s8253+random%2
hitsound = s8250,0
sparkxy = 0,0
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime = 12
ground.velocity = 1,-5
air.type = Low
air.hittime = 5
air.velocity = 1,-6
fall=1
fall.recover=0

[State 513,3]
type = Velset
trigger1 = FrontEdgeDist <1
x = -5
y = 0

[State 513]
type = ParentVarAdd
trigger1 = abs(RootDist X)<= 1
v = 5
value = 1

[State 513]
type = DestroySelf
trigger1 = (MoveContact)
trigger2 = time > 10
trigger2 = abs(RootDist X) <= 1

[Statedef 515]
type = A
movetype = A
physics = N
ctrl = 0
anim = 510
sprpriority = 5
velset = 7,0

[State 0]
type = HitDef
trigger1 = time = 0
attr = A,SP
damage = 10,5
animtype = Hard
guardflag = A
hitflag = MAF
priority = 4, Hit
pausetime = 2,2
sparkno = s8253+random%2
hitsound = s8250,0
sparkxy = 0,0
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime = 12
ground.velocity = 1,-5
air.type = Low
air.hittime = 5
air.velocity = 1,-6
fall=1
fall.recover=0

[State 0]
type = ParentVarAdd
trigger1 = time = 0
v = 5
value = -2

[State 513]
type = DestroySelf
trigger1 = (MoveContact)
trigger1 = time = 50
Re: Rebounding Helpers and Variables
#12  February 21, 2018, 06:37:25 am
  • ******
    • www.justnopoint.com/
Re: Rebounding Helpers and Variables
#13  February 21, 2018, 06:56:02 am
  • *****
  • Shame on you!
    • USA
One main tip, When you're making multiple versions of one move it's best to get the first one working perfect, then copy/paste/edit it into the other 2 states.
Sometimes you can edit all 3 states to see which yields the best results while debugging though.

One thing is, Do you know what Abs() is doing? Your distance check is shocking that it actually works. Because you're only getting 1 value to work. It pretty much HAS TO BE 0.

[State 513]
type = DestroySelf
trigger1 = (MoveContact)
trigger2 = time > 10
trigger2 = RootDist X <= 5  ;5 is close to P1, so anything close connects.
;trigger2 = RootDist X >= -5 ;comment this in if you only want it to work close to P1.
If it goes past, it will work with this commented out. You could also increase the Abs() value so it has a higher tolerance. If you only want it to activate while it's in front of P1, set the two values to positive.

The way you have it, once it got past P1 even 1 pixel, absolute value switched from -1 to 1, so it wouldn't fire off.  You'll also probably want to check P1's Pos Y if you don't want it to work while P1 is in the air/above it.

[State 0]  ;This may be why the var never gets set above 1?
type = VarSet
trigger1 = time = 0
v = 5
value = 0
 
Why  do you want the var to get above 1, and why are you resetting it? I'm not sure what the value is supposed to represent with it being subtracted in 513. What's the value doing?
vVv Ryuko718 Updated 10/31/22 vVv
Last Edit: February 21, 2018, 06:59:23 am by Odb718
Re: Rebounding Helpers and Variables
#14  February 21, 2018, 04:38:02 pm
  • avatar
  • **
@Just No Point: I'll bookmark this for future ref. Thanks again.

@Odb718: I did read everything you posted, but my issue for the most part is solved. I'll try to resolve everything involving abs(Dist) and see if I can refine it. That snippet you posted will get deleted since it serves no function now, there are other triggers that clear that variable anyway.

@altoiddealer: I appreciate the help as always.

I would implore you all to check out my other topic if you feel inclined to do so.
Re: Rebounding Helpers and Variables
New #15  February 21, 2018, 05:17:05 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Although using abs() eliminates working out the negative/positive values, it's not a good answer here due to the factor of velocity.

The player's don't move in smooth float values... Vel 5 means the player essentially jumps forward 5 pixels every tick.

So, if P1 doesn't move, and the Helper has a velocity of 5, then it's not guaranteed to trigger unless abs(RootDist X) <= 3... for the helper to be guaranteed to land in that 6 pixel window.

However, if P1 and the helper are walking towards each other, both with Vel 5.  Now it's not guaranteed to trigger unless abs(RootDist X) <= 5.  The bigger you make this window, the more variable the results.


So, use DisplayToClipboard to check the helper's RootDist X values to determine if there is an issue with positive/negative values.  From what I could tell, I thought you had this aspect correct to begin with -- rootdist X <= 0

Last Edit: February 21, 2018, 05:20:33 pm by altoiddealer