]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_minstanex.qc
In minstagib when the player gets killed by running out of ammo do not reset immediat...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_minstanex.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", _("MinstaNex"))
3 #else
4 #ifdef SVQC
5 .float minstanex_lasthit;
6
7 void W_MinstaNex_Attack (void)
8 {
9         float flying;
10         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
11
12         W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CH_WEAPON_A, 10000);
13
14         yoda = 0;
15         damage_goodhits = 0;
16         headshot = 0;
17         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
18
19         if(g_minstagib)
20         {
21                 if(yoda)
22                         AnnounceTo(self, "yoda");
23         }
24         else
25         {
26                 if(yoda && flying)
27                         AnnounceTo(self, "yoda");
28                 if(headshot)
29                 {
30                         AnnounceTo(self, "headshot");
31                 }
32                 if(damage_goodhits && self.minstanex_lasthit)
33                 {
34                         if(AnnounceTo(self, "impressive"))
35                                 damage_goodhits = 0; // only every second time
36                 }
37         }
38
39         self.minstanex_lasthit = damage_goodhits;
40
41         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
42
43         // teamcolor / hit beam effect
44         vector v;
45         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
46         if(teamplay)
47         {
48             switch(self.team)
49             {
50             case COLOR_TEAM1:   // Red
51                 if(damage_goodhits)
52                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
53                 else
54                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
55                 break;
56             case COLOR_TEAM2:   // Blue
57                 if(damage_goodhits)
58                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
59                 else
60                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
61                 break;
62             case COLOR_TEAM3:   // Yellow
63                 if(damage_goodhits)
64                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
65                 else
66                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
67                 break;
68             case COLOR_TEAM4:   // Pink
69                 if(damage_goodhits)
70                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
71                 else
72                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
73                 break;
74             }
75         }
76         else
77         WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
78
79         // flash and burn the wall
80         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
81                 Damage_DamageInfo(trace_endpos, 10000, 0, 0, 800 * w_shotdir, WEP_MINSTANEX, self);
82
83         if (g_minstagib)
84                 W_DecreaseAmmo(ammo_cells, 1, autocvar_g_balance_minstanex_reload_ammo);
85         else
86                 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_reload_ammo);
87 }
88
89
90 .float minstagib_nextthink;
91 .float minstagib_needammo;
92 void minstagib_stop_countdown(entity e)
93 {
94         if (!e.minstagib_needammo)
95                 return;
96         Send_CSQC_Centerprint_Generic_Expire(e, CPID_MINSTA_FINDAMMO);
97         e.minstagib_needammo = FALSE;
98 }
99 void minstagib_ammocheck(void)
100 {
101         if (time < self.minstagib_nextthink)
102                 return;
103
104         if (self.deadflag || gameover)
105                 minstagib_stop_countdown(self);
106         else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO))
107         {
108                 minstagib_stop_countdown(self);
109                 self.health = 100;
110         }
111         else
112         {
113                 self.minstagib_needammo = TRUE;
114                 if (self.health == 5)
115                 {
116                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
117                         AnnounceTo(self, "terminated");
118                 }
119                 else if (self.health == 10)
120                 {
121                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
122                         AnnounceTo(self, "1");
123                 }
124                 else if (self.health == 20)
125                 {
126                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
127                         AnnounceTo(self, "2");
128                 }
129                 else if (self.health == 30)
130                 {
131                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
132                         AnnounceTo(self, "3");
133                 }
134                 else if (self.health == 40)
135                 {
136                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
137                         AnnounceTo(self, "4");
138                 }
139                 else if (self.health == 50)
140                 {
141                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
142                         AnnounceTo(self, "5");
143                 }
144                 else if (self.health == 60)
145                 {
146                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
147                         AnnounceTo(self, "6");
148                 }
149                 else if (self.health == 70)
150                 {
151                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
152                         AnnounceTo(self, "7");
153                 }
154                 else if (self.health == 80)
155                 {
156                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
157                         AnnounceTo(self, "8");
158                 }
159                 else if (self.health == 90)
160                 {
161                         Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "^1%d^7 seconds left to find some ammo", 1, 9);
162                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
163                         AnnounceTo(self, "9");
164                 }
165                 else if (self.health == 100)
166                 {
167                         Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^3%d^7 seconds...", 1, 10);
168                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
169                         if not(self.flags & FL_GODMODE)
170                                 AnnounceTo(self, "10");
171                 }
172         }
173         self.minstagib_nextthink = time + 1;
174 }
175
176 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
177
178 float w_minstanex(float req)
179 {
180         float ammo_amount;
181         float minstanex_ammo;
182
183         // now multiple WR_s use this
184         if(g_minstagib)
185                 minstanex_ammo = 1;
186         else
187                 minstanex_ammo = autocvar_g_balance_minstanex_ammo;
188
189         if (req == WR_AIM)
190         {
191                 if(self.ammo_cells > 0)
192                         self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
193                 else
194                         self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
195         }
196         else if (req == WR_THINK)
197         {
198                 // if the laser uses load, we also consider its ammo for reloading
199                 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
200                         weapon_action(self.weapon, WR_RELOAD);
201                 else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
202                         weapon_action(self.weapon, WR_RELOAD);
203                 else if (self.BUTTON_ATCK)
204                 {
205                         if (weapon_prepareattack(0, autocvar_g_balance_minstanex_refire))
206                         {
207                                 W_MinstaNex_Attack();
208                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_minstanex_animtime, w_ready);
209                         }
210                 }
211                 else if (self.BUTTON_ATCK2)
212                 {
213                         if (self.jump_interval <= time)
214                         {
215                                 self.jump_interval = time + autocvar_g_balance_laser_primary_refire * W_WeaponRateFactor();
216
217                                 // decrease ammo for the laser?
218                                 if(autocvar_g_balance_minstanex_laser_ammo)
219                                         W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo);
220
221                                 // ugly minstagib hack to reuse the fire mode of the laser
222                                 float w;
223                                 w = self.weapon;
224                                 self.weapon = WEP_LASER;
225                                 W_Laser_Attack(2);
226                                 self.weapon = w;
227                         }
228                 }
229         }
230         else if (req == WR_PRECACHE)
231         {
232                 precache_model ("models/nexflash.md3");
233                 precache_model ("models/weapons/g_minstanex.md3");
234                 precache_model ("models/weapons/v_minstanex.md3");
235                 precache_model ("models/weapons/h_minstanex.iqm");
236                 precache_sound ("weapons/minstanexfire.wav");
237                 precache_sound ("weapons/nexwhoosh1.wav");
238                 precache_sound ("weapons/nexwhoosh2.wav");
239                 precache_sound ("weapons/nexwhoosh3.wav");
240                 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
241                 w_laser(WR_PRECACHE);
242         }
243         else if (req == WR_SETUP)
244         {
245                 weapon_setup(WEP_MINSTANEX);
246                 self.current_ammo = ammo_cells;
247                 self.minstanex_lasthit = 0;
248         }
249         else if (req == WR_CHECKAMMO1)
250         {
251                 ammo_amount = self.ammo_cells >= minstanex_ammo;
252                 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= minstanex_ammo;
253                 return ammo_amount;
254         }
255         else if (req == WR_CHECKAMMO2)
256         {
257                 if(!autocvar_g_balance_minstanex_laser_ammo)
258                         return TRUE;
259                 ammo_amount = self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
260                 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= autocvar_g_balance_minstanex_laser_ammo;
261                 return ammo_amount;
262         }
263         else if (req == WR_RESETPLAYER)
264         {
265                 self.minstanex_lasthit = 0;
266         }
267         else if (req == WR_RELOAD)
268         {
269                 float used_ammo;
270                 if(autocvar_g_balance_minstanex_laser_ammo)
271                         used_ammo = min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo);
272                 else
273                         used_ammo = minstanex_ammo;
274
275                 W_Reload(used_ammo, autocvar_g_balance_minstanex_reload_ammo, autocvar_g_balance_minstanex_reload_time, "weapons/reload.wav");
276         }
277         return TRUE;
278 }
279 #endif
280 #ifdef CSQC
281 float w_minstanex(float req)
282 {
283         if(req == WR_IMPACTEFFECT)
284         {
285                 vector org2;
286                 org2 = w_org + w_backoff * 6;
287                 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
288                 if(!w_issilent)
289                         sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
290         }
291         else if(req == WR_PRECACHE)
292         {
293                 precache_sound("weapons/neximpact.wav");
294         }
295         else if (req == WR_SUICIDEMESSAGE)
296                 w_deathtypestring = _("%s is now thinking with portals");
297         else if (req == WR_KILLMESSAGE)
298                 w_deathtypestring = _("%s has been vaporized by %s's minstanex");
299         return TRUE;
300 }
301 #endif
302 #endif