From 94f08aa593b180c22318e88d1ae925f91139f2b1 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 27 Nov 2014 15:12:33 -0600 Subject: [PATCH] - Added: Boolean to specify if A_Raise functions should perform CopyFriendliness based upon who raised it. By default, this is false. --- src/p_lnspec.cpp | 4 ++-- src/p_local.h | 2 +- src/p_things.cpp | 8 +++++++- src/thingdef/thingdef_codeptr.cpp | 28 ++++++++++++++++++++++------ wadsrc/static/actors/actor.txt | 6 +++--- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 0d74b4d423..67215cf41e 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1510,7 +1510,7 @@ FUNC(LS_Thing_Raise) if (arg0==0) { - ok = P_Thing_Raise (it); + ok = P_Thing_Raise (it,NULL); } else { @@ -1518,7 +1518,7 @@ FUNC(LS_Thing_Raise) while ( (target = iterator.Next ()) ) { - ok |= P_Thing_Raise(target); + ok |= P_Thing_Raise(target,NULL); } } return ok; diff --git a/src/p_local.h b/src/p_local.h index dec80ecaa1..c0a754e25b 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -171,7 +171,7 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool add, bool setbob); void P_RemoveThing(AActor * actor); -bool P_Thing_Raise(AActor *thing); +bool P_Thing_Raise(AActor *thing, AActor *raiser); bool P_Thing_CanRaise(AActor *thing); const PClass *P_GetSpawnableType(int spawnnum); diff --git a/src/p_things.cpp b/src/p_things.cpp index 0189848e4e..63173564c3 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -412,7 +412,7 @@ void P_RemoveThing(AActor * actor) } -bool P_Thing_Raise(AActor *thing) +bool P_Thing_Raise(AActor *thing, AActor *raiser) { FState * RaiseState = thing->GetRaiseState(); if (RaiseState == NULL) @@ -445,6 +445,12 @@ bool P_Thing_Raise(AActor *thing) thing->Revive(); + if (raiser != NULL) + { + // Let's copy the friendliness of the one who raised it. + thing->CopyFriendliness(raiser, false); + } + thing->SetState (RaiseState); return true; } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 5629edd9e1..a620f0080a 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3761,11 +3761,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag) // A_RaiseMaster // //=========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster) +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RaiseMaster) { + ACTION_PARAM_START(1); + ACTION_PARAM_BOOL(copy, 0); + if (self->master != NULL) { - P_Thing_Raise(self->master); + if (copy) + P_Thing_Raise(self->master, self); + else + P_Thing_Raise(self->master, NULL); } } @@ -3774,8 +3780,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster) // A_RaiseChildren // //=========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RaiseChildren) { + ACTION_PARAM_START(1); + ACTION_PARAM_BOOL(copy, 0); TThinkerIterator it; AActor *mo; @@ -3783,7 +3791,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) { if (mo->master == self) { - P_Thing_Raise(mo); + if (copy) + P_Thing_Raise(mo, self); + else + P_Thing_Raise(mo, NULL); } } } @@ -3793,8 +3804,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren) // A_RaiseSiblings // //=========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RaiseSiblings) { + ACTION_PARAM_START(1); + ACTION_PARAM_BOOL(copy, 0); TThinkerIterator it; AActor *mo; @@ -3804,7 +3817,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) { if (mo->master == self->master && mo != self) { - P_Thing_Raise(mo); + if (copy) + P_Thing_Raise(mo, self); + else + P_Thing_Raise(mo, NULL); } } } diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index c8e689dae0..2f97c2a71b 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -241,9 +241,9 @@ ACTOR Actor native //: Thinker action native A_KillMaster(name damagetype = "none", int flags = 0); action native A_KillChildren(name damagetype = "none", int flags = 0); action native A_KillSiblings(name damagetype = "none", int flags = 0); - action native A_RaiseMaster(); - action native A_RaiseChildren(); - action native A_RaiseSiblings(); + action native A_RaiseMaster(bool copy = 0); + action native A_RaiseChildren(bool copy = 0); + action native A_RaiseSiblings(bool copy = 0); action native A_CheckFloor(state label); action native A_CheckCeiling(state label); action native A_PlayerSkinCheck(state label);