Merge branch 'ChaseThresholdScript' of https://github.com/MajorCooke/zdoom

# Conflicts:
#	src/version.h
This commit is contained in:
Christoph Oelckers 2016-02-08 13:06:08 +01:00
commit 43b4d452db
12 changed files with 61 additions and 10 deletions

View file

@ -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<AActor> LastLookActor; // Actor last looked for (if TIDtoHate != 0)

View file

@ -90,7 +90,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
self->flags &= ~MF_SPECIAL;
static_cast<AInventory *>(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

View file

@ -300,6 +300,8 @@ xx(Z)
xx(MomX)
xx(MomY)
xx(MomZ)
xx(Threshold)
xx(DefThreshold)
xx(Abs)
xx(ACS_NamedExecuteWithResult)
xx(CallACS)

View file

@ -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);

View file

@ -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
//

View file

@ -433,6 +433,10 @@ void AActor::Serialize (FArchive &arc)
<< RipLevelMin
<< RipLevelMax;
}
if (SaveVersion >= 4533)
{
arc << DefThreshold;
}
{
FString tagstr;

View file

@ -516,7 +516,7 @@ void P_SerializeWorld (FArchive &arc)
arc << zn->Environment;
}
if (SaveVersion >= 4532)
if (SaveVersion >= 4533)
{
arc << linePortals;
}

View file

@ -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;
}
}

View file

@ -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)));
}

View file

@ -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;
}
//==========================================================================
//
//==========================================================================

View file

@ -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)

View file

@ -31,13 +31,13 @@ ACTOR Actor native //: Thinker
RipperLevel 0
RipLevelMin 0
RipLevelMax 0
ChaseThreshold 100
// Functions
native bool CheckClass(class<Actor> 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<Actor> 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<Actor> 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);