diff --git a/src/actor.h b/src/actor.h index 86bfd9796..e6ae8d9f8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1041,6 +1041,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 26d46cffc..f78f38d43 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -90,7 +90,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 d06ca9ccc..e7af23025 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -300,6 +300,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 b97d17af8..eb3c6d354 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1511,7 +1511,7 @@ dopain: { if (source == target->target) { - target->threshold = BASETHRESHOLD; + target->threshold = target->DefThreshold; if (target->state == target->SpawnState && target->SeeState != NULL) { target->SetState (target->SeeState); @@ -1532,7 +1532,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 1064abbf9..9030a0736 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 562128542..d47460038 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -433,6 +433,10 @@ void AActor::Serialize (FArchive &arc) << RipLevelMin << RipLevelMax; } + if (SaveVersion >= 4533) + { + arc << DefThreshold; + } { FString tagstr; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index f0aedd5c6..cf2be64e8 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -516,7 +516,7 @@ void P_SerializeWorld (FArchive &arc) arc << zn->Environment; } - if (SaveVersion >= 4532) + if (SaveVersion >= 4533) { arc << linePortals; } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 70a6d96ec..22146228d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6360,6 +6360,35 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRipMax) return 0; } +//=========================================================================== +// +// 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) +{ + PARAM_ACTION_PROLOGUE; + PARAM_INT(threshold); + PARAM_BOOL_OPT(def) { def = false; } + PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + + + AActor *mobj = COPY_AAPTR(self, ptr); + if (!mobj) + { + ACTION_SET_RESULT(false); + return 0; + } + if (def) + mobj->DefThreshold = (threshold >= 0) ? threshold : 0; + else + mobj->threshold = (threshold >= 0) ? threshold : 0; + return 0; +} + //========================================================================== // // A_CheckProximity(jump, classname, distance, count, flags, ptr) @@ -6687,4 +6716,4 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) } } return numret; -} \ No newline at end of file +} diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 8581ca8b2..82fe3a739 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -651,4 +651,6 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_ReactionTime,TypeSInt32, VARF_Native, myoffsetof(AActor,reactiontime))); symt.AddSymbol(new PField(NAME_MeleeRange, TypeFixed, VARF_Native, myoffsetof(AActor,meleerange))); symt.AddSymbol(new PField(NAME_Speed, TypeFixed, VARF_Native, myoffsetof(AActor,Speed))); + symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native, myoffsetof(AActor,threshold))); + symt.AddSymbol(new PField(NAME_DefThreshold,TypeSInt32, VARF_Native, myoffsetof(AActor,DefThreshold))); } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index fef2c075a..5b9874a35 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -544,6 +544,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 3af1c1b7f..a585e9aec 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 4532 +#define SAVEVER 4533 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 1f7efd895..869d9dd2e 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -31,13 +31,13 @@ ACTOR Actor native //: Thinker RipperLevel 0 RipLevelMin 0 RipLevelMax 0 - + ChaseThreshold 100 + // Functions native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); native bool IsPointerEqual(int ptr_select1, int ptr_select2); // Action functions - // Meh, MBF redundant functions. Only for DeHackEd support. action native A_Turn(float angle = 0); action native A_LineEffect(int boomspecial = 0, int tag = 0); @@ -307,7 +307,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);