]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_minstanex.qc
No need for that extra prefix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_minstanex.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id */ MINSTANEX,
4 /* function */ w_minstanex,
5 /* ammotype */ ammo_cells,
6 /* impulse  */ 7,
7 /* flags    */ WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN,
8 /* rating   */ BOT_PICKUP_RATING_HIGH,
9 /* model    */ "minstanex",
10 /* netname  */ "minstanex",
11 /* fullname */ _("Vaporizer")
12 );
13
14 #define MINSTANEX_SETTINGS(w_cvar,w_prop) MINSTANEX_SETTINGS_LIST(w_cvar, w_prop, MINSTANEX, minstanex)
15 #define MINSTANEX_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16         w_cvar(id, sn, PRI, ammo) \
17         w_cvar(id, sn, PRI, animtime) \
18         w_cvar(id, sn, PRI, refire) \
19         w_cvar(id, sn, SEC, ammo) \
20         w_cvar(id, sn, SEC, animtime) \
21         w_cvar(id, sn, SEC, damage) \
22         w_cvar(id, sn, SEC, delay) \
23         w_cvar(id, sn, SEC, edgedamage) \
24         w_cvar(id, sn, SEC, force) \
25         w_cvar(id, sn, SEC, lifetime) \
26         w_cvar(id, sn, SEC, radius) \
27         w_cvar(id, sn, SEC, refire) \
28         w_cvar(id, sn, SEC, shotangle) \
29         w_cvar(id, sn, SEC, speed) \
30         w_cvar(id, sn, SEC, spread) \
31         w_prop(id, sn, float,  reloading_ammo, reload_ammo) \
32         w_prop(id, sn, float,  reloading_time, reload_time) \
33         w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
34         w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
35         w_prop(id, sn, string, weaponreplace, weaponreplace) \
36         w_prop(id, sn, float,  weaponstart, weaponstart) \
37         w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride)
38
39 #ifdef SVQC
40 MINSTANEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
41 .float minstanex_lasthit;
42 .float jump_interval;
43 #endif
44 #else
45 #ifdef SVQC
46 void spawnfunc_weapon_minstanex (void) { weapon_defaultspawnfunc(WEP_MINSTANEX); }
47
48 void W_MinstaNex_Attack (void)
49 {
50         float flying;
51         flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
52
53         W_SetupShot (self, TRUE, 0, "weapons/minstanexfire.wav", CH_WEAPON_A, 10000);
54
55         yoda = 0;
56         damage_goodhits = 0;
57         FireRailgunBullet (w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, 10000, 800, 0, 0, 0, 0, WEP_MINSTANEX);
58
59         if(yoda && flying)
60                 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
61         if(damage_goodhits && self.minstanex_lasthit)
62         {
63                 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
64                 damage_goodhits = 0; // only every second time
65         }
66
67         self.minstanex_lasthit = damage_goodhits;
68
69         pointparticles(particleeffectnum("nex_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
70
71         // teamcolor / hit beam effect
72         vector v;
73         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
74         switch(self.team)
75         {
76                 case NUM_TEAM_1:   // Red
77                         if(damage_goodhits)
78                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED_HIT"), w_shotorg, v);
79                         else
80                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3RED"), w_shotorg, v);
81                         break;
82                 case NUM_TEAM_2:   // Blue
83                         if(damage_goodhits)
84                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE_HIT"), w_shotorg, v);
85                         else
86                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3BLUE"), w_shotorg, v);
87                         break;
88                 case NUM_TEAM_3:   // Yellow
89                         if(damage_goodhits)
90                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW_HIT"), w_shotorg, v);
91                         else
92                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3YELLOW"), w_shotorg, v);
93                         break;
94                 case NUM_TEAM_4:   // Pink
95                         if(damage_goodhits)
96                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK_HIT"), w_shotorg, v);
97                         else
98                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3PINK"), w_shotorg, v);
99                         break;
100                 default:
101                         if(damage_goodhits)
102                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3_HIT"), w_shotorg, v);
103                         else
104                                 WarpZone_TrailParticles(world, particleeffectnum("TE_TEI_G3"), w_shotorg, v);
105                         break;
106         }
107         
108         W_DecreaseAmmo(((g_minstagib) ? 1 : WEP_CVAR_PRI(minstanex, ammo)));
109 }
110
111 float w_minstanex(float req)
112 {
113         float ammo_amount;
114         float minstanex_ammo;
115
116         // now multiple WR_s use this
117         minstanex_ammo = ((g_minstagib) ? 1 : WEP_CVAR_PRI(minstanex, ammo));
118
119         switch(req)
120         {
121                 case WR_AIM:
122                 {
123                         if(self.ammo_cells > 0)
124                                 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
125                         else
126                                 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(minstanex, speed), 0, WEP_CVAR_SEC(minstanex, lifetime), FALSE); // WEAPONTODO: replace with proper minstanex cvars
127                                 
128                         return TRUE;
129                 }
130                 case WR_THINK:
131                 {
132                         // if the laser uses load, we also consider its ammo for reloading
133                         if(WEP_CVAR(minstanex, reload_ammo) && WEP_CVAR_SEC(minstanex, ammo) && self.clip_load < min(minstanex_ammo, WEP_CVAR_SEC(minstanex, ammo))) // forced reload
134                                 WEP_ACTION(self.weapon, WR_RELOAD);
135                         else if(WEP_CVAR(minstanex, reload_ammo) && self.clip_load < minstanex_ammo) // forced reload
136                                 WEP_ACTION(self.weapon, WR_RELOAD);
137                         else if (self.BUTTON_ATCK)
138                         {
139                                 if (weapon_prepareattack(0, WEP_CVAR_PRI(minstanex, refire)))
140                                 {
141                                         W_MinstaNex_Attack();
142                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(minstanex, animtime), w_ready);
143                                 }
144                         }
145                         else if (self.BUTTON_ATCK2)
146                         {
147                                 if (self.jump_interval <= time)
148                                 if (weapon_prepareattack(1, -1))
149                                 {
150                                         // handle refire manually, so that primary and secondary can be fired without conflictions (important for minstagib)
151                                         self.jump_interval = time + WEP_CVAR_SEC(minstanex, refire) * W_WeaponRateFactor();
152                                         
153                                         // decrease ammo for the laser?
154                                         if(WEP_CVAR_SEC(minstanex, ammo))
155                                                 W_DecreaseAmmo(WEP_CVAR_SEC(minstanex, ammo));
156
157                                         // ugly minstagib hack to reuse the fire mode of the laser
158                                         float w;
159                                         w = self.weapon;
160                                         self.weapon = WEP_BLASTER;
161                                         W_Blaster_Attack(
162                                                 WEP_CVAR_SEC(minstanex, shotangle),
163                                                 WEP_CVAR_SEC(minstanex, damage),
164                                                 WEP_CVAR_SEC(minstanex, edgedamage),
165                                                 WEP_CVAR_SEC(minstanex, radius),
166                                                 WEP_CVAR_SEC(minstanex, force),
167                                                 WEP_CVAR_SEC(minstanex, speed),
168                                                 WEP_CVAR_SEC(minstanex, spread),
169                                                 WEP_CVAR_SEC(minstanex, delay),
170                                                 WEP_CVAR_SEC(minstanex, lifetime)
171                                         );
172                                         self.weapon = w;
173                                         
174                                         // now do normal refire
175                                         weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(minstanex, animtime), w_ready);
176                                 }
177                         }
178                         
179                         return TRUE;
180                 }
181                 case WR_INIT:
182                 {
183                         precache_model("models/nexflash.md3");
184                         precache_model("models/weapons/g_minstanex.md3");
185                         precache_model("models/weapons/v_minstanex.md3");
186                         precache_model("models/weapons/h_minstanex.iqm");
187                         precache_sound("weapons/minstanexfire.wav");
188                         precache_sound("weapons/nexwhoosh1.wav");
189                         precache_sound("weapons/nexwhoosh2.wav");
190                         precache_sound("weapons/nexwhoosh3.wav");
191                         //W_Blaster(WR_INIT); // Samual: Is this really the proper thing to do? Didn't we already run this previously?
192                         MINSTANEX_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
193                         return TRUE;
194                 }
195                 case WR_SETUP:
196                 {
197                         self.current_ammo = ammo_cells;
198                         self.minstanex_lasthit = 0;
199                         return TRUE;
200                 }
201                 case WR_CHECKAMMO1:
202                 {
203                         ammo_amount = self.ammo_cells >= minstanex_ammo;
204                         ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= minstanex_ammo;
205                         return ammo_amount;
206                 }
207                 case WR_CHECKAMMO2:
208                 {
209                         if(!WEP_CVAR_SEC(minstanex, ammo))
210                                 return TRUE;
211                         ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(minstanex, ammo);
212                         ammo_amount += self.(weapon_load[WEP_MINSTANEX]) >= WEP_CVAR_SEC(minstanex, ammo);
213                         return ammo_amount;
214                 }
215                 case WR_CONFIG:
216                 {
217                         MINSTANEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
218                         return TRUE;
219                 }
220                 case WR_RESETPLAYER:
221                 {
222                         self.minstanex_lasthit = 0;
223                         return TRUE;
224                 }
225                 case WR_RELOAD:
226                 {
227                         float used_ammo;
228                         if(WEP_CVAR_SEC(minstanex, ammo))
229                                 used_ammo = min(minstanex_ammo, WEP_CVAR_SEC(minstanex, ammo));
230                         else
231                                 used_ammo = minstanex_ammo;
232
233                         W_Reload(used_ammo, "weapons/reload.wav");
234                         return TRUE;
235                 }
236                 case WR_SUICIDEMESSAGE:
237                 {
238                         return WEAPON_THINKING_WITH_PORTALS;
239                 }
240                 case WR_KILLMESSAGE:
241                 {
242                         return WEAPON_MINSTANEX_MURDER;
243                 }
244         }
245         return TRUE;
246 }
247 #endif
248 #ifdef CSQC
249 float w_minstanex(float req)
250 {
251         switch(req)
252         {
253                 case WR_IMPACTEFFECT:
254                 {
255                         vector org2;
256                         org2 = w_org + w_backoff * 6;
257                         pointparticles(particleeffectnum("nex_impact"), org2, '0 0 0', 1);
258                         if(!w_issilent)
259                                 sound(self, CH_SHOTS, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM);
260                                 
261                         return TRUE;
262                 }
263                 case WR_INIT:
264                 {
265                         precache_sound("weapons/neximpact.wav");
266                         return TRUE;
267                 }
268         }
269         return TRUE;
270 }
271 #endif
272 #endif