1 #include "okshotgun.qh"
4 spawnfunc(weapon_okshotgun) { weapon_defaultspawnfunc(this, WEP_OVERKILL_SHOTGUN); }
6 .float okshotgun_primarytime;
8 METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
10 if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(okshotgun, bot_range)))
12 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
16 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
20 METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
22 if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo)) // forced reload
24 thiswep.wr_reload(thiswep, actor, weaponentity);
27 if (fire & 1) // Primary attack
29 if (time >= actor.(weaponentity).okshotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
31 if (weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, animtime)))
33 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
34 WEP_CVAR_PRI(okshotgun, ammo),
35 WEP_CVAR_PRI(okshotgun, damage),
36 WEP_CVAR_PRI(okshotgun, bullets),
37 WEP_CVAR_PRI(okshotgun, spread),
38 WEP_CVAR_PRI(okshotgun, solidpenetration),
39 WEP_CVAR_PRI(okshotgun, force));
40 actor.(weaponentity).okshotgun_primarytime = time + WEP_CVAR_PRI(okshotgun, refire) * W_WeaponRateFactor(actor);
41 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
45 else if (fire & 2) // Secondary attack
47 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
51 // ugly instagib hack to reuse the fire mode of the laser
52 makevectors(actor.v_angle);
53 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
54 actor.(weaponentity).m_weapon = WEP_BLASTER;
58 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
59 WEP_CVAR_SEC(okshotgun, shotangle),
60 WEP_CVAR_SEC(okshotgun, damage),
61 WEP_CVAR_SEC(okshotgun, edgedamage),
62 WEP_CVAR_SEC(okshotgun, radius),
63 WEP_CVAR_SEC(okshotgun, force),
64 WEP_CVAR_SEC(okshotgun, speed),
65 WEP_CVAR_SEC(okshotgun, spread),
66 WEP_CVAR_SEC(okshotgun, delay),
67 WEP_CVAR_SEC(okshotgun, lifetime)
69 actor.(weaponentity).m_weapon = oldwep;
70 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
74 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
76 float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(okshotgun, ammo);
77 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
81 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
83 if (WEP_CVAR_SEC(okshotgun, ammo) == 0)
87 float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(okshotgun, ammo);
88 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_SEC(okshotgun, ammo);
92 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
94 W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
97 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
99 return WEAPON_THINKING_WITH_PORTALS;
102 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
104 if(w_deathtype & HITTYPE_SECONDARY)
105 return WEAPON_BLASTER_MURDER;
107 return WEAPON_SHOTGUN_MURDER;
114 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
116 vector org2 = w_org + w_backoff * 2;
117 pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
118 if(!w_issilent && time - actor.prevric > 0.25)
121 sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
122 actor.prevric = time;