10 METHOD(OverkillNex, wr_glow, vector(OverkillNex this, entity actor, entity wepent))
12 if (!WEP_CVAR(oknex, charge)) return '0 0 0';
13 float charge = wepent.oknex_charge;
14 float animlimit = WEP_CVAR(oknex, charge_animlimit);
16 g.x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, charge / animlimit);
17 g.y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, charge / animlimit);
18 g.z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, charge / animlimit);
19 if (charge > animlimit)
21 g.x += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (charge - animlimit) / (1 - animlimit);
22 g.y += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (charge - animlimit) / (1 - animlimit);
23 g.z += autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (charge - animlimit) / (1 - animlimit);
30 REGISTER_MUTATOR(oknex_charge, true);
32 MUTATOR_HOOKFUNCTION(oknex_charge, GetPressedKeys)
34 entity player = M_ARGV(0, entity);
37 if(!WEP_CVAR(oknex, charge) || !WEP_CVAR(oknex, charge_velocity_rate))
40 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
42 .entity weaponentity = weaponentities[slot];
44 if (player.(weaponentity).m_weapon == WEP_OVERKILL_NEX && WEP_CVAR(oknex, charge) && WEP_CVAR(oknex, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(oknex, charge_minspeed)))
46 float xyspeed = vlen(vec2(player.velocity));
47 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
48 xyspeed = min(xyspeed, WEP_CVAR(oknex, charge_maxspeed));
49 float f = (xyspeed - WEP_CVAR(oknex, charge_minspeed)) / (WEP_CVAR(oknex, charge_maxspeed) - WEP_CVAR(oknex, charge_minspeed));
50 // add the extra charge
51 player.(weaponentity).oknex_charge = min(1, player.(weaponentity).oknex_charge + WEP_CVAR(oknex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
56 void W_OverkillNex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary)
58 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
60 mydmg = WEP_CVAR_BOTH(oknex, !issecondary, damage);
61 myforce = WEP_CVAR_BOTH(oknex, !issecondary, force);
62 mymindist = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_mindist);
63 mymaxdist = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_maxdist);
64 myhalflife = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_halflife);
65 myforcehalflife = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_forcehalflife);
66 myammo = WEP_CVAR_BOTH(oknex, !issecondary, ammo);
69 flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
71 if (WEP_CVAR(oknex, charge))
73 charge = WEP_CVAR(oknex, charge_mindmg) / mydmg + (1 - WEP_CVAR(oknex, charge_mindmg) / mydmg) * actor.(weaponentity).oknex_charge;
74 actor.(weaponentity).oknex_charge *= WEP_CVAR(oknex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
75 // O RLY? -- divVerent
85 W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg);
86 if(charge > WEP_CVAR(oknex, charge_animlimit) && WEP_CVAR(oknex, charge_animlimit)) // if the OverkillNex is overcharged, we play an extra sound
88 sound(actor, CH_WEAPON_B, SND_NEXCHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(oknex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(oknex, charge_animlimit)), ATTN_NORM);
93 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_OVERKILL_NEX.m_id);
96 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
97 if(damage_goodhits && actor.oknex_lasthit)
99 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
100 damage_goodhits = 0; // only every second time
103 actor.oknex_lasthit = damage_goodhits;
105 //beam and muzzle flash done on client
106 SendCSQCVortexBeamParticle(charge);
108 W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
111 .float oknex_chargepool_pauseregen_finished;
113 METHOD(OverkillNex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
115 if(bot_aim(actor, weaponentity, 1000000, 0, 1, false))
116 PHYS_INPUT_BUTTON_ATCK(actor) = true;
119 if(WEP_CVAR(oknex, charge))
120 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
124 METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
126 if (WEP_CVAR(oknex, charge) && actor.(weaponentity).oknex_charge < WEP_CVAR(oknex, charge_limit))
128 actor.(weaponentity).oknex_charge = min(1, actor.(weaponentity).oknex_charge + WEP_CVAR(oknex, charge_rate) * frametime / W_TICSPERFRAME);
131 if (weaponslot(weaponentity) == 0)
133 actor.oknex_charge = actor.(weaponentity).oknex_charge;
136 if (WEP_CVAR_SEC(oknex, chargepool))
137 if (actor.(weaponentity).oknex_chargepool_ammo < 1)
139 if (actor.oknex_chargepool_pauseregen_finished < time)
140 actor.(weaponentity).oknex_chargepool_ammo = min(1, actor.(weaponentity).oknex_chargepool_ammo + WEP_CVAR_SEC(oknex, chargepool_regen) * frametime / W_TICSPERFRAME);
141 actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(oknex, chargepool_pause_regen));
144 if(weaponslot(weaponentity) == 0)
145 actor.oknex_chargepool_ammo = actor.(weaponentity).oknex_chargepool_ammo;
147 if ((WEP_CVAR_SEC(oknex, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
149 // Secondary uses it's own refire timer if refire_type is 1.
150 actor.jump_interval = time + WEP_CVAR_SEC(oknex, refire) * W_WeaponRateFactor(actor);
151 // Ugly hack to reuse the fire mode of the blaster.
152 makevectors(actor.v_angle);
153 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
154 actor.(weaponentity).m_weapon = WEP_BLASTER;
158 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
159 WEP_CVAR_SEC(oknex, shotangle),
160 WEP_CVAR_SEC(oknex, damage),
161 WEP_CVAR_SEC(oknex, edgedamage),
162 WEP_CVAR_SEC(oknex, radius),
163 WEP_CVAR_SEC(oknex, force),
164 WEP_CVAR_SEC(oknex, speed),
165 WEP_CVAR_SEC(oknex, spread),
166 WEP_CVAR_SEC(oknex, delay),
167 WEP_CVAR_SEC(oknex, lifetime)
169 actor.(weaponentity).m_weapon = oldwep;
170 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
171 (actor.(weaponentity).wframe == WFRAME_FIRE2))
173 // Set secondary fire animation.
175 actor.(weaponentity).wframe = WFRAME_FIRE2;
176 a = actor.(weaponentity).anim_fire2;
177 a.z *= g_weaponratefactor;
178 FOREACH_CLIENT(true, LAMBDA(
179 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
181 wframe_send(it, actor.(weaponentity), a, true);
184 animdecide_setaction(actor, ANIMACTION_SHOOT, true);
188 if (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR_PRI(oknex, ammo))
191 thiswep.wr_reload(thiswep, actor, weaponentity);
194 if (fire & 1) // Primary attack
196 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(oknex, refire)))
200 W_OverkillNex_Attack(thiswep, actor, weaponentity, 0);
201 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(oknex, animtime), w_ready);
204 if ((fire & 2) && (WEP_CVAR(oknex, secondary) == 2) && (WEP_CVAR_SEC(oknex, refire_type) == 0))
207 if (!weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(oknex, refire)))
211 // ugly instagib hack to reuse the fire mode of the laser
212 makevectors(actor.v_angle);
213 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
214 actor.(weaponentity).m_weapon = WEP_BLASTER;
218 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
219 WEP_CVAR_SEC(oknex, shotangle),
220 WEP_CVAR_SEC(oknex, damage),
221 WEP_CVAR_SEC(oknex, edgedamage),
222 WEP_CVAR_SEC(oknex, radius),
223 WEP_CVAR_SEC(oknex, force),
224 WEP_CVAR_SEC(oknex, speed),
225 WEP_CVAR_SEC(oknex, spread),
226 WEP_CVAR_SEC(oknex, delay),
227 WEP_CVAR_SEC(oknex, lifetime)
229 actor.(weaponentity).m_weapon = oldwep;
230 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready);
233 //if ((WEP_CVAR(oknex, charge) && (WEP_CVAR(oknex, secondary) == 1)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))
235 // if(WEP_CVAR(oknex, charge))
237 // actor.(weaponentity).oknex_charge_rottime = time + WEP_CVAR(oknex, charge_rot_pause);
238 // float dt = frametime / W_TICSPERFRAME;
240 // if(actor.(weaponentity).oknex_charge < 1)
242 // if(WEP_CVAR_SEC(oknex, chargepool))
244 // if(WEP_CVAR_SEC(oknex, ammo))
246 // // always deplete if secondary is held
247 // actor.oknex_chargepool_ammo = max(0, actor.oknex_chargepool_ammo - WEP_CVAR_SEC(oknex, ammo) * dt);
249 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
250 // actor.oknex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(oknex, chargepool_pause_regen);
251 // dt = min(dt, actor.oknex_chargepool_ammo);
254 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
258 // else if(WEP_CVAR_SEC(oknex, ammo))
260 // if(fire & 2) // only eat ammo when the button is pressed
262 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
263 // if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
265 // // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
266 // if(autocvar_g_balance_vortex_reload_ammo)
268 // dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(oknex, ammo)) / WEP_CVAR_SEC(oknex, ammo));
272 // actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(oknex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(oknex, ammo) * dt);
274 // actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) = actor.(weaponentity).clip_load;
278 // dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(oknex, ammo)) / WEP_CVAR_SEC(oknex, ammo));
282 // actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(oknex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(oknex, ammo) * dt);
286 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
292 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
293 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
297 // else if(WEP_CVAR(oknex, secondary))
299 // if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(oknex, refire)))
301 // W_OverkillNex_Attack(thiswep, actor, weaponentity, 1);
302 // weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(oknex, animtime), w_ready);
308 METHOD(OverkillNex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
310 actor.oknex_lasthit = 0;
313 METHOD(OverkillNex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
315 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
316 ammo_amount += (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) >= WEP_CVAR_PRI(oknex, ammo));
320 METHOD(OverkillNex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
322 if (WEP_CVAR(oknex, secondary))
324 // don't allow charging if we don't have enough ammo
325 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
326 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) >= WEP_CVAR_SEC(oknex, ammo);
331 return false; // zoom is not a fire mode
335 METHOD(OverkillNex, wr_resetplayer, void(entity thiswep, entity actor))
337 if (WEP_CVAR(oknex, charge)) {
338 if (WEP_CVAR_SEC(oknex, chargepool)) {
339 actor.oknex_chargepool_ammo = 1;
341 actor.oknex_charge = WEP_CVAR(oknex, charge_start);
342 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
344 .entity weaponentity = weaponentities[slot];
345 actor.(weaponentity).oknex_charge = WEP_CVAR(oknex, charge_start);
347 if (WEP_CVAR_SEC(oknex, chargepool))
348 actor.(weaponentity).oknex_chargepool_ammo = 1;
351 actor.oknex_lasthit = 0;
354 METHOD(OverkillNex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
356 W_Reload(actor, weaponentity, WEP_CVAR_PRI(oknex, ammo), SND_RELOAD);
359 METHOD(OverkillNex, wr_suicidemessage, Notification(entity thiswep))
361 return WEAPON_THINKING_WITH_PORTALS;
364 METHOD(OverkillNex, wr_killmessage, Notification(entity thiswep))
366 return WEAPON_OVERKILL_NEX_MURDER;
369 METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
371 return PHYS_INPUT_BUTTON_ATCK2(actor) && !WEP_CVAR(oknex, secondary);
377 METHOD(OverkillNex, wr_impacteffect, void(entity thiswep, entity actor))
380 vector org2 = w_org + w_backoff * 6;
381 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
383 sound(this, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
386 METHOD(OverkillNex, wr_init, void(entity thiswep))
388 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
390 precache_pic("gfx/reticle_nex");
394 METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
396 if(button_zoom || zoomscript_caught || (!WEP_CVAR(oknex, secondary) && button_attack2))
402 // no weapon specific image for this weapon
407 METHOD(OverkillNex, wr_zoomdir, bool(entity thiswep))
409 return button_attack2 && !WEP_CVAR(oknex, secondary);