Skip to content

Commit

Permalink
inject: add explosion sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 22, 2024
1 parent f7c5121 commit 5bdd966
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-××
- fixed double "Fly mode enabled" message when using `/fly` console command (regression from 4.0)
- changed the easter egg console command to pack more punch

## [4.4](https://github.com/LostArtefacts/TR1X/compare/4.3-102-g458cd96...4.4) - 2024-09-20
- added `/exit` command (#1462)
Expand Down
2 changes: 2 additions & 0 deletions data/ship/cfg/TR1X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"data/injections/lara_jumping.bin",
"data/injections/purple_crystal.bin",
"data/injections/uzi_sfx.bin",
"data/injections/explosion.bin",
],
"convert_dropped_guns": false,

Expand All @@ -38,6 +39,7 @@
"data/injections/lara_animations.bin",
"data/injections/lara_jumping.bin",
"data/injections/uzi_sfx.bin",
"data/injections/explosion.bin",
],
"sequence": [
{"type": "play_fmv", "fmv_path": "fmv/mansion.avi"},
Expand Down
Binary file added data/ship/data/injections/explosion.bin
Binary file not shown.
5 changes: 5 additions & 0 deletions src/game/effects/exploding_death.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

#include <stdint.h>

// Mesh_bits: which meshes to affect.
// Damage:
// * Positive values - deal damage, enable body part explosions.
// * Negative values - deal damage, disable body part explosions.
// * Zero - don't deal any damage, disable body part explosions.
int32_t Effect_ExplodingDeath(
int16_t item_num, int32_t mesh_bits, int16_t damage);
6 changes: 6 additions & 0 deletions src/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "game/lara/common.h"
#include "game/lot.h"
#include "game/music.h"
#include "game/objects/creatures/mutant.h"
#include "game/objects/creatures/pierre.h"
#include "game/objects/setup.h"
#include "game/output.h"
Expand Down Expand Up @@ -919,6 +920,11 @@ static void M_CompleteSetup(int32_t level_num)
}
}

// We inject explosions sprites and sounds, although in the original game,
// some levels lack them, resulting in no audio or visual effects when
// killing mutants. This is to maintain that feature.
Mutant_ToggleExplosions(g_Objects[O_EXPLOSION_1].loaded);

Inject_AllInjections(&m_LevelInfo);

M_MarkWaterEdgeVertices();
Expand Down
10 changes: 9 additions & 1 deletion src/game/objects/creatures/mutant.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ enum FLYER_ANIM {
FLYER_FLY = 13,
};

static bool m_EnableExplosions = true;
static BITE_INFO m_WarriorBite = { -27, 98, 0, 10 };
static BITE_INFO m_WarriorRocket = { 51, 213, 0, 14 };
static BITE_INFO m_WarriorShard = { -35, 269, 0, 9 };

void Mutant_ToggleExplosions(bool enable)
{
m_EnableExplosions = enable;
}

void Mutant_Setup(OBJECT_INFO *obj)
{
if (!obj->loaded) {
Expand Down Expand Up @@ -117,7 +123,9 @@ void Mutant_FlyerControl(int16_t item_num)
int16_t angle = 0;

if (item->hit_points <= 0) {
if (Effect_ExplodingDeath(item_num, -1, FLYER_PART_DAMAGE)) {
if (Effect_ExplodingDeath(
item_num, -1,
m_EnableExplosions ? FLYER_SMARTNESS : -FLYER_PART_DAMAGE)) {
Sound_Effect(SFX_ATLANTEAN_DEATH, &item->pos, SPM_NORMAL);
LOT_DisableBaddieAI(item_num);
Item_Kill(item_num);
Expand Down
1 change: 1 addition & 0 deletions src/game/objects/creatures/mutant.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void Mutant_Setup(OBJECT_INFO *obj);
void Mutant_Setup2(OBJECT_INFO *obj);
void Mutant_Setup3(OBJECT_INFO *obj);

void Mutant_ToggleExplosions(bool enable);
void Mutant_FlyerControl(int16_t item_num);

void Mutant_Initialise2(int16_t item_num);
8 changes: 4 additions & 4 deletions src/game/objects/effects/body_part.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void BodyPart_Control(int16_t fx_num)
const int32_t height =
Room_GetHeight(sector, fx->pos.x, fx->pos.y, fx->pos.z);
if (fx->pos.y >= height) {
if (fx->counter) {
if (fx->counter > 0) {
fx->speed = 0;
fx->frame_num = 0;
fx->counter = 0;
Expand All @@ -51,10 +51,10 @@ void BodyPart_Control(int16_t fx_num)
return;
}

if (Lara_IsNearItem(&fx->pos, fx->counter * 2)) {
Lara_TakeDamage(fx->counter, true);
if (Lara_IsNearItem(&fx->pos, ABS(fx->counter) * 2)) {
Lara_TakeDamage(ABS(fx->counter), true);

if (fx->counter) {
if (fx->counter > 0) {
fx->speed = 0;
fx->frame_num = 0;
fx->counter = 0;
Expand Down

0 comments on commit 5bdd966

Please sign in to comment.