1 #include "okshotgun.qh"
4 spawnfunc(weapon_okshotgun) { weapon_defaultspawnfunc(this, WEP_OVERKILL_SHOTGUN); }
6 METHOD(OverkillShotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
8 if (vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_PRI(okshotgun, bot_range)))
10 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
14 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
18 METHOD(OverkillShotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
20 if ((WEP_CVAR_SEC(okshotgun, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
22 // Secondary uses it's own refire timer if refire_type is 1.
23 actor.jump_interval = time + WEP_CVAR_SEC(okshotgun, refire) * W_WeaponRateFactor(actor);
24 // Ugly hack to reuse the fire mode of the blaster.
25 makevectors(actor.v_angle);
26 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
27 actor.(weaponentity).m_weapon = WEP_BLASTER;
31 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
32 WEP_CVAR_SEC(okshotgun, shotangle),
33 WEP_CVAR_SEC(okshotgun, damage),
34 WEP_CVAR_SEC(okshotgun, edgedamage),
35 WEP_CVAR_SEC(okshotgun, radius),
36 WEP_CVAR_SEC(okshotgun, force),
37 WEP_CVAR_SEC(okshotgun, speed),
38 WEP_CVAR_SEC(okshotgun, spread),
39 WEP_CVAR_SEC(okshotgun, delay),
40 WEP_CVAR_SEC(okshotgun, lifetime)
42 actor.(weaponentity).m_weapon = oldwep;
43 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
44 (actor.(weaponentity).wframe == WFRAME_FIRE2))
46 // Set secondary fire animation.
48 actor.(weaponentity).wframe = WFRAME_FIRE2;
49 a = actor.(weaponentity).anim_fire2;
50 a.z *= g_weaponratefactor;
51 FOREACH_CLIENT(true, LAMBDA(
52 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
54 wframe_send(it, actor.(weaponentity), a, true);
57 animdecide_setaction(actor, ANIMACTION_SHOOT, true);
60 if (WEP_CVAR(okshotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okshotgun, ammo))
63 thiswep.wr_reload(thiswep, actor, weaponentity);
66 if (fire & 1) // Primary attack
68 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okshotgun, animtime)))
72 W_Shotgun_Attack(thiswep, actor, weaponentity, true,
73 WEP_CVAR_PRI(okshotgun, ammo),
74 WEP_CVAR_PRI(okshotgun, damage),
75 WEP_CVAR_PRI(okshotgun, bullets),
76 WEP_CVAR_PRI(okshotgun, spread),
77 WEP_CVAR_PRI(okshotgun, solidpenetration),
78 WEP_CVAR_PRI(okshotgun, force));
79 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okshotgun, animtime), w_ready);
82 if ((fire & 2) && (WEP_CVAR_SEC(okshotgun, refire_type) == 0)) // Secondary attack
84 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
88 // ugly instagib hack to reuse the fire mode of the laser
89 makevectors(actor.v_angle);
90 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
91 actor.(weaponentity).m_weapon = WEP_BLASTER;
95 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
96 WEP_CVAR_SEC(okshotgun, shotangle),
97 WEP_CVAR_SEC(okshotgun, damage),
98 WEP_CVAR_SEC(okshotgun, edgedamage),
99 WEP_CVAR_SEC(okshotgun, radius),
100 WEP_CVAR_SEC(okshotgun, force),
101 WEP_CVAR_SEC(okshotgun, speed),
102 WEP_CVAR_SEC(okshotgun, spread),
103 WEP_CVAR_SEC(okshotgun, delay),
104 WEP_CVAR_SEC(okshotgun, lifetime)
106 actor.(weaponentity).m_weapon = oldwep;
107 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
111 METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
113 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
114 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
118 METHOD(OverkillShotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
120 if (WEP_CVAR_SEC(okshotgun, ammo) == 0)
124 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(okshotgun, ammo);
125 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_SEC(okshotgun, ammo);
129 METHOD(OverkillShotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
131 W_Reload(actor, weaponentity, WEP_CVAR_PRI(okshotgun, ammo), SND_RELOAD); // WEAPONTODO
134 METHOD(OverkillShotgun, wr_suicidemessage, Notification(entity thiswep))
136 return WEAPON_THINKING_WITH_PORTALS;
139 METHOD(OverkillShotgun, wr_killmessage, Notification(entity thiswep))
141 if(w_deathtype & HITTYPE_SECONDARY)
142 return WEAPON_BLASTER_MURDER;
144 return WEAPON_SHOTGUN_MURDER;
151 METHOD(OverkillShotgun, wr_impacteffect, void(entity thiswep, entity actor))
153 vector org2 = w_org + w_backoff * 2;
154 pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
155 if(!w_issilent && time - actor.prevric > 0.25)
158 sound(actor, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
159 actor.prevric = time;