From a77705e04ef329bfd2ad09862c542dce0fc6b967 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 6 Sep 2012 03:36:25 +0000 Subject: [PATCH] - Added A_JumpIfTargetOutsideMeleeRange and A_JumpIfTargetInsideMeleeRange because I thought I could be clever and have the beggar chase after you some after you attack him, with a random chance to cease pursuit. However, that didn't look much different from his normal wandering animation, and he usually gave up before getting anywhere near you, so it was kind of pointless. I kept the action functions around anyway, since they're simple things that somebody else might find useful. - Added a melee range check to A_SentinelRefire for actors without missile states. This fixes Strife's Beggar trying to attack you when you're nowhere near him. SVN r3863 (trunk) --- src/g_strife/a_sentinel.cpp | 1 + src/thingdef/thingdef_codeptr.cpp | 33 +++++++++++++++++++++++++++++++ wadsrc/static/actors/actor.txt | 2 ++ 3 files changed, 36 insertions(+) diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 9f582dcd59..696858f81f 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -81,6 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelRefire) self->target->health <= 0 || !P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES) || P_HitFriend(self) || + (self->MissileState == NULL && !self->CheckMeleeRange()) || pr_sentinelrefire() < 40) { self->SetState (self->SeeState); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 8fe1b24caa..c55cd32ac5 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -607,6 +607,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! } +//========================================================================== +// +// State jump function +// +//========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); + + if (!self->CheckMeleeRange()) + { + ACTION_JUMP(jump); + } + ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! +} + +//========================================================================== +// +// State jump function +// +//========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); + + if (self->CheckMeleeRange()) + { + ACTION_JUMP(jump); + } + ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains! +} //========================================================================== // // State jump function diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 6bad67ceb7..3b22d5734a 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -201,6 +201,8 @@ ACTOR Actor native //: Thinker 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_JumpIfTargetOutsideMeleeRange(state label); + action native A_JumpIfTargetInsideMeleeRange(state label); action native A_JumpIfInventory(class itemtype, int itemamount, state label, int owner = AAPTR_DEFAULT); action native A_JumpIfArmorType(string Type, state label, int amount = 1); action native A_GiveInventory(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT);