effects: add dynamic light to guns and explosions

This adds dynamic light for explosion and (enemy) gunshots in TR1 and
makes it optional in TR2.

Resolves #2357.
This commit is contained in:
lahm86 2025-01-23 14:20:19 +00:00
parent dfab21842f
commit 2f16613d74
8 changed files with 31 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -16,6 +16,7 @@
| Toggle photo mode UI | --- | H |
- changed the `/kill` command with no arguments to look for enemies within 5 tiles (#2297)
- changed the game data to use a separate strings file for text information, removing it from the game flow file
- changed dynamic lighting for gun flashes and explosions to be optional (#2357)
- fixed showing inventory ring up/down arrows when uncalled for (#2225)
- fixed Lara never stepping backwards off a step using her right foot (#1602)
- fixed blood spawning on Lara from gunshots using incorrect positioning data (#2253)

View file

@ -100,6 +100,7 @@ game with new enhancements and features.
- changed the hardware renderer to always use 16-bit textures
- changed the software renderer to use the picture's palette for the background pictures
- changed fullscreen behavior to use windowed desktop mode
- changed dynamic lighting for gun flashes and explosions to be optional
- fixed fullscreen issues
- fixed black borders in windowed mode
- fixed "Failed to create device" when toggling fullscreen

View file

@ -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;
@ -11,12 +14,18 @@ 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.visuals.enable_gun_lighting
&& effect->frame_num > obj->mesh_count) {
Output_AddDynamicLight(effect->pos, 13, 11);
} else if (effect->frame_num <= obj->mesh_count) {
Effect_Kill(effect_num);
}
} else if (g_Config.visuals.enable_gun_lighting) {
Output_AddDynamicLight(effect->pos, 12, 10);
}
}

View file

@ -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;
@ -17,4 +20,7 @@ void GunShot_Control(int16_t effect_num)
return;
}
effect->rot.z = Random_GetControl();
if (g_Config.visuals.enable_gun_lighting) {
Output_AddDynamicLight(effect->pos, 12, 11);
}
}

View file

@ -5,6 +5,8 @@
#include "game/output.h"
#include "global/vars.h"
#include <libtrx/config.h>
void Explosion_Control(const int16_t effect_num)
{
EFFECT *const effect = Effect_Get(effect_num);
@ -13,12 +15,13 @@ void Explosion_Control(const int16_t effect_num)
if (effect->counter == 2) {
effect->frame_num--;
effect->counter = 0;
if (effect->frame_num > obj->mesh_count) {
if (g_Config.visuals.enable_gun_lighting
&& effect->frame_num > obj->mesh_count) {
Output_AddDynamicLight(effect->pos, 13, 11);
} else {
} else if (effect->frame_num <= obj->mesh_count) {
Effect_Kill(effect_num);
}
} else {
} else if (g_Config.visuals.enable_gun_lighting) {
Output_AddDynamicLight(effect->pos, 12, 10);
}
}

View file

@ -5,6 +5,8 @@
#include "game/random.h"
#include "global/vars.h"
#include <libtrx/config.h>
void GunFlash_Control(const int16_t effect_num)
{
EFFECT *const effect = Effect_Get(effect_num);
@ -16,7 +18,9 @@ void GunFlash_Control(const int16_t effect_num)
}
effect->rot.z = Random_GetControl();
Output_AddDynamicLight(effect->pos, 12, 11);
if (g_Config.visuals.enable_gun_lighting) {
Output_AddDynamicLight(effect->pos, 12, 11);
}
}
void GunFlash_Setup(void)