2 REGISTER_WEAPON(NEX, w_nex, IT_CELLS, 7, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex");
5 void SendCSQCNexBeamParticle(float charge) {
7 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
8 WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
9 WriteByte(MSG_BROADCAST, TE_CSQC_NEXGUNBEAMPARTICLE);
10 WriteCoord(MSG_BROADCAST, w_shotorg_x);
11 WriteCoord(MSG_BROADCAST, w_shotorg_y);
12 WriteCoord(MSG_BROADCAST, w_shotorg_z);
13 WriteCoord(MSG_BROADCAST, v_x);
14 WriteCoord(MSG_BROADCAST, v_y);
15 WriteCoord(MSG_BROADCAST, v_z);
16 WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
19 void W_Nex_Attack (float issecondary)
21 float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
24 mydmg = autocvar_g_balance_nex_secondary_damage;
25 myforce = autocvar_g_balance_nex_secondary_force;
26 mymindist = autocvar_g_balance_nex_secondary_damagefalloff_mindist;
27 mymaxdist = autocvar_g_balance_nex_secondary_damagefalloff_maxdist;
28 myhalflife = autocvar_g_balance_nex_secondary_damagefalloff_halflife;
29 myforcehalflife = autocvar_g_balance_nex_secondary_damagefalloff_forcehalflife;
30 myammo = autocvar_g_balance_nex_secondary_ammo;
34 mydmg = autocvar_g_balance_nex_primary_damage;
35 myforce = autocvar_g_balance_nex_primary_force;
36 mymindist = autocvar_g_balance_nex_primary_damagefalloff_mindist;
37 mymaxdist = autocvar_g_balance_nex_primary_damagefalloff_maxdist;
38 myhalflife = autocvar_g_balance_nex_primary_damagefalloff_halflife;
39 myforcehalflife = autocvar_g_balance_nex_primary_damagefalloff_forcehalflife;
40 myammo = autocvar_g_balance_nex_primary_ammo;
44 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
46 if(autocvar_g_balance_nex_charge)
48 charge = autocvar_g_balance_nex_charge_mindmg / mydmg + (1 - autocvar_g_balance_nex_charge_mindmg / mydmg) * self.nex_charge;
49 self.nex_charge *= autocvar_g_balance_nex_charge_shot_multiplier; // do this AFTER setting mydmg/myforce
50 // O RLY? -- divVerent
58 W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", CHAN_WEAPON, mydmg);
59 if(charge > autocvar_g_balance_nex_charge_limit && autocvar_g_balance_nex_charge_limit) // if the Nex is overcharged, we play an extra sound
61 sound (self, CHAN_WEAPON2, "weapons/nexcharge.wav", VOL_BASE * (charge - 0.5 * autocvar_g_balance_nex_charge_limit) / (1 - 0.5 * autocvar_g_balance_nex_charge_limit), ATTN_NORM);
65 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_NEX);
68 AnnounceTo(self, "yoda");
70 //beam and muzzle flash done on client
71 SendCSQCNexBeamParticle(charge);
73 // flash and burn the wall
74 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
75 Damage_DamageInfo(trace_endpos, mydmg, 0, 0, myforce * w_shotdir, WEP_NEX, self);
77 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
78 self.ammo_cells = self.ammo_cells - myammo;
81 void spawnfunc_weapon_nex (void); // defined in t_items.qc
83 .float nex_chargepool_pauseregen_finished;
84 float w_nex(float req)
89 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
90 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 1, FALSE);
92 else if (req == WR_THINK)
94 if(autocvar_g_balance_nex_charge && self.nex_charge < autocvar_g_balance_nex_charge_limit)
95 self.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_rate * frametime / W_TICSPERFRAME);
97 if(autocvar_g_balance_nex_charge)
99 self.weaponentity.weaponentity.glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * bound(0, self.weaponentity.weaponentity.glowmod_y + self.nex_charge / autocvar_g_balance_nex_charge_limit, 1);
100 self.weaponentity.weaponentity.glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * bound(0, self.weaponentity.weaponentity.glowmod_y + self.nex_charge / autocvar_g_balance_nex_charge_limit, 1);
101 self.weaponentity.weaponentity.glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * bound(0, self.weaponentity.weaponentity.glowmod_z + self.nex_charge / autocvar_g_balance_nex_charge_limit, 1);
103 if(self.nex_charge > autocvar_g_balance_nex_charge_limit)
105 self.weaponentity.weaponentity.glowmod_x = self.weaponentity.weaponentity.glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_limit) / (1 - autocvar_g_balance_nex_charge_limit);
106 self.weaponentity.weaponentity.glowmod_y = self.weaponentity.weaponentity.glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_limit) / (1 - autocvar_g_balance_nex_charge_limit);
107 self.weaponentity.weaponentity.glowmod_z = self.weaponentity.weaponentity.glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_limit) / (1 - autocvar_g_balance_nex_charge_limit);
111 if(autocvar_g_balance_nex_secondary_chargepool)
112 if(self.nex_chargepool_ammo < 1)
114 if(self.nex_chargepool_pauseregen_finished < time)
115 self.nex_chargepool_ammo = min(1, self.nex_chargepool_ammo + autocvar_g_balance_nex_secondary_chargepool_regen * frametime / W_TICSPERFRAME);
116 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_nex_secondary_chargepool_pause_health_regen);
119 if (self.BUTTON_ATCK)
121 if (weapon_prepareattack(0, autocvar_g_balance_nex_primary_refire))
124 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nex_primary_animtime, w_ready);
127 if (self.BUTTON_ATCK2)
129 if(autocvar_g_balance_nex_secondary_charge)
131 self.nex_charge_rottime = time + autocvar_g_balance_nex_charge_rot_pause;
132 dt = frametime / W_TICSPERFRAME;
134 if(autocvar_g_balance_nex_secondary_chargepool)
136 if(autocvar_g_balance_nex_secondary_ammo)
138 // always deplete if secondary is held
139 self.nex_chargepool_ammo = max(0, self.nex_chargepool_ammo - autocvar_g_balance_nex_secondary_ammo * dt);
141 dt = min(dt, (1 - self.nex_charge) / autocvar_g_balance_nex_secondary_charge_rate);
142 self.nex_chargepool_pauseregen_finished = time + autocvar_g_balance_nex_secondary_chargepool_pause_regen;
143 dt = min(dt, self.nex_chargepool_ammo);
146 self.nex_charge += dt * autocvar_g_balance_nex_secondary_charge_rate;
150 else if(autocvar_g_balance_nex_secondary_ammo)
152 if(self.nex_charge < 1)
154 dt = min(dt, (1 - self.nex_charge) / autocvar_g_balance_nex_secondary_charge_rate);
155 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
157 dt = min(dt, (self.ammo_cells - autocvar_g_balance_nex_primary_ammo) / autocvar_g_balance_nex_secondary_ammo);
161 self.ammo_cells = max(autocvar_g_balance_nex_secondary_ammo, self.ammo_cells - autocvar_g_balance_nex_secondary_ammo * dt);
164 self.nex_charge += dt * autocvar_g_balance_nex_secondary_charge_rate;
168 else if(autocvar_g_balance_nex_secondary)
170 if (weapon_prepareattack(0, autocvar_g_balance_nex_secondary_refire))
173 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nex_secondary_animtime, w_ready);
178 else if (req == WR_PRECACHE)
180 precache_model ("models/nexflash.md3");
181 precache_model ("models/weapons/g_nex.md3");
182 precache_model ("models/weapons/v_nex.md3");
183 precache_model ("models/weapons/h_nex.iqm");
184 precache_sound ("weapons/nexfire.wav");
185 precache_sound ("weapons/nexcharge.wav");
186 precache_sound ("weapons/nexwhoosh1.wav");
187 precache_sound ("weapons/nexwhoosh2.wav");
188 precache_sound ("weapons/nexwhoosh3.wav");
190 else if (req == WR_SETUP)
191 weapon_setup(WEP_NEX);
192 else if (req == WR_CHECKAMMO1)
193 return self.ammo_cells >= autocvar_g_balance_nex_primary_ammo;
194 else if (req == WR_CHECKAMMO2)
195 return self.ammo_cells >= autocvar_g_balance_nex_primary_ammo; // don't allow charging if we don't have enough ammo
200 float w_nex(float req)
202 if(req == WR_IMPACTEFFECT)
205 org2 = w_org + w_backoff * 6;
206 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
208 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
210 else if(req == WR_PRECACHE)
212 precache_sound("weapons/neximpact.wav");
214 else if (req == WR_SUICIDEMESSAGE)
215 w_deathtypestring = "%s did the impossible";
216 else if (req == WR_KILLMESSAGE)
217 w_deathtypestring = "%s has been vaporized by %s";