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