2021-03-08 01:38:54 -08:00
|
|
|
/*
|
2022-03-13 16:59:12 -07:00
|
|
|
* Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
|
2021-03-08 01:38:54 -08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*QUAKED weapon_usp45 (0 0 1) (-16 -16 0) (16 16 32)
|
|
|
|
"model" "models/w_usp45.mdl"
|
|
|
|
|
|
|
|
COUNTER-STRIKE (1999) ENTITY
|
|
|
|
|
|
|
|
Heckler & Koch USP .45 Tactical Weapon
|
|
|
|
|
|
|
|
Default arsenal for Counter-Terrorists
|
|
|
|
|
|
|
|
- Buy Menu -
|
|
|
|
Price: $500
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
USP45_IDLE,
|
|
|
|
USP45_SHOOT1,
|
|
|
|
USP45_SHOOT2,
|
|
|
|
USP45_SHOOT3,
|
|
|
|
USP45_SHOOTLAST,
|
|
|
|
USP45_RELOAD,
|
|
|
|
USP45_DRAW,
|
|
|
|
USP45_ADDSIL,
|
|
|
|
USP45_IDLEUNSIL,
|
|
|
|
USP45_SHOOT1UNSIL,
|
|
|
|
USP45_SHOOT2UNSIL,
|
|
|
|
USP45_SHOOT3UNSIL,
|
|
|
|
USP45_SHOOTLASTUNSIL,
|
|
|
|
USP45_RELOADUNSIL,
|
|
|
|
USP45_DRAWUNSIL,
|
|
|
|
USP45_DETACHSIL
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
w_usp45_precache(void)
|
|
|
|
{
|
|
|
|
#ifdef SERVER
|
|
|
|
Sound_Precache("weapon_usp45.fire");
|
|
|
|
Sound_Precache("weapon_usp45.silenced");
|
|
|
|
precache_model("models/w_usp.mdl");
|
|
|
|
#else
|
|
|
|
precache_model("models/v_usp.mdl");
|
|
|
|
precache_model("models/p_usp.mdl");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
w_usp45_updateammo(player pl)
|
|
|
|
{
|
|
|
|
Weapons_UpdateAmmo(pl, pl.usp45_mag, pl.ammo_45acp, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
w_usp45_wmodel(void)
|
|
|
|
{
|
|
|
|
return "models/w_usp.mdl";
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
2022-04-25 10:37:07 -07:00
|
|
|
w_usp45_pmodel(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
return "models/p_usp.mdl";
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
w_usp45_deathmsg(void)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_pickup(player pl, int new, int startammo)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
#ifdef SERVER
|
|
|
|
|
|
|
|
if (new) {
|
|
|
|
if (startammo == -1)
|
|
|
|
pl.usp45_mag = 12;
|
|
|
|
else
|
|
|
|
pl.usp45_mag = startammo;
|
|
|
|
} else {
|
|
|
|
if (pl.ammo_45acp < AMMO_MAX_45ACP) {
|
|
|
|
pl.ammo_45acp = bound(0, pl.ammo_45acp + 12, AMMO_MAX_45ACP);
|
|
|
|
} else {
|
2021-05-09 23:16:51 -07:00
|
|
|
return (0);
|
2021-03-08 01:38:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2021-05-09 23:16:51 -07:00
|
|
|
return (1);
|
2021-03-08 01:38:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_draw(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
|
|
|
|
Weapons_SetModel("models/v_usp.mdl");
|
|
|
|
if (pl.mode_usp45 == 1) {
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_DRAW);
|
2021-03-08 01:38:54 -08:00
|
|
|
} else {
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_DRAWUNSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CLIENT
|
|
|
|
pl.cs_cross_mindist = 8;
|
|
|
|
pl.cs_cross_deltadist = 3;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_primary(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.w_attack_next > 0.0)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.gflags & GF_SEMI_TOGGLED)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
2021-05-08 08:46:20 -07:00
|
|
|
if (!pl.usp45_mag)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
|
|
|
|
2023-07-04 05:49:06 -07:00
|
|
|
|
|
|
|
float accuracy = Cstrike_CalculateAccuracy(pl,30,2);
|
2023-03-01 14:47:20 -08:00
|
|
|
int dmg = 0;
|
2021-03-08 01:38:54 -08:00
|
|
|
pl.usp45_mag--;
|
|
|
|
|
|
|
|
/* this stuff is predicted */
|
|
|
|
int r = (float)input_sequence % 3;
|
|
|
|
if (pl.mode_usp45 == 1) {
|
|
|
|
if (pl.usp45_mag <= 0) {
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOTLAST);
|
2021-03-08 01:38:54 -08:00
|
|
|
} else {
|
|
|
|
switch (r) {
|
|
|
|
case 0:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT1);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT2);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
default:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT3);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pl.usp45_mag <= 0) {
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOTLASTUNSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
} else {
|
|
|
|
switch (r) {
|
|
|
|
case 0:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT1UNSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT2UNSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
default:
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_SHOOT3UNSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:04:20 -07:00
|
|
|
if (pl.flags & FL_CROUCHING)
|
2021-05-08 08:46:20 -07:00
|
|
|
Animation_PlayerTop(pl, ANIM_SHOOT_ONEHAND, 0.45f);
|
|
|
|
else
|
|
|
|
Animation_PlayerTop(pl, ANIM_CROUCH_SHOOT_ONEHAND, 0.45f);
|
|
|
|
|
2021-03-29 22:31:33 -07:00
|
|
|
#ifdef CLIENT
|
|
|
|
if (pl.mode_usp45 == 1) {
|
|
|
|
View_SetMuzzleflash(0);
|
|
|
|
} else {
|
|
|
|
View_SetMuzzleflash(MUZZLE_SMALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
View_AddEvent(w_pistol_ejectshell, 0.0f);
|
|
|
|
#else
|
|
|
|
/* Different sounds without silencer */
|
|
|
|
if (pl.mode_usp45 == 1) {
|
|
|
|
Sound_Play(pl, CHAN_WEAPON, "weapon_usp45.silenced");
|
|
|
|
} else {
|
|
|
|
Sound_Play(pl, CHAN_WEAPON, "weapon_usp45.fire");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actual firing */
|
2023-03-01 14:47:20 -08:00
|
|
|
dmg = Skill_GetValue("plr_usp45_dmg", 33);
|
2022-04-24 17:24:01 -07:00
|
|
|
TraceAttack_SetRangeModifier(0.79); /* can penetrate 6 but not 7 units */
|
2022-04-24 00:22:27 -07:00
|
|
|
TraceAttack_SetPenetrationPower(1);
|
2023-07-04 05:49:06 -07:00
|
|
|
g_CstrikeBulletRecoil.ApplyPre(pl,0.625);
|
2023-03-01 14:47:20 -08:00
|
|
|
TraceAttack_FireBulletsWithDecal(1, pl.origin + pl.view_ofs, dmg, [accuracy,accuracy], WEAPON_USP45, "Impact.BigShot");
|
2023-07-04 05:49:06 -07:00
|
|
|
g_CstrikeBulletRecoil.ApplyPost(pl,0.625);
|
2021-03-29 22:31:33 -07:00
|
|
|
#endif
|
2023-07-04 05:49:06 -07:00
|
|
|
Cstrike_ShotMultiplierAdd(pl, 10, 0.4);
|
2021-03-29 22:31:33 -07:00
|
|
|
|
2021-03-08 01:38:54 -08:00
|
|
|
pl.gflags |= GF_SEMI_TOGGLED;
|
|
|
|
pl.w_attack_next = 0.15f;
|
|
|
|
pl.w_idle_next = pl.w_attack_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_secondary(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.w_attack_next > 0)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* toggle silencer */
|
|
|
|
pl.mode_usp45 = 1 - pl.mode_usp45;
|
|
|
|
|
|
|
|
/* play the animation */
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.mode_usp45)
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_ADDSIL);
|
2021-05-08 08:46:20 -07:00
|
|
|
else
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_DETACHSIL);
|
2021-03-08 01:38:54 -08:00
|
|
|
|
|
|
|
pl.w_attack_next = 3.1f;
|
|
|
|
pl.w_idle_next = pl.w_attack_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_reload(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.w_attack_next > 0.0)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.usp45_mag >= 12)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
2021-05-08 08:46:20 -07:00
|
|
|
if (!pl.ammo_45acp)
|
2021-03-08 01:38:54 -08:00
|
|
|
return;
|
|
|
|
|
2021-05-08 08:46:20 -07:00
|
|
|
if (pl.mode_usp45 == 1)
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_RELOAD);
|
2021-05-08 08:46:20 -07:00
|
|
|
else
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_ViewAnimation(pl, USP45_RELOADUNSIL);
|
2021-05-08 08:46:20 -07:00
|
|
|
|
2022-04-26 09:57:03 -07:00
|
|
|
pl.w_attack_next = 2.5f;
|
|
|
|
pl.w_idle_next = pl.w_attack_next;
|
|
|
|
|
2021-05-08 08:46:20 -07:00
|
|
|
#ifdef SERVER
|
2022-04-26 09:57:03 -07:00
|
|
|
static void w_weapon_reload_done(void) {
|
|
|
|
player pl = (player)self;
|
|
|
|
Weapons_ReloadWeapon(pl, player::usp45_mag, player::ammo_45acp, 12);
|
|
|
|
}
|
2021-03-08 01:38:54 -08:00
|
|
|
|
2022-04-26 09:57:03 -07:00
|
|
|
pl.think = w_weapon_reload_done;
|
|
|
|
pl.nextthink = time + pl.w_attack_next - 0.1f;
|
|
|
|
#endif
|
2021-03-08 01:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-03-17 03:51:50 -07:00
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_release(player pl)
|
2021-03-17 03:51:50 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
w_cstrike_weaponrelease();
|
|
|
|
|
|
|
|
/* auto-reload if need be */
|
|
|
|
if (pl.w_attack_next <= 0.0)
|
|
|
|
if (pl.usp45_mag == 0 && pl.ammo_45acp > 0) {
|
2022-03-15 19:35:04 -07:00
|
|
|
Weapons_Reload(pl);
|
2021-03-17 03:51:50 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-08 01:38:54 -08:00
|
|
|
float
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_aimanim(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
2022-03-15 19:35:04 -07:00
|
|
|
return w_deagle_aimanim(pl);
|
2021-03-08 01:38:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_hud(player pl)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
#ifdef CLIENT
|
|
|
|
Cstrike_DrawCrosshair();
|
|
|
|
HUD_DrawAmmo1();
|
|
|
|
HUD_DrawAmmo2();
|
|
|
|
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
|
2021-03-31 04:42:36 -07:00
|
|
|
drawsubpic(aicon_pos, [24,24], g_hud7_spr, [96/256,72/256], [24/256, 24/256], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);
|
2021-03-08 01:38:54 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:47:34 -07:00
|
|
|
int
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_isempty(player pl)
|
2021-05-12 06:47:34 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
if (pl.usp45_mag <= 0 && pl.ammo_45acp <= 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-08 01:38:54 -08:00
|
|
|
void
|
2022-03-15 19:35:04 -07:00
|
|
|
w_usp45_hudpic(player pl, int selected, vector pos, float a)
|
2021-03-08 01:38:54 -08:00
|
|
|
{
|
|
|
|
#ifdef CLIENT
|
|
|
|
vector hud_col;
|
|
|
|
|
2022-03-15 19:35:04 -07:00
|
|
|
if (w_usp45_isempty(pl))
|
2021-03-08 01:38:54 -08:00
|
|
|
hud_col = [1,0,0];
|
|
|
|
else
|
|
|
|
hud_col = g_hud_color;
|
|
|
|
|
|
|
|
HUD_DrawAmmoBar(pos, pl.ammo_45acp, AMMO_MAX_45ACP, a);
|
|
|
|
|
|
|
|
if (selected) {
|
|
|
|
drawsubpic(
|
|
|
|
pos,
|
|
|
|
[170,45],
|
|
|
|
g_hud4_spr,
|
|
|
|
[0,90/256],
|
|
|
|
[170/256,45/256],
|
|
|
|
hud_col,
|
2021-03-17 03:51:50 -07:00
|
|
|
a,
|
2021-03-08 01:38:54 -08:00
|
|
|
DRAWFLAG_ADDITIVE
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
drawsubpic(
|
|
|
|
pos,
|
|
|
|
[170,45],
|
|
|
|
g_hud1_spr,
|
|
|
|
[0,90/256],
|
|
|
|
[170/256,45/256],
|
|
|
|
hud_col,
|
2021-03-17 03:51:50 -07:00
|
|
|
a,
|
2021-03-08 01:38:54 -08:00
|
|
|
DRAWFLAG_ADDITIVE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
weapon_t w_usp45 =
|
|
|
|
{
|
|
|
|
.name = "usp",
|
2022-04-25 10:37:07 -07:00
|
|
|
.id = ITEM_USP45,
|
2021-03-08 01:38:54 -08:00
|
|
|
.slot = 1,
|
|
|
|
.slot_pos = 0,
|
2021-05-12 06:47:34 -07:00
|
|
|
.weight = 5,
|
2021-03-08 01:38:54 -08:00
|
|
|
.allow_drop = TRUE,
|
|
|
|
.draw = w_usp45_draw,
|
|
|
|
.holster = __NULL__,
|
|
|
|
.primary = w_usp45_primary,
|
|
|
|
.secondary = w_usp45_secondary,
|
|
|
|
.reload = w_usp45_reload,
|
2021-03-17 03:51:50 -07:00
|
|
|
.release = w_usp45_release,
|
2022-03-15 19:35:04 -07:00
|
|
|
.postdraw = w_usp45_hud,
|
2021-03-08 01:38:54 -08:00
|
|
|
.precache = w_usp45_precache,
|
|
|
|
.pickup = w_usp45_pickup,
|
|
|
|
.updateammo = w_usp45_updateammo,
|
|
|
|
.wmodel = w_usp45_wmodel,
|
|
|
|
.pmodel = w_usp45_pmodel,
|
|
|
|
.deathmsg = w_usp45_deathmsg,
|
|
|
|
.aimanim = w_usp45_aimanim,
|
2021-05-12 06:47:34 -07:00
|
|
|
.hudpic = w_usp45_hudpic,
|
2022-03-10 19:01:08 -08:00
|
|
|
.type = csweapon_ranged_type,
|
2021-05-12 06:47:34 -07:00
|
|
|
.isempty = w_usp45_isempty
|
2021-03-08 01:38:54 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef SERVER
|
|
|
|
void
|
|
|
|
weapon_usp45(void)
|
|
|
|
{
|
|
|
|
Weapons_InitItem(WEAPON_USP45);
|
|
|
|
}
|
|
|
|
#endif
|