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