Allow "fade light level" linedef executor to fade relative to current value

This commit is contained in:
MascaraSnake 2021-09-19 23:12:30 +02:00
parent 318c1b477d
commit 6871262909
6 changed files with 17 additions and 11 deletions

View file

@ -2660,7 +2660,7 @@ udmf
} }
arg2 arg2
{ {
title = "Speed"; title = "Fading speed";
} }
arg3 arg3
{ {
@ -2668,8 +2668,9 @@ udmf
type = 12; type = 12;
enum enum
{ {
1 = "Speed is tic duration"; 1 = "Add to current translucency";
2 = "Override existing fade"; 2 = "Interrupt ongoing fades";
4 = "Speed is duration";
} }
} }
} }

View file

@ -2342,9 +2342,10 @@ static int lib_pFadeLight(lua_State *L)
INT32 speed = (INT32)luaL_checkinteger(L, 3); INT32 speed = (INT32)luaL_checkinteger(L, 3);
boolean ticbased = lua_optboolean(L, 4); boolean ticbased = lua_optboolean(L, 4);
boolean force = lua_optboolean(L, 5); boolean force = lua_optboolean(L, 5);
boolean relative = lua_optboolean(L, 6);
NOHUD NOHUD
INLEVEL INLEVEL
P_FadeLight(tag, destvalue, speed, ticbased, force); P_FadeLight(tag, destvalue, speed, ticbased, force, relative);
return 0; return 0;
} }

View file

@ -358,9 +358,10 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean
} }
} }
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force, boolean relative)
{ {
INT32 i; INT32 i;
INT32 realdestvalue;
// search all sectors for ones with tag // search all sectors for ones with tag
TAG_ITER_SECTORS(tag, i) TAG_ITER_SECTORS(tag, i)
@ -373,7 +374,9 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, bool
CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer); CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer);
continue; continue;
} }
P_FadeLightBySector(&sectors[i], destvalue, speed, ticbased);
realdestvalue = relative ? max(0, min(255, sectors[i].lightlevel + destvalue)) : destvalue;
P_FadeLightBySector(&sectors[i], realdestvalue, speed, ticbased);
} }
} }

View file

@ -3745,7 +3745,7 @@ static void P_ConvertBinaryMap(void)
if (lines[i].flags & ML_EFFECT4) if (lines[i].flags & ML_EFFECT4)
lines[i].args[3] |= TMF_TICBASED; lines[i].args[3] |= TMF_TICBASED;
if (lines[i].flags & ML_EFFECT5) if (lines[i].flags & ML_EFFECT5)
lines[i].args[3] |= TMF_FORCE; lines[i].args[3] |= TMF_OVERRIDE;
break; break;
case 421: //Stop lighting effect case 421: //Stop lighting effect
lines[i].args[0] = tag; lines[i].args[0] = tag;

View file

@ -2527,7 +2527,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
break; break;
case 420: // Fade light levels in tagged sectors to new value case 420: // Fade light levels in tagged sectors to new value
P_FadeLight(line->args[0], line->args[1], line->args[2], line->args[3] & TMF_TICBASED, line->args[3] & TMF_FORCE); P_FadeLight(line->args[0], line->args[1], line->args[2], line->args[3] & TMF_TICBASED, line->args[3] & TMF_OVERRIDE, line->args[3] & TMF_RELATIVE);
break; break;
case 421: // Stop lighting effect in tagged sectors case 421: // Stop lighting effect in tagged sectors

View file

@ -121,8 +121,9 @@ typedef enum
typedef enum typedef enum
{ {
TMF_TICBASED = 1, TMF_RELATIVE = 1,
TMF_FORCE = 1<<1, TMF_OVERRIDE = 1<<1,
TMF_TICBASED = 1<<2,
} textmapfadeflags_t; } textmapfadeflags_t;
typedef enum typedef enum
@ -301,7 +302,7 @@ void T_Glow(glow_t *g);
glow_t *P_SpawnAdjustableGlowingLight(sector_t *sector, INT16 lighta, INT16 lightb, INT32 length); glow_t *P_SpawnAdjustableGlowingLight(sector_t *sector, INT16 lighta, INT16 lightb, INT32 length);
void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased);
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force); void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force, boolean relative);
void T_LightFade(lightlevel_t *ll); void T_LightFade(lightlevel_t *ll);
typedef enum typedef enum