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);
15 float f = autocvar_g_weapon_charge_colormod_hdrmultiplier * min(1, charge / animlimit);
17 g.x = f * autocvar_g_weapon_charge_colormod_red_half;
18 g.y = f * autocvar_g_weapon_charge_colormod_green_half;
19 g.z = f * autocvar_g_weapon_charge_colormod_blue_half;
20 if (charge > animlimit)
22 f = autocvar_g_weapon_charge_colormod_hdrmultiplier * (charge - animlimit) / (1 - animlimit);
23 g.x += f * autocvar_g_weapon_charge_colormod_red_full;
24 g.y += f * autocvar_g_weapon_charge_colormod_green_full;
25 g.z += f * autocvar_g_weapon_charge_colormod_blue_full;
27 // transition color can't be '0 0 0' as it defaults to player model glow color
35 REGISTER_MUTATOR(oknex_charge, true);
37 MUTATOR_HOOKFUNCTION(oknex_charge, GetPressedKeys)
39 entity player = M_ARGV(0, entity);
42 if(!WEP_CVAR(oknex, charge) || !WEP_CVAR(oknex, charge_velocity_rate))
45 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
47 .entity weaponentity = weaponentities[slot];
49 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)))
51 float xyspeed = vlen(vec2(player.velocity));
52 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
53 xyspeed = min(xyspeed, WEP_CVAR(oknex, charge_maxspeed));
54 float f = (xyspeed - WEP_CVAR(oknex, charge_minspeed)) / (WEP_CVAR(oknex, charge_maxspeed) - WEP_CVAR(oknex, charge_minspeed));
55 // add the extra charge
56 player.(weaponentity).oknex_charge = min(1, player.(weaponentity).oknex_charge + WEP_CVAR(oknex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
61 void W_OverkillNex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary)
63 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
65 mydmg = WEP_CVAR_BOTH(oknex, !issecondary, damage);
66 myforce = WEP_CVAR_BOTH(oknex, !issecondary, force);
67 mymindist = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_mindist);
68 mymaxdist = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_maxdist);
69 myhalflife = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_halflife);
70 myforcehalflife = WEP_CVAR_BOTH(oknex, !issecondary, damagefalloff_forcehalflife);
71 myammo = WEP_CVAR_BOTH(oknex, !issecondary, ammo);
74 flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
76 if (WEP_CVAR(oknex, charge))
78 charge = WEP_CVAR(oknex, charge_mindmg) / mydmg + (1 - WEP_CVAR(oknex, charge_mindmg) / mydmg) * actor.(weaponentity).oknex_charge;
79 actor.(weaponentity).oknex_charge *= WEP_CVAR(oknex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
80 // O RLY? -- divVerent
90 W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg, thiswep.m_id);
91 if(charge > WEP_CVAR(oknex, charge_animlimit) && WEP_CVAR(oknex, charge_animlimit)) // if the OverkillNex is overcharged, we play an extra sound
93 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);
98 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, thiswep.m_id);
101 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
102 if(damage_goodhits && actor.oknex_lasthit)
104 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
105 damage_goodhits = 0; // only every second time
108 actor.oknex_lasthit = damage_goodhits;
110 //beam and muzzle flash done on client
111 SendCSQCVortexBeamParticle(charge);
113 W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
116 .float oknex_chargepool_pauseregen_finished;
118 METHOD(OverkillNex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
120 if(bot_aim(actor, weaponentity, 1000000, 0, 1, false))
121 PHYS_INPUT_BUTTON_ATCK(actor) = true;
124 if(WEP_CVAR(oknex, charge))
125 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
129 METHOD(OverkillNex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
131 if (WEP_CVAR(oknex, charge) && actor.(weaponentity).oknex_charge < WEP_CVAR(oknex, charge_limit))
133 actor.(weaponentity).oknex_charge = min(1, actor.(weaponentity).oknex_charge + WEP_CVAR(oknex, charge_rate) * frametime / W_TICSPERFRAME);
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 ((WEP_CVAR_SEC(oknex, refire_type) == 1) && (fire & 2) && (time >= actor.jump_interval))
146 // Secondary uses it's own refire timer if refire_type is 1.
147 actor.jump_interval = time + WEP_CVAR_SEC(oknex, refire) * W_WeaponRateFactor(actor);
148 BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
149 if ((actor.(weaponentity).wframe == WFRAME_IDLE) ||
150 (actor.(weaponentity).wframe == WFRAME_FIRE2))
152 // Set secondary fire animation.
154 actor.(weaponentity).wframe = WFRAME_FIRE2;
155 a = actor.(weaponentity).anim_fire2;
156 a.z *= g_weaponratefactor;
157 FOREACH_CLIENT(true, LAMBDA(
158 if (it == actor || (IS_SPEC(it) && it.enemy == actor))
160 wframe_send(it, actor.(weaponentity), a, true);
163 animdecide_setaction(actor, ANIMACTION_SHOOT, true);
167 if (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR_PRI(oknex, ammo))
170 thiswep.wr_reload(thiswep, actor, weaponentity);
173 if (fire & 1) // Primary attack
175 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(oknex, refire)))
179 W_OverkillNex_Attack(thiswep, actor, weaponentity, 0);
180 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(oknex, animtime), w_ready);
183 if ((fire & 2) && (WEP_CVAR(oknex, secondary) == 2) && (WEP_CVAR_SEC(oknex, refire_type) == 0))
186 if (!weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(oknex, refire)))
190 BLASTER_SECONDARY_ATTACK(oknex, actor, weaponentity);
191 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(oknex, animtime), w_ready);
194 //if ((WEP_CVAR(oknex, charge) && (WEP_CVAR(oknex, secondary) == 1)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))
196 // if(WEP_CVAR(oknex, charge))
198 // actor.(weaponentity).oknex_charge_rottime = time + WEP_CVAR(oknex, charge_rot_pause);
199 // float dt = frametime / W_TICSPERFRAME;
201 // if(actor.(weaponentity).oknex_charge < 1)
203 // if(WEP_CVAR_SEC(oknex, chargepool))
205 // if(WEP_CVAR_SEC(oknex, ammo))
207 // // always deplete if secondary is held
208 // actor.(weaponentity).oknex_chargepool_ammo = max(0, actor.(weaponentity).oknex_chargepool_ammo - WEP_CVAR_SEC(oknex, ammo) * dt);
210 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
211 // actor.oknex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(oknex, chargepool_pause_regen);
212 // dt = min(dt, actor.(weaponentity).oknex_chargepool_ammo);
215 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
219 // else if(WEP_CVAR_SEC(oknex, ammo))
221 // if(fire & 2) // only eat ammo when the button is pressed
223 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
224 // if(!(actor.items & IT_UNLIMITED_AMMO))
226 // // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
227 // if(autocvar_g_balance_vortex_reload_ammo)
229 // dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(oknex, ammo)) / WEP_CVAR_SEC(oknex, ammo));
233 // actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(oknex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(oknex, ammo) * dt);
235 // actor.(weaponentity).(weapon_load[WEP_OVERKILL_NEX.m_id]) = actor.(weaponentity).clip_load;
239 // dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(oknex, ammo)) / WEP_CVAR_SEC(oknex, ammo));
243 // actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(oknex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(oknex, ammo) * dt);
247 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
253 // dt = min(dt, (1 - actor.(weaponentity).oknex_charge) / WEP_CVAR(oknex, charge_rate));
254 // actor.(weaponentity).oknex_charge += dt * WEP_CVAR(oknex, charge_rate);
258 // else if(WEP_CVAR(oknex, secondary))
260 // if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(oknex, refire)))
262 // W_OverkillNex_Attack(thiswep, actor, weaponentity, 1);
263 // weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(oknex, animtime), w_ready);
269 METHOD(OverkillNex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
271 actor.oknex_lasthit = 0;
274 METHOD(OverkillNex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
276 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
277 ammo_amount += (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(oknex, ammo));
281 METHOD(OverkillNex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
283 if (WEP_CVAR(oknex, secondary))
285 // don't allow charging if we don't have enough ammo
286 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
287 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(oknex, ammo);
292 return false; // zoom is not a fire mode
296 METHOD(OverkillNex, wr_resetplayer, void(entity thiswep, entity actor))
298 if (WEP_CVAR(oknex, charge)) {
299 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
301 .entity weaponentity = weaponentities[slot];
302 actor.(weaponentity).oknex_charge = WEP_CVAR(oknex, charge_start);
305 actor.oknex_lasthit = 0;
308 METHOD(OverkillNex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
310 W_Reload(actor, weaponentity, WEP_CVAR_PRI(oknex, ammo), SND_RELOAD);
313 METHOD(OverkillNex, wr_suicidemessage, Notification(entity thiswep))
315 return WEAPON_THINKING_WITH_PORTALS;
318 METHOD(OverkillNex, wr_killmessage, Notification(entity thiswep))
320 return WEAPON_OVERKILL_NEX_MURDER;
323 METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
325 return PHYS_INPUT_BUTTON_ATCK2(actor) && !WEP_CVAR(oknex, secondary);
331 METHOD(OverkillNex, wr_impacteffect, void(entity thiswep, entity actor))
334 vector org2 = w_org + w_backoff * 6;
335 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
337 sound(this, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
340 METHOD(OverkillNex, wr_init, void(entity thiswep))
342 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
344 precache_pic("gfx/reticle_nex");
348 METHOD(OverkillNex, wr_zoom, bool(entity thiswep, entity actor))
350 if(button_zoom || zoomscript_caught || (!WEP_CVAR(oknex, secondary) && button_attack2))
356 // no weapon specific image for this weapon
361 METHOD(OverkillNex, wr_zoomdir, bool(entity thiswep))
363 return button_attack2 && !WEP_CVAR(oknex, secondary);