GetHitVar(*) (Triggers) (Read 5882 times)

Started by Just No Point, October 09, 2015, 05:04:46 am
Share this topic:
GetHitVar(*) (Triggers)
#1  October 09, 2015, 05:04:46 am
  • ******
When the player is in a gethit state, returns the value of the specified hit parameter.



          The name of the hit parameter to check. Valid values are:
xveladd, yveladd, type, animtype, airtype, groundtype, damage, hitcount, fallcount, hitshaketime, hittime, slidetime, ctrltime, recovertime, xoff, yoff, zoff, xvel, yvel, yaccel, hitid, chainid, guarded, fall, fall.damage, fall.xvel, fall.yvel, fall.recover, fall.time, fall.recovertime.

Return type:
     Depends on specified hit parameter. See Details.

Error conditions:
  • xveladd: Returns the additional x-velocity that is added to the player's own when he is KOed. (float)
  • yveladd: Returns the additional y-velocity that is added to the player's own when he is KOed. (float)
  • type: Returns the type of the hit: 0 for none, 1 for high, 2 for low, 3 for trip (ground only).
  • animtype: Returns the animation type of the hit. (0 for light, 1 for medium, 2 for hard, 3 for back, 4 for up, 5 for diag-up)
  • airtype: Returns the type specified in the HitDef for an air hit.
  • groundtype: Returns the type specified in the HitDef for a ground hit.
  • damage: Returns the damage given by the hit. (int)
  • hitcount: Returns the number of hits taken by the player in current combo. (int)
  • fallcount: Returns the number of times player has hit the ground in the current combo. (int)
  • hitshaketime: Returns time player is "frozen" during the hit. This number counts down by 1 for each game tick, and stops when it reaches zero. (int)
  • hittime: Returns time before player regains control and returns to an idle state after being hit. This counts down by 1 per game tick, as long as hitshaketime (see above) is greater than 0. It stops counting down when the value reaches -1. (int) "GetHitVar(hittime) < 0" is equivalent to the HitOver trigger.
  • slidetime: Returns time that player slides backwards (on the ground) after the hit. (int)
  • ctrltime: Returns time before player regains control after guarding the hit. (int)
  • recovertime: Returns time before player gets up from liedown state This number counts down to 0 for each game tick, and will count down faster if buttons are hit. (int)
  • xoff: "Snap" x offset when hit (deprecated)
  • yoff: "Snap" y offset when hit (deprecated)
  • xvel: Fixed x-velocity imparted by hit. (float)
  • yvel: Fixed y-velocity imparted by hit. (float)
  • yaccel: y acceleration set by the hit. (float)
  • chainid: Player-assigned chainID for last hit taken. (int)
  • guarded: True if the last hit was guarded, false otherwise.
  • isbound: True if the player is the subject of an attacker's TargetBind controller. Useful to prevent being stuck in thrown states. (int)
  • fall: True if falling, false otherwise (int)
  • fall.damage: Damage taken upon fall (int)
  • all.xvel: x velocity after bouncing off ground (float)
  • fall.yvel: y velocity after bouncing off ground (float)
  • fall.recover: True if player can recover, false otherwise.
  • fall.recovertime: time before player can recover. (int)
  • fall.kill: value of fall.kill parameter in attacker's hitdef. (int)
  • fall.envshake.time: See below. (int)
  • fall.envshake.freq: See below. (float)
  • fall.envshake.ampl: See below. (int)
  • fall.envshake.phase: Returns values set by the fall.envshake.* parameters in an attacker's hitdef. (float)


trigger1 = GetHitVar(yvel) < -5.5
  Triggers if the hit's specified y velocity is less than -5.5.

Use this is conjunction with VelSet to replace the deprecated HitVelSet

[State VelSet]
type = velset
trigger1 =
x = gethitvar(xvel)* facing
Last Edit: December 02, 2015, 03:16:59 pm by Just No Point
Re: GetHitVar(*) (Triggers)
#2  October 10, 2015, 02:34:47 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
And by gethit that means movetype = H. Not necessarily one of the 5000 series of hitstates from the common1.cns

In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: GetHitVar(*) (Triggers)
#3  March 14, 2017, 02:56:37 am
  • ****
  • Robotics Engineer
    • USA
You can attach information to a HitDef by using one of these often unused HitDef parameters:
DO NOT include the fall.envshake.time parameter

In P1's HitDef, Example:
fall.envshake.ampl = var(5)

This information can now easily be read from a custom state using the GetHitVar(*) trigger.

In the custom state, example:

[State 9876, 0]
type = ChangeAnim
trigger1 = GetHitVar(fall.envshake.ampl) = 1
value = 9876
persistent = 0

Player in custom state will change to anim 9876 if P1's var(5) = 1 (when P1 performed the attack).

Another neat thing you can do is get P1's PlayerID, so you can easily redirect triggers back to P1.

In P1's HitDef, Example:
fall.envshake.ampl = ID

In the custom state, example:

[State 9876, 0]
type = VelSet
trigger1 = PlayerIDExist(GetHitVar(fall.envshake.ampl)) ;check that the value snagged from the HitDef is actually a PlayerID
trigger1 = PlayerID(GetHitVar(fall.envshake.ampl)),StateNo = 9996
value = 10
persistent = 0

So this will trigger if P1 is in State 9996

Using the PlayerID option is obviously ideal, because you can reliably access so much info from P1 with just that one HitDefAttr

Re: GetHitVar(*) (Triggers)
#4  November 25, 2018, 06:17:53 pm
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
Gethitvar(isbound) will bug if P2 performs the move with the TargetBind controllers AND the movetype is set to I.
Under this instance, P1 will see Gethitvar(isbound)=0 and eventually go back to his owns SelfState if using a trigger like !Gethitvar(isbound).
In the same scenario, if P1 performs the same move instead, P2 will see Gethitvar(isbound)=1 and still be under P1's custom state, hence the bug with the internal engine

In this scenario, TargetBind is working fine and positioning the player in the corresponding screen position, but since the movetype is set to I (no attack), P1 gets a different gethitvar(isbound) data than P2.

The "fix" to this bug is to ensure that any state with TargetBind controllers are set as movetype=A, otherwise it will work only for P1 but not for P2

More details here:
XGargoyle: Battle posing since 1979  <-- Please click that link  <-- Donations welcome!