YesNoOk
avatar

GetHitVar(*) (Triggers) (Read 62735 times)

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

Format:

     GetHitVar(param_name)

Arguments:
     param_name
          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:
     none
Details:
  • 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)

Example:

Code:
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

Example:
Code:
[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
    • network.mugenguild.com/cyanide/
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
    • altoiddealer@gmail.com
You can attach information to a HitDef by using one of these often unused HitDef parameters:
fall.envshake.freq
fall.envshake.ampl
fall.envshake.phase
DO NOT include the fall.envshake.time parameter

In P1's HitDef, Example:
Code:
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:

Code:
[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:
Code:
fall.envshake.ampl = ID

In the custom state, example:

Code:
[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
    • xgargoyle.mgbr.net
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:
http://mugenguild.com/forum/topics/p1-not-bound-if-p2-initiates-hold-possible-bug-gethitvarisbound-185393.0.html
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: GetHitVar(*) (Triggers)
#5  April 11, 2019, 06:45:03 am
  • ***
  • too obsessed with NES stuff
    • USA
To clarify, GetHitVar(damage) doesn't return the actual damage value from the attack but the amount of life lost from said attack. This means if the attack does more than your current life, GetHitVar(damage) will only return the life you lost. (Example: If you have 200 life and you're hit with an attack that does 250 damage, GetHitVar(damage) will only return 200.)
might as well put this forum about bootleg games here
BGC Forums
Last Edit: April 11, 2019, 06:49:50 am by KingPepe2010

2OS

Re: GetHitVar(*) (Triggers)
#6  June 06, 2019, 05:41:07 am
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
chiming in to say that the above post is absolutely false in training mode.

in training mode if damage=2000 and lifemax=1000 gethitvar(damage) will return 2000.

this could be part of yet another formula to detect training mode.

training mode is weird.
Re: GetHitVar(*) (Triggers)
#7  November 10, 2020, 05:03:00 am
  • avatar
  • *
    • Canada
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:
http://mugenguild.com/forum/topics/p1-not-bound-if-p2-initiates-hold-possible-bug-gethitvarisbound-185393.0.html


Big necro, but I noticed this and I want to clarify why this isn't a bug. It comes down to player processing order, and the duration of TargetBind.

Sorry for long post OTL

In MUGEN, in general, players 'move' (or process their states) in player slot order: P1->P2->(P3->P4->)Helper1->Helper2->...->Helper56. However, players and helpers with MoveType = A always move before players and helpers with MoveType != A. I think this is to help with making sure attacks land consistently.

Therefore, P1 will always move before P2 in a frame, with the single exception of P2 having MT=A and P1 having MT!=A (e.g. MoveType=I). In addition, the default time value for TargetBind is 1, so it lasts for a single frame (since no time parameter was set on the TargetBind stecons in the linked post) - I believe that setting the time parameter to something other than 1 would solve the linked issue, but I didn't bother to check whether IsBound resets to 0 every frame independent of the time parameter or not.

Knowing this, we can deconstruct the details of the linked scenario:

Case 1 - Player 1 MT=I, Player 2 MT=H, Player 1 has thrown Player 2 and Player 2 wants to check GetHitVar(IsBound). This is the case where it was working.

Since both Player 1 and Player 2 have MT != A, they move in player slot order: P1->P2. Now this happens in the span of one frame:
- Player 1 performs TargetBind, this sets Player2,GetHitVar(IsBound) = 1
- Player 2 reads GetHitVar(IsBound), it evaluates to 1
- Player 2 remains bound
- IsBound becomes 0 at the end of the frame.

Obviously, it works as expected.

Case 2 - Player 1 MT=H, Player 2 MT=I, Player 2 has thrown Player 1 and Player 1 wants to check GetHitVar(IsBound). This is the case where it failed.

Again, both Player 1 and Player 2 have MT != A, so they move in slot order:
- Player 1 reads GetHitVar(IsBound), it evaluates to 0
- Player 2 performs TargetBind, this sets Player1,GetHitVar(IsBound) = 1
- IsBound becomes 0 at the end of the frame.

...as you can see, there is never a chance for P1 to read GetHitVar(IsBound) while it's set to 1. Player 2 moves second, and it gets unset at the end of the frame. Therefore, it fails.

Case 3 - Player 1 MT=H, Player 2 MT=A, Player 2 has thrown Player 1 and Player 1 wants to check GetHitVar(IsBound). This is the described workaround.

In this case, since Player 2 has MT=A, it will move before all players and helpers with MT != A, including Player 1:
- Player 2 performs TargetBind, this sets Player1,GetHitVar(IsBound) = 1
- Player 1 reads GetHitVar(IsBound), it evaluates to 1
- Player 1 remains bound
- IsBound becomes 0 at the end of the frame

...all this to say, if you want an effect that's active for only 1 frame to be readable by any other player or helper, you should make sure to set MT=A!