]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/vaporizer.qc
3e2575838b8b19ef64c081f01d18df4947ee1a58
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / vaporizer.qc
1 #include "vaporizer.qh"
2 #ifndef IMPLEMENTATION
3 CLASS(Vaporizer, Weapon)
4 /* ammotype  */ ATTRIB(Vaporizer, ammo_field, .int, ammo_cells);
5 /* impulse   */ ATTRIB(Vaporizer, impulse, int, 7);
6 /* flags     */ ATTRIB(Vaporizer, spawnflags, int, WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN);
7 /* rating    */ ATTRIB(Vaporizer, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
8 /* color     */ ATTRIB(Vaporizer, wpcolor, vector, '0.5 1 1');
9 /* modelname */ ATTRIB(Vaporizer, mdl, string, "minstanex");
10 #ifdef GAMEQC
11 /* model     */ ATTRIB(Vaporizer, m_model, Model, MDL_VAPORIZER_ITEM);
12 #endif
13 /* crosshair */ ATTRIB(Vaporizer, w_crosshair, string, "gfx/crosshairminstanex");
14 /* crosshair */ ATTRIB(Vaporizer, w_crosshair_size, float, 0.6);
15 /* reticle   */ ATTRIB(Vaporizer, w_reticle, string, "gfx/reticle_nex");
16 /* wepimg    */ ATTRIB(Vaporizer, model2, string, "weaponminstanex");
17 /* refname   */ ATTRIB(Vaporizer, netname, string, "vaporizer");
18 /* wepname   */ ATTRIB(Vaporizer, m_name, string, _("Vaporizer"));
19
20 #define X(BEGIN, P, END, class, prefix) \
21         BEGIN(class) \
22                 P(class, prefix, ammo, float, PRI) \
23         P(class, prefix, animtime, float, PRI) \
24         P(class, prefix, damage, float, PRI) \
25         P(class, prefix, refire, float, PRI) \
26         P(class, prefix, ammo, float, SEC) \
27         P(class, prefix, animtime, float, SEC) \
28         P(class, prefix, damage, float, SEC) \
29         P(class, prefix, delay, float, SEC) \
30         P(class, prefix, edgedamage, float, SEC) \
31         P(class, prefix, force, float, SEC) \
32         P(class, prefix, lifetime, float, SEC) \
33         P(class, prefix, radius, float, SEC) \
34         P(class, prefix, refire, float, SEC) \
35         P(class, prefix, shotangle, float, SEC) \
36         P(class, prefix, speed, float, SEC) \
37         P(class, prefix, spread, float, SEC) \
38         P(class, prefix, reload_ammo, float, NONE) \
39         P(class, prefix, reload_time, float, NONE) \
40         P(class, prefix, switchdelay_raise, float, NONE) \
41         P(class, prefix, switchdelay_drop, float, NONE) \
42         P(class, prefix, weaponreplace, string, NONE) \
43         P(class, prefix, weaponstart, float, NONE) \
44         P(class, prefix, weaponstartoverride, float, NONE) \
45         P(class, prefix, weaponthrowable, float, NONE) \
46         END()
47     W_PROPS(X, Vaporizer, vaporizer)
48 #undef X
49
50 ENDCLASS(Vaporizer)
51 REGISTER_WEAPON(VAPORIZER, vaporizer, NEW(Vaporizer));
52
53
54 #ifdef SVQC
55 .float vaporizer_lasthit;
56 .float jump_interval;
57 .float jump_interval2;
58 .bool held_down;
59 .float rm_force;
60 .float rm_damage;
61 .float rm_edmg;
62 #endif
63 #endif
64 #ifdef IMPLEMENTATION
65
66 REGISTER_NET_TEMP(TE_CSQC_VAPORBEAMPARTICLE)
67
68 #if defined(SVQC)
69 void SendCSQCVaporizerBeamParticle(entity player, int hit) {
70         vector v;
71         v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
72         WriteHeader(MSG_BROADCAST, TE_CSQC_VAPORBEAMPARTICLE);
73         WriteCoord(MSG_BROADCAST, w_shotorg.x);
74         WriteCoord(MSG_BROADCAST, w_shotorg.y);
75         WriteCoord(MSG_BROADCAST, w_shotorg.z);
76         WriteCoord(MSG_BROADCAST, v.x);
77         WriteCoord(MSG_BROADCAST, v.y);
78         WriteCoord(MSG_BROADCAST, v.z);
79         WriteByte(MSG_BROADCAST, hit);
80         WriteByte(MSG_BROADCAST, etof(player));
81         WriteByte(MSG_BROADCAST, player.team);
82 }
83 #elif defined(CSQC)
84 bool autocvar_cl_vaporizerbeam_particle = false;
85 float autocvar_cl_vaporizerbeam_lifetime = 0.8;
86 float autocvar_cl_vaporizerbeam_colorboost = 0.7;
87
88 string Draw_VaporizerBeam_trace_callback_tex;
89 float Draw_VaporizerBeam_trace_callback_rnd;
90 vector Draw_VaporizerBeam_trace_callback_rgb;
91 float Draw_VaporizerBeam_trace_callback_a;
92 void Draw_VaporizerBeam_trace_callback(vector start, vector hit, vector end)
93 {
94         float i;
95         vector vorg;
96         vorg = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
97         for(i = 0; i < Draw_VaporizerBeam_trace_callback_a; ++i)
98                 Draw_CylindricLine(hit, start, 8, Draw_VaporizerBeam_trace_callback_tex, 0.25, Draw_VaporizerBeam_trace_callback_rnd, Draw_VaporizerBeam_trace_callback_rgb, min(1, Draw_VaporizerBeam_trace_callback_a - i), DRAWFLAG_NORMAL, vorg);
99         Draw_VaporizerBeam_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
100 }
101
102 .vector vorg1, vorg2;
103 .float spawn_time;
104 void VaporizerBeam_Draw(entity this)
105 {
106         //draw either the old v2.3 beam or the new beam
107         particles_alphamin = particles_alphamax = particles_fade = 1;
108
109         string tex = "particles/lgbeam";
110         if(this.cnt)
111                 tex = "particles/gauntletbeam";
112         vector rgb;
113         //entity e = CSQCModel_server2csqc(this.sv_entnum - 1);
114         //if (e == NULL)
115         //{
116                 rgb = colormapPaletteColor(entcs_GetClientColors(this.sv_entnum - 1) & 0x0F, true);
117                 //rgb = '1 1 1';
118         //}
119         //else
120         //      rgb = e.glowmod;
121         rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
122
123         float fail = (this.nextthink - time);
124
125         Draw_VaporizerBeam_trace_callback_tex = tex;
126         Draw_VaporizerBeam_trace_callback_rnd = 0;
127         Draw_VaporizerBeam_trace_callback_rgb = rgb;
128         Draw_VaporizerBeam_trace_callback_a = bound(0, fail, 1);
129         WarpZone_TraceBox_ThroughZone(this.vorg1, '0 0 0', '0 0 0', this.vorg2, MOVE_NOTHING, NULL, NULL, Draw_VaporizerBeam_trace_callback);
130         Draw_VaporizerBeam_trace_callback_tex = string_null;
131
132         /*if(!MUTATOR_CALLHOOK(Particles_VaporizerBeam, this.vorg1, this.vorg2))
133         if(autocvar_cl_particles_oldvortexbeam && (STAT(ALLOW_OLDVORTEXBEAM) || isdemo()))
134                 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
135         else
136                 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);*/
137 }
138
139 NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
140 {
141         Net_Accept(vortex_beam);
142         setthink(this, SUB_Remove);
143         this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
144         this.draw = VaporizerBeam_Draw;
145         if (isNew) IL_PUSH(g_drawables, this);
146         this.drawmask = MASK_NORMAL;
147
148         this.vorg1_x = ReadCoord(); this.vorg1_y = ReadCoord(); this.vorg1_z = ReadCoord();
149         this.vorg2_x = ReadCoord(); this.vorg2_y = ReadCoord(); this.vorg2_z = ReadCoord();
150         this.cnt = ReadByte();
151         int myowner = ReadByte();
152         this.owner = playerslots[myowner - 1];
153         this.sv_entnum = myowner;
154         this.team = ReadByte() - 1;
155
156         pointparticles(EFFECT_VORTEX_MUZZLEFLASH, this.vorg1, normalize(this.vorg2 - this.vorg1) * 1000, 1);
157
158         if(autocvar_cl_vaporizerbeam_particle)
159         {
160                 WarpZone_TrailParticles(NULL, particleeffectnum(((this.cnt) ? EFFECT_VAPORIZER_HIT(this.team) : EFFECT_VAPORIZER(this.team))), this.vorg1, this.vorg2);
161                 this.draw = func_null;
162                 this.drawmask = MASK_NORMAL;
163                 delete(this);
164         }
165
166         return true;
167 }
168 #endif
169
170 #ifdef SVQC
171 spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(this, WEP_VAPORIZER); }
172 spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); }
173
174 void W_RocketMinsta_Explosion(entity actor, vector loc)
175 {
176         if(accuracy_canbegooddamage(actor))
177                 accuracy_add(actor, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
178         entity dmgent = spawn();
179         dmgent.owner = dmgent.realowner = actor;
180         setorigin(dmgent, loc);
181         RadiusDamage (dmgent, actor, autocvar_g_rm_damage, autocvar_g_rm_edgedamage, autocvar_g_rm_radius, NULL, NULL, autocvar_g_rm_force, WEP_DEVASTATOR.m_id | HITTYPE_SPLASH, other);
182         delete(dmgent);
183 }
184
185 void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
186 {
187         bool flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
188         float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
189
190         W_SetupShot(actor, weaponentity, true, 0, SND_Null, CH_WEAPON_A, vaporizer_damage);
191         // handle sound separately so we can change the volume
192         // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway)
193         sound (actor, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM);
194
195         yoda = 0;
196         damage_goodhits = 0;
197         FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
198
199         // do this now, as goodhits is disabled below
200         SendCSQCVaporizerBeamParticle(actor, damage_goodhits);
201
202         if(yoda && flying)
203                 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
204         if(damage_goodhits && actor.vaporizer_lasthit)
205         {
206                 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
207                 damage_goodhits = 0; // only every second time
208         }
209
210         actor.vaporizer_lasthit = damage_goodhits;
211
212         if(autocvar_g_rm)
213         if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
214                 W_RocketMinsta_Explosion(actor, trace_endpos);
215
216         W_DecreaseAmmo(thiswep, actor, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)), weaponentity);
217 }
218
219 void W_RocketMinsta_Laser_Explode (entity this, entity directhitentity)
220 {
221         if(directhitentity.takedamage == DAMAGE_AIM)
222                 if(IS_PLAYER(directhitentity))
223                         if(DIFF_TEAM(this.realowner, directhitentity))
224                                 if(!IS_DEAD(directhitentity))
225                                         if(IsFlying(directhitentity))
226                                                 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
227
228         this.event_damage = func_null;
229         this.takedamage = DAMAGE_NO;
230         RadiusDamage (this, this.realowner, this.rm_damage, this.rm_edmg, autocvar_g_rm_laser_radius, NULL, NULL, this.rm_force, this.projectiledeathtype, directhitentity);
231         delete(this);
232 }
233
234 void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger)
235 {
236         W_RocketMinsta_Laser_Explode(this, trigger); // we probably don't want trigger used here, but this matches closest to old behaviour
237 }
238
239 void W_RocketMinsta_Laser_Touch(entity this, entity toucher)
240 {
241         PROJECTILE_TOUCH(this, toucher);
242         //W_RocketMinsta_Laser_Explode ();
243         RadiusDamage(this, this.realowner, this.rm_damage, this.rm_edmg, autocvar_g_rm_laser_radius, NULL, NULL, this.rm_force, this.projectiledeathtype, toucher);
244         delete(this);
245 }
246
247 void W_RocketMinsta_Attack2(entity actor, .entity weaponentity)
248 {
249         makevectors(actor.v_angle);
250
251         entity proj;
252         float counter = 0;
253         float total = autocvar_g_rm_laser_count;
254         float spread = autocvar_g_rm_laser_spread;
255         float rndspread = autocvar_g_rm_laser_spread_random;
256
257         Weapon w = actor.(weaponentity).m_weapon;
258         actor.(weaponentity).m_weapon = WEP_ELECTRO;
259         W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage);
260         actor.(weaponentity).m_weapon = w;
261
262         Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
263
264     while(counter < total)
265         {
266         proj = new(plasma_prim);
267         proj.owner = proj.realowner = actor;
268         proj.bot_dodge = true;
269         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
270         proj.use = W_RocketMinsta_Laser_Explode_use;
271         setthink(proj, adaptor_think2use_hittype_splash);
272         proj.nextthink = time + autocvar_g_rm_laser_lifetime;
273         PROJECTILE_MAKETRIGGER(proj);
274         proj.projectiledeathtype = WEP_ELECTRO.m_id;
275         setorigin(proj, w_shotorg);
276
277                 proj.rm_force = autocvar_g_rm_laser_force / total;
278                 proj.rm_damage = autocvar_g_rm_laser_damage / total;
279                 proj.rm_edmg = proj.rm_damage;
280
281         //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
282
283         set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
284         //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
285                 proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * (spread * (rndspread ? random() : 1))) * cvar("g_rm_laser_speed");
286                 proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
287                 proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true);
288         proj.angles = vectoangles(proj.velocity);
289         settouch(proj, W_RocketMinsta_Laser_Touch);
290         setsize(proj, '0 0 -3', '0 0 -3');
291         proj.flags = FL_PROJECTILE;
292         IL_PUSH(g_projectiles, proj);
293         IL_PUSH(g_bot_dodge, proj);
294         proj.missile_flags = MIF_SPLASH;
295
296         CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
297
298         MUTATOR_CALLHOOK(EditProjectile, actor, proj);
299         counter++;
300     }
301 }
302
303 void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity)
304 {
305         makevectors(actor.v_angle);
306
307         entity proj;
308         float counter = 0;
309         float total = 1;
310
311         Weapon w = actor.(weaponentity).m_weapon;
312         actor.(weaponentity).m_weapon = WEP_ELECTRO;
313         W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage);
314         actor.(weaponentity).m_weapon = w;
315
316         Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
317
318     while(counter < total)
319         {
320         proj = new(plasma_prim);
321         proj.owner = proj.realowner = actor;
322         proj.bot_dodge = true;
323         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
324         proj.use = W_RocketMinsta_Laser_Explode_use;
325         setthink(proj, adaptor_think2use_hittype_splash);
326         proj.nextthink = time + autocvar_g_rm_laser_lifetime;
327         PROJECTILE_MAKETRIGGER(proj);
328         proj.projectiledeathtype = WEP_ELECTRO.m_id;
329         setorigin(proj, w_shotorg);
330
331                 proj.rm_force = autocvar_g_rm_laser_force / total;
332                 proj.rm_damage = autocvar_g_rm_laser_damage / total;
333                 proj.rm_edmg = proj.rm_damage;
334
335         //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
336
337         set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
338                 proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
339                 proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true);
340         proj.angles = vectoangles(proj.velocity);
341         settouch(proj, W_RocketMinsta_Laser_Touch);
342         setsize(proj, '0 0 -3', '0 0 -3');
343         proj.flags = FL_PROJECTILE;
344         IL_PUSH(g_projectiles, proj);
345         IL_PUSH(g_bot_dodge, proj);
346         proj.missile_flags = MIF_SPLASH;
347
348         CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
349
350         MUTATOR_CALLHOOK(EditProjectile, actor, proj);
351         counter++;
352     }
353 }
354
355 METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
356 {
357     if(actor.(thiswep.ammo_field) > 0)
358         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false);
359     else
360         PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
361 }
362 METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
363 {
364     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
365     // if the laser uses load, we also consider its ammo for reloading
366     if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.(weaponentity).clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
367         thiswep.wr_reload(thiswep, actor, weaponentity);
368     } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.(weaponentity).clip_load < vaporizer_ammo) { // forced reload
369         thiswep.wr_reload(thiswep, actor, weaponentity);
370     }
371     if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
372     {
373         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
374         {
375             W_Vaporizer_Attack(thiswep, actor, weaponentity);
376             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
377         }
378     }
379     if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm))
380     {
381         if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
382         {
383             bool rapid = autocvar_g_rm_laser_rapid;
384             if(actor.(weaponentity).jump_interval <= time && !actor.(weaponentity).held_down)
385             {
386                 if(rapid)
387                     actor.(weaponentity).held_down = true;
388                 actor.(weaponentity).jump_interval = time + autocvar_g_rm_laser_refire;
389                 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
390                 damage_goodhits = 0;
391                 W_RocketMinsta_Attack2(actor, weaponentity);
392             }
393             else if(rapid && actor.(weaponentity).jump_interval2 <= time && actor.(weaponentity).held_down)
394             {
395                 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
396                 damage_goodhits = 0;
397                 W_RocketMinsta_Attack3(actor, weaponentity);
398                 //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
399             }
400         }
401         else if (actor.(weaponentity).jump_interval <= time)
402         {
403             // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib)
404             actor.(weaponentity).jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(actor);
405
406             // decrease ammo for the laser?
407             if(WEP_CVAR_SEC(vaporizer, ammo))
408                 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo), weaponentity);
409
410             // ugly instagib hack to reuse the fire mode of the laser
411             makevectors(actor.v_angle);
412             Weapon oldwep = actor.(weaponentity).m_weapon; // we can't avoid this hack
413             actor.(weaponentity).m_weapon = WEP_BLASTER;
414             W_Blaster_Attack(
415                 actor,
416                 weaponentity,
417                 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
418                 WEP_CVAR_SEC(vaporizer, shotangle),
419                 WEP_CVAR_SEC(vaporizer, damage),
420                 WEP_CVAR_SEC(vaporizer, edgedamage),
421                 WEP_CVAR_SEC(vaporizer, radius),
422                 WEP_CVAR_SEC(vaporizer, force),
423                 WEP_CVAR_SEC(vaporizer, speed),
424                 WEP_CVAR_SEC(vaporizer, spread),
425                 WEP_CVAR_SEC(vaporizer, delay),
426                 WEP_CVAR_SEC(vaporizer, lifetime)
427             );
428             actor.(weaponentity).m_weapon = oldwep;
429
430             // now do normal refire
431             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
432         }
433     }
434     else
435         actor.(weaponentity).held_down = false;
436 }
437 METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
438 {
439     actor.vaporizer_lasthit = 0;
440 }
441 METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
442 {
443     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
444     float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
445     ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
446     return ammo_amount;
447 }
448 METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
449 {
450     if(!WEP_CVAR_SEC(vaporizer, ammo))
451         return true;
452     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
453     ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
454     return ammo_amount;
455 }
456 METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor))
457 {
458     actor.vaporizer_lasthit = 0;
459 }
460 METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
461 {
462     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
463     float used_ammo;
464     if(WEP_CVAR_SEC(vaporizer, ammo))
465         used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo));
466     else
467         used_ammo = vaporizer_ammo;
468
469     W_Reload(actor, weaponentity, used_ammo, SND_RELOAD);
470 }
471 METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep))
472 {
473     return WEAPON_THINKING_WITH_PORTALS;
474 }
475 METHOD(Vaporizer, wr_killmessage, Notification(entity thiswep))
476 {
477     return WEAPON_VAPORIZER_MURDER;
478 }
479
480 #endif
481 #ifdef CSQC
482
483 METHOD(Vaporizer, wr_impacteffect, void(entity thiswep, entity actor))
484 {
485     vector org2 = w_org + w_backoff * 6;
486     if(w_deathtype & HITTYPE_SECONDARY)
487     {
488         pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
489         if(!w_issilent) { sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
490     }
491     else
492     {
493         pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
494         if(!w_issilent) { sound(actor, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); }
495     }
496 }
497 METHOD(Vaporizer, wr_init, void(entity thiswep))
498 {
499     if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
500     {
501         precache_pic("gfx/reticle_nex");
502     }
503 }
504 METHOD(Vaporizer, wr_zoom, bool(entity thiswep, entity actor))
505 {
506     if(button_zoom || zoomscript_caught)
507     {
508         return true;
509     }
510     else
511     {
512         // no weapon specific image for this weapon
513         return false;
514     }
515 }
516
517 #endif
518 #endif