3 /* WEP_##id */ VAPORIZER,
4 /* function */ W_Vaporizer,
5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
10 /* modelname */ "minstanex",
11 /* model */ MDL_VAPORIZER_ITEM,
12 /* simplemdl */ "foobar",
13 /* crosshair */ "gfx/crosshairminstanex 0.6",
14 /* wepimg */ "weaponminstanex",
15 /* refname */ "vaporizer",
16 /* wepname */ _("Vaporizer")
19 #define VAPORIZER_SETTINGS(w_cvar,w_prop) VAPORIZER_SETTINGS_LIST(w_cvar, w_prop, VAPORIZER, vaporizer)
20 #define VAPORIZER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
21 w_cvar(id, sn, PRI, ammo) \
22 w_cvar(id, sn, PRI, animtime) \
23 w_cvar(id, sn, PRI, damage) \
24 w_cvar(id, sn, PRI, refire) \
25 w_cvar(id, sn, SEC, ammo) \
26 w_cvar(id, sn, SEC, animtime) \
27 w_cvar(id, sn, SEC, damage) \
28 w_cvar(id, sn, SEC, delay) \
29 w_cvar(id, sn, SEC, edgedamage) \
30 w_cvar(id, sn, SEC, force) \
31 w_cvar(id, sn, SEC, lifetime) \
32 w_cvar(id, sn, SEC, radius) \
33 w_cvar(id, sn, SEC, refire) \
34 w_cvar(id, sn, SEC, shotangle) \
35 w_cvar(id, sn, SEC, speed) \
36 w_cvar(id, sn, SEC, spread) \
37 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
38 w_prop(id, sn, float, reloading_time, reload_time) \
39 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
40 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
41 w_prop(id, sn, string, weaponreplace, weaponreplace) \
42 w_prop(id, sn, float, weaponstart, weaponstart) \
43 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
44 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
47 VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
48 .float vaporizer_lasthit;
50 .float jump_interval2;
59 void spawnfunc_weapon_vaporizer(void) { weapon_defaultspawnfunc(WEP_VAPORIZER.m_id); }
60 void spawnfunc_weapon_minstanex(void) { spawnfunc_weapon_vaporizer(); }
62 void W_RocketMinsta_Explosion(vector loc)
64 if(accuracy_canbegooddamage(self))
65 accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
66 entity dmgent = spawn();
67 dmgent.owner = dmgent.realowner = self;
68 setorigin(dmgent, loc);
69 RadiusDamage (dmgent, self, autocvar_g_rm_damage, autocvar_g_rm_edgedamage, autocvar_g_rm_radius, world, world, autocvar_g_rm_force, WEP_DEVASTATOR.m_id | HITTYPE_SPLASH, other);
73 void W_Vaporizer_Attack(void)
75 bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
76 float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
78 W_SetupShot(self, true, 0, "", CH_WEAPON_A, vaporizer_damage);
79 // handle sound separately so we can change the volume
80 // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway)
81 sound (self, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM);
85 FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
88 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
89 if(damage_goodhits && self.vaporizer_lasthit)
91 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
92 damage_goodhits = 0; // only every second time
95 self.vaporizer_lasthit = damage_goodhits;
97 Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
99 // teamcolor / hit beam effect
100 vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
101 Send_Effect((damage_goodhits ? EFFECT_VAPORIZER_HIT(self.team) : EFFECT_VAPORIZER(self.team)), w_shotorg, v, 1);
104 if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
105 W_RocketMinsta_Explosion(trace_endpos);
107 W_DecreaseAmmo(((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
110 void W_RocketMinsta_Laser_Explode (void)
112 if(other.takedamage == DAMAGE_AIM)
114 if(DIFF_TEAM(self.realowner, other))
115 if(other.deadflag == DEAD_NO)
117 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
119 self.event_damage = func_null;
120 self.takedamage = DAMAGE_NO;
121 RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
125 void W_RocketMinsta_Laser_Touch (void)
128 //W_RocketMinsta_Laser_Explode ();
129 RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
133 void W_RocketMinsta_Attack2(void)
135 makevectors(self.v_angle);
139 float total = autocvar_g_rm_laser_count;
140 float spread = autocvar_g_rm_laser_spread;
141 float rndspread = autocvar_g_rm_laser_spread_random;
143 float w = self.weapon;
144 self.weapon = WEP_ELECTRO.m_id;
145 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(CRYLINK_FIRE), CH_WEAPON_A, autocvar_g_rm_laser_damage);
148 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
150 while(counter < total)
153 proj.classname = "plasma_prim";
154 proj.owner = proj.realowner = self;
155 proj.bot_dodge = true;
156 proj.bot_dodgerating = autocvar_g_rm_laser_damage;
157 proj.use = W_RocketMinsta_Laser_Explode;
158 proj.think = adaptor_think2use_hittype_splash;
159 proj.nextthink = time + autocvar_g_rm_laser_lifetime;
160 PROJECTILE_MAKETRIGGER(proj);
161 proj.projectiledeathtype = WEP_ELECTRO.m_id;
162 setorigin(proj, w_shotorg);
164 proj.rm_force = autocvar_g_rm_laser_force / total;
165 proj.rm_damage = autocvar_g_rm_laser_damage / total;
166 proj.rm_edmg = proj.rm_damage;
168 //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
170 proj.movetype = MOVETYPE_BOUNCEMISSILE;
171 //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
172 proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * (spread * (rndspread ? random() : 1))) * cvar("g_rm_laser_speed");
173 proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
174 proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
175 proj.angles = vectoangles(proj.velocity);
176 proj.touch = W_RocketMinsta_Laser_Touch;
177 setsize(proj, '0 0 -3', '0 0 -3');
178 proj.flags = FL_PROJECTILE;
179 proj.missile_flags = MIF_SPLASH;
181 CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
183 MUTATOR_CALLHOOK(EditProjectile, self, proj);
188 void W_RocketMinsta_Attack3 (void)
190 makevectors(self.v_angle);
197 self.weapon = WEP_ELECTRO.m_id;
198 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(ELECTRO_FIRE2), CH_WEAPON_A, autocvar_g_rm_laser_damage);
201 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
203 while(counter < total)
206 proj.classname = "plasma_prim";
207 proj.owner = proj.realowner = self;
208 proj.bot_dodge = true;
209 proj.bot_dodgerating = autocvar_g_rm_laser_damage;
210 proj.use = W_RocketMinsta_Laser_Explode;
211 proj.think = adaptor_think2use_hittype_splash;
212 proj.nextthink = time + autocvar_g_rm_laser_lifetime;
213 PROJECTILE_MAKETRIGGER(proj);
214 proj.projectiledeathtype = WEP_ELECTRO.m_id;
215 setorigin(proj, w_shotorg);
217 proj.rm_force = autocvar_g_rm_laser_force / total;
218 proj.rm_damage = autocvar_g_rm_laser_damage / total;
219 proj.rm_edmg = proj.rm_damage;
221 //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
223 proj.movetype = MOVETYPE_BOUNCEMISSILE;
224 proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
225 proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
226 proj.angles = vectoangles(proj.velocity);
227 proj.touch = W_RocketMinsta_Laser_Touch;
228 setsize(proj, '0 0 -3', '0 0 -3');
229 proj.flags = FL_PROJECTILE;
230 proj.missile_flags = MIF_SPLASH;
232 CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
234 MUTATOR_CALLHOOK(EditProjectile, self, proj);
239 float W_Vaporizer(entity thiswep, float req)
242 float vaporizer_ammo;
243 float rapid = autocvar_g_rm_laser_rapid;
245 // now multiple WR_s use this
246 vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
252 if(self.WEP_AMMO(VAPORIZER) > 0)
253 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false);
255 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
261 // if the laser uses load, we also consider its ammo for reloading
262 if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && self.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) // forced reload
263 _WEP_ACTION(self.weapon, WR_RELOAD);
264 else if(WEP_CVAR(vaporizer, reload_ammo) && self.clip_load < vaporizer_ammo) // forced reload
265 _WEP_ACTION(self.weapon, WR_RELOAD);
266 if(self.BUTTON_ATCK && (self.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(self))
268 if(weapon_prepareattack(0, WEP_CVAR_PRI(vaporizer, refire)))
270 W_Vaporizer_Attack();
271 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
274 if(self.BUTTON_ATCK2 || (self.BUTTON_ATCK && !self.ammo_cells && autocvar_g_rm))
276 if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
278 if(self.jump_interval <= time && !self.held_down)
281 self.held_down = true;
282 self.jump_interval = time + autocvar_g_rm_laser_refire;
283 self.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
285 W_RocketMinsta_Attack2();
287 else if(rapid && self.jump_interval2 <= time && self.held_down)
289 self.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
291 W_RocketMinsta_Attack3();
292 //weapon_thinkf(WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
295 else if (self.jump_interval <= time)
297 // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib)
298 self.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor();
300 // decrease ammo for the laser?
301 if(WEP_CVAR_SEC(vaporizer, ammo))
302 W_DecreaseAmmo(WEP_CVAR_SEC(vaporizer, ammo));
304 // ugly instagib hack to reuse the fire mode of the laser
305 makevectors(self.v_angle);
306 int oldwep = self.weapon; // we can't avoid this hack
307 self.weapon = WEP_BLASTER.m_id;
309 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
310 WEP_CVAR_SEC(vaporizer, shotangle),
311 WEP_CVAR_SEC(vaporizer, damage),
312 WEP_CVAR_SEC(vaporizer, edgedamage),
313 WEP_CVAR_SEC(vaporizer, radius),
314 WEP_CVAR_SEC(vaporizer, force),
315 WEP_CVAR_SEC(vaporizer, speed),
316 WEP_CVAR_SEC(vaporizer, spread),
317 WEP_CVAR_SEC(vaporizer, delay),
318 WEP_CVAR_SEC(vaporizer, lifetime)
320 self.weapon = oldwep;
322 // now do normal refire
323 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
327 self.held_down = false;
333 //W_Blaster(WR_INIT); // Samual: Is this really the proper thing to do? Didn't we already run this previously?
334 VAPORIZER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
339 self.ammo_field = WEP_AMMO(VAPORIZER);
340 self.vaporizer_lasthit = 0;
345 ammo_amount = self.WEP_AMMO(VAPORIZER) >= vaporizer_ammo;
346 ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
351 if(!WEP_CVAR_SEC(vaporizer, ammo))
353 ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
354 ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
359 VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
364 self.vaporizer_lasthit = 0;
370 if(WEP_CVAR_SEC(vaporizer, ammo))
371 used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo));
373 used_ammo = vaporizer_ammo;
375 W_Reload(used_ammo, SND(RELOAD));
378 case WR_SUICIDEMESSAGE:
380 return WEAPON_THINKING_WITH_PORTALS;
384 return WEAPON_VAPORIZER_MURDER;
391 float W_Vaporizer(entity thiswep, float req)
395 case WR_IMPACTEFFECT:
397 vector org2 = w_org + w_backoff * 6;
398 if(w_deathtype & HITTYPE_SECONDARY)
400 pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
401 if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
405 pointparticles(particleeffectnum(EFFECT_VORTEX_IMPACT), org2, '0 0 0', 1);
406 if(!w_issilent) { sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); }
412 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
414 precache_pic("gfx/reticle_nex");
420 if(button_zoom || zoomscript_caught)
422 reticle_image = "gfx/reticle_nex";
427 // no weapon specific image for this weapon