diff --git a/src/actor.h b/src/actor.h index 468dcc0c6..ff011cb78 100644 --- a/src/actor.h +++ b/src/actor.h @@ -932,6 +932,7 @@ public: // player to freeze a bit after teleporting SDWORD threshold; // if > 0, the target will be chased // no matter what (even if shot) + SDWORD DefThreshold; // [MC] Default threshold which the actor will reset its threshold to after switching targets player_t *player; // only valid if type of APlayerPawn TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) fixed_t SpawnPoint[3]; // For nightmare respawn diff --git a/src/namedef.h b/src/namedef.h index 0d49bba76..f420aca96 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -294,6 +294,8 @@ xx(Z) xx(MomX) xx(MomY) xx(MomZ) +xx(Threshold) +xx(DefThreshold) xx(Abs) xx(ACS_NamedExecuteWithResult) xx(CallACS) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 25724172c..9d9db5167 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1516,7 +1516,7 @@ dopain: { if (source == target->target) { - target->threshold = BASETHRESHOLD; + target->threshold = target->DefThreshold; //BASETHRESHOLD is no longer used here. if (target->state == target->SpawnState && target->SeeState != NULL) { target->SetState (target->SeeState); @@ -1537,7 +1537,7 @@ dopain: target->lastenemy = target->target; // remember last enemy - killough } target->target = source; - target->threshold = BASETHRESHOLD; + target->threshold = target->DefThreshold; if (target->state == target->SpawnState && target->SeeState != NULL) { target->SetState (target->SeeState); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 901372eef..3a55e2232 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -344,6 +344,10 @@ void AActor::Serialize (FArchive &arc) << RipLevelMin << RipLevelMax; } + if (SaveVersion >= 4525) + { + arc << DefThreshold; + } { FString tagstr; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index f56fa6633..dfb3b5407 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5870,6 +5870,33 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRipMax) self->RipLevelMax = max; } +//=========================================================================== +// +// A_SetChaseThreshold(int threshold, bool def, int ptr) +// +// Sets the current chase threshold of the actor (pointer). If def is true, +// changes the default threshold which the actor resets to once it switches +// targets and doesn't have the +QUICKTORETALIATE flag. +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetChaseThreshold) +{ + ACTION_PARAM_START(3); + ACTION_PARAM_INT(threshold, 0); + ACTION_PARAM_BOOL(def, 1); + ACTION_PARAM_INT(ptr, 2); + + AActor *mobj = COPY_AAPTR(self, ptr); + if (!mobj) + { + ACTION_SET_RESULT(false); + return; + } + if (def) + mobj->DefThreshold = (threshold >= 0) ? threshold : 0; + else + mobj->threshold = (threshold >= 0) ? threshold : 0; +} + /*=========================================================================== A_CheckBlock (state block, int flags, int ptr) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 3746a6ca7..7c352d8d7 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -90,7 +90,8 @@ DEFINE_MEMBER_VARIABLE(reactiontime, AActor) DEFINE_MEMBER_VARIABLE(meleerange, AActor) DEFINE_MEMBER_VARIABLE(Speed, AActor) DEFINE_MEMBER_VARIABLE(roll, AActor) - +DEFINE_MEMBER_VARIABLE(threshold, AActor) +DEFINE_MEMBER_VARIABLE(DefThreshold, AActor) //========================================================================== // diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 183cf2709..c32379051 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -532,6 +532,17 @@ DEFINE_PROPERTY(painthreshold, I, Actor) defaults->PainThreshold = id; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(chasethreshold, I, Actor) +{ + PROP_INT_PARM(id, 0); + if (id < 0) + I_Error("ChaseThreshold cannot be negative."); + defaults->DefThreshold = id; +} + //========================================================================== // //========================================================================== diff --git a/src/version.h b/src/version.h index 913c9bd18..168cb7519 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4524 +#define SAVEVER 4525 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index d44dd4627..0c42ea574 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -31,6 +31,7 @@ ACTOR Actor native //: Thinker RipperLevel 0 RipLevelMin 0 RipLevelMax 0 + ChaseThreshold 100 // Variables for the expression evaluator // NOTE: fixed_t and angle_t are only used here to ensure proper conversion @@ -69,6 +70,8 @@ ACTOR Actor native //: Thinker native fixed_t meleerange; native fixed_t speed; native angle_t roll; + native int threshold; + native int DefThreshold; // Meh, MBF redundant functions. Only for DeHackEd support. action native A_Turn(float angle = 0); @@ -337,6 +340,7 @@ ACTOR Actor native //: Thinker action native A_SetRipperLevel(int level); action native A_SetRipMin(int min); action native A_SetRipMax(int max); + action native A_SetChaseThreshold(int threshold, bool def = false, int ptr = AAPTR_DEFAULT); action native A_CheckBlock(state block, int flags = 0, int ptr = AAPTR_DEFAULT); action native A_CheckSightOrRange(float distance, state label, bool two_dimension = false); action native A_CheckRange(float distance, state label, bool two_dimension = false);