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 = cvar("g_balance_nex_secondary_damage");
25 myforce = cvar("g_balance_nex_secondary_force");
26 mymindist = cvar("g_balance_nex_secondary_damagefalloff_mindist");
27 mymaxdist = cvar("g_balance_nex_secondary_damagefalloff_maxdist");
28 myhalflife = cvar("g_balance_nex_secondary_damagefalloff_halflife");
29 myforcehalflife = cvar("g_balance_nex_secondary_damagefalloff_forcehalflife");
30 myammo = cvar("g_balance_nex_secondary_ammo");
34 mydmg = cvar("g_balance_nex_primary_damage");
35 myforce = cvar("g_balance_nex_primary_force");
36 mymindist = cvar("g_balance_nex_primary_damagefalloff_mindist");
37 mymaxdist = cvar("g_balance_nex_primary_damagefalloff_maxdist");
38 myhalflife = cvar("g_balance_nex_primary_damagefalloff_halflife");
39 myforcehalflife = cvar("g_balance_nex_primary_damagefalloff_forcehalflife");
40 myammo = cvar("g_balance_nex_primary_ammo");
44 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
46 if(cvar("g_balance_nex_charge"))
48 charge = cvar("g_balance_nex_charge_mindmg") / mydmg + (1 - cvar("g_balance_nex_charge_mindmg") / mydmg) * self.nex_charge;
49 self.nex_charge *= cvar("g_balance_nex_charge_shot_multiplier"); // do this AFTER setting mydmg/myforce
50 // O RLY? -- divVerent
57 W_SetupShot (self, TRUE, 5, "weapons/nexfire.wav", mydmg);
60 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_NEX);
63 AnnounceTo(self, "yoda");
65 //beam and muzzle flash done on client
66 SendCSQCNexBeamParticle(charge);
68 // flash and burn the wall
69 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
70 Damage_DamageInfo(trace_endpos, mydmg, 0, 0, myforce * w_shotdir, WEP_NEX, self);
72 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
73 self.ammo_cells = self.ammo_cells - myammo;
76 void spawnfunc_weapon_nex (void); // defined in t_items.qc
78 float w_nex(float req)
83 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
84 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 1, FALSE);
86 else if (req == WR_THINK)
88 if(cvar("g_balance_nex_charge") && self.nex_charge < cvar("g_balance_nex_charge_limit"))
89 self.nex_charge = min(1, self.nex_charge + cvar("g_balance_nex_charge_rate") * frametime / W_TICSPERFRAME);
93 if (weapon_prepareattack(0, cvar("g_balance_nex_primary_refire")))
96 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_primary_animtime"), w_ready);
99 if (self.BUTTON_ATCK2)
101 if(cvar("g_balance_nex_secondary_charge"))
103 self.nex_charge_rottime = time + cvar("g_balance_nex_charge_rot_pause");
104 dt = frametime / W_TICSPERFRAME;
105 if(self.nex_charge < 1)
107 dt = min(dt, (1 - self.nex_charge) / cvar("g_balance_nex_secondary_charge_rate"));
108 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
110 if(cvar("g_balance_nex_secondary_ammo"))
112 dt = min(dt, (self.ammo_cells - cvar("g_balance_nex_primary_ammo")) / cvar("g_balance_nex_secondary_ammo"));
116 self.ammo_cells = max(cvar("g_balance_nex_secondary_ammo"), self.ammo_cells - cvar("g_balance_nex_secondary_ammo") * dt);
120 self.nex_charge += dt * cvar("g_balance_nex_secondary_charge_rate");
123 else if(cvar("g_balance_nex_secondary"))
125 if (weapon_prepareattack(0, cvar("g_balance_nex_secondary_refire")))
128 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_nex_secondary_animtime"), w_ready);
133 else if (req == WR_PRECACHE)
135 precache_model ("models/nexflash.md3");
136 precache_model ("models/weapons/g_nex.md3");
137 precache_model ("models/weapons/v_nex.md3");
138 precache_model ("models/weapons/h_nex.iqm");
139 precache_sound ("weapons/nexfire.wav");
140 precache_sound ("weapons/nexwhoosh1.wav");
141 precache_sound ("weapons/nexwhoosh2.wav");
142 precache_sound ("weapons/nexwhoosh3.wav");
144 else if (req == WR_SETUP)
145 weapon_setup(WEP_NEX);
146 else if (req == WR_CHECKAMMO1)
147 return self.ammo_cells >= cvar("g_balance_nex_primary_ammo");
148 else if (req == WR_CHECKAMMO2)
150 if(cvar("g_balance_nex_secondary_charge"))
151 return self.ammo_cells >= cvar("g_balance_nex_primary_ammo");
152 return self.ammo_cells >= cvar("g_balance_nex_secondary_ammo");
158 float w_nex(float req)
160 if(req == WR_IMPACTEFFECT)
163 org2 = w_org + w_backoff * 6;
164 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
166 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
168 else if(req == WR_PRECACHE)
170 precache_sound("weapons/neximpact.wav");
172 else if (req == WR_SUICIDEMESSAGE)
173 w_deathtypestring = "%s did the impossible";
174 else if (req == WR_KILLMESSAGE)
175 w_deathtypestring = "%s has been vaporized by %s";