Skip to content

Commit 8387fad

Browse files
committed
add shotgun fire
1 parent 85be97f commit 8387fad

File tree

6 files changed

+61
-67
lines changed

6 files changed

+61
-67
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Currently the following configuration options are supported:
3333
etc. (similar to TR2 style).
3434
- `enable_enhanced_ui`: enables UI scaling of in-game inventory text and ammo
3535
text (useful for 4k screens).
36+
- `enable_shotgun_flash`: draws flame when firing a shotgun, like for other guns.
3637
- `enable_numeric_keys`: enables quick weapon draws and medpack usage.
3738
- <kbd>1</kbd>: draw pistols
3839
- <kbd>2</kbd>: draw shotgun

Tomb1Main.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"enable_enemy_healthbar": true,
99
"enable_enhanced_look": true,
1010
"enable_enhanced_ui": true,
11+
"enable_shotgun_flash": true,
1112
"enable_numeric_keys": true,
1213
"healthbar_showing_mode": "flashing",
1314
"fix_end_of_level_freeze": true,

src/game/draw.c

+39-54
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "game/health.h"
88
#include "specific/game.h"
99
#include "specific/output.h"
10+
#include "mod.h"
1011
#include "util.h"
1112

1213
int32_t __cdecl DrawPhaseCinematic()
@@ -656,18 +657,7 @@ void __cdecl DrawLara(ITEM_INFO* item)
656657
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_R], clip);
657658

658659
if (Lara.right_arm.flash_gun) {
659-
saved_matrix._00 = PhdMatrixPtr->_00;
660-
saved_matrix._01 = PhdMatrixPtr->_01;
661-
saved_matrix._02 = PhdMatrixPtr->_02;
662-
saved_matrix._03 = PhdMatrixPtr->_03;
663-
saved_matrix._10 = PhdMatrixPtr->_10;
664-
saved_matrix._11 = PhdMatrixPtr->_11;
665-
saved_matrix._12 = PhdMatrixPtr->_12;
666-
saved_matrix._13 = PhdMatrixPtr->_13;
667-
saved_matrix._20 = PhdMatrixPtr->_20;
668-
saved_matrix._21 = PhdMatrixPtr->_21;
669-
saved_matrix._22 = PhdMatrixPtr->_22;
670-
saved_matrix._23 = PhdMatrixPtr->_23;
660+
saved_matrix = *PhdMatrixPtr;
671661
}
672662

673663
phd_PopMatrix();
@@ -705,18 +695,7 @@ void __cdecl DrawLara(ITEM_INFO* item)
705695
DrawGunFlash(fire_arms, clip);
706696
}
707697
if (Lara.right_arm.flash_gun) {
708-
PhdMatrixPtr->_00 = saved_matrix._00;
709-
PhdMatrixPtr->_01 = saved_matrix._01;
710-
PhdMatrixPtr->_02 = saved_matrix._02;
711-
PhdMatrixPtr->_03 = saved_matrix._03;
712-
PhdMatrixPtr->_10 = saved_matrix._10;
713-
PhdMatrixPtr->_11 = saved_matrix._11;
714-
PhdMatrixPtr->_12 = saved_matrix._12;
715-
PhdMatrixPtr->_13 = saved_matrix._13;
716-
PhdMatrixPtr->_20 = saved_matrix._20;
717-
PhdMatrixPtr->_21 = saved_matrix._21;
718-
PhdMatrixPtr->_22 = saved_matrix._22;
719-
PhdMatrixPtr->_23 = saved_matrix._23;
698+
*PhdMatrixPtr = saved_matrix;
720699
DrawGunFlash(fire_arms, clip);
721700
}
722701

@@ -740,6 +719,10 @@ void __cdecl DrawLara(ITEM_INFO* item)
740719
phd_RotYXZpack(packed_rotation[LM_HAND_R]);
741720
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_R], clip);
742721

722+
if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
723+
saved_matrix = *PhdMatrixPtr;
724+
}
725+
743726
phd_PopMatrix();
744727

745728
phd_PushMatrix();
@@ -758,6 +741,11 @@ void __cdecl DrawLara(ITEM_INFO* item)
758741
phd_RotYXZpack(packed_rotation[LM_HAND_L]);
759742
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_L], clip);
760743

744+
if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
745+
*PhdMatrixPtr = saved_matrix;
746+
DrawGunFlash(fire_arms, clip);
747+
}
748+
761749
phd_PopMatrix();
762750
break;
763751
}
@@ -772,27 +760,37 @@ void __cdecl DrawLara(ITEM_INFO* item)
772760

773761
void __cdecl DrawGunFlash(int32_t weapon_type, int32_t clip)
774762
{
775-
int light;
776-
int g_len;
763+
int32_t light;
764+
int32_t len;
765+
int32_t off;
777766

778767
switch (weapon_type) {
779768
case LGT_MAGNUMS:
780769
light = 16 * 256;
781-
g_len = 155;
770+
len = 155;
771+
off = 55;
782772
break;
783773

784774
case LGT_UZIS:
785775
light = 10 * 256;
786-
g_len = 180;
776+
len = 180;
777+
off = 55;
787778
break;
788779

789780
default:
790781
light = 20 * 256;
791-
g_len = 155;
782+
len = 155;
783+
off = 55;
792784
break;
793785
}
794786

795-
phd_TranslateRel(0, g_len, 55);
787+
if (Tomb1MConfig.enable_shotgun_flash && weapon_type == LGT_SHOTGUN) {
788+
light = 10 * 256;
789+
len = 285;
790+
off = 0;
791+
}
792+
793+
phd_TranslateRel(0, len, off);
796794
phd_RotYXZ(0, -90 * ONE_DEGREE, (PHD_ANGLE)(GetRandomDraw() * 2));
797795
S_CalculateStaticLight(light);
798796
phd_PutPolygons(Meshes[Objects[O_GUN_FLASH].mesh_index], clip);
@@ -980,18 +978,7 @@ void __cdecl DrawLaraInt(
980978
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_R], clip);
981979

982980
if (Lara.right_arm.flash_gun) {
983-
saved_matrix._00 = PhdMatrixPtr->_00;
984-
saved_matrix._01 = PhdMatrixPtr->_01;
985-
saved_matrix._02 = PhdMatrixPtr->_02;
986-
saved_matrix._03 = PhdMatrixPtr->_03;
987-
saved_matrix._10 = PhdMatrixPtr->_10;
988-
saved_matrix._11 = PhdMatrixPtr->_11;
989-
saved_matrix._12 = PhdMatrixPtr->_12;
990-
saved_matrix._13 = PhdMatrixPtr->_13;
991-
saved_matrix._20 = PhdMatrixPtr->_20;
992-
saved_matrix._21 = PhdMatrixPtr->_21;
993-
saved_matrix._22 = PhdMatrixPtr->_22;
994-
saved_matrix._23 = PhdMatrixPtr->_23;
981+
saved_matrix = *PhdMatrixPtr;
995982
}
996983

997984
phd_PopMatrix_I();
@@ -1021,18 +1008,7 @@ void __cdecl DrawLaraInt(
10211008
}
10221009

10231010
if (Lara.right_arm.flash_gun) {
1024-
PhdMatrixPtr->_00 = saved_matrix._00;
1025-
PhdMatrixPtr->_01 = saved_matrix._01;
1026-
PhdMatrixPtr->_02 = saved_matrix._02;
1027-
PhdMatrixPtr->_03 = saved_matrix._03;
1028-
PhdMatrixPtr->_10 = saved_matrix._10;
1029-
PhdMatrixPtr->_11 = saved_matrix._11;
1030-
PhdMatrixPtr->_12 = saved_matrix._12;
1031-
PhdMatrixPtr->_13 = saved_matrix._13;
1032-
PhdMatrixPtr->_20 = saved_matrix._20;
1033-
PhdMatrixPtr->_21 = saved_matrix._21;
1034-
PhdMatrixPtr->_22 = saved_matrix._22;
1035-
PhdMatrixPtr->_23 = saved_matrix._23;
1011+
*PhdMatrixPtr = saved_matrix;
10361012
DrawGunFlash(fire_arms, clip);
10371013
}
10381014

@@ -1057,6 +1033,10 @@ void __cdecl DrawLaraInt(
10571033
phd_RotYXZpack(packed_rotation1[LM_HAND_R]);
10581034
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_R], clip);
10591035

1036+
if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
1037+
saved_matrix = *PhdMatrixPtr;
1038+
}
1039+
10601040
phd_PopMatrix();
10611041

10621042
phd_PushMatrix();
@@ -1075,6 +1055,11 @@ void __cdecl DrawLaraInt(
10751055
phd_RotYXZpack(packed_rotation1[LM_HAND_L]);
10761056
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_L], clip);
10771057

1058+
if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
1059+
*PhdMatrixPtr = saved_matrix;
1060+
DrawGunFlash(fire_arms, clip);
1061+
}
1062+
10781063
phd_PopMatrix_I();
10791064
break;
10801065
}

src/game/lara1gun.c

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "game/lara.h"
44
#include "specific/game.h"
55
#include "specific/input.h"
6+
#include "mod.h"
67

78
void __cdecl RifleHandler(int32_t weapon_type)
89
{
@@ -118,6 +119,9 @@ void __cdecl FireShotgun()
118119
}
119120
}
120121
if (fired) {
122+
if (Tomb1MConfig.enable_shotgun_flash) {
123+
Lara.right_arm.flash_gun = Weapons[LGT_SHOTGUN].flash_time;
124+
}
121125
SoundEffect(Weapons[LGT_SHOTGUN].sample_num, &LaraItem->pos, 0);
122126
}
123127
}

src/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static int Tomb1MReadConfig()
8585
tr1m_json_get_boolean_value(json, "enable_enhanced_look");
8686
Tomb1MConfig.enable_enhanced_ui =
8787
tr1m_json_get_boolean_value(json, "enable_enhanced_ui");
88+
Tomb1MConfig.enable_shotgun_flash =
89+
tr1m_json_get_boolean_value(json, "enable_shotgun_flash");
8890

8991
const char* healthbar_showing_mode =
9092
tr1m_json_get_string_value(json, "healthbar_showing_mode");

src/mod.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ typedef enum {
1717
} Tomb1M_BAR_SHOW_MODE;
1818

1919
struct {
20-
int disable_healing_between_levels;
21-
int disable_medpacks;
22-
int disable_magnums;
23-
int disable_uzis;
24-
int disable_shotgun;
25-
int enable_red_healthbar;
26-
int enable_enemy_healthbar;
27-
int enable_enhanced_look;
28-
int enable_enhanced_ui;
29-
int enable_numeric_keys;
30-
int healthbar_showing_mode;
31-
int fix_end_of_level_freeze;
32-
int fix_tihocan_secret_sound;
20+
int8_t disable_healing_between_levels;
21+
int8_t disable_medpacks;
22+
int8_t disable_magnums;
23+
int8_t disable_uzis;
24+
int8_t disable_shotgun;
25+
int8_t enable_red_healthbar;
26+
int8_t enable_enemy_healthbar;
27+
int8_t enable_enhanced_look;
28+
int8_t enable_enhanced_ui;
29+
int8_t enable_numeric_keys;
30+
int8_t enable_shotgun_flash;
31+
int8_t healthbar_showing_mode;
32+
int8_t fix_end_of_level_freeze;
33+
int8_t fix_tihocan_secret_sound;
3334
} Tomb1MConfig;
3435

3536
struct {

0 commit comments

Comments
 (0)