Half-Life: Auto-reload for the few weapons it applies for (when empty)

This commit is contained in:
Marco Cawthorne 2020-12-28 08:13:57 +01:00
parent 5edcdb892c
commit f52638c715
7 changed files with 44 additions and 9 deletions

View File

@ -268,6 +268,13 @@ w_crossbow_release(void)
{
player pl = (player)self;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}

View File

@ -255,6 +255,13 @@ w_glock_release(void)
player pl = (player)self;
int r;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}

View File

@ -270,6 +270,13 @@ void
w_mp5_release(void)
{
player pl = (player)self;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}

View File

@ -192,6 +192,7 @@ void
w_python_reload(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
return;
}
@ -230,6 +231,13 @@ w_python_release(void)
{
player pl = (player)self;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}

View File

@ -215,19 +215,17 @@ void w_rpg_reload(void)
void w_rpg_release(void)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
#ifdef CLIENT
if (pl.a_ammo1 <= 0 && pl.a_ammo2 > 0) {
w_rpg_reload();
if (pl.w_idle_next > 0.0) {
return;
}
#else
if (pl.rpg_mag <= 0 && pl.ammo_rocket > 0) {
w_rpg_reload();
}
#endif
int r = (float)input_sequence % 3;

View File

@ -217,6 +217,13 @@ void w_shotgun_release(void)
{
player pl = (player)self;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo3 == SHOTTY_IDLE && pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}

View File

@ -40,6 +40,7 @@ typedef struct
void(int, vector, float) hudpic;
} weapon_t;
void Weapons_Reload(void);
void Weapons_DrawCrosshair(void);
void Weapons_MakeVectors(void);
vector Weapons_GetCameraPos(void);