From cea36c6da0bba01a456eb1f582d9db55a8d4c2d9 Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Tue, 27 Apr 2021 00:09:53 -0300 Subject: [PATCH] Add A_SetBlendMode action --- src/deh_tables.c | 1 + src/info.h | 2 ++ src/lua_mobjlib.c | 8 +++++++- src/p_enemy.c | 24 ++++++++++++++++++++++++ src/r_draw.c | 2 +- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index dd6d7d69f..73ccc4f96 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -219,6 +219,7 @@ actionpointer_t actionpointers[] = {{A_SetTargetsTarget}, "A_SETTARGETSTARGET"}, {{A_SetObjectFlags}, "A_SETOBJECTFLAGS"}, {{A_SetObjectFlags2}, "A_SETOBJECTFLAGS2"}, + {{A_SetBlendMode}, "A_SETBLENDMODE"}, {{A_RandomState}, "A_RANDOMSTATE"}, {{A_RandomStateRange}, "A_RANDOMSTATERANGE"}, {{A_DualAction}, "A_DUALACTION"}, diff --git a/src/info.h b/src/info.h index 60e970246..5aac16e3b 100644 --- a/src/info.h +++ b/src/info.h @@ -175,6 +175,7 @@ enum actionnum A_SETTARGETSTARGET, A_SETOBJECTFLAGS, A_SETOBJECTFLAGS2, + A_SETBLENDMODE, A_RANDOMSTATE, A_RANDOMSTATERANGE, A_DUALACTION, @@ -441,6 +442,7 @@ void A_ZThrust(); void A_SetTargetsTarget(); void A_SetObjectFlags(); void A_SetObjectFlags2(); +void A_SetBlendMode(); void A_RandomState(); void A_RandomStateRange(); void A_DualAction(); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 65adceb15..994f6a789 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -12,6 +12,7 @@ #include "doomdef.h" #include "fastcmp.h" +#include "r_data.h" #include "r_skins.h" #include "p_local.h" #include "g_game.h" @@ -654,8 +655,13 @@ static int mobj_set(lua_State *L) break; } case mobj_blendmode: - mo->blendmode = (INT32)luaL_checkinteger(L, 3); + { + INT32 blendmode = (INT32)luaL_checkinteger(L, 3); + if (blendmode < 0 || blendmode > AST_OVERLAY) + return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); + mo->blendmode = blendmode; break; + } case mobj_bnext: return NOSETPOS; case mobj_bprev: diff --git a/src/p_enemy.c b/src/p_enemy.c index 59176d6cc..19030567b 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -197,6 +197,7 @@ void A_ZThrust(mobj_t *actor); void A_SetTargetsTarget(mobj_t *actor); void A_SetObjectFlags(mobj_t *actor); void A_SetObjectFlags2(mobj_t *actor); +void A_SetBlendMode(mobj_t *actor); void A_RandomState(mobj_t *actor); void A_RandomStateRange(mobj_t *actor); void A_DualAction(mobj_t *actor); @@ -9085,6 +9086,29 @@ void A_SetObjectFlags2(mobj_t *actor) actor->flags2 = locvar1; } +// Function: A_SetBlendMode +// +// Description: Sets the blend mode of an object +// +// var1 = blend mode to set +// var2 = unused +// +void A_SetBlendMode(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction(A_SETBLENDMODE, actor)) + return; + + if (locvar1 < 0 || locvar1 > AST_OVERLAY) + { + CONS_Debug(DBG_GAMELOGIC, "Blend mode %d out of range!\n", locvar1); + return; + } + + actor->blendmode = locvar1; +} + // Function: A_BossJetFume // // Description: Spawns jet fumes/other attachment miscellany for the boss. To only be used when he is spawned. diff --git a/src/r_draw.c b/src/r_draw.c index 9a835ee58..00ffe34dc 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -341,7 +341,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { size_t offs; - if (style == AST_COPY || style == AST_OVERLAY) + if (style <= AST_COPY || style >= AST_OVERLAY) return NULL; offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT);