diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 6c5729cf38..a5fc1d08e7 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -470,30 +470,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) // State jump function // //========================================================================== -DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) +void DoJumpIfCloser(AActor *target, DECLARE_PARAMINFO) { ACTION_PARAM_START(2); ACTION_PARAM_FIXED(dist, 0); ACTION_PARAM_STATE(jump, 1); - AActor *target; - - if (!self->player) - { - target=self->target; - } - else - { - // Does the player aim at something that can be shot? - P_BulletSlope(self, &target); - } - ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! // No target - no jump - if (target==NULL) return; - - if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist && + if (target != NULL && P_AproxDistance(self->x-target->x, self->y-target->y) < dist && ( (self->z > target->z && self->z - (target->z + target->height) < dist) || (self->z <=target->z && target->z - (self->z + self->height) < dist) ) @@ -503,6 +489,36 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) } } +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser) +{ + AActor *target; + + if (!self->player) + { + target = self->target; + } + else + { + // Does the player aim at something that can be shot? + P_BulletSlope(self, &target); + } + DoJumpIfCloser(target, PUSH_PARAMINFO); +} + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTracerCloser) +{ + // Is there really any reason to limit this to seeker missiles? + if (self->flags2 & MF2_SEEKERMISSILE) + { + DoJumpIfCloser(self->tracer, PUSH_PARAMINFO); + } +} + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfMasterCloser) +{ + DoJumpIfCloser(self->master, PUSH_PARAMINFO); +} + //========================================================================== // // State jump function diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 1a18d2ed40..ec6e0cea03 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -188,6 +188,8 @@ ACTOR Actor native //: Thinker action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, bool aim = false, float maxdiff = 0, class pufftype = "BulletPuff"); action native A_JumpIfHealthLower(int health, state label); action native A_JumpIfCloser(float distance, state label); + action native A_JumpIfTracerCloser(float distance, state label); + action native A_JumpIfMasterCloser(float distance, state label); action native A_JumpIfInventory(class itemtype, int itemamount, state label); action native A_JumpIfArmorType(string Type, state label, int amount = 1); action native A_GiveInventory(class itemtype, int amount = 0);