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