837d73dca55c5c885b073daa6a29601a872f7b2d
[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_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", 0);
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                         print("h\n");
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 not(self.items & IT_UNLIMITED_WEAPON_AMMO)
85         {
86                 if (g_minstagib)
87                         self.ammo_cells = self.ammo_cells - 1;
88                 else
89                         self.ammo_cells = self.ammo_cells - cvar("g_balance_minstanex_ammo");
90         }
91 }
92
93
94 .float minstagib_nextthink;
95 void minstagib_ammocheck (void)
96 {
97         if (time < self.minstagib_nextthink || self.deadflag || gameover)
98                 return;
99
100         if (self.ammo_cells <= 0)
101         {
102                 if (self.health == 5)
103                 {
104                         centerprint(self, "you're dead now...\n");
105                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
106                         AnnounceTo(self, "terminated");
107                 }
108                 else if (self.health == 10)
109                 {
110                         centerprint(self, "^11^7 second left to find some ammo\n");
111                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
112                         AnnounceTo(self, "1");
113                 }
114                 else if (self.health == 20)
115                 {
116                         centerprint(self, "^12^7 seconds left to find some ammo\n");
117                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
118                         AnnounceTo(self, "2");
119                 }
120                 else if (self.health == 30)
121                 {
122                         centerprint(self, "^13^7 seconds left to find some ammo\n");
123                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
124                         AnnounceTo(self, "3");
125                 }
126                 else if (self.health == 40)
127                 {
128                         centerprint(self, "^14^7 seconds left to find some ammo\n");
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                         centerprint(self, "^15^7 seconds left to find some ammo\n");
135                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
136                         AnnounceTo(self, "5");
137                 }
138                 else if (self.health == 60)
139                 {
140                         centerprint(self, "^36^7 seconds left to find some ammo\n");
141                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
142                         AnnounceTo(self, "6");
143                 }
144                 else if (self.health == 70)
145                 {
146                         centerprint(self, "^37^7 seconds left to find some ammo\n");
147                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
148                         AnnounceTo(self, "7");
149                 }
150                 else if (self.health == 80)
151                 {
152                         centerprint(self, "^38^7 seconds left to find some ammo\n");
153                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
154                         AnnounceTo(self, "8");
155                 }
156                 else if (self.health == 90)
157                 {
158                         centerprint(self, "^39^7 seconds left to find some ammo\n");
159                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
160                         AnnounceTo(self, "9");
161                 }
162                 else if (self.health == 100)
163                 {
164                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
165                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
166                         if not(self.flags & FL_GODMODE)
167                                 AnnounceTo(self, "10");
168                 }
169         }
170         self.minstagib_nextthink = time + 1;
171 }
172
173 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
174
175 float w_minstanex(float req)
176 {
177         if (req == WR_AIM)
178         {
179                 if(self.ammo_cells>0)
180                         self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
181                 else
182                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
183         }
184         else if (req == WR_THINK)
185         {
186                 if (self.BUTTON_ATCK)
187                 {
188                         if (weapon_prepareattack(0, cvar("g_balance_minstanex_refire")))
189                         {
190                                 W_MinstaNex_Attack();
191                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstanex_animtime"), w_ready);
192                         }
193                 }
194                 else if (self.BUTTON_ATCK2)
195                 {
196                         if (self.jump_interval <= time)
197                         {
198                                 self.jump_interval = time + 0.9 * W_WeaponRateFactor();
199
200                                 // ugly minstagib hack to reuse the fire mode of the laser
201                                 float w;
202                                 w = self.weapon;
203                                 self.weapon = WEP_LASER;
204                                 W_Laser_Attack(2);
205                                 self.weapon = w;
206                         }
207                 }
208         }
209         else if (req == WR_PRECACHE)
210         {
211                 precache_model ("models/nexflash.md3");
212                 precache_model ("models/weapons/g_minstanex.md3");
213                 precache_model ("models/weapons/v_minstanex.md3");
214                 precache_model ("models/weapons/h_minstanex.iqm");
215                 precache_sound ("weapons/minstanexfire.wav");
216                 precache_sound ("weapons/nexwhoosh1.wav");
217                 precache_sound ("weapons/nexwhoosh2.wav");
218                 precache_sound ("weapons/nexwhoosh3.wav");
219                 w_laser(WR_PRECACHE);
220         }
221         else if (req == WR_SETUP)
222         {
223                 weapon_setup(WEP_MINSTANEX);
224                 self.minstanex_lasthit = 0;
225         }
226         else if (req == WR_CHECKAMMO1)
227         {
228                 if (g_minstagib)
229                         return self.ammo_cells >= 1;
230                 else
231                         return self.ammo_cells >= cvar("g_balance_minstanex_ammo");
232         }
233         else if (req == WR_CHECKAMMO2)
234                 return TRUE;
235         else if (req == WR_SUICIDEMESSAGE)
236                 w_deathtypestring = "did the impossible";
237         else if (req == WR_KILLMESSAGE)
238                 w_deathtypestring = "has been vaporized by";
239         else if (req == WR_RESETPLAYER)
240         {
241                 self.minstanex_lasthit = 0;
242         }
243         return TRUE;
244 };
245 #endif
246 #ifdef CSQC
247 float w_minstanex(float req)
248 {
249         return TRUE;
250 }
251 #endif
252 #endif