From a556d1d8ff6293a3b9b440d31b0a8d8a82bda939 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:20:19 +0000 Subject: [PATCH] tr1/effects: add dynamic light to guns and explosions This adds dynamic light for explosion and (enemy) gunshots. Resolves #2357. --- docs/tr1/CHANGELOG.md | 1 + docs/tr1/README.md | 1 + src/tr1/game/objects/effects/explosion.c | 9 ++++++++- src/tr1/game/objects/effects/gunshot.c | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/tr1/CHANGELOG.md b/docs/tr1/CHANGELOG.md index fdb1daeaa..2ff0a391d 100644 --- a/docs/tr1/CHANGELOG.md +++ b/docs/tr1/CHANGELOG.md @@ -9,6 +9,7 @@ - added pause screen support to demos - added a fade-out effect when exiting the pause screen to the inventory - added exit fade-out effects (#2348) +- added optional dynamic lighting for gun flashes and explosions, similar to TR2+ (#2357) - ⚠️ changed the game data to use a separate strings file for text information, removing it from the game flow file - changed the sprite limit from 512 to 1024 - changed demo to be interrupted only by esc or action keys diff --git a/docs/tr1/README.md b/docs/tr1/README.md index bae809509..a3aa24d7d 100644 --- a/docs/tr1/README.md +++ b/docs/tr1/README.md @@ -519,6 +519,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det - added support for animated room sprites, which also restores intended behavior in, for example, The Cistern room 0 - added skybox support, with a default option provided for Lost Valley, Colosseum and Obelisk of Khamoon; custom level builders can use object slot `184` - added reflections of Midas Hand death animation and savegame crystals +- added optional dynamic lighting for gun flashes and explosions, similar to TR2+ - changed the Scion in The Great Pyramid from spawning blood when hit to a ricochet effect - fixed thin black lines between polygons - fixed black screen flashing when navigating the inventory diff --git a/src/tr1/game/objects/effects/explosion.c b/src/tr1/game/objects/effects/explosion.c index 2278ec4b6..cd33117b5 100644 --- a/src/tr1/game/objects/effects/explosion.c +++ b/src/tr1/game/objects/effects/explosion.c @@ -3,6 +3,9 @@ #include "game/effects.h" #include "global/vars.h" +#include +#include + void Explosion_Setup(OBJECT *obj) { obj->control = Explosion_Control; @@ -11,11 +14,15 @@ void Explosion_Setup(OBJECT *obj) void Explosion_Control(int16_t effect_num) { EFFECT *effect = Effect_Get(effect_num); + const OBJECT *const obj = Object_GetObject(effect->object_id); effect->counter++; if (effect->counter == 2) { effect->counter = 0; effect->frame_num--; - if (effect->frame_num <= g_Objects[effect->object_id].mesh_count) { + if (g_Config.gameplay.enable_gun_flash + && effect->frame_num > obj->mesh_count) { + Output_AddDynamicLight(effect->pos, 13, 11); + } else if (effect->frame_num <= obj->mesh_count) { Effect_Kill(effect_num); } } diff --git a/src/tr1/game/objects/effects/gunshot.c b/src/tr1/game/objects/effects/gunshot.c index 6ab01b857..bfc844588 100644 --- a/src/tr1/game/objects/effects/gunshot.c +++ b/src/tr1/game/objects/effects/gunshot.c @@ -3,6 +3,9 @@ #include "game/effects.h" #include "game/random.h" +#include +#include + void GunShot_Setup(OBJECT *obj) { obj->control = GunShot_Control; @@ -17,4 +20,7 @@ void GunShot_Control(int16_t effect_num) return; } effect->rot.z = Random_GetControl(); + if (g_Config.gameplay.enable_gun_flash) { + Output_AddDynamicLight(effect->pos, 12, 11); + } }