2 REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", _("MinstaNex"))
5 .float minstanex_lasthit;
8 void W_MinstaNex_Attack (void)
11 flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
13 W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CH_WEAPON_A, 10000);
18 FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
23 AnnounceTo(self, "yoda");
28 AnnounceTo(self, "yoda");
31 AnnounceTo(self, "headshot");
33 if(damage_goodhits && self.minstanex_lasthit)
35 if(AnnounceTo(self, "impressive"))
36 damage_goodhits = 0; // only every second time
40 self.minstanex_lasthit = damage_goodhits;
42 pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
44 // teamcolor / hit beam effect
46 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
51 case COLOR_TEAM1: // Red
53 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
55 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
57 case COLOR_TEAM2: // Blue
59 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
61 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
63 case COLOR_TEAM3: // Yellow
65 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
67 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
69 case COLOR_TEAM4: // Pink
71 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
73 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
78 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
81 W_DecreaseAmmo(ammo_cells, 1, autocvar_g_balance_minstanex_reload_ammo);
83 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_reload_ammo);
87 .float minstagib_nextthink;
88 .float minstagib_needammo;
89 void minstagib_stop_countdown(entity e)
91 if (!e.minstagib_needammo)
93 Send_CSQC_Centerprint_Generic_Expire(e, CPID_MINSTA_FINDAMMO);
94 e.minstagib_needammo = FALSE;
96 void minstagib_ammocheck(void)
98 if (time < self.minstagib_nextthink)
101 if (self.deadflag || gameover)
102 minstagib_stop_countdown(self);
103 else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO))
105 minstagib_stop_countdown(self);
110 self.minstagib_needammo = TRUE;
111 if (self.health == 5)
113 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
114 AnnounceTo(self, "terminated");
116 else if (self.health == 10)
118 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
119 AnnounceTo(self, "1");
121 else if (self.health == 20)
123 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
124 AnnounceTo(self, "2");
126 else if (self.health == 30)
128 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
129 AnnounceTo(self, "3");
131 else if (self.health == 40)
133 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
134 AnnounceTo(self, "4");
136 else if (self.health == 50)
138 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
139 AnnounceTo(self, "5");
141 else if (self.health == 60)
143 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
144 AnnounceTo(self, "6");
146 else if (self.health == 70)
148 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
149 AnnounceTo(self, "7");
151 else if (self.health == 80)
153 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
154 AnnounceTo(self, "8");
156 else if (self.health == 90)
158 Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "^1%d^7 seconds left to find some ammo", 1, 9);
159 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
160 AnnounceTo(self, "9");
162 else if (self.health == 100)
164 Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^3%d^7 seconds...", 1, 10);
165 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
166 if not(self.flags & FL_GODMODE)
167 AnnounceTo(self, "10");
170 self.minstagib_nextthink = time + 1;
173 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
175 float w_minstanex(float req)
178 float minstanex_ammo;
180 // now multiple WR_s use this
184 minstanex_ammo = autocvar_g_balance_minstanex_ammo;
188 if(self.ammo_cells > 0)
189 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
191 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
193 else if (req == WR_THINK)
195 // if the laser uses load, we also consider its ammo for reloading
196 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
197 weapon_action(self.weapon, WR_RELOAD);
198 else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
199 weapon_action(self.weapon, WR_RELOAD);
200 else if (self.BUTTON_ATCK)
202 if (weapon_prepareattack(0, autocvar_g_balance_minstanex_refire))
204 W_MinstaNex_Attack();
205 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_minstanex_animtime, w_ready);
208 else if (self.BUTTON_ATCK2)
210 if (self.jump_interval <= time)
211 if (weapon_prepareattack(1, -1))
213 // handle refire manually, so that primary and secondary can be fired without conflictions (important for minstagib)
214 self.jump_interval = time + autocvar_g_balance_minstanex_laser_refire * W_WeaponRateFactor();
216 // decrease ammo for the laser?
217 if(autocvar_g_balance_minstanex_laser_ammo)
218 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo);
220 // ugly minstagib hack to reuse the fire mode of the laser
223 self.weapon = WEP_LASER;
227 // now do normal refire
228 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_minstanex_laser_animtime, w_ready);
232 else if (req == WR_PRECACHE)
234 precache_model ("models/nexflash.md3");
235 precache_model ("models/weapons/g_minstanex.md3");
236 precache_model ("models/weapons/v_minstanex.md3");
237 precache_model ("models/weapons/h_minstanex.iqm");
238 precache_sound ("weapons/minstanexfire.wav");
239 precache_sound ("weapons/nexwhoosh1.wav");
240 precache_sound ("weapons/nexwhoosh2.wav");
241 precache_sound ("weapons/nexwhoosh3.wav");
242 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
243 w_laser(WR_PRECACHE);
245 else if (req == WR_SETUP)
247 weapon_setup(WEP_MINSTANEX);
248 self.current_ammo = ammo_cells;
249 self.minstanex_lasthit = 0;
251 else if (req == WR_CHECKAMMO1)
253 ammo_amount = self.ammo_cells >= minstanex_ammo;
254 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= minstanex_ammo;
257 else if (req == WR_CHECKAMMO2)
259 if(!autocvar_g_balance_minstanex_laser_ammo)
261 ammo_amount = self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
262 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= autocvar_g_balance_minstanex_laser_ammo;
265 else if (req == WR_RESETPLAYER)
267 self.minstanex_lasthit = 0;
269 else if (req == WR_RELOAD)
272 if(autocvar_g_balance_minstanex_laser_ammo)
273 used_ammo = min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo);
275 used_ammo = minstanex_ammo;
277 W_Reload(used_ammo, autocvar_g_balance_minstanex_reload_ammo, autocvar_g_balance_minstanex_reload_time, "weapons/reload.wav");
283 float w_minstanex(float req)
285 if(req == WR_IMPACTEFFECT)
288 org2 = w_org + w_backoff * 6;
289 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
291 sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
293 else if(req == WR_PRECACHE)
295 precache_sound("weapons/neximpact.wav");
297 else if (req == WR_SUICIDEMESSAGE)
298 w_deathtypestring = _("%s is now thinking with portals");
299 else if (req == WR_KILLMESSAGE)
300 w_deathtypestring = _("%s has been vaporized by %s's minstanex");