diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 3b57dd2830..2216ebf3a1 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -1135,16 +1135,61 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay) PARAM_ACTION_PROLOGUE; PARAM_INT (layer); PARAM_STATE_OPT (state) { state = nullptr; } + PARAM_BOOL_OPT (dontoverride) { dontoverride = false; } player_t *player = self->player; if (player == nullptr) - return 0; + ACTION_RETURN_BOOL(false); DPSprite *pspr; + if (dontoverride && (player->FindPSprite(layer) != nullptr)) + { + ACTION_RETURN_BOOL(false); + } pspr = new DPSprite(player, stateowner, layer); pspr->SetState(state); - return 0; + ACTION_RETURN_BOOL(true); +} + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearOverlays) +{ + PARAM_ACTION_PROLOGUE; + PARAM_INT_OPT(start) { start = 0; } + PARAM_INT_OPT(stop) { stop = 0; } + PARAM_BOOL_OPT(safety) { safety = true; } + + if (!ACTION_CALL_FROM_PSPRITE()) + { + ACTION_RETURN_INT(0); + } + player_t *player = self->player; + if (!start && !stop) + { + start = -INT_MAX; + stop = PSP_TARGETCENTER - 1; + } + + int count = 0; + for (int i = start; i <= stop; i++) + { + if (safety) + { + if (i >= PSP_TARGETCENTER) + break; + else if ((i >= PSP_STRIFEHANDS && i <= PSP_WEAPON) || (i == PSP_FLASH)) + continue; + } + // [MC]Don't affect non-hardcoded layers unless it's really desired. + DPSprite *pspr = player->FindPSprite(i); + if (pspr != nullptr) + { + pspr->SetState(nullptr); + count++; + } + + } + ACTION_RETURN_INT(count); } // diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8e6f0f3388..ea22edbf4c 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -329,12 +329,13 @@ ACTOR Actor native //: Thinker native state A_CheckSightOrRange(float distance, state label, bool two_dimension = false); native state A_CheckRange(float distance, state label, bool two_dimension = false); action native bool A_FaceMovementDirection(float offset = 0, float anglelimit = 0, float pitchlimit = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + action native int A_ClearOverlays(int start = 0, int stop = 0, bool safety = true); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER); - action native A_Overlay(int layer, state start = ""); + action native bool A_Overlay(int layer, state start = "", bool nooverride = false); action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0); action native A_OverlayOffset(int layer = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0); action native A_OverlayFlags(int layer, int flags, bool set);