2 REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_CANCLIMB | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", _("MinstaNex"))
5 .float minstanex_lasthit;
7 void W_Minstanex_SetAmmoCounter()
9 // set clip_load to the weapon we have switched to, if the gun uses reloading
10 if(!autocvar_g_balance_minstanex_reload_ammo)
11 self.clip_load = 0; // also keeps crosshair ammo from displaying
14 self.clip_load = self.minstanex_load;
15 self.clip_size = autocvar_g_balance_minstanex_reload_ammo; // for the crosshair ammo display
19 void W_Minstanex_ReloadedAndReady()
23 // now do the ammo transfer
24 self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
25 while(self.clip_load < autocvar_g_balance_minstanex_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
30 self.minstanex_load = self.clip_load;
32 t = ATTACK_FINISHED(self) - autocvar_g_balance_minstanex_reload_time - 1;
33 ATTACK_FINISHED(self) = t;
37 void W_Minstanex_Reload()
39 // return if reloading is disabled for this weapon
40 if(!autocvar_g_balance_minstanex_reload_ammo)
43 if(autocvar_g_balance_minstanex_laser_ammo)
45 if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo)))
48 else if(!W_ReloadCheck(self.ammo_cells, autocvar_g_balance_minstanex_ammo))
53 sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
55 t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_minstanex_reload_time + 1;
56 ATTACK_FINISHED(self) = t;
58 weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_minstanex_reload_time, W_Minstanex_ReloadedAndReady);
60 self.old_clip_load = self.clip_load;
64 void W_MinstaNex_Attack (void)
67 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
69 W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CHAN_WEAPON, 10000);
74 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
79 AnnounceTo(self, "yoda");
84 AnnounceTo(self, "yoda");
87 AnnounceTo(self, "headshot");
89 if(damage_goodhits && self.minstanex_lasthit)
91 if(AnnounceTo(self, "impressive"))
92 damage_goodhits = 0; // only every second time
96 self.minstanex_lasthit = damage_goodhits;
98 pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
100 // teamcolor / hit beam effect
102 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
107 case COLOR_TEAM1: // Red
109 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
111 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
113 case COLOR_TEAM2: // Blue
115 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
117 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
119 case COLOR_TEAM3: // Yellow
121 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
123 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
125 case COLOR_TEAM4: // Pink
127 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
129 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
134 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
136 // flash and burn the wall
137 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
138 Damage_DamageInfo(trace_endpos, 10000, 0, 0, 800 * w_shotdir, WEP_MINSTANEX, self);
140 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
141 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
143 if(autocvar_g_balance_minstanex_reload_ammo)
146 self.clip_load -= - 1;
148 self.clip_load -= autocvar_g_balance_minstanex_ammo;
149 self.minstanex_load = self.clip_load;
154 self.ammo_cells -= - 1;
156 self.ammo_cells -= autocvar_g_balance_minstanex_ammo;
162 .float minstagib_nextthink;
163 void minstagib_ammocheck (void)
165 if (time < self.minstagib_nextthink || self.deadflag || gameover)
168 if (self.ammo_cells <= 0)
170 if (self.health == 5)
172 centerprint(self, "you're dead now...\n");
173 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
174 AnnounceTo(self, "terminated");
176 else if (self.health == 10)
178 centerprint(self, "^11^7 second left to find some ammo\n");
179 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
180 AnnounceTo(self, "1");
182 else if (self.health == 20)
184 centerprint(self, "^12^7 seconds left to find some ammo\n");
185 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
186 AnnounceTo(self, "2");
188 else if (self.health == 30)
190 centerprint(self, "^13^7 seconds left to find some ammo\n");
191 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
192 AnnounceTo(self, "3");
194 else if (self.health == 40)
196 centerprint(self, "^14^7 seconds left to find some ammo\n");
197 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
198 AnnounceTo(self, "4");
200 else if (self.health == 50)
202 centerprint(self, "^15^7 seconds left to find some ammo\n");
203 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
204 AnnounceTo(self, "5");
206 else if (self.health == 60)
208 centerprint(self, "^36^7 seconds left to find some ammo\n");
209 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
210 AnnounceTo(self, "6");
212 else if (self.health == 70)
214 centerprint(self, "^37^7 seconds left to find some ammo\n");
215 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
216 AnnounceTo(self, "7");
218 else if (self.health == 80)
220 centerprint(self, "^38^7 seconds left to find some ammo\n");
221 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
222 AnnounceTo(self, "8");
224 else if (self.health == 90)
226 centerprint(self, "^39^7 seconds left to find some ammo\n");
227 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
228 AnnounceTo(self, "9");
230 else if (self.health == 100)
232 centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
233 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
234 if not(self.flags & FL_GODMODE)
235 AnnounceTo(self, "10");
238 self.minstagib_nextthink = time + 1;
241 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
243 float minstanex_ammo;
244 float w_minstanex(float req)
248 if(self.ammo_cells > 0)
249 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
251 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
253 else if (req == WR_THINK)
258 minstanex_ammo = autocvar_g_balance_minstanex_ammo;
260 // if the laser uses load, we also consider its ammo for reloading
261 if(autocvar_g_balance_minstanex_reload_ammo && autocvar_g_balance_minstanex_laser_ammo && self.clip_load < min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo)) // forced reload
262 W_Minstanex_Reload();
263 else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
264 W_Minstanex_Reload();
265 else if (self.BUTTON_ATCK)
267 if (weapon_prepareattack(0, autocvar_g_balance_minstanex_refire))
269 W_MinstaNex_Attack();
270 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_minstanex_animtime, w_ready);
273 else if (self.BUTTON_ATCK2)
275 if (self.jump_interval <= time)
277 self.jump_interval = time + autocvar_g_balance_laser_primary_refire * W_WeaponRateFactor();
279 // decrease ammo for the laser?
280 if(autocvar_g_balance_minstanex_laser_ammo)
282 if(autocvar_g_balance_minstanex_reload_ammo)
283 self.clip_load -= autocvar_g_balance_minstanex_laser_ammo;
285 self.ammo_cells -= autocvar_g_balance_minstanex_laser_ammo;
288 // ugly minstagib hack to reuse the fire mode of the laser
291 self.weapon = WEP_LASER;
297 else if (req == WR_PRECACHE)
299 precache_model ("models/nexflash.md3");
300 precache_model ("models/weapons/g_minstanex.md3");
301 precache_model ("models/weapons/v_minstanex.md3");
302 precache_model ("models/weapons/h_minstanex.iqm");
303 precache_sound ("weapons/minstanexfire.wav");
304 precache_sound ("weapons/nexwhoosh1.wav");
305 precache_sound ("weapons/nexwhoosh2.wav");
306 precache_sound ("weapons/nexwhoosh3.wav");
307 precache_sound ("weapons/reload.wav");
308 w_laser(WR_PRECACHE);
310 else if (req == WR_SETUP)
312 weapon_setup(WEP_MINSTANEX);
313 W_Minstanex_SetAmmoCounter();
314 self.minstanex_lasthit = 0;
316 else if (req == WR_CHECKAMMO1)
318 if(autocvar_g_balance_minstanex_reload_ammo)
319 return self.clip_load >= minstanex_ammo;
321 return self.ammo_cells >= minstanex_ammo;
323 else if (req == WR_CHECKAMMO2)
325 if(!autocvar_g_balance_minstanex_laser_ammo)
327 if(autocvar_g_balance_minstanex_reload_ammo)
328 return self.clip_load >= autocvar_g_balance_minstanex_laser_ammo;
330 return self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
332 else if (req == WR_RESETPLAYER)
334 self.minstanex_lasthit = 0;
336 else if (req == WR_RELOAD)
338 W_Minstanex_Reload();
340 else if (req == WR_SWITCHABLE)
342 // checks if this weapon can be switched to, when reloading is enabled
343 // returns true if there's either enough load in the weapon to use it,
344 // or we have enough ammo to reload the weapon to a usable point
349 ammo_amount = autocvar_g_balance_minstanex_ammo;
350 if(autocvar_g_balance_minstanex_laser_ammo)
351 ammo_amount = min(ammo_amount, autocvar_g_balance_minstanex_laser_ammo);
353 return self.minstanex_load >= ammo_amount || self.ammo_cells >= ammo_amount;
359 float w_minstanex(float req)
361 if(req == WR_IMPACTEFFECT)
364 org2 = w_org + w_backoff * 6;
365 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
367 sound(self, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
369 else if(req == WR_PRECACHE)
371 precache_sound("weapons/neximpact.wav");
373 else if (req == WR_SUICIDEMESSAGE)
374 w_deathtypestring = "%s did the impossible";
375 else if (req == WR_KILLMESSAGE)
376 w_deathtypestring = "%s has been vaporized by %s";