5 .float okvortex_lasthit;
10 METHOD(OverkillVortex, wr_glow, vector(OverkillVortex this, entity actor, entity wepent))
12 if (!WEP_CVAR(okvortex, charge)) return '0 0 0';
13 float charge = wepent.okvortex_charge;
14 float animlimit = WEP_CVAR(okvortex, 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 spawnfunc(weapon_okvortex) { weapon_defaultspawnfunc(this, WEP_OVERKILL_VORTEX); }
32 REGISTER_MUTATOR(okvortex_charge, true);
34 MUTATOR_HOOKFUNCTION(okvortex_charge, GetPressedKeys)
36 entity player = M_ARGV(0, entity);
39 if(!WEP_CVAR(okvortex, charge) || !WEP_CVAR(okvortex, charge_velocity_rate))
42 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
44 .entity weaponentity = weaponentities[slot];
46 if (player.(weaponentity).m_weapon == WEP_OVERKILL_VORTEX && WEP_CVAR(okvortex, charge) && WEP_CVAR(okvortex, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(okvortex, charge_minspeed)))
48 float xyspeed = vlen(vec2(player.velocity));
49 // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
50 xyspeed = min(xyspeed, WEP_CVAR(okvortex, charge_maxspeed));
51 float f = (xyspeed - WEP_CVAR(okvortex, charge_minspeed)) / (WEP_CVAR(okvortex, charge_maxspeed) - WEP_CVAR(okvortex, charge_minspeed));
52 // add the extra charge
53 player.(weaponentity).okvortex_charge = min(1, player.(weaponentity).okvortex_charge + WEP_CVAR(okvortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH);
58 void W_OverkillVortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary)
60 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
62 mydmg = WEP_CVAR_BOTH(okvortex, !issecondary, damage);
63 myforce = WEP_CVAR_BOTH(okvortex, !issecondary, force);
64 mymindist = WEP_CVAR_BOTH(okvortex, !issecondary, damagefalloff_mindist);
65 mymaxdist = WEP_CVAR_BOTH(okvortex, !issecondary, damagefalloff_maxdist);
66 myhalflife = WEP_CVAR_BOTH(okvortex, !issecondary, damagefalloff_halflife);
67 myforcehalflife = WEP_CVAR_BOTH(okvortex, !issecondary, damagefalloff_forcehalflife);
68 myammo = WEP_CVAR_BOTH(okvortex, !issecondary, ammo);
71 flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
73 if (WEP_CVAR(okvortex, charge))
75 charge = WEP_CVAR(okvortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(okvortex, charge_mindmg) / mydmg) * actor.(weaponentity).okvortex_charge;
76 actor.(weaponentity).okvortex_charge *= WEP_CVAR(okvortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
77 // O RLY? -- divVerent
87 W_SetupShot(actor, weaponentity, true, 5, SND_NEXFIRE, CH_WEAPON_A, mydmg);
88 if(charge > WEP_CVAR(okvortex, charge_animlimit) && WEP_CVAR(okvortex, charge_animlimit)) // if the OverkillVortex is overcharged, we play an extra sound
90 sound(actor, CH_WEAPON_B, SND_NEXCHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(okvortex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(okvortex, charge_animlimit)), ATTN_NORM);
95 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_OVERKILL_VORTEX.m_id);
98 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
99 if(damage_goodhits && actor.okvortex_lasthit)
101 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
102 damage_goodhits = 0; // only every second time
105 actor.okvortex_lasthit = damage_goodhits;
107 //beam and muzzle flash done on client
108 SendCSQCVortexBeamParticle(charge);
110 W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
113 .float okvortex_chargepool_pauseregen_finished;
115 METHOD(OverkillVortex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
117 if(bot_aim(actor, weaponentity, 1000000, 0, 1, false))
118 PHYS_INPUT_BUTTON_ATCK(actor) = true;
121 if(WEP_CVAR(okvortex, charge))
122 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
126 METHOD(OverkillVortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
128 if (WEP_CVAR(okvortex, charge) && actor.(weaponentity).okvortex_charge < WEP_CVAR(okvortex, charge_limit))
130 actor.(weaponentity).okvortex_charge = min(1, actor.(weaponentity).okvortex_charge + WEP_CVAR(okvortex, charge_rate) * frametime / W_TICSPERFRAME);
133 if (weaponslot(weaponentity) == 0)
135 actor.okvortex_charge = actor.(weaponentity).okvortex_charge;
138 if (WEP_CVAR_SEC(okvortex, chargepool))
139 if (actor.(weaponentity).okvortex_chargepool_ammo < 1)
141 if (actor.okvortex_chargepool_pauseregen_finished < time)
142 actor.(weaponentity).okvortex_chargepool_ammo = min(1, actor.(weaponentity).okvortex_chargepool_ammo + WEP_CVAR_SEC(okvortex, chargepool_regen) * frametime / W_TICSPERFRAME);
143 actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(okvortex, chargepool_pause_regen));
146 if(weaponslot(weaponentity) == 0)
147 actor.okvortex_chargepool_ammo = actor.(weaponentity).okvortex_chargepool_ammo;
149 if (autocvar_g_balance_okvortex_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR_PRI(okvortex, ammo))
152 thiswep.wr_reload(thiswep, actor, weaponentity);
158 if (weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(okvortex, refire)))
160 W_OverkillVortex_Attack(thiswep, actor, weaponentity, 0);
161 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okvortex, animtime), w_ready);
164 else if ((fire & 2) && (WEP_CVAR(okvortex, secondary) == 2))
166 if (!weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okshotgun, refire)))
170 // ugly instagib hack to reuse the fire mode of the laser
171 makevectors(actor.v_angle);
172 Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
173 actor.(weaponentity).m_weapon = WEP_BLASTER;
177 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
178 WEP_CVAR_SEC(okshotgun, shotangle),
179 WEP_CVAR_SEC(okshotgun, damage),
180 WEP_CVAR_SEC(okshotgun, edgedamage),
181 WEP_CVAR_SEC(okshotgun, radius),
182 WEP_CVAR_SEC(okshotgun, force),
183 WEP_CVAR_SEC(okshotgun, speed),
184 WEP_CVAR_SEC(okshotgun, spread),
185 WEP_CVAR_SEC(okshotgun, delay),
186 WEP_CVAR_SEC(okshotgun, lifetime)
188 actor.(weaponentity).m_weapon = oldwep;
189 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(okshotgun, animtime), w_ready);
192 if((WEP_CVAR(okvortex, charge) && !WEP_CVAR(okvortex, secondary)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))
194 if(WEP_CVAR(okvortex, charge))
196 actor.(weaponentity).okvortex_charge_rottime = time + WEP_CVAR(okvortex, charge_rot_pause);
197 float dt = frametime / W_TICSPERFRAME;
199 if(actor.(weaponentity).okvortex_charge < 1)
201 if(WEP_CVAR_SEC(okvortex, chargepool))
203 if(WEP_CVAR_SEC(okvortex, ammo))
205 // always deplete if secondary is held
206 actor.okvortex_chargepool_ammo = max(0, actor.okvortex_chargepool_ammo - WEP_CVAR_SEC(okvortex, ammo) * dt);
208 dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
209 actor.okvortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(okvortex, chargepool_pause_regen);
210 dt = min(dt, actor.okvortex_chargepool_ammo);
213 actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
217 else if(WEP_CVAR_SEC(okvortex, ammo))
219 if(fire & 2) // only eat ammo when the button is pressed
221 dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
222 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
224 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
225 if(autocvar_g_balance_vortex_reload_ammo)
227 dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
231 actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(okvortex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(okvortex, ammo) * dt);
233 actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) = actor.(weaponentity).clip_load;
237 dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(okvortex, ammo)) / WEP_CVAR_SEC(okvortex, ammo));
241 actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(okvortex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(okvortex, ammo) * dt);
245 actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
251 dt = min(dt, (1 - actor.(weaponentity).okvortex_charge) / WEP_CVAR(okvortex, charge_rate));
252 actor.(weaponentity).okvortex_charge += dt * WEP_CVAR(okvortex, charge_rate);
256 else if(WEP_CVAR(okvortex, secondary))
258 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(okvortex, refire)))
260 W_OverkillVortex_Attack(thiswep, actor, weaponentity, 1);
261 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(okvortex, animtime), w_ready);
268 METHOD(OverkillVortex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
270 actor.okvortex_lasthit = 0;
273 METHOD(OverkillVortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
275 float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(okvortex, ammo);
276 ammo_amount += (autocvar_g_balance_okvortex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) >= WEP_CVAR_PRI(okvortex, ammo));
280 METHOD(OverkillVortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
282 if(WEP_CVAR(okvortex, secondary))
284 // don't allow charging if we don't have enough ammo
285 float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(okvortex, ammo);
286 ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_VORTEX.m_id]) >= WEP_CVAR_SEC(okvortex, ammo);
291 return false; // zoom is not a fire mode
295 METHOD(OverkillVortex, wr_resetplayer, void(entity thiswep, entity actor))
297 if (WEP_CVAR(okvortex, charge)) {
298 if (WEP_CVAR_SEC(okvortex, chargepool)) {
299 actor.okvortex_chargepool_ammo = 1;
301 actor.okvortex_charge = WEP_CVAR(okvortex, charge_start);
302 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
304 .entity weaponentity = weaponentities[slot];
305 actor.(weaponentity).okvortex_charge = WEP_CVAR(okvortex, charge_start);
307 if (WEP_CVAR_SEC(okvortex, chargepool))
308 actor.(weaponentity).okvortex_chargepool_ammo = 1;
311 actor.okvortex_lasthit = 0;
314 METHOD(OverkillVortex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
316 W_Reload(actor, weaponentity, WEP_CVAR_PRI(okvortex, ammo), SND_RELOAD);
319 METHOD(OverkillVortex, wr_suicidemessage, Notification(entity thiswep))
321 return WEAPON_THINKING_WITH_PORTALS;
324 METHOD(OverkillVortex, wr_killmessage, Notification(entity thiswep))
326 return WEAPON_VORTEX_MURDER;
329 METHOD(OverkillVortex, wr_zoom, bool(entity thiswep, entity actor))
331 return PHYS_INPUT_BUTTON_ATCK2(actor) && !WEP_CVAR(okvortex, secondary);
337 METHOD(OverkillVortex, wr_impacteffect, void(entity thiswep, entity actor))
340 vector org2 = w_org + w_backoff * 6;
341 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
343 sound(this, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
346 METHOD(OverkillVortex, wr_init, void(entity thiswep))
348 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
350 precache_pic("gfx/reticle_nex");
354 METHOD(OverkillVortex, wr_zoom, bool(entity thiswep, entity actor))
356 if(button_zoom || zoomscript_caught || (!WEP_CVAR(okvortex, secondary) && button_attack2))
362 // no weapon specific image for this weapon