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 (autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
95 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
97 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
103 spawnfunc(weapon_vortex) { weapon_defaultspawnfunc(this, WEP_VORTEX); }
104 spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); }
106 void W_Vortex_Attack(Weapon thiswep, float issecondary)
108 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
110 mydmg = WEP_CVAR_BOTH(vortex, !issecondary, damage);
111 myforce = WEP_CVAR_BOTH(vortex, !issecondary, force);
112 mymindist = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_mindist);
113 mymaxdist = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_maxdist);
114 myhalflife = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_halflife);
115 myforcehalflife = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_forcehalflife);
116 myammo = WEP_CVAR_BOTH(vortex, !issecondary, ammo);
119 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
121 if(WEP_CVAR(vortex, charge))
123 charge = WEP_CVAR(vortex, charge_mindmg) / mydmg + (1 - WEP_CVAR(vortex, charge_mindmg) / mydmg) * self.vortex_charge;
124 self.vortex_charge *= WEP_CVAR(vortex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
125 // O RLY? -- divVerent
126 // YA RLY -- FruitieX
133 W_SetupShot(self, true, 5, SND(NEXFIRE), CH_WEAPON_A, mydmg);
134 if(charge > WEP_CVAR(vortex, charge_animlimit) && WEP_CVAR(vortex, charge_animlimit)) // if the Vortex is overcharged, we play an extra sound
136 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);
141 FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
144 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
145 if(damage_goodhits && self.vortex_lasthit)
147 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
148 damage_goodhits = 0; // only every second time
151 self.vortex_lasthit = damage_goodhits;
153 //beam and muzzle flash done on client
154 SendCSQCVortexBeamParticle(charge);
156 W_DecreaseAmmo(thiswep, self, myammo);
159 .float vortex_chargepool_pauseregen_finished;
161 METHOD(Vortex, wr_aim, void(entity thiswep))
163 if(bot_aim(1000000, 0, 1, false))
164 self.BUTTON_ATCK = true;
167 if(WEP_CVAR(vortex, charge))
168 self.BUTTON_ATCK2 = true;
171 METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
173 if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit))
174 actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
176 if(WEP_CVAR_SEC(vortex, chargepool))
177 if(actor.vortex_chargepool_ammo < 1)
179 if(actor.vortex_chargepool_pauseregen_finished < time)
180 actor.vortex_chargepool_ammo = min(1, actor.vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME);
181 actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen));
184 if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
185 Weapon w = get_weaponinfo(actor.weapon);
191 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire)))
193 W_Vortex_Attack(thiswep, 0);
194 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
197 if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : (fire & 2))
199 if(WEP_CVAR(vortex, charge))
201 actor.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause);
202 float dt = frametime / W_TICSPERFRAME;
204 if(actor.vortex_charge < 1)
206 if(WEP_CVAR_SEC(vortex, chargepool))
208 if(WEP_CVAR_SEC(vortex, ammo))
210 // always deplete if secondary is held
211 actor.vortex_chargepool_ammo = max(0, actor.vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt);
213 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
214 actor.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen);
215 dt = min(dt, actor.vortex_chargepool_ammo);
218 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
222 else if(WEP_CVAR_SEC(vortex, ammo))
224 if(fire & 2) // only eat ammo when the button is pressed
226 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
227 if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
229 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
230 if(autocvar_g_balance_vortex_reload_ammo)
232 dt = min(dt, (actor.clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
236 actor.clip_load = max(WEP_CVAR_SEC(vortex, ammo), actor.clip_load - WEP_CVAR_SEC(vortex, ammo) * dt);
238 actor.(weapon_load[WEP_VORTEX.m_id]) = actor.clip_load;
242 dt = min(dt, (actor.WEP_AMMO(VORTEX) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
246 actor.WEP_AMMO(VORTEX) = max(WEP_CVAR_SEC(vortex, ammo), actor.WEP_AMMO(VORTEX) - WEP_CVAR_SEC(vortex, ammo) * dt);
250 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
256 dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
257 actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate);
261 else if(WEP_CVAR(vortex, secondary))
263 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire)))
265 W_Vortex_Attack(thiswep, 1);
266 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
272 METHOD(Vortex, wr_init, void(entity thiswep))
274 VORTEX_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
276 METHOD(Vortex, wr_setup, void(entity thiswep))
278 self.vortex_lasthit = 0;
280 METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
282 float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_PRI(vortex, ammo);
283 ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
286 METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
288 if(WEP_CVAR(vortex, secondary))
290 // don't allow charging if we don't have enough ammo
291 float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_SEC(vortex, ammo);
292 ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
297 return false; // zoom is not a fire mode
300 METHOD(Vortex, wr_config, void(entity thiswep))
302 VORTEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
304 METHOD(Vortex, wr_resetplayer, void(entity thiswep))
306 if (WEP_CVAR(vortex, charge)) {
307 if (WEP_CVAR_SEC(vortex, chargepool)) {
308 self.vortex_chargepool_ammo = 1;
310 self.vortex_charge = WEP_CVAR(vortex, charge_start);
312 self.vortex_lasthit = 0;
314 METHOD(Vortex, wr_reload, void(entity thiswep))
316 W_Reload(self, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND(RELOAD));
318 METHOD(Vortex, wr_suicidemessage, int(entity thiswep))
320 return WEAPON_THINKING_WITH_PORTALS;
322 METHOD(Vortex, wr_killmessage, int(entity thiswep))
324 return WEAPON_VORTEX_MURDER;
329 float autocvar_g_balance_vortex_secondary = 0; // WEAPONTODO
331 METHOD(Vortex, wr_impacteffect, void(entity thiswep))
333 vector org2 = w_org + w_backoff * 6;
334 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
336 sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM);
338 METHOD(Vortex, wr_init, void(entity thiswep))
340 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
342 precache_pic("gfx/reticle_nex");
345 METHOD(Vortex, wr_zoomreticle, bool(entity thiswep))
347 if(button_zoom || zoomscript_caught || (!WEP_CVAR(vortex, secondary) && button_attack2))
349 reticle_image = "gfx/reticle_nex";
354 // no weapon specific image for this weapon