]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_minstanex.qc
Merge branch 'master' into mirceakitsune/damage_effects
[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         if (g_minstagib)
80                 W_DecreaseAmmo(ammo_cells, 1, autocvar_g_balance_minstanex_reload_ammo);
81         else
82                 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_reload_ammo);
83 }
84
85
86 .float minstagib_nextthink;
87 .float minstagib_needammo;
88 void minstagib_stop_countdown(void)
89 {
90         if (self.minstagib_needammo)
91         {
92                 self.health = 100;
93                 Send_CSQC_Centerprint_Generic_Expire(self, CPID_MINSTA_FINDAMMO);
94         }
95         self.minstagib_needammo = FALSE;
96 }
97 void minstagib_ammocheck(void)
98 {
99         if (time < self.minstagib_nextthink)
100                 return;
101
102         if (self.deadflag || gameover || self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO))
103                 minstagib_stop_countdown();
104         else
105         {
106                 self.minstagib_needammo = TRUE;
107                 if (self.health == 5)
108                 {
109                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
110                         AnnounceTo(self, "terminated");
111                 }
112                 else if (self.health == 10)
113                 {
114                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
115                         AnnounceTo(self, "1");
116                 }
117                 else if (self.health == 20)
118                 {
119                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
120                         AnnounceTo(self, "2");
121                 }
122                 else if (self.health == 30)
123                 {
124                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
125                         AnnounceTo(self, "3");
126                 }
127                 else if (self.health == 40)
128                 {
129                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
130                         AnnounceTo(self, "4");
131                 }
132                 else if (self.health == 50)
133                 {
134                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
135                         AnnounceTo(self, "5");
136                 }
137                 else if (self.health == 60)
138                 {
139                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
140                         AnnounceTo(self, "6");
141                 }
142                 else if (self.health == 70)
143                 {
144                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
145                         AnnounceTo(self, "7");
146                 }
147                 else if (self.health == 80)
148                 {
149                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
150                         AnnounceTo(self, "8");
151                 }
152                 else if (self.health == 90)
153                 {
154                         Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "^1%d^7 seconds left to find some ammo", 1, 9);
155                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
156                         AnnounceTo(self, "9");
157                 }
158                 else if (self.health == 100)
159                 {
160                         Send_CSQC_Centerprint_Generic(self, CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^3%d^7 seconds...", 1, 10);
161                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
162                         if not(self.flags & FL_GODMODE)
163                                 AnnounceTo(self, "10");
164                 }
165         }
166         self.minstagib_nextthink = time + 1;
167 }
168
169 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
170
171 float w_minstanex(float req)
172 {
173         float ammo_amount;
174         float minstanex_ammo;
175
176         // now multiple WR_s use this
177         if(g_minstagib)
178                 minstanex_ammo = 1;
179         else
180                 minstanex_ammo = autocvar_g_balance_minstanex_ammo;
181
182         if (req == WR_AIM)
183         {
184                 if(self.ammo_cells > 0)
185                         self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
186                 else
187                         self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
188         }
189         else if (req == WR_THINK)
190         {
191                 // if the laser uses load, we also consider its ammo for reloading
192                 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
193                         weapon_action(self.weapon, WR_RELOAD);
194                 else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
195                         weapon_action(self.weapon, WR_RELOAD);
196                 else if (self.BUTTON_ATCK)
197                 {
198                         if (weapon_prepareattack(0, autocvar_g_balance_minstanex_refire))
199                         {
200                                 W_MinstaNex_Attack();
201                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_minstanex_animtime, w_ready);
202                         }
203                 }
204                 else if (self.BUTTON_ATCK2)
205                 {
206                         if (self.jump_interval <= time)
207                         {
208                                 self.jump_interval = time + autocvar_g_balance_laser_primary_refire * W_WeaponRateFactor();
209
210                                 // decrease ammo for the laser?
211                                 if(autocvar_g_balance_minstanex_laser_ammo)
212                                         W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo);
213
214                                 // ugly minstagib hack to reuse the fire mode of the laser
215                                 float w;
216                                 w = self.weapon;
217                                 self.weapon = WEP_LASER;
218                                 W_Laser_Attack(2);
219                                 self.weapon = w;
220                         }
221                 }
222         }
223         else if (req == WR_PRECACHE)
224         {
225                 precache_model ("models/nexflash.md3");
226                 precache_model ("models/weapons/g_minstanex.md3");
227                 precache_model ("models/weapons/v_minstanex.md3");
228                 precache_model ("models/weapons/h_minstanex.iqm");
229                 precache_sound ("weapons/minstanexfire.wav");
230                 precache_sound ("weapons/nexwhoosh1.wav");
231                 precache_sound ("weapons/nexwhoosh2.wav");
232                 precache_sound ("weapons/nexwhoosh3.wav");
233                 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
234                 w_laser(WR_PRECACHE);
235         }
236         else if (req == WR_SETUP)
237         {
238                 weapon_setup(WEP_MINSTANEX);
239                 self.current_ammo = ammo_cells;
240                 self.minstanex_lasthit = 0;
241         }
242         else if (req == WR_CHECKAMMO1)
243         {
244                 ammo_amount = self.ammo_cells >= minstanex_ammo;
245                 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= minstanex_ammo;
246                 return ammo_amount;
247         }
248         else if (req == WR_CHECKAMMO2)
249         {
250                 if(!autocvar_g_balance_minstanex_laser_ammo)
251                         return TRUE;
252                 ammo_amount = self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
253                 ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= autocvar_g_balance_minstanex_laser_ammo;
254                 return ammo_amount;
255         }
256         else if (req == WR_RESETPLAYER)
257         {
258                 self.minstanex_lasthit = 0;
259         }
260         else if (req == WR_RELOAD)
261         {
262                 float used_ammo;
263                 if(autocvar_g_balance_minstanex_laser_ammo)
264                         used_ammo = min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo);
265                 else
266                         used_ammo = minstanex_ammo;
267
268                 W_Reload(used_ammo, autocvar_g_balance_minstanex_reload_ammo, autocvar_g_balance_minstanex_reload_time, "weapons/reload.wav");
269         }
270         return TRUE;
271 }
272 #endif
273 #ifdef CSQC
274 float w_minstanex(float req)
275 {
276         if(req == WR_IMPACTEFFECT)
277         {
278                 vector org2;
279                 org2 = w_org + w_backoff * 6;
280                 pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
281                 if(!w_issilent)
282                         sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
283         }
284         else if(req == WR_PRECACHE)
285         {
286                 precache_sound("weapons/neximpact.wav");
287         }
288         else if (req == WR_SUICIDEMESSAGE)
289                 w_deathtypestring = _("%s is now thinking with portals");
290         else if (req == WR_KILLMESSAGE)
291                 w_deathtypestring = _("%s has been vaporized by %s's minstanex");
292         return TRUE;
293 }
294 #endif
295 #endif