Skip to content

Commit

Permalink
add shotgun fire
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Feb 20, 2021
1 parent 85be97f commit 8387fad
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 67 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Currently the following configuration options are supported:
etc. (similar to TR2 style).
- `enable_enhanced_ui`: enables UI scaling of in-game inventory text and ammo
text (useful for 4k screens).
- `enable_shotgun_flash`: draws flame when firing a shotgun, like for other guns.
- `enable_numeric_keys`: enables quick weapon draws and medpack usage.
- <kbd>1</kbd>: draw pistols
- <kbd>2</kbd>: draw shotgun
Expand Down
1 change: 1 addition & 0 deletions Tomb1Main.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"enable_enemy_healthbar": true,
"enable_enhanced_look": true,
"enable_enhanced_ui": true,
"enable_shotgun_flash": true,
"enable_numeric_keys": true,
"healthbar_showing_mode": "flashing",
"fix_end_of_level_freeze": true,
Expand Down
93 changes: 39 additions & 54 deletions src/game/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "game/health.h"
#include "specific/game.h"
#include "specific/output.h"
#include "mod.h"
#include "util.h"

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

if (Lara.right_arm.flash_gun) {
saved_matrix._00 = PhdMatrixPtr->_00;
saved_matrix._01 = PhdMatrixPtr->_01;
saved_matrix._02 = PhdMatrixPtr->_02;
saved_matrix._03 = PhdMatrixPtr->_03;
saved_matrix._10 = PhdMatrixPtr->_10;
saved_matrix._11 = PhdMatrixPtr->_11;
saved_matrix._12 = PhdMatrixPtr->_12;
saved_matrix._13 = PhdMatrixPtr->_13;
saved_matrix._20 = PhdMatrixPtr->_20;
saved_matrix._21 = PhdMatrixPtr->_21;
saved_matrix._22 = PhdMatrixPtr->_22;
saved_matrix._23 = PhdMatrixPtr->_23;
saved_matrix = *PhdMatrixPtr;
}

phd_PopMatrix();
Expand Down Expand Up @@ -705,18 +695,7 @@ void __cdecl DrawLara(ITEM_INFO* item)
DrawGunFlash(fire_arms, clip);
}
if (Lara.right_arm.flash_gun) {
PhdMatrixPtr->_00 = saved_matrix._00;
PhdMatrixPtr->_01 = saved_matrix._01;
PhdMatrixPtr->_02 = saved_matrix._02;
PhdMatrixPtr->_03 = saved_matrix._03;
PhdMatrixPtr->_10 = saved_matrix._10;
PhdMatrixPtr->_11 = saved_matrix._11;
PhdMatrixPtr->_12 = saved_matrix._12;
PhdMatrixPtr->_13 = saved_matrix._13;
PhdMatrixPtr->_20 = saved_matrix._20;
PhdMatrixPtr->_21 = saved_matrix._21;
PhdMatrixPtr->_22 = saved_matrix._22;
PhdMatrixPtr->_23 = saved_matrix._23;
*PhdMatrixPtr = saved_matrix;
DrawGunFlash(fire_arms, clip);
}

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

if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
saved_matrix = *PhdMatrixPtr;
}

phd_PopMatrix();

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

if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
*PhdMatrixPtr = saved_matrix;
DrawGunFlash(fire_arms, clip);
}

phd_PopMatrix();
break;
}
Expand All @@ -772,27 +760,37 @@ void __cdecl DrawLara(ITEM_INFO* item)

void __cdecl DrawGunFlash(int32_t weapon_type, int32_t clip)
{
int light;
int g_len;
int32_t light;
int32_t len;
int32_t off;

switch (weapon_type) {
case LGT_MAGNUMS:
light = 16 * 256;
g_len = 155;
len = 155;
off = 55;
break;

case LGT_UZIS:
light = 10 * 256;
g_len = 180;
len = 180;
off = 55;
break;

default:
light = 20 * 256;
g_len = 155;
len = 155;
off = 55;
break;
}

phd_TranslateRel(0, g_len, 55);
if (Tomb1MConfig.enable_shotgun_flash && weapon_type == LGT_SHOTGUN) {
light = 10 * 256;
len = 285;
off = 0;
}

phd_TranslateRel(0, len, off);
phd_RotYXZ(0, -90 * ONE_DEGREE, (PHD_ANGLE)(GetRandomDraw() * 2));
S_CalculateStaticLight(light);
phd_PutPolygons(Meshes[Objects[O_GUN_FLASH].mesh_index], clip);
Expand Down Expand Up @@ -980,18 +978,7 @@ void __cdecl DrawLaraInt(
phd_PutPolygons(Lara.mesh_ptrs[LM_HAND_R], clip);

if (Lara.right_arm.flash_gun) {
saved_matrix._00 = PhdMatrixPtr->_00;
saved_matrix._01 = PhdMatrixPtr->_01;
saved_matrix._02 = PhdMatrixPtr->_02;
saved_matrix._03 = PhdMatrixPtr->_03;
saved_matrix._10 = PhdMatrixPtr->_10;
saved_matrix._11 = PhdMatrixPtr->_11;
saved_matrix._12 = PhdMatrixPtr->_12;
saved_matrix._13 = PhdMatrixPtr->_13;
saved_matrix._20 = PhdMatrixPtr->_20;
saved_matrix._21 = PhdMatrixPtr->_21;
saved_matrix._22 = PhdMatrixPtr->_22;
saved_matrix._23 = PhdMatrixPtr->_23;
saved_matrix = *PhdMatrixPtr;
}

phd_PopMatrix_I();
Expand Down Expand Up @@ -1021,18 +1008,7 @@ void __cdecl DrawLaraInt(
}

if (Lara.right_arm.flash_gun) {
PhdMatrixPtr->_00 = saved_matrix._00;
PhdMatrixPtr->_01 = saved_matrix._01;
PhdMatrixPtr->_02 = saved_matrix._02;
PhdMatrixPtr->_03 = saved_matrix._03;
PhdMatrixPtr->_10 = saved_matrix._10;
PhdMatrixPtr->_11 = saved_matrix._11;
PhdMatrixPtr->_12 = saved_matrix._12;
PhdMatrixPtr->_13 = saved_matrix._13;
PhdMatrixPtr->_20 = saved_matrix._20;
PhdMatrixPtr->_21 = saved_matrix._21;
PhdMatrixPtr->_22 = saved_matrix._22;
PhdMatrixPtr->_23 = saved_matrix._23;
*PhdMatrixPtr = saved_matrix;
DrawGunFlash(fire_arms, clip);
}

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

if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
saved_matrix = *PhdMatrixPtr;
}

phd_PopMatrix();

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

if (Tomb1MConfig.enable_shotgun_flash && Lara.right_arm.flash_gun) {
*PhdMatrixPtr = saved_matrix;
DrawGunFlash(fire_arms, clip);
}

phd_PopMatrix_I();
break;
}
Expand Down
4 changes: 4 additions & 0 deletions src/game/lara1gun.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "game/lara.h"
#include "specific/game.h"
#include "specific/input.h"
#include "mod.h"

void __cdecl RifleHandler(int32_t weapon_type)
{
Expand Down Expand Up @@ -118,6 +119,9 @@ void __cdecl FireShotgun()
}
}
if (fired) {
if (Tomb1MConfig.enable_shotgun_flash) {
Lara.right_arm.flash_gun = Weapons[LGT_SHOTGUN].flash_time;
}
SoundEffect(Weapons[LGT_SHOTGUN].sample_num, &LaraItem->pos, 0);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ static int Tomb1MReadConfig()
tr1m_json_get_boolean_value(json, "enable_enhanced_look");
Tomb1MConfig.enable_enhanced_ui =
tr1m_json_get_boolean_value(json, "enable_enhanced_ui");
Tomb1MConfig.enable_shotgun_flash =
tr1m_json_get_boolean_value(json, "enable_shotgun_flash");

const char* healthbar_showing_mode =
tr1m_json_get_string_value(json, "healthbar_showing_mode");
Expand Down
27 changes: 14 additions & 13 deletions src/mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ typedef enum {
} Tomb1M_BAR_SHOW_MODE;

struct {
int disable_healing_between_levels;
int disable_medpacks;
int disable_magnums;
int disable_uzis;
int disable_shotgun;
int enable_red_healthbar;
int enable_enemy_healthbar;
int enable_enhanced_look;
int enable_enhanced_ui;
int enable_numeric_keys;
int healthbar_showing_mode;
int fix_end_of_level_freeze;
int fix_tihocan_secret_sound;
int8_t disable_healing_between_levels;
int8_t disable_medpacks;
int8_t disable_magnums;
int8_t disable_uzis;
int8_t disable_shotgun;
int8_t enable_red_healthbar;
int8_t enable_enemy_healthbar;
int8_t enable_enhanced_look;
int8_t enable_enhanced_ui;
int8_t enable_numeric_keys;
int8_t enable_shotgun_flash;
int8_t healthbar_showing_mode;
int8_t fix_end_of_level_freeze;
int8_t fix_tihocan_secret_sound;
} Tomb1MConfig;

struct {
Expand Down

0 comments on commit 8387fad

Please sign in to comment.