/* * Copyright (c) 2023 Marco Cawthorne * * 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_9mmhandgun (0 0 1) (-16 -16 0) (16 16 32) "model" "models/g_shot2.mdl" HALF-LIFE (1998) ENTITY 9mm Handgun/Glock Weapon Same as weapon_glock */ /*QUAKED weapon_glock (0 0 1) (-16 -16 0) (16 16 32) "model" "models/g_shot2.mdl" HALF-LIFE (1998) ENTITY 9mm Handgun/Glock Weapon Same as weapon_9mmhandgun */ enum { SUPERSHOT_IDLE, SUPERSHOT_SHOOT, }; #ifdef CLIENT void w_supershotgun_ejectshell(void) { static void w_supershotgun_ejectshell_death(void) { remove(self); } static void w_supershotgun_ejectshell_touch(void) { if (other == world) Sound_Play(self, CHAN_BODY, "modelevent_shell.land"); } entity eShell = spawn(); setmodel(eShell, "models/shell.mdl"); eShell.solid = SOLID_BBOX; eShell.movetype = MOVETYPE_BOUNCE; eShell.drawmask = MASK_ENGINE; eShell.angles = [pSeat->m_eViewModel.angles[0], pSeat->m_eViewModel.angles[1], 0]; eShell.velocity = pSeat->m_vecPredictedVelocity; makevectors(pSeat->m_eViewModel.angles); eShell.velocity += (v_forward * 0); eShell.velocity += (v_right * 80); eShell.velocity += (v_up * 100); eShell.touch = w_supershotgun_ejectshell_touch; eShell.avelocity = [0,45,900]; eShell.think = w_supershotgun_ejectshell_death; eShell.nextthink = time + 2.5f; setsize(eShell, [0,0,0], [0,0,0]); setorigin(eShell, pSeat->m_eViewModel.origin + (v_forward * 26) + (v_right * 8) + (v_up * -4)); } #endif void w_supershotgun_precache(void) { #ifdef SERVER Sound_Precache("weapon_supershotgun.shoot"); precache_model("models/g_shot2.mdl"); precache_model("models/shell.mdl"); #else precache_model("models/v_shot2.mdl"); precache_model("models/p_shot2.mdl"); precache_model("models/shell.mdl"); Sound_Precache("modelevent_shell.land"); #endif } void w_supershotgun_updateammo(player pl) { Weapons_UpdateAmmo(pl, -1, pl.ammo_shells, -1); } string w_supershotgun_wmodel(void) { return "models/g_shot2.mdl"; } string w_supershotgun_pmodel(player pl) { return "models/p_shot2.mdl"; } string w_supershotgun_deathmsg(void) { return ""; } int w_supershotgun_pickup(player pl, int new, int startammo) { #ifdef SERVER if (pl.ammo_shells < MAX_A_SHELLS) { pl.ammo_shells = bound(0, pl.ammo_shells + 5, MAX_A_SHELLS); } else { if (!new) return (0); } #endif return (1); } void w_supershotgun_draw(player pl) { Weapons_SetModel("models/v_shot2.mdl"); Weapons_ViewAnimation(pl, SUPERSHOT_IDLE); } void w_supershotgun_primary(player pl) { if (pl.w_attack_next > 0.0) return; if (pl.ammo_shells < 2) { Weapons_SwitchBest(pl, 0); return; } /* actual firing */ pl.ammo_shells -= 2; #ifdef CLIENT View_AddEvent(w_supershotgun_ejectshell, 0.0f); #else TraceAttack_FireBulletsWithDecal(14, pl.origin + pl.view_ofs, Skill_GetValue("plr_supershotgun", 4), [0.14,0.08], WEAPON_SUPERSHOTGUN, "Impact.BigShot"); Sound_Play(pl, CHAN_WEAPON, "weapon_supershotgun.shoot"); if (pl.HasQuadDamage()) { Sound_Play(pl, CHAN_ITEM, "item_artifact_super_damage.attack"); } #endif Weapons_ViewPunchAngle(pl, [-2,0,0]); Weapons_ViewAnimation(pl, SUPERSHOT_SHOOT); Animation_PlayerTop(pl, (pl.flags & FL_CROUCHING) ? ANIM_CR_SHOOTSHOTGUN : ANIM_SHOOTSHOTGUN, 0.5f); pl.w_attack_next = 0.7f; } float w_supershotgun_aimanim(player pl) { return pl.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN; } void w_supershotgun_hud(player pl) { #ifdef CLIENT vector aicon_pos; aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; HUD_DrawQuakeCrosshair(); HUD_DrawAmmo2(); drawsubpic(aicon_pos, [24,24], g_hudssgammo, [0, 0], [1,1], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE); #endif } int w_supershotgun_isempty(player pl) { if (pl.ammo_shells <= 0) return 1; return 0; } void w_supershotgun_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT vector hud_col; if (w_supershotgun_isempty(pl)) hud_col = [1,0,0]; else hud_col = g_hud_color; if (selected) { drawsubpic(pos, [170,45], g_hudssg_spr, [0,0], [1,0.625], hud_col, a, DRAWFLAG_ADDITIVE); } else { drawsubpic(pos, [170,45], g_hudssg_spr, [0,0], [1,0.625], hud_col, a, DRAWFLAG_ADDITIVE); } HUD_DrawAmmoBar(pos, pl.ammo_shells, MAX_A_SHELLS, a); #endif } weapontype_t w_supershotgun_type(player pl) { return WPNTYPE_RANGED; } weapon_t w_supershotgun = { .name = "doubleshotgun", .id = ITEM_SUPERSHOTGUN, .slot = 2, .slot_pos = 0, .weight = 5, .draw = w_supershotgun_draw, .holster = __NULL__, .primary = w_supershotgun_primary, .secondary = __NULL__, .reload = __NULL__, .release = __NULL__, .postdraw = w_supershotgun_hud, .precache = w_supershotgun_precache, .pickup = w_supershotgun_pickup, .updateammo = w_supershotgun_updateammo, .wmodel = w_supershotgun_wmodel, .pmodel = w_supershotgun_pmodel, .deathmsg = w_supershotgun_deathmsg, .aimanim = w_supershotgun_aimanim, .isempty = w_supershotgun_isempty, .type = w_supershotgun_type, .hudpic = w_supershotgun_hudpic };