Add auto-reload when empty, clean up misc weapon code and add alpha to

the hudpic display functions that I missed.
This commit is contained in:
Marco Cawthorne 2021-03-17 11:51:50 +01:00
parent 5635eb0d80
commit 81d7630dd7
27 changed files with 401 additions and 164 deletions

View file

@ -180,6 +180,21 @@ w_ak47_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_ak47_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.ak47_mag == 0 && pl.ammo_762mm > 0) {
Weapons_Reload();
return;
}
}
float
w_ak47_aimanim(void)
{
@ -220,7 +235,7 @@ w_ak47_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -231,7 +246,7 @@ w_ak47_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -250,7 +265,7 @@ weapon_t w_ak47 =
.primary = w_ak47_primary,
.secondary = __NULL__,
.reload = w_ak47_reload,
.release = w_cstrike_weaponrelease,
.release = w_ak47_release,
.crosshair = w_ak47_hud,
.precache = w_ak47_precache,
.pickup = w_ak47_pickup,

View file

@ -200,6 +200,21 @@ w_aug_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_aug_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.aug_mag == 0 && pl.ammo_762mm > 0) {
Weapons_Reload();
return;
}
}
float
w_aug_aimanim(void)
{
@ -245,7 +260,7 @@ w_aug_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -256,7 +271,7 @@ w_aug_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -275,7 +290,7 @@ weapon_t w_aug =
.primary = w_aug_primary,
.secondary = w_aug_secondary,
.reload = w_aug_reload,
.release = w_cstrike_weaponrelease,
.release = w_aug_release,
.crosshair = w_aug_hud,
.precache = w_aug_precache,
.pickup = w_aug_pickup,

View file

@ -116,6 +116,13 @@ w_awp_release(void)
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.awp_mag == 0 && pl.ammo_338mag > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0f) {
pl.viewzoom = 1.0f;
return;
@ -272,7 +279,7 @@ w_awp_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -283,7 +290,7 @@ w_awp_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -107,6 +107,8 @@ void
w_c4bomb_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
if (pl.mode_temp == C4S_DROPPING) {
if (pl.w_idle_next <= 0.0f) {
@ -190,7 +192,7 @@ w_c4bomb_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -201,7 +203,7 @@ w_c4bomb_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -185,6 +185,21 @@ w_deagle_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_deagle_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.deagle_mag == 0 && pl.ammo_50ae > 0) {
Weapons_Reload();
return;
}
}
float
w_deagle_aimanim(void)
{
@ -225,7 +240,7 @@ w_deagle_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -236,7 +251,7 @@ w_deagle_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -255,7 +270,7 @@ weapon_t w_deagle =
.primary = w_deagle_primary,
.secondary = __NULL__,
.reload = w_deagle_reload,
.release = w_cstrike_weaponrelease,
.release = w_deagle_release,
.crosshair = w_deagle_hud,
.precache = w_deagle_precache,
.pickup = w_deagle_pickup,

View file

@ -237,6 +237,21 @@ w_elites_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_elites_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.elites_mag == 0 && pl.ammo_9mm > 0) {
Weapons_Reload();
return;
}
}
float
w_elites_aimanim(void)
{
@ -277,7 +292,7 @@ w_elites_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -288,7 +303,7 @@ w_elites_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -307,7 +322,7 @@ weapon_t w_elites =
.primary = w_elites_primary,
.secondary = __NULL__,
.reload = w_elites_reload,
.release = w_cstrike_weaponrelease,
.release = w_elites_release,
.crosshair = w_elites_hud,
.precache = w_elites_precache,
.pickup = w_elites_pickup,

View file

@ -185,6 +185,21 @@ w_fiveseven_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_fiveseven_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.fiveseven_mag == 0 && pl.ammo_57mm > 0) {
Weapons_Reload();
return;
}
}
float
w_fiveseven_aimanim(void)
{
@ -225,7 +240,7 @@ w_fiveseven_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -236,7 +251,7 @@ w_fiveseven_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -255,7 +270,7 @@ weapon_t w_fiveseven =
.primary = w_fiveseven_primary,
.secondary = __NULL__,
.reload = w_fiveseven_reload,
.release = w_cstrike_weaponrelease,
.release = w_fiveseven_release,
.crosshair = w_fiveseven_hud,
.precache = w_fiveseven_precache,
.pickup = w_fiveseven_pickup,

View file

@ -179,6 +179,8 @@ void
w_flashbang_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
if (pl.w_idle_next > 0.0) {
return;
@ -241,7 +243,7 @@ w_flashbang_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -252,7 +254,7 @@ w_flashbang_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -194,6 +194,21 @@ w_g3sg1_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_g3sg1_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.g3sg1_mag == 0 && pl.ammo_762mm > 0) {
Weapons_Reload();
return;
}
}
float
w_g3sg1_aimanim(void)
{
@ -237,7 +252,7 @@ w_g3sg1_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -248,7 +263,7 @@ w_g3sg1_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -267,7 +282,7 @@ weapon_t w_g3sg1 =
.primary = w_g3sg1_primary,
.secondary = w_g3sg1_secondary,
.reload = w_g3sg1_reload,
.release = w_cstrike_weaponrelease,
.release = w_g3sg1_release,
.crosshair = w_g3sg1_hud,
.precache = w_g3sg1_precache,
.pickup = w_g3sg1_pickup,

View file

@ -141,17 +141,27 @@ w_glock18_primary(void)
return;
}
Cstrike_ShotMultiplierAdd(pl, 1);
float accuracy = Cstrike_CalculateAccuracy(pl, 200);
pl.glock18_mag--;
int shotcount = (pl.mode_glock18) ? 3 : 1;
/* fix shotcount if we're < 3 in burst mode */
if (pl.glock18_mag < 3 && pl.mode_glock18)
shotcount = pl.glock18_mag;
for (int i = 0; i < shotcount; i ++) {
Cstrike_ShotMultiplierAdd(pl, 1);
float accuracy = Cstrike_CalculateAccuracy(pl, (pl.mode_glock18) ? 175 : 200);
pl.glock18_mag--;
#ifdef SERVER
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 25, [accuracy,accuracy], WEAPON_GLOCK18);
#endif
}
#ifdef CLIENT
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 25, [accuracy,accuracy], WEAPON_GLOCK18);
if (self.flags & FL_CROUCHING)
if (pl.flags & FL_CROUCHING)
Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f);
else
Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f);
@ -245,6 +255,21 @@ w_glock18_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_glock18_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.glock18_mag == 0 && pl.ammo_9mm > 0) {
Weapons_Reload();
return;
}
}
float
w_glock18_aimanim(void)
{
@ -285,7 +310,7 @@ w_glock18_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -296,7 +321,7 @@ w_glock18_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -315,7 +340,7 @@ weapon_t w_glock18 =
.primary = w_glock18_primary,
.secondary = w_glock18_secondary,
.reload = w_glock18_reload,
.release = w_cstrike_weaponrelease,
.release = w_glock18_release,
.crosshair = w_glock18_hud,
.precache = w_glock18_precache,
.pickup = w_glock18_pickup,

View file

@ -166,15 +166,9 @@ w_hegrenade_primary(void)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_hegrenade <= 0) {
return;
}
#else
if (pl.ammo_hegrenade <= 0) {
return;
}
#endif
Weapons_ViewAnimation(HEGRENADE_PULLPIN);
@ -187,17 +181,18 @@ void
w_hegrenade_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
if (pl.w_idle_next > 0.0) {
return;
}
if (pl.mode_temp == 1) {
#ifdef CLIENT
pl.ammo_hegrenade--;
#ifdef CLIENT
Weapons_ViewAnimation(HEGRENADE_THROW);
#else
pl.ammo_hegrenade--;
w_hegrenade_throw();
#endif
pl.mode_temp = 2;
@ -250,7 +245,7 @@ w_hegrenade_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -261,7 +256,7 @@ w_hegrenade_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -192,7 +192,7 @@ w_knife_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -203,7 +203,7 @@ w_knife_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -126,26 +126,19 @@ w_m3_primary(void)
return;
}
#ifdef CLIENT
if (!pl.m3_mag) {
return;
}
#else
if (!pl.m3_mag) {
return;
}
#endif
Cstrike_ShotMultiplierAdd(pl, 9);
float accuracy = Cstrike_CalculateAccuracy(pl, 200);
pl.m3_mag--;
#ifdef CLIENT
pl.m3_mag--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(9, pl.origin + pl.view_ofs, 26, [accuracy,accuracy], WEAPON_M3);
pl.m3_mag--;
if (self.flags & FL_CROUCHING)
Animation_PlayerTopTemp(ANIM_SHOOT_SHOTGUN, 0.45f);
@ -173,21 +166,13 @@ void
w_m3_reload(void)
{
player pl = (player)self;
#ifdef CLIENT
if (pl.m3_mag >= 8) {
return;
}
if (pl.ammo_buckshot <= 0) {
return;
}
#else
if (pl.m3_mag >= 8) {
return;
}
if (pl.ammo_buckshot <= 0) {
return;
}
#endif
if (pl.mode_temp > M3S_IDLE) {
return;
@ -203,6 +188,13 @@ w_m3_release(void)
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.mode_temp == M3S_IDLE && pl.m3_mag == 0 && pl.ammo_buckshot > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}
@ -213,21 +205,15 @@ w_m3_release(void)
pl.w_idle_next = 0.65f;
} else if (pl.mode_temp == M3S_RELOAD) {
Weapons_ViewAnimation(M3_INSERT);
#ifdef CLIENT
pl.m3_mag++;
pl.ammo_buckshot--;
if (pl.ammo_buckshot <= 0 || pl.m3_mag >= 8) {
pl.mode_temp = M3S_RELOAD_END;
}
#else
pl.m3_mag++;
pl.ammo_buckshot--;
w_m3_updateammo(pl);
#ifdef SERVER
//Sound_Play(pl, CHAN_WEAPON, "weapon_m3.insertshell");
#endif
if (pl.ammo_buckshot <= 0 || pl.m3_mag >= 8) {
pl.mode_temp = M3S_RELOAD_END;
}
#endif
pl.w_idle_next = 0.5f;
} else if (pl.mode_temp == M3S_RELOAD_END) {
Weapons_ViewAnimation(M3_RELOAD_END);
@ -277,7 +263,7 @@ w_m3_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -288,7 +274,7 @@ w_m3_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -272,6 +272,13 @@ w_m4a1_release(void)
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.m4a1_mag == 0 && pl.ammo_556mm > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}
@ -306,7 +313,7 @@ w_m4a1_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -317,7 +324,7 @@ w_m4a1_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -180,6 +180,21 @@ w_mac10_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_mac10_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.mac10_mag == 0 && pl.ammo_45acp > 0) {
Weapons_Reload();
return;
}
}
float
w_mac10_aimanim(void)
{
@ -220,7 +235,7 @@ w_mac10_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -231,7 +246,7 @@ w_mac10_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -250,7 +265,7 @@ weapon_t w_mac10 =
.primary = w_mac10_primary,
.secondary = __NULL__,
.reload = w_mac10_reload,
.release = w_cstrike_weaponrelease,
.release = w_mac10_release,
.crosshair = w_mac10_hud,
.precache = w_mac10_precache,
.pickup = w_mac10_pickup,

View file

@ -180,6 +180,21 @@ w_mp5_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_mp5_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.mp5_mag == 0 && pl.ammo_9mm > 0) {
Weapons_Reload();
return;
}
}
float
w_mp5_aimanim(void)
{
@ -220,7 +235,7 @@ w_mp5_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -231,7 +246,7 @@ w_mp5_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -250,7 +265,7 @@ weapon_t w_mp5 =
.primary = w_mp5_primary,
.secondary = __NULL__,
.reload = w_mp5_reload,
.release = w_cstrike_weaponrelease,
.release = w_mp5_release,
.crosshair = w_mp5_hud,
.precache = w_mp5_precache,
.pickup = w_mp5_pickup,

View file

@ -189,6 +189,21 @@ w_p228_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_p228_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.p228_mag == 0 && pl.ammo_357sig > 0) {
Weapons_Reload();
return;
}
}
float
w_p228_aimanim(void)
{
@ -229,7 +244,7 @@ w_p228_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -240,7 +255,7 @@ w_p228_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -259,7 +274,7 @@ weapon_t w_p228 =
.primary = w_p228_primary,
.secondary = __NULL__,
.reload = w_p228_reload,
.release = w_cstrike_weaponrelease,
.release = w_p228_release,
.crosshair = w_p228_hud,
.precache = w_p228_precache,
.pickup = w_p228_pickup,

View file

@ -180,6 +180,21 @@ w_p90_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_p90_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.p90_mag == 0 && pl.ammo_57mm > 0) {
Weapons_Reload();
return;
}
}
float
w_p90_aimanim(void)
{
@ -220,7 +235,7 @@ w_p90_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -231,7 +246,7 @@ w_p90_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -250,7 +265,7 @@ weapon_t w_p90 =
.primary = w_p90_primary,
.secondary = __NULL__,
.reload = w_p90_reload,
.release = w_cstrike_weaponrelease,
.release = w_p90_release,
.crosshair = w_p90_hud,
.precache = w_p90_precache,
.pickup = w_p90_pickup,

View file

@ -176,6 +176,21 @@ w_para_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_para_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.para_mag == 0 && pl.ammo_556mmbox > 0) {
Weapons_Reload();
return;
}
}
float
w_para_aimanim(void)
{
@ -216,7 +231,7 @@ w_para_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -227,7 +242,7 @@ w_para_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -246,7 +261,7 @@ weapon_t w_para =
.primary = w_para_primary,
.secondary = __NULL__,
.reload = w_para_reload,
.release = w_cstrike_weaponrelease,
.release = w_para_release,
.crosshair = w_para_hud,
.precache = w_para_precache,
.pickup = w_para_pickup,

View file

@ -115,6 +115,13 @@ w_scout_release(void)
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.scout_mag == 0 && pl.ammo_762mm > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0f) {
pl.viewzoom = 1.0f;
return;
@ -269,7 +276,7 @@ w_scout_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -280,7 +287,7 @@ w_scout_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -194,6 +194,21 @@ w_sg550_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_sg550_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.sg550_mag == 0 && pl.ammo_556mm > 0) {
Weapons_Reload();
return;
}
}
float
w_sg550_aimanim(void)
{
@ -237,7 +252,7 @@ w_sg550_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -248,7 +263,7 @@ w_sg550_hudpic(int selected, vector pos, float a)
[0,180/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -200,6 +200,21 @@ w_sg552_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_sg552_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.sg552_mag == 0 && pl.ammo_556mm > 0) {
Weapons_Reload();
return;
}
}
float
w_sg552_aimanim(void)
{
@ -245,7 +260,7 @@ w_sg552_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -256,7 +271,7 @@ w_sg552_hudpic(int selected, vector pos, float a)
[0,45/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -164,15 +164,9 @@ w_smokegrenade_primary(void)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_smokegrenade <= 0) {
return;
}
#else
if (pl.ammo_smokegrenade <= 0) {
return;
}
#endif
Weapons_ViewAnimation(SMOKEGRENADE_PULLPIN);
pl.mode_temp = 1;
@ -184,17 +178,18 @@ void
w_smokegrenade_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
if (pl.w_idle_next > 0.0) {
return;
}
if (pl.mode_temp == 1) {
#ifdef CLIENT
pl.ammo_smokegrenade--;
#ifdef CLIENT
Weapons_ViewAnimation(SMOKEGRENADE_THROW);
#else
pl.ammo_smokegrenade--;
w_smokegrenade_throw();
#endif
pl.mode_temp = 2;
@ -246,7 +241,7 @@ w_smokegrenade_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -257,7 +252,7 @@ w_smokegrenade_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
g_hud_color,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -182,6 +182,21 @@ w_tmp_reload(void)
pl.w_idle_next = pl.w_attack_next;
}
void
w_tmp_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.tmp_mag == 0 && pl.ammo_9mm > 0) {
Weapons_Reload();
return;
}
}
float
w_tmp_aimanim(void)
{
@ -222,7 +237,7 @@ w_tmp_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -233,7 +248,7 @@ w_tmp_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}

View file

@ -117,26 +117,19 @@ w_ump45_primary(void)
}
/* ammo check */
#ifdef CLIENT
if (!pl.ump45_mag) {
return;
}
#else
if (!pl.ump45_mag) {
return;
}
#endif
Cstrike_ShotMultiplierAdd(pl, 1);
float accuracy = Cstrike_CalculateAccuracy(pl, 210);
pl.ump45_mag--;
#ifdef CLIENT
pl.ump45_mag--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 30, [accuracy,accuracy], WEAPON_UMP45);
pl.ump45_mag--;
if (self.flags & FL_CROUCHING)
Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f);
@ -171,31 +164,39 @@ w_ump45_reload(void)
if (pl.w_attack_next > 0.0) {
return;
}
if (pl.ump45_mag >= 25) {
return;
}
if (!pl.ammo_45acp) {
return;
}
#ifdef CLIENT
if (pl.ump45_mag >= 25) {
return;
}
if (!pl.ammo_45acp) {
return;
}
Weapons_ViewAnimation(UMP45_RELOAD);
#else
if (pl.ump45_mag >= 25) {
return;
}
if (!pl.ammo_45acp) {
return;
}
Weapons_ReloadWeapon(pl, player::ump45_mag, player::ammo_45acp, 25);
Weapons_UpdateAmmo(pl, pl.ump45_mag, pl.ammo_45acp, -1);
#endif
Weapons_ViewAnimation(UMP45_RELOAD);
pl.w_attack_next = 3.5f;
pl.w_idle_next = pl.w_attack_next;
}
void
w_ump45_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.ump45_mag == 0 && pl.ammo_45acp > 0) {
Weapons_Reload();
return;
}
}
float
w_ump45_aimanim(void)
{
@ -236,7 +237,7 @@ w_ump45_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -247,7 +248,7 @@ w_ump45_hudpic(int selected, vector pos, float a)
[0,0],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -266,7 +267,7 @@ weapon_t w_ump45 =
.primary = w_ump45_primary,
.secondary = __NULL__,
.reload = w_ump45_reload,
.release = w_cstrike_weaponrelease,
.release = w_ump45_release,
.crosshair = w_ump45_hud,
.precache = w_ump45_precache,
.pickup = w_ump45_pickup,

View file

@ -263,6 +263,21 @@ w_usp45_reload(void)
pl.w_attack_next = 2.5f;
}
void
w_usp45_release(void)
{
player pl = (player)self;
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.usp45_mag == 0 && pl.ammo_45acp > 0) {
Weapons_Reload();
return;
}
}
float
w_usp45_aimanim(void)
{
@ -303,7 +318,7 @@ w_usp45_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -314,7 +329,7 @@ w_usp45_hudpic(int selected, vector pos, float a)
[0,90/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}
@ -333,7 +348,7 @@ weapon_t w_usp45 =
.primary = w_usp45_primary,
.secondary = w_usp45_secondary,
.reload = w_usp45_reload,
.release = w_cstrike_weaponrelease,
.release = w_usp45_release,
.crosshair = w_usp45_hud,
.precache = w_usp45_precache,
.pickup = w_usp45_pickup,

View file

@ -128,26 +128,19 @@ w_xm1014_primary(void)
}
/* ammo check */
#ifdef CLIENT
if (!pl.xm1014_mag) {
return;
}
#else
if (!pl.xm1014_mag) {
return;
}
#endif
Cstrike_ShotMultiplierAdd(pl, 6);
float accuracy = Cstrike_CalculateAccuracy(pl, 200);
pl.xm1014_mag--;
#ifdef CLIENT
pl.xm1014_mag--;
View_SetMuzzleflash(MUZZLE_RIFLE);
#else
TraceAttack_SetPenetrationPower(0);
TraceAttack_FireBullets(6, pl.origin + pl.view_ofs, 22, [accuracy,accuracy], WEAPON_XM1014);
pl.xm1014_mag--;
if (self.flags & FL_CROUCHING)
Animation_PlayerTopTemp(ANIM_SHOOT_SHOTGUN, 0.45f);
@ -175,21 +168,13 @@ void
w_xm1014_reload(void)
{
player pl = (player)self;
#ifdef CLIENT
if (pl.xm1014_mag >= 7) {
return;
}
if (pl.ammo_buckshot <= 0) {
return;
}
#else
if (pl.xm1014_mag >= 7) {
return;
}
if (pl.ammo_buckshot <= 0) {
return;
}
#endif
if (pl.mode_temp > XM1014S_IDLE) {
return;
@ -205,6 +190,13 @@ w_xm1014_release(void)
w_cstrike_weaponrelease();
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.mode_temp == XM1014S_IDLE && pl.xm1014_mag == 0 && pl.ammo_buckshot > 0) {
Weapons_Reload();
return;
}
if (pl.w_idle_next > 0.0) {
return;
}
@ -215,22 +207,15 @@ w_xm1014_release(void)
pl.w_idle_next = 0.65f;
} else if (pl.mode_temp == XM1014S_RELOAD) {
Weapons_ViewAnimation(XM1014_INSERT);
#ifdef CLIENT
pl.xm1014_mag++;
pl.ammo_buckshot--;
if (pl.ammo_buckshot <= 0 || pl.xm1014_mag >= 7) {
pl.mode_temp = XM1014S_RELOAD_END;
}
#else
pl.xm1014_mag++;
pl.ammo_buckshot--;
w_xm1014_updateammo(pl);
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_xm1014.insertshell");
#endif
if (pl.ammo_buckshot <= 0 || pl.xm1014_mag >= 7) {
pl.mode_temp = XM1014S_RELOAD_END;
}
#endif
pl.w_idle_next = 0.5f;
} else if (pl.mode_temp == XM1014S_RELOAD_END) {
Weapons_ViewAnimation(XM1014_RELOAD_END);
@ -280,7 +265,7 @@ w_xm1014_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
} else {
@ -291,7 +276,7 @@ w_xm1014_hudpic(int selected, vector pos, float a)
[0,135/256],
[170/256,45/256],
hud_col,
1.0f,
a,
DRAWFLAG_ADDITIVE
);
}