YesNoOk
avatar

removing helper on hit/guard (Read 2860 times)

Started by txcrvnt, October 03, 2022, 08:18:25 pm
Share this topic:
removing helper on hit/guard
#1  October 03, 2022, 08:18:25 pm
    • Brazil
hi again!

my homing projectile is doing well, except i've tumbled with another problem. I want the helper to disappear after 4 hits or after being blocked 4 times. for that, i've made the following hitdef:

Code:
[State 1042, Hit]
type = hitdef
trigger1 = time%60
priority = 4, hit
attr = S, SP
damage = 20 * ifelse(vel x < 0,(-vel X),(vel x))
animtype = Hard
hitflag = MAFD
guardflag = MA
pausetime = 1,1
sparkno = S10001 + (random%4)
sparkxy = -10, 0
hitsound = S2, ifelse(random < 500, 5, 2)
guardsound = S3, ifelse(random < 500, 0, 1)
ground.type = high
ground.slidetime = 16
ground.hittime = 16
ground.velocity = ifelse(p2dist x > 0,-30,30), 0
ground.cornerpush.veloff = 0
air.velocity = 0, -15
air.fall = 1
fall.recovertime = 30
givepower = 36, 36
envshake.time = 14
envshake.freq = 120
envshake.ampl = 4
yaccel = .5
airguard.ctrltime = 16
airguard.velocity = -8, -1.5
forcestand = 1

and then, it was supposed to change state (to vanish) if meeting these conditions:

Code:
[State 1042, End]
type = changestate
trigger1 = hitcount > 3 ;------------------> works
trigger2 = moveguarded >= 3 ;----------> do not work
trigger3 = pos y > 0
value = 1042
ignorehitpause = 1

[State 1042, End]
type = destroyself
trigger1 = hitcount > 3 ;------------------> works
trigger2 = moveguarded >= 3 ;----------> do not work

what should I do to replace trigger2 and then get it blocked 4 times before vanishing? because if I change it to moveguarded, then it vanishes on first hit and that's not what I want...
Re: removing helper on hit/guard
#2  October 04, 2022, 12:04:49 am
  • *****
  • Shame on you!
    • USA
You'll want to use a Var to keep track. I could imagine a situation where P2 guards 2x and then tries to attack, and gets hit 2x. With the way you want it to work, there could be a total of 7; 3 blocks and 4 hits.
You'll want to set a var to 0 at the start of the move. Then

[State 0, VarAdd]
type = VarAdd
trigger1 = MoveGuarded = 1
trigger2 = MoveHit = 1
var(51) = 1

MoveGuarded doesn't keep track of how many times, just if it's happened.
https://mugenguild.com/forum/topics/moveguarded-triggers-169090.0.html

Don't forget about Mugen Class. You can look up the things that aren't working exactly how you'd expect. Check out MoveContact. You might be able to simplify your VarAdd.

You can use DisplayToClipboard to watch the var you use to see if it counts properly.
Once everything seems to count the hits and blocks properly, you can use
trigger2 = var(51) >= 4 ;instead of moveguarded >= 3

Make sure you're not using var 51 if you use it.
vVv Ryuko718 Updated 10/31/22 vVv
Last Edit: October 04, 2022, 12:09:58 am by Odb718
Re: removing helper on hit/guard
#3  October 05, 2022, 04:49:08 pm
    • Brazil
thank you! did it!

google has been sending me to Mugen Class every time I need some help. by the way, love the way things are organized here with labels (such as triggers and sctrls) and so on. the only problem I have is to be unaware of what I can do with coding, for example: how am i supposed to know if animelem can have commas after it? because i've seen things like [animelem = 10, >=1] without crashing!!!!

but for now, there's another question: I have a 5s sound fx that plays when the projectile is spawned, then as it floats around the sound loops.

Code:
[State 0, PlaySnd]
type = PlaySnd
trigger1 = stateno = 1041 ;-------> this makes the sound play with every and each tick it's floating around
value = S10,10
channel = 30
loop = 1
persistent = 0

[State 0, stopsnd]
type = stopSnd
trigger1 = stateno != 1041 ;---------> this seems to make the sound stop playing every tick, but the last sound instance keeps playing until it finishes even if the helper is gone
channel = 30

how can I make a code that play the sound ONCE when the helper spawns, loop itself when it ends, then stop playing if the projectile is gone?
Last Edit: October 05, 2022, 04:53:29 pm by txcrvnt
Re: removing helper on hit/guard
#4  October 06, 2022, 10:40:38 am
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Animelem is deprecated, better use Animelemtime or Animelemno

Regarding the sound question. Is state 1041 the projectile? Where is the PlaySnd/stopSnd code located? Inside the projectile's state 1041? or within another state such as -2 or -3?

If you are inside the helper's state 1041, you can't use the "trigger1 = stateno != 1041" because when it should trigger, the state machine is no longer reading that line as you are already in another state.
You either need to place the stopsnd in the next state the helper goes (if it goes there), or use the same conditions that you are doing for the destroyself, so whenever the destroyself activates, it also stops the sound

To avoid playing the sound every tick, just use time=0 instead of trigger1 = stateno = 1041
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: removing helper on hit/guard
#5  October 06, 2022, 07:44:15 pm
  • *****
  • Shame on you!
    • USA
One thing I like to do to have things happen "after" something is destroyed is to have a blank sprite in the Anim. Then when the animation hit that "sprite", we see nothing and mugen still has time to deactivate everything.
So if you're making your fireball disappear, you might want to try that technique. But if the fireball goes to a state to have a destroy animation or something like that, XGargoyle's method is easiest.
vVv Ryuko718 Updated 10/31/22 vVv