3 /* ammotype */ ATTRIB(Vortex, ammo_field, .int, ammo_cells)
4 /* impulse */ ATTRIB(Vortex, impulse, int, 7)
5 /* flags */ ATTRIB(Vortex, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN);
6 /* rating */ ATTRIB(Vortex, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
7 /* color */ ATTRIB(Vortex, wpcolor, vector, '0.5 1 1');
8 /* modelname */ ATTRIB(Vortex, mdl, string, "nex");
10 /* model */ ATTRIB(Vortex, m_model, Model, MDL_VORTEX_ITEM);
12 /* crosshair */ ATTRIB(Vortex, w_crosshair, string, "gfx/crosshairnex");
13 /* crosshair */ ATTRIB(Vortex, w_crosshair_size, float, 0.65);
14 /* wepimg */ ATTRIB(Vortex, model2, string, "weaponnex");
15 /* refname */ ATTRIB(Vortex, netname, string, "vortex");
16 /* wepname */ ATTRIB(Vortex, m_name, string, _("Vortex"));
18 REGISTER_WEAPON(VORTEX, NEW(Vortex));
20 #define VORTEX_SETTINGS(w_cvar,w_prop) VORTEX_SETTINGS_LIST(w_cvar, w_prop, VORTEX, vortex)
21 #define VORTEX_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
22 w_cvar(id, sn, BOTH, ammo) \
23 w_cvar(id, sn, BOTH, animtime) \
24 w_cvar(id, sn, BOTH, damage) \
25 w_cvar(id, sn, BOTH, force) \
26 w_cvar(id, sn, BOTH, damagefalloff_mindist) \
27 w_cvar(id, sn, BOTH, damagefalloff_maxdist) \
28 w_cvar(id, sn, BOTH, damagefalloff_halflife) \
29 w_cvar(id, sn, BOTH, damagefalloff_forcehalflife) \
30 w_cvar(id, sn, BOTH, refire) \
31 w_cvar(id, sn, NONE, charge) \
32 w_cvar(id, sn, NONE, charge_mindmg) \
33 w_cvar(id, sn, NONE, charge_shot_multiplier) \
34 w_cvar(id, sn, NONE, charge_animlimit) \
35 w_cvar(id, sn, NONE, charge_limit) \
36 w_cvar(id, sn, NONE, charge_rate) \
37 w_cvar(id, sn, NONE, charge_rot_rate) \
38 w_cvar(id, sn, NONE, charge_rot_pause) \
39 w_cvar(id, sn, NONE, charge_start) \
40 w_cvar(id, sn, NONE, charge_minspeed) \
41 w_cvar(id, sn, NONE, charge_maxspeed) \
42 w_cvar(id, sn, NONE, charge_velocity_rate) \
43 w_cvar(id, sn, NONE, secondary) \
44 w_cvar(id, sn, SEC, chargepool) \
45 w_cvar(id, sn, SEC, chargepool_regen) \
46 w_cvar(id, sn, SEC, chargepool_pause_regen) \
47 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
48 w_prop(id, sn, float, reloading_time, reload_time) \
49 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
50 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
51 w_prop(id, sn, string, weaponreplace, weaponreplace) \
52 w_prop(id, sn, float, weaponstart, weaponstart) \
53 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
54 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
57 VORTEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
59 .float vortex_lasthit;
64 REGISTER_NET_TEMP(TE_CSQC_VORTEXBEAMPARTICLE)
67 void SendCSQCVortexBeamParticle(float charge) {
69 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
70 WriteHeader(MSG_BROADCAST, TE_CSQC_VORTEXBEAMPARTICLE);
71 WriteCoord(MSG_BROADCAST, w_shotorg.x);
72 WriteCoord(MSG_BROADCAST, w_shotorg.y);
73 WriteCoord(MSG_BROADCAST, w_shotorg.z);
74 WriteCoord(MSG_BROADCAST, v.x);
75 WriteCoord(MSG_BROADCAST, v.y);
76 WriteCoord(MSG_BROADCAST, v.z);
77 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
80 NET_HANDLE(TE_CSQC_VORTEXBEAMPARTICLE, bool isNew)
82 vector shotorg, endpos;
84 shotorg.x = ReadCoord(); shotorg.y = ReadCoord(); shotorg.z = ReadCoord();
85 endpos.x = ReadCoord(); endpos.y = ReadCoord(); endpos.z = ReadCoord();
86 charge = ReadByte() / 255.0;
88 pointparticles(EFFECT_VORTEX_MUZZLEFLASH, shotorg, normalize(endpos - shotorg) * 1000, 1);
90 //draw either the old v2.3 beam or the new beam
91 charge = sqrt(charge); // divide evenly among trail spacing and alpha
92 particles_alphamin = particles_alphamax = particles_fade = charge;
94 if(!MUTATOR_CALLHOOK(Particles_VortexBeam, shotorg, endpos))
95 if(autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
96 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
98 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
104 spawnfunc(weapon_vortex) { weapon_defaultspawnfunc(this, WEP_VORTEX); }
105 spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); }
107 void W_Vortex_Attack(Weapon thiswep, float issecondary)
109 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
111 mydmg = WEP_CVAR_BOTH(vortex, !issecondary, damage);
112 myforce = WEP_CVAR_BOTH(vortex, !issecondary, force);
113 mymindist = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_mindist);
114 mymaxdist = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_maxdist);
115 myhalflife = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_halflife);
116 myforcehalflife = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_forcehalflife);
117 myammo = WEP_CVAR_BOTH(vortex, !issecondary, ammo);
120 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
122 if(WEP_CVAR(vortex, charge))
124 charge = WEP_CVAR(vortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(vortex, charge_mindmg) / mydmg) * self.vortex_charge;
125 self.vortex_charge *= WEP_CVAR(vortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
126 // O RLY? -- divVerent
127 // YA RLY -- FruitieX
134 W_SetupShot(self, true, 5, SND(NEXFIRE), CH_WEAPON_A, mydmg);
135 if(charge > WEP_CVAR(vortex, charge_animlimit) && WEP_CVAR(vortex, charge_animlimit)) // if the Vortex is overcharged, we play an extra sound
137 sound(self, CH_WEAPON_B, SND_NEXCHARGE, VOL_BASE * (charge - 0.5 * WEP_CVAR(vortex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(vortex, charge_animlimit)), ATTN_NORM);
142 FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
145 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
146 if(damage_goodhits && self.vortex_lasthit)
148 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
149 damage_goodhits = 0; // only every second time
152 self.vortex_lasthit = damage_goodhits;
154 //beam and muzzle flash done on client
155 SendCSQCVortexBeamParticle(charge);
157 W_DecreaseAmmo(thiswep, self, myammo);
160 .float vortex_chargepool_pauseregen_finished;
162 METHOD(Vortex, wr_aim, void(entity thiswep))
164 if(bot_aim(1000000, 0, 1, false))
165 self.BUTTON_ATCK = true;
168 if(WEP_CVAR(vortex, charge))
169 self.BUTTON_ATCK2 = true;
172 METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
174 if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit))
175 actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
177 if(WEP_CVAR_SEC(vortex, chargepool))
178 if(actor.vortex_chargepool_ammo < 1)
180 if(actor.vortex_chargepool_pauseregen_finished < time)
181 actor.vortex_chargepool_ammo = min(1, actor.vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME);
182 actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen));
185 if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
186 Weapon w = get_weaponinfo(actor.weapon);
192 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire)))
194 W_Vortex_Attack(thiswep, 0);
195 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
198 if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : (fire & 2))
200 if(WEP_CVAR(vortex, charge))
202 actor.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause);
203 float dt = frametime / W_TICSPERFRAME;
205 if(actor.vortex_charge < 1)
207 if(WEP_CVAR_SEC(vortex, chargepool))
209 if(WEP_CVAR_SEC(vortex, ammo))
211 // always deplete if secondary is held
212 actor.vortex_chargepool_ammo = max(0, actor.vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt);
214 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
215 actor.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen);
216 dt = min(dt, actor.vortex_chargepool_ammo);
219 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
223 else if(WEP_CVAR_SEC(vortex, ammo))
225 if(fire & 2) // only eat ammo when the button is pressed
227 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
228 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
230 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
231 if(autocvar_g_balance_vortex_reload_ammo)
233 dt = min(dt, (actor.clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
237 actor.clip_load = max(WEP_CVAR_SEC(vortex, ammo), actor.clip_load - WEP_CVAR_SEC(vortex, ammo) * dt);
239 actor.(weapon_load[WEP_VORTEX.m_id]) = actor.clip_load;
243 dt = min(dt, (actor.WEP_AMMO(VORTEX) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
247 actor.WEP_AMMO(VORTEX) = max(WEP_CVAR_SEC(vortex, ammo), actor.WEP_AMMO(VORTEX) - WEP_CVAR_SEC(vortex, ammo) * dt);
251 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
257 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
258 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
262 else if(WEP_CVAR(vortex, secondary))
264 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire)))
266 W_Vortex_Attack(thiswep, 1);
267 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
273 METHOD(Vortex, wr_init, void(entity thiswep))
275 VORTEX_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
277 METHOD(Vortex, wr_setup, void(entity thiswep))
279 self.vortex_lasthit = 0;
281 METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
283 float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_PRI(vortex, ammo);
284 ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
287 METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
289 if(WEP_CVAR(vortex, secondary))
291 // don't allow charging if we don't have enough ammo
292 float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_SEC(vortex, ammo);
293 ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
298 return false; // zoom is not a fire mode
301 METHOD(Vortex, wr_config, void(entity thiswep))
303 VORTEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
305 METHOD(Vortex, wr_resetplayer, void(entity thiswep))
307 if (WEP_CVAR(vortex, charge)) {
308 if (WEP_CVAR_SEC(vortex, chargepool)) {
309 self.vortex_chargepool_ammo = 1;
311 self.vortex_charge = WEP_CVAR(vortex, charge_start);
313 self.vortex_lasthit = 0;
315 METHOD(Vortex, wr_reload, void(entity thiswep))
317 W_Reload(self, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND(RELOAD));
319 METHOD(Vortex, wr_suicidemessage, int(entity thiswep))
321 return WEAPON_THINKING_WITH_PORTALS;
323 METHOD(Vortex, wr_killmessage, int(entity thiswep))
325 return WEAPON_VORTEX_MURDER;
330 float autocvar_g_balance_vortex_secondary = 0; // WEAPONTODO
332 METHOD(Vortex, wr_impacteffect, void(entity thiswep))
334 vector org2 = w_org + w_backoff * 6;
335 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
337 sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
339 METHOD(Vortex, wr_init, void(entity thiswep))
341 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
343 precache_pic("gfx/reticle_nex");
346 METHOD(Vortex, wr_zoomreticle, bool(entity thiswep))
348 if(button_zoom || zoomscript_caught || (!WEP_CVAR(vortex, secondary) && button_attack2))
350 reticle_image = "gfx/reticle_nex";
355 // no weapon specific image for this weapon