diff --git a/src/actor.h b/src/actor.h index ed38d0020..f8545624a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1048,6 +1048,7 @@ public: SDWORD reactiontime; // if non 0, don't attack yet; used by // player to freeze a bit after teleporting SDWORD threshold; // if > 0, the target will be chased + SDWORD DefThreshold; // [MC] Default threshold which the actor will reset its threshold to after switching targets // no matter what (even if shot) player_t *player; // only valid if type of APlayerPawn TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 6c8652f7c..78a27c95d 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -85,7 +85,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) self->flags &= ~MF_SPECIAL; static_cast(self)->DropTime = 0; // Set up the new rebel. - rebel->threshold = BASETHRESHOLD; + rebel->threshold = rebel->DefThreshold; rebel->target = NULL; rebel->flags4 |= MF4_INCOMBAT; rebel->LastHeard = owner; // Make sure the rebels look for targets diff --git a/src/namedef.h b/src/namedef.h index ae456883c..c0fbf4630 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -298,6 +298,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 0c61b2d7d..57c7cdfa0 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_local.h b/src/p_local.h index 395a05990..79050472a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -87,7 +87,8 @@ inline int GetSafeBlockY(long long blocky) #define PLAYERMISSILERANGE (8192*FRACUNIT) // [RH] New MISSILERANGE for players // follow a player exlusively for 3 seconds -#define BASETHRESHOLD 100 +// No longer used. +// #define BASETHRESHOLD 100 // diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 789c468d1..317af441c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -348,6 +348,10 @@ void AActor::Serialize (FArchive &arc) << RipLevelMin << RipLevelMax; } + if (SaveVersion >= 4531) + { + arc << DefThreshold; + } { FString tagstr; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 8608915f4..ba584f5b7 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6028,6 +6028,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_CheckProximity(jump, classname, distance, count, flags, ptr) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 6267ae6d9..7abc00925 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 fd0636a70..0f6b302aa 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 167f8a303..34e7c22f7 100644 --- a/src/version.h +++ b/src/version.h @@ -75,8 +75,8 @@ const char *GetVersionString(); #define MINSAVEVER 3100 // Use 4500 as the base git save version, since it's higher than the -// SVN revision ever got. -#define SAVEVER 4531 +// SVN revision ever got. +#define SAVEVER 4532 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 08e376e61..8bc4f6dc2 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); @@ -339,7 +342,8 @@ 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_CheckProximity(state jump, class classname, float distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT); + action native A_SetChaseThreshold(int threshold, bool def = false, int ptr = AAPTR_DEFAULT); + action native A_CheckProximity(state jump, class classname, float distance, int count = 1, int flags = 0, 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);