5 /* ammotype */ IT_CELLS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
11 /* fullname */ _("Nex")
14 #define NEX_SETTINGS(w_cvar,w_prop) \
15 w_cvar(WEP_NEX, nex, MO_BOTH, ammo) \
16 w_cvar(WEP_NEX, nex, MO_BOTH, animtime) \
17 w_cvar(WEP_NEX, nex, MO_BOTH, damage) \
18 w_cvar(WEP_NEX, nex, MO_BOTH, force) \
19 w_cvar(WEP_NEX, nex, MO_BOTH, damagefalloff_mindist) \
20 w_cvar(WEP_NEX, nex, MO_BOTH, damagefalloff_maxdist) \
21 w_cvar(WEP_NEX, nex, MO_BOTH, damagefalloff_halflife) \
22 w_cvar(WEP_NEX, nex, MO_BOTH, damagefalloff_forcehalflife) \
23 w_cvar(WEP_NEX, nex, MO_BOTH, refire) \
24 w_cvar(WEP_NEX, nex, MO_NONE, charge) \
25 w_cvar(WEP_NEX, nex, MO_NONE, charge_mindmg) \
26 w_cvar(WEP_NEX, nex, MO_NONE, charge_shot_multiplier) \
27 w_cvar(WEP_NEX, nex, MO_NONE, charge_animlimit) \
28 w_cvar(WEP_NEX, nex, MO_NONE, charge_limit) \
29 w_cvar(WEP_NEX, nex, MO_NONE, charge_rate) \
30 w_cvar(WEP_NEX, nex, MO_NONE, charge_rot_rate) \
31 w_cvar(WEP_NEX, nex, MO_NONE, charge_rot_pause) \
32 w_cvar(WEP_NEX, nex, MO_NONE, charge_start) \
33 w_cvar(WEP_NEX, nex, MO_NONE, charge_minspeed) \
34 w_cvar(WEP_NEX, nex, MO_NONE, charge_maxspeed) \
35 w_cvar(WEP_NEX, nex, MO_NONE, charge_velocity_rate) \
36 w_cvar(WEP_NEX, nex, MO_NONE, secondary) \
37 w_cvar(WEP_NEX, nex, MO_SEC, chargepool) \
38 w_cvar(WEP_NEX, nex, MO_SEC, chargepool_regen) \
39 w_cvar(WEP_NEX, nex, MO_SEC, chargepool_pause_regen) \
40 w_prop(WEP_NEX, nex, float, reloading_ammo, reload_ammo) \
41 w_prop(WEP_NEX, nex, float, reloading_time, reload_time) \
42 w_prop(WEP_NEX, nex, float, switchdelay_raise, switchdelay_raise) \
43 w_prop(WEP_NEX, nex, float, switchdelay_drop, switchdelay_drop) \
44 w_prop(WEP_NEX, nex, string, weaponreplace, weaponreplace) \
45 w_prop(WEP_NEX, nex, float, weaponstart, weaponstart)
48 NEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
52 void spawnfunc_weapon_nex (void) { weapon_defaultspawnfunc(WEP_NEX); }
54 void SendCSQCNexBeamParticle(float charge) {
56 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
57 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
58 WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
59 WriteCoord(MSG_BROADCAST, w_shotorg_x);
60 WriteCoord(MSG_BROADCAST, w_shotorg_y);
61 WriteCoord(MSG_BROADCAST, w_shotorg_z);
62 WriteCoord(MSG_BROADCAST, v_x);
63 WriteCoord(MSG_BROADCAST, v_y);
64 WriteCoord(MSG_BROADCAST, v_z);
65 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
68 void W_Nex_Attack (float issecondary)
70 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
72 mydmg = WEP_CVAR_BOTH(nex, !issecondary, damage);
73 myforce = WEP_CVAR_BOTH(nex, !issecondary, force);
74 mymindist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_mindist);
75 mymaxdist = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_maxdist);
76 myhalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_halflife);
77 myforcehalflife = WEP_CVAR_BOTH(nex, !issecondary, damagefalloff_forcehalflife);
78 myammo = WEP_CVAR_BOTH(nex, !issecondary, ammo);
81 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
83 if(WEP_CVAR(nex, charge))
85 charge = WEP_CVAR(nex, charge_mindmg) / mydmg + (1 - WEP_CVAR(nex, charge_mindmg) / mydmg) * self.nex_charge;
86 self.nex_charge *= WEP_CVAR(nex, charge_shot_multiplier); // do this AFTER setting mydmg/myforce
87 // O RLY? -- divVerent
95 W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", CH_WEAPON_A, mydmg);
96 if(charge > WEP_CVAR(nex, charge_animlimit) && WEP_CVAR(nex, charge_animlimit)) // if the Nex is overcharged, we play an extra sound
98 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);
102 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_NEX);
105 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
107 //beam and muzzle flash done on client
108 SendCSQCNexBeamParticle(charge);
110 W_DecreaseAmmo(ammo_cells, myammo, autocvar_g_balance_nex_reload_ammo);
113 void spawnfunc_weapon_nex (void); // defined in t_items.qc
115 .float nex_chargepool_pauseregen_finished;
116 float w_nex(float req)
124 if(bot_aim(1000000, 0, 1, FALSE))
125 self.BUTTON_ATCK = TRUE;
128 if(WEP_CVAR(nex, charge))
129 self.BUTTON_ATCK2 = TRUE;
135 if(WEP_CVAR(nex, charge) && self.nex_charge < WEP_CVAR(nex, charge_limit))
136 self.nex_charge = min(1, self.nex_charge + WEP_CVAR(nex, charge_rate) * frametime / W_TICSPERFRAME);
138 if(WEP_CVAR_SEC(nex, chargepool))
139 if(self.nex_chargepool_ammo < 1)
141 if(self.nex_chargepool_pauseregen_finished < time)
142 self.nex_chargepool_ammo = min(1, self.nex_chargepool_ammo + WEP_CVAR_SEC(nex, chargepool_regen) * frametime / W_TICSPERFRAME);
143 self.pauseregen_finished = max(self.pauseregen_finished, time + WEP_CVAR_SEC(nex, chargepool_pause_regen));
146 if(autocvar_g_balance_nex_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo))) // forced reload
147 WEP_ACTION(self.weapon, WR_RELOAD);
150 if (self.BUTTON_ATCK)
152 if (weapon_prepareattack(0, WEP_CVAR_PRI(nex, refire)))
155 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(nex, animtime), w_ready);
158 if ((WEP_CVAR(nex, charge) && !WEP_CVAR(nex, secondary)) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : self.BUTTON_ATCK2)
160 if(WEP_CVAR(nex, charge))
162 self.nex_charge_rottime = time + WEP_CVAR(nex, charge_rot_pause);
163 dt = frametime / W_TICSPERFRAME;
165 if(self.nex_charge < 1)
167 if(WEP_CVAR_SEC(nex, chargepool))
169 if(WEP_CVAR_SEC(nex, ammo))
171 // always deplete if secondary is held
172 self.nex_chargepool_ammo = max(0, self.nex_chargepool_ammo - WEP_CVAR_SEC(nex, ammo) * dt);
174 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
175 self.nex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(nex, chargepool_pause_regen);
176 dt = min(dt, self.nex_chargepool_ammo);
179 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
183 else if(WEP_CVAR_SEC(nex, ammo))
185 if(self.BUTTON_ATCK2) // only eat ammo when the button is pressed
187 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
188 if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
190 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
191 if(autocvar_g_balance_nex_reload_ammo)
193 dt = min(dt, (self.clip_load - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
197 self.clip_load = max(WEP_CVAR_SEC(nex, ammo), self.clip_load - WEP_CVAR_SEC(nex, ammo) * dt);
199 self.(weapon_load[WEP_NEX]) = self.clip_load;
203 dt = min(dt, (self.ammo_cells - WEP_CVAR_PRI(nex, ammo)) / WEP_CVAR_SEC(nex, ammo));
207 self.ammo_cells = max(WEP_CVAR_SEC(nex, ammo), self.ammo_cells - WEP_CVAR_SEC(nex, ammo) * dt);
211 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
217 dt = min(dt, (1 - self.nex_charge) / WEP_CVAR(nex, charge_rate));
218 self.nex_charge += dt * WEP_CVAR(nex, charge_rate);
222 else if(WEP_CVAR(nex, secondary))
224 if (weapon_prepareattack(0, WEP_CVAR_SEC(nex, refire)))
227 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(nex, animtime), w_ready);
237 precache_model ("models/nexflash.md3");
238 precache_model ("models/weapons/g_nex.md3");
239 precache_model ("models/weapons/v_nex.md3");
240 precache_model ("models/weapons/h_nex.iqm");
241 precache_sound ("weapons/nexfire.wav");
242 precache_sound ("weapons/nexcharge.wav");
243 precache_sound ("weapons/nexwhoosh1.wav");
244 precache_sound ("weapons/nexwhoosh2.wav");
245 precache_sound ("weapons/nexwhoosh3.wav");
246 NEX_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
251 self.current_ammo = ammo_cells;
256 ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(nex, ammo);
257 ammo_amount += (autocvar_g_balance_nex_reload_ammo && self.(weapon_load[WEP_NEX]) >= WEP_CVAR_PRI(nex, ammo));
262 if(WEP_CVAR(nex, secondary))
264 // don't allow charging if we don't have enough ammo
265 ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(nex, ammo);
266 ammo_amount += self.(weapon_load[WEP_NEX]) >= WEP_CVAR_SEC(nex, ammo);
271 return FALSE; // zoom is not a fire mode
276 NEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
281 W_Reload(min(WEP_CVAR_PRI(nex, ammo), WEP_CVAR_SEC(nex, ammo)), "weapons/reload.wav");
284 case WR_SUICIDEMESSAGE:
286 return WEAPON_THINKING_WITH_PORTALS;
290 return WEAPON_NEX_MURDER;
297 float w_nex(float req)
301 case WR_IMPACTEFFECT:
304 org2 = w_org + w_backoff * 6;
305 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
307 sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
313 precache_sound("weapons/neximpact.wav");