]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_minstanex.qc
MinstaNex now can shoot through warpzones... using warpzone-aware tracebox and trailp...
[divverent/nexuiz.git] / data / 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 .float minstanex_lasthit;
5
6 void W_MinstaNex_Attack (void)
7 {
8         float flying;
9         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
10
11         W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", 0);
12
13         yoda = 0;
14         damage_goodhits = 0;
15         headshot = 0;
16         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
17
18         if(g_minstagib)
19         {
20                 if(yoda)
21                         AnnounceTo(self, "yoda");
22         }
23         else
24         {
25                 if(yoda && flying)
26                         AnnounceTo(self, "yoda");
27                 if(headshot)
28                 {
29                         AnnounceTo(self, "headshot");
30                         print("h\n");
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         if(teamplay)
45         {
46             switch(self.team)
47             {
48             case COLOR_TEAM1:   // Red
49                 if(damage_goodhits)
50                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, WarpZone_trace_endpos);
51                 else
52                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, WarpZone_trace_endpos);
53                 break;
54             case COLOR_TEAM2:   // Blue
55                 if(damage_goodhits)
56                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, WarpZone_trace_endpos);
57                 else
58                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, WarpZone_trace_endpos);
59                 break;
60             case COLOR_TEAM3:   // Yellow
61                 if(damage_goodhits)
62                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, WarpZone_trace_endpos);
63                 else
64                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, WarpZone_trace_endpos);
65                 break;
66             case COLOR_TEAM4:   // Pink
67                 if(damage_goodhits)
68                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, WarpZone_trace_endpos);
69                 else
70                     WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, WarpZone_trace_endpos);
71                 break;
72             }
73         }
74         else
75         WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, WarpZone_trace_endpos);
76
77         // flash and burn the wall
78         if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
79                 Damage_DamageInfo(trace_endpos, 10000, 0, 0, 800 * w_shotdir, WEP_MINSTANEX, self);
80
81         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
82         {
83                 if (g_minstagib)
84                         self.ammo_cells = self.ammo_cells - 1;
85                 else
86                         self.ammo_cells = self.ammo_cells - cvar("g_balance_minstanex_ammo");
87         }
88 }
89
90
91 .float minstagib_nextthink;
92 void minstagib_ammocheck (void)
93 {
94         if (time < self.minstagib_nextthink || self.deadflag || gameover)
95                 return;
96
97         if (self.ammo_cells <= 0)
98         {
99                 if (self.health == 5)
100                 {
101                         centerprint(self, "you're dead now...\n");
102                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
103                         AnnounceTo(self, "terminated");
104                 }
105                 else if (self.health == 10)
106                 {
107                         centerprint(self, "^11^7 second left to find some ammo\n");
108                         Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
109                         AnnounceTo(self, "1");
110                 }
111                 else if (self.health == 20)
112                 {
113                         centerprint(self, "^12^7 seconds left to find some ammo\n");
114                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
115                         AnnounceTo(self, "2");
116                 }
117                 else if (self.health == 30)
118                 {
119                         centerprint(self, "^13^7 seconds left to find some ammo\n");
120                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
121                         AnnounceTo(self, "3");
122                 }
123                 else if (self.health == 40)
124                 {
125                         centerprint(self, "^14^7 seconds left to find some ammo\n");
126                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
127                         AnnounceTo(self, "4");
128                 }
129                 else if (self.health == 50)
130                 {
131                         centerprint(self, "^15^7 seconds left to find some ammo\n");
132                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
133                         AnnounceTo(self, "5");
134                 }
135                 else if (self.health == 60)
136                 {
137                         centerprint(self, "^36^7 seconds left to find some ammo\n");
138                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
139                         AnnounceTo(self, "6");
140                 }
141                 else if (self.health == 70)
142                 {
143                         centerprint(self, "^37^7 seconds left to find some ammo\n");
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                         centerprint(self, "^38^7 seconds left to find some ammo\n");
150                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
151                         AnnounceTo(self, "8");
152                 }
153                 else if (self.health == 90)
154                 {
155                         centerprint(self, "^39^7 seconds left to find some ammo\n");
156                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
157                         AnnounceTo(self, "9");
158                 }
159                 else if (self.health == 100)
160                 {
161                         centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
162                         Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
163                         if not(self.flags & FL_GODMODE)
164                                 AnnounceTo(self, "10");
165                 }
166         }
167         self.minstagib_nextthink = time + 1;
168 }
169
170 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
171
172 float w_minstanex(float req)
173 {
174         if (req == WR_AIM)
175         {
176                 if(self.ammo_cells>0)
177                         self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
178                 else
179                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
180         }
181         else if (req == WR_THINK)
182         {
183                 if (self.BUTTON_ATCK)
184                 {
185                         if (weapon_prepareattack(0, cvar("g_balance_minstanex_refire")))
186                         {
187                                 W_MinstaNex_Attack();
188                                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_minstanex_animtime"), w_ready);
189                         }
190                 }
191                 else if (self.BUTTON_ATCK2)
192                 {
193                         if (self.jump_interval <= time)
194                         {
195                                 self.jump_interval = time + 0.9 * W_WeaponRateFactor();
196
197                                 // ugly minstagib hack to reuse the fire mode of the laser
198                                 float w;
199                                 w = self.weapon;
200                                 self.weapon = WEP_LASER;
201                                 W_Laser_Attack(2);
202                                 self.weapon = w;
203                         }
204                 }
205         }
206         else if (req == WR_PRECACHE)
207         {
208                 precache_model ("models/nexflash.md3");
209                 precache_model ("models/weapons/g_minstanex.md3");
210                 precache_model ("models/weapons/v_minstanex.md3");
211                 precache_model ("models/weapons/h_minstanex.dpm");
212                 precache_sound ("weapons/minstanexfire.wav");
213                 precache_sound ("weapons/nexwhoosh1.wav");
214                 precache_sound ("weapons/nexwhoosh2.wav");
215                 precache_sound ("weapons/nexwhoosh3.wav");
216                 w_laser(WR_PRECACHE);
217         }
218         else if (req == WR_SETUP)
219         {
220                 weapon_setup(WEP_MINSTANEX);
221                 self.minstanex_lasthit = 0;
222         }
223         else if (req == WR_CHECKAMMO1)
224         {
225                 if (g_minstagib)
226                         return self.ammo_cells >= 1;
227                 else
228                         return self.ammo_cells >= cvar("g_balance_minstanex_ammo");
229         }
230         else if (req == WR_CHECKAMMO2)
231                 return TRUE;
232         else if (req == WR_SUICIDEMESSAGE)
233                 w_deathtypestring = "did the impossible";
234         else if (req == WR_KILLMESSAGE)
235                 w_deathtypestring = "has been vaporized by";
236         else if (req == WR_RESETPLAYER)
237         {
238                 self.minstanex_lasthit = 0;
239         }
240         return TRUE;
241 };
242 #endif