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