Skip to content

Commit

Permalink
tr1/effects: add dynamic light to guns and explosions
Browse files Browse the repository at this point in the history
This adds dynamic light for explosion and (enemy) gunshots.

Resolves #2357.
  • Loading branch information
lahm86 committed Jan 23, 2025
1 parent da474e5 commit a556d1d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/tr1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/tr1/game/objects/effects/explosion.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "game/effects.h"
#include "global/vars.h"

#include <libtrx/config.h>
#include <libtrx/game/output.h>

void Explosion_Setup(OBJECT *obj)
{
obj->control = Explosion_Control;
Expand All @@ -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);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/tr1/game/objects/effects/gunshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "game/effects.h"
#include "game/random.h"

#include <libtrx/config.h>
#include <libtrx/game/output.h>

void GunShot_Setup(OBJECT *obj)
{
obj->control = GunShot_Control;
Expand All @@ -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);
}
}

0 comments on commit a556d1d

Please sign in to comment.