220 lines
4.6 KiB
Plaintext
220 lines
4.6 KiB
Plaintext
/*
|
|
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
|
*
|
|
* 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_supernailgun (0 0 1) (-16 -16 0) (16 16 32)
|
|
"model" "models/g_nail2.mdl"
|
|
|
|
HALF-LIFE (1998) ENTITY
|
|
|
|
MP5/9mmAR Weapon
|
|
Same as weapon_9mmAR
|
|
|
|
*/
|
|
|
|
/* Animations */
|
|
enum
|
|
{
|
|
SUPERNAIL_IDLE,
|
|
SUPERNAIL_SHOOT
|
|
};
|
|
|
|
void
|
|
w_supernailgun_precache(void)
|
|
{
|
|
#ifdef SERVER
|
|
Sound_Precache("weapon_supernailgun.shoot");
|
|
precache_model("models/g_nail2.mdl");
|
|
precache_model("models/spike.mdl");
|
|
#else
|
|
precache_model("models/v_nail2.mdl");
|
|
precache_model("models/p_nail2.mdl");
|
|
Sound_Precache("modelevent_shell.land");
|
|
#endif
|
|
}
|
|
|
|
int
|
|
w_supernailgun_pickup(player pl, int new, int startammo)
|
|
{
|
|
#ifdef SERVER
|
|
if (pl.ammo_nails < MAX_A_NAILS) {
|
|
pl.ammo_nails = bound(0, pl.ammo_nails + 30, MAX_A_NAILS);
|
|
} else {
|
|
if (!new)
|
|
return (0);
|
|
}
|
|
#endif
|
|
return (1);
|
|
}
|
|
|
|
void
|
|
w_supernailgun_updateammo(player pl)
|
|
{
|
|
Weapons_UpdateAmmo(pl, -1, pl.ammo_nails, -1);
|
|
}
|
|
|
|
string
|
|
w_supernailgun_wmodel(void)
|
|
{
|
|
return "models/g_nail2.mdl";
|
|
}
|
|
|
|
string
|
|
w_supernailgun_pmodel(player pl)
|
|
{
|
|
return "models/p_nail2.mdl";
|
|
}
|
|
|
|
string
|
|
w_supernailgun_deathmsg(void)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
void
|
|
w_supernailgun_draw(player pl)
|
|
{
|
|
Weapons_SetModel("models/v_nail2.mdl");
|
|
Weapons_ViewAnimation(pl, SUPERNAIL_IDLE);
|
|
}
|
|
|
|
void
|
|
w_supernailgun_primary(player pl)
|
|
{
|
|
if (pl.w_attack_next > 0.0f)
|
|
return;
|
|
|
|
pl.ammo_nails--;
|
|
Weapons_ViewAnimation(pl, SUPERNAIL_SHOOT);
|
|
Weapons_ViewPunchAngle(pl, [-2,0,0]);
|
|
Animation_PlayerTop(pl, (pl.flags & FL_CROUCHING) ? ANIM_CR_SHOOTMP5 : ANIM_SHOOTMP5, 0.1f);
|
|
|
|
#ifdef CLIENT
|
|
#else
|
|
{
|
|
static void nail_touch(void) {
|
|
remove(self);
|
|
}
|
|
|
|
entity nail = spawn();
|
|
setmodel(nail, "models/spike.mdl");
|
|
setorigin(nail, Weapons_GetCameraPos(pl) + (v_up * -5));
|
|
setsize(nail, g_vec_null, g_vec_null);
|
|
nail.movetype = MOVETYPE_FLYMISSILE;
|
|
nail.solid = SOLID_BBOX;
|
|
nail.touch = nail_touch;
|
|
nail.owner = pl;
|
|
Weapons_MakeVectors(pl);
|
|
nail.velocity = v_forward * 1000 + (v_up * -5);
|
|
nail.angles = vectoangles(nail.velocity);
|
|
}
|
|
|
|
Sound_Play(pl, CHAN_WEAPON, "weapon_supernailgun.shoot");
|
|
#endif
|
|
|
|
pl.w_attack_next = 0.085f;
|
|
pl.w_idle_next = 10.0f;
|
|
}
|
|
|
|
void
|
|
w_supernailgun_crosshair(player pl)
|
|
{
|
|
#ifdef CLIENT
|
|
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
|
|
|
|
Cross_DrawSub(g_cross_spr, [24,24], [0,48/128], [0.1875, 0.1875]);
|
|
|
|
HUD_DrawAmmo2();
|
|
|
|
drawsubpic(aicon_pos, [24,24], g_hudsngammo, [0, 0], [1,1], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);
|
|
#endif
|
|
}
|
|
|
|
float
|
|
w_supernailgun_aimanim(player pl)
|
|
{
|
|
return pl.flags & ANIM_CR_AIMMP5 ? ANIM_CR_AIMCROWBAR : ANIM_AIMMP5;
|
|
}
|
|
|
|
int
|
|
w_supernailgun_isempty(player pl)
|
|
{
|
|
if (pl.ammo_nails <= 0)
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void
|
|
w_supernailgun_hudpic(player pl, int selected, vector pos, float a)
|
|
{
|
|
#ifdef CLIENT
|
|
vector hud_col;
|
|
|
|
if (w_supernailgun_isempty(pl))
|
|
hud_col = [1,0,0];
|
|
else
|
|
hud_col = g_hud_color;
|
|
|
|
if (selected) {
|
|
drawsubpic(pos, [170,45], g_hudsng_spr, [0,0], [1,0.625], hud_col, a, DRAWFLAG_ADDITIVE);
|
|
} else {
|
|
drawsubpic(pos, [170,45], g_hudsng_spr, [0,0], [1,0.625], hud_col, a, DRAWFLAG_ADDITIVE);
|
|
}
|
|
|
|
HUD_DrawAmmoBar(pos, pl.ammo_nails, MAX_A_NAILS, a);
|
|
#endif
|
|
}
|
|
|
|
weapontype_t
|
|
w_supernailgun_type(player pl)
|
|
{
|
|
return WPNTYPE_RANGED;
|
|
}
|
|
|
|
weapon_t w_supernailgun =
|
|
{
|
|
.name = "supernail",
|
|
.id = ITEM_SUPERNAILGUN,
|
|
.slot = 4,
|
|
.slot_pos = 0,
|
|
.weight = 3,
|
|
.draw = w_supernailgun_draw,
|
|
.holster = __NULL__,
|
|
.primary = w_supernailgun_primary,
|
|
.secondary = __NULL__,
|
|
.reload = __NULL__,
|
|
.release = __NULL__,
|
|
.postdraw = w_supernailgun_crosshair,
|
|
.precache = w_supernailgun_precache,
|
|
.pickup = w_supernailgun_pickup,
|
|
.updateammo = w_supernailgun_updateammo,
|
|
.wmodel = w_supernailgun_wmodel,
|
|
.pmodel = w_supernailgun_pmodel,
|
|
.deathmsg = w_supernailgun_deathmsg,
|
|
.aimanim = w_supernailgun_aimanim,
|
|
.isempty = w_supernailgun_isempty,
|
|
.type = w_supernailgun_type,
|
|
.hudpic = w_supernailgun_hudpic
|
|
};
|
|
|
|
#ifdef SERVER
|
|
void
|
|
weapon_supernailgun(void)
|
|
{
|
|
Weapons_InitItem(WEAPON_SUPERNAILGUN);
|
|
}
|
|
#endif
|