- Added A_JumpIfHigherOrLower.

- (int ptr = AAPTR_TARGET, state high, state low, float offsethigh = 0, float offsetlow = 0, bool includeHeight = true)
- Jumps if the pointer of the calling actor is higher or lower than itself, adding offsethigh or offsetlow depending on the circumstance.
- includeHeight works twofold.
- Includes the height of the calling actor if the pointer is higher to truly determine if they are completely above them or not.
- Includes the height of the pointer if the pointer is lower.
- Disable it to only check z differences without adding height.
This commit is contained in:
MajorCooke 2015-04-30 08:15:48 -05:00
parent 033712d044
commit 492ef1b716
2 changed files with 38 additions and 0 deletions

View File

@ -5844,6 +5844,43 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth)
}
}
//===========================================================================
// A_JumpIfHigherOrLower
//
// Jumps if a target, master, or tracer is higher or lower than the calling
// actor. Can also specify how much higher/lower the actor needs to be than
// itself. Can also take into account the height of the actor in question,
// depending on which it's checking. This means adding height of the
// calling actor's self if the pointer is higher, or height of the pointer
// if its lower.
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower)
{
ACTION_PARAM_START(6);
ACTION_PARAM_INT(ptr, 0);
ACTION_PARAM_STATE(high, 1);
ACTION_PARAM_STATE(low, 2);
ACTION_PARAM_FIXED(offsethigh, 3);
ACTION_PARAM_FIXED(offsetlow, 4);
ACTION_PARAM_BOOL(includeHeight, 5);
AActor *mobj = COPY_AAPTR(self, ptr);
if (!mobj || (mobj == self)) //AAPTR_DEFAULT is completely useless in this regard.
{
return;
}
ACTION_SET_RESULT(false); //No inventory jump chains please.
if ((high) && (mobj->z > ((includeHeight ? self->height : 0) + self->z + offsethigh)))
ACTION_JUMP(high);
else if ((low) && (mobj->z + (includeHeight ? mobj->height : 0)) < (self->z + offsetlow))
ACTION_JUMP(low);
}
//===========================================================================
//
// A_SetRipperLevel(int level)

View File

@ -330,6 +330,7 @@ ACTOR Actor native //: Thinker
action native A_SetFloatBobPhase(int bob);
action native A_SetHealth(int health, int ptr = AAPTR_DEFAULT);
action native A_ResetHealth(int ptr = AAPTR_DEFAULT);
action native A_JumpIfHigherOrLower(int ptr = AAPTR_TARGET, state high, state low, float offsethigh = 0, float offsetlow = 0, bool includeHeight = true);
action native A_SetRipperLevel(int level);
action native A_SetRipMin(int min);
action native A_SetRipMax(int max);