5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
12 /* fullname */ _("Vortex")
15 #define NEX_SETTINGS(w_cvar,w_prop) NEX_SETTINGS_LIST(w_cvar, w_prop, NEX, nex)
16 #define NEX_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
17 w_cvar(id, sn, BOTH, ammo) \
18 w_cvar(id, sn, BOTH, animtime) \
19 w_cvar(id, sn, BOTH, damage) \
20 w_cvar(id, sn, BOTH, force) \
21 w_cvar(id, sn, BOTH, damagefalloff_mindist) \
22 w_cvar(id, sn, BOTH, damagefalloff_maxdist) \
23 w_cvar(id, sn, BOTH, damagefalloff_halflife) \
24 w_cvar(id, sn, BOTH, damagefalloff_forcehalflife) \
25 w_cvar(id, sn, BOTH, refire) \
26 w_cvar(id, sn, NONE, charge) \
27 w_cvar(id, sn, NONE, charge_mindmg) \
28 w_cvar(id, sn, NONE, charge_shot_multiplier) \
29 w_cvar(id, sn, NONE, charge_animlimit) \
30 w_cvar(id, sn, NONE, charge_limit) \
31 w_cvar(id, sn, NONE, charge_rate) \
32 w_cvar(id, sn, NONE, charge_rot_rate) \
33 w_cvar(id, sn, NONE, charge_rot_pause) \
34 w_cvar(id, sn, NONE, charge_start) \
35 w_cvar(id, sn, NONE, charge_minspeed) \
36 w_cvar(id, sn, NONE, charge_maxspeed) \
37 w_cvar(id, sn, NONE, charge_velocity_rate) \
38 w_cvar(id, sn, NONE, secondary) \
39 w_cvar(id, sn, SEC, chargepool) \
40 w_cvar(id, sn, SEC, chargepool_regen) \
41 w_cvar(id, sn, SEC, chargepool_pause_regen) \
42 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
43 w_prop(id, sn, float, reloading_time, reload_time) \
44 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
45 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
46 w_prop(id, sn, string, weaponreplace, weaponreplace) \
47 w_prop(id, sn, float, weaponstart, weaponstart) \
48 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
51 NEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
55 void spawnfunc_weapon_nex (void) { weapon_defaultspawnfunc(WEP_NEX); }
57 void SendCSQCNexBeamParticle(float charge) {
59 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
60 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
61 WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
62 WriteCoord(MSG_BROADCAST, w_shotorg_x);
63 WriteCoord(MSG_BROADCAST, w_shotorg_y);
64 WriteCoord(MSG_BROADCAST, w_shotorg_z);
65 WriteCoord(MSG_BROADCAST, v_x);
66 WriteCoord(MSG_BROADCAST, v_y);
67 WriteCoord(MSG_BROADCAST, v_z);
68 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
71 void W_Nex_Attack (float issecondary)
73 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
75 mydmg = WEP_CVAR_BOTH(nex, !issecondary, damage);
76 myforce = WEP_CVAR_BOTH(nex, !issecondary, force);
77 mymindist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_mindist);
78 mymaxdist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_maxdist);
79 myhalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_halflife);
80 myforcehalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_forcehalflife);
81 myammo = WEP_CVAR_BOTH(nex, !issecondary, ammo);
84 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
86 if(WEP_CVAR(nex, charge))
88 charge = WEP_CVAR(nex, charge_mindmg) / mydmg + (1 - WEP_CVAR(nex, charge_mindmg) / mydmg) * self.nex_charge;
89 self.nex_charge *= WEP_CVAR(nex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
90 // O RLY? -- divVerent
98 W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", CH_WEAPON_A, mydmg);
99 if(charge > WEP_CVAR(nex, charge_animlimit) && WEP_CVAR(nex, charge_animlimit)) // if the Nex is overcharged, we play an extra sound
101 sound (self, CH_WEAPON_B, "weapons/nexcharge.wav", VOL_BASE * (charge - 0.5 * WEP_CVAR(nex, charge_animlimit)) / (1 - 0.5 * WEP_CVAR(nex, charge_animlimit)), ATTN_NORM);
105 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_NEX);
108 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
110 //beam and muzzle flash done on client
111 SendCSQCNexBeamParticle(charge);
113 W_DecreaseAmmo(myammo);
116 void spawnfunc_weapon_nex (void); // defined in t_items.qc
118 .float nex_chargepool_pauseregen_finished;
119 float w_nex(float req)
127 if(bot_aim(1000000, 0, 1, FALSE))
128 self.BUTTON_ATCK = TRUE;
131 if(WEP_CVAR(nex, charge))
132 self.BUTTON_ATCK2 = TRUE;
138 if(WEP_CVAR(nex, charge) && self.nex_charge < WEP_CVAR(nex, charge_limit))
139 self.nex_charge = min(1, self.nex_charge + WEP_CVAR(nex, charge_rate) * frametime / W_TICSPERFRAME);
141 if(WEP_CVAR_SEC(nex, chargepool))
142 if(self.nex_chargepool_ammo < 1)
144 if(self.nex_chargepool_pauseregen_finished < time)
145 self.nex_chargepool_ammo = min(1, self.nex_chargepool_ammo + WEP_CVAR_SEC(nex, chargepool_regen) * frametime / W_TICSPERFRAME);
146 self.pauseregen_finished = max(self.pauseregen_finished, time + WEP_CVAR_SEC(nex, chargepool_pause_regen));
149 if(autocvar_g_balance_nex_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo))) // forced reload
150 WEP_ACTION(self.weapon, WR_RELOAD);
153 if (self.BUTTON_ATCK)
155 if (weapon_prepareattack(0, WEP_CVAR_PRI(nex, refire)))
158 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(nex, animtime), w_ready);
161 if ((WEP_CVAR(nex, charge) && !WEP_CVAR(nex, secondary)) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : self.BUTTON_ATCK2)
163 if(WEP_CVAR(nex, charge))
165 self.nex_charge_rottime = time + WEP_CVAR(nex, charge_rot_pause);
166 dt = frametime / W_TICSPERFRAME;
168 if(self.nex_charge < 1)
170 if(WEP_CVAR_SEC(nex, chargepool))
172 if(WEP_CVAR_SEC(nex, ammo))
174 // always deplete if secondary is held
175 self.nex_chargepool_ammo = max(0, self.nex_chargepool_ammo - WEP_CVAR_SEC(nex, ammo) * dt);
177 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
178 self.nex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(nex, chargepool_pause_regen);
179 dt = min(dt, self.nex_chargepool_ammo);
182 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
186 else if(WEP_CVAR_SEC(nex, ammo))
188 if(self.BUTTON_ATCK2) // only eat ammo when the button is pressed
190 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
191 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
193 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
194 if(autocvar_g_balance_nex_reload_ammo)
196 dt = min(dt, (self.clip_load - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
200 self.clip_load = max(WEP_CVAR_SEC(nex, ammo), self.clip_load - WEP_CVAR_SEC(nex, ammo) * dt);
202 self.(weapon_load[WEP_NEX]) = self.clip_load;
206 dt = min(dt, (self.AMMO_VAL(WEP_NEX) - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
210 self.AMMO_VAL(WEP_NEX) = max(WEP_CVAR_SEC(nex, ammo), self.AMMO_VAL(WEP_NEX) - WEP_CVAR_SEC(nex, ammo) * dt);
214 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
220 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
221 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
225 else if(WEP_CVAR(nex, secondary))
227 if (weapon_prepareattack(0, WEP_CVAR_SEC(nex, refire)))
230 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(nex, animtime), w_ready);
240 precache_model ("models/nexflash.md3");
241 precache_model ("models/weapons/g_nex.md3");
242 precache_model ("models/weapons/v_nex.md3");
243 precache_model ("models/weapons/h_nex.iqm");
244 precache_sound ("weapons/nexfire.wav");
245 precache_sound ("weapons/nexcharge.wav");
246 precache_sound ("weapons/nexwhoosh1.wav");
247 precache_sound ("weapons/nexwhoosh2.wav");
248 precache_sound ("weapons/nexwhoosh3.wav");
249 NEX_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
254 ammo_amount = self.AMMO_VAL(WEP_NEX) >= WEP_CVAR_PRI(nex, ammo);
255 ammo_amount += (autocvar_g_balance_nex_reload_ammo && self.(weapon_load[WEP_NEX]) >= WEP_CVAR_PRI(nex, ammo));
260 if(WEP_CVAR(nex, secondary))
262 // don't allow charging if we don't have enough ammo
263 ammo_amount = self.AMMO_VAL(WEP_NEX) >= WEP_CVAR_SEC(nex, ammo);
264 ammo_amount += self.(weapon_load[WEP_NEX]) >= WEP_CVAR_SEC(nex, ammo);
269 return FALSE; // zoom is not a fire mode
274 NEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
279 W_Reload(min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo)), "weapons/reload.wav");
282 case WR_SUICIDEMESSAGE:
284 return WEAPON_THINKING_WITH_PORTALS;
288 return WEAPON_NEX_MURDER;
295 float w_nex(float req)
299 case WR_IMPACTEFFECT:
302 org2 = w_org + w_backoff * 6;
303 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
305 sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
311 precache_sound("weapons/neximpact.wav");