2 CLASS(Vaporizer, Weapon)
3 /* ammotype */ ATTRIB(Vaporizer, ammo_field, .int, ammo_cells)
4 /* impulse */ ATTRIB(Vaporizer, impulse, int, 7)
5 /* flags */ ATTRIB(Vaporizer, spawnflags, int, WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN);
6 /* rating */ ATTRIB(Vaporizer, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
7 /* color */ ATTRIB(Vaporizer, wpcolor, vector, '0.5 1 1');
8 /* modelname */ ATTRIB(Vaporizer, mdl, string, "minstanex");
10 /* model */ ATTRIB(Vaporizer, m_model, Model, MDL_VAPORIZER_ITEM);
12 /* crosshair */ ATTRIB(Vaporizer, w_crosshair, string, "gfx/crosshairminstanex");
13 /* crosshair */ ATTRIB(Vaporizer, w_crosshair_size, float, 0.6);
14 /* wepimg */ ATTRIB(Vaporizer, model2, string, "weaponminstanex");
15 /* refname */ ATTRIB(Vaporizer, netname, string, "vaporizer");
16 /* wepname */ ATTRIB(Vaporizer, message, string, _("Vaporizer"));
18 REGISTER_WEAPON(VAPORIZER, NEW(Vaporizer));
20 #define VAPORIZER_SETTINGS(w_cvar,w_prop) VAPORIZER_SETTINGS_LIST(w_cvar, w_prop, VAPORIZER, vaporizer)
21 #define VAPORIZER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
22 w_cvar(id, sn, PRI, ammo) \
23 w_cvar(id, sn, PRI, animtime) \
24 w_cvar(id, sn, PRI, damage) \
25 w_cvar(id, sn, PRI, refire) \
26 w_cvar(id, sn, SEC, ammo) \
27 w_cvar(id, sn, SEC, animtime) \
28 w_cvar(id, sn, SEC, damage) \
29 w_cvar(id, sn, SEC, delay) \
30 w_cvar(id, sn, SEC, edgedamage) \
31 w_cvar(id, sn, SEC, force) \
32 w_cvar(id, sn, SEC, lifetime) \
33 w_cvar(id, sn, SEC, radius) \
34 w_cvar(id, sn, SEC, refire) \
35 w_cvar(id, sn, SEC, shotangle) \
36 w_cvar(id, sn, SEC, speed) \
37 w_cvar(id, sn, SEC, spread) \
38 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
39 w_prop(id, sn, float, reloading_time, reload_time) \
40 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
41 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
42 w_prop(id, sn, string, weaponreplace, weaponreplace) \
43 w_prop(id, sn, float, weaponstart, weaponstart) \
44 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
45 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
48 VAPORIZER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
49 .float vaporizer_lasthit;
51 .float jump_interval2;
60 spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(WEP_VAPORIZER.m_id); }
61 spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); }
63 void W_RocketMinsta_Explosion(vector loc)
65 if(accuracy_canbegooddamage(self))
66 accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
67 entity dmgent = spawn();
68 dmgent.owner = dmgent.realowner = self;
69 setorigin(dmgent, loc);
70 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);
74 void W_Vaporizer_Attack(Weapon thiswep)
76 bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
77 float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
79 W_SetupShot(self, true, 0, "", CH_WEAPON_A, vaporizer_damage);
80 // handle sound separately so we can change the volume
81 // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway)
82 sound (self, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM);
86 FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
89 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
90 if(damage_goodhits && self.vaporizer_lasthit)
92 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
93 damage_goodhits = 0; // only every second time
96 self.vaporizer_lasthit = damage_goodhits;
98 Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
100 // teamcolor / hit beam effect
101 vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
102 Send_Effect((damage_goodhits ? EFFECT_VAPORIZER_HIT(self.team) : EFFECT_VAPORIZER(self.team)), w_shotorg, v, 1);
105 if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
106 W_RocketMinsta_Explosion(trace_endpos);
108 W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
111 void W_RocketMinsta_Laser_Explode (void)
113 if(other.takedamage == DAMAGE_AIM)
115 if(DIFF_TEAM(self.realowner, other))
116 if(other.deadflag == DEAD_NO)
118 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
120 self.event_damage = func_null;
121 self.takedamage = DAMAGE_NO;
122 RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
126 void W_RocketMinsta_Laser_Touch (void)
129 //W_RocketMinsta_Laser_Explode ();
130 RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
134 void W_RocketMinsta_Attack2(void)
136 makevectors(self.v_angle);
140 float total = autocvar_g_rm_laser_count;
141 float spread = autocvar_g_rm_laser_spread;
142 float rndspread = autocvar_g_rm_laser_spread_random;
144 float w = self.weapon;
145 self.weapon = WEP_ELECTRO.m_id;
146 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(CRYLINK_FIRE), CH_WEAPON_A, autocvar_g_rm_laser_damage);
149 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
151 while(counter < total)
154 proj.classname = "plasma_prim";
155 proj.owner = proj.realowner = self;
156 proj.bot_dodge = true;
157 proj.bot_dodgerating = autocvar_g_rm_laser_damage;
158 proj.use = W_RocketMinsta_Laser_Explode;
159 proj.think = adaptor_think2use_hittype_splash;
160 proj.nextthink = time + autocvar_g_rm_laser_lifetime;
161 PROJECTILE_MAKETRIGGER(proj);
162 proj.projectiledeathtype = WEP_ELECTRO.m_id;
163 setorigin(proj, w_shotorg);
165 proj.rm_force = autocvar_g_rm_laser_force / total;
166 proj.rm_damage = autocvar_g_rm_laser_damage / total;
167 proj.rm_edmg = proj.rm_damage;
169 //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
171 proj.movetype = MOVETYPE_BOUNCEMISSILE;
172 //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
173 proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * (spread * (rndspread ? random() : 1))) * cvar("g_rm_laser_speed");
174 proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
175 proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
176 proj.angles = vectoangles(proj.velocity);
177 proj.touch = W_RocketMinsta_Laser_Touch;
178 setsize(proj, '0 0 -3', '0 0 -3');
179 proj.flags = FL_PROJECTILE;
180 proj.missile_flags = MIF_SPLASH;
182 CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
184 MUTATOR_CALLHOOK(EditProjectile, self, proj);
189 void W_RocketMinsta_Attack3 (void)
191 makevectors(self.v_angle);
198 self.weapon = WEP_ELECTRO.m_id;
199 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', false, 2, SND(ELECTRO_FIRE2), CH_WEAPON_A, autocvar_g_rm_laser_damage);
202 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
204 while(counter < total)
207 proj.classname = "plasma_prim";
208 proj.owner = proj.realowner = self;
209 proj.bot_dodge = true;
210 proj.bot_dodgerating = autocvar_g_rm_laser_damage;
211 proj.use = W_RocketMinsta_Laser_Explode;
212 proj.think = adaptor_think2use_hittype_splash;
213 proj.nextthink = time + autocvar_g_rm_laser_lifetime;
214 PROJECTILE_MAKETRIGGER(proj);
215 proj.projectiledeathtype = WEP_ELECTRO.m_id;
216 setorigin(proj, w_shotorg);
218 proj.rm_force = autocvar_g_rm_laser_force / total;
219 proj.rm_damage = autocvar_g_rm_laser_damage / total;
220 proj.rm_edmg = proj.rm_damage;
222 //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
224 proj.movetype = MOVETYPE_BOUNCEMISSILE;
225 proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
226 proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
227 proj.angles = vectoangles(proj.velocity);
228 proj.touch = W_RocketMinsta_Laser_Touch;
229 setsize(proj, '0 0 -3', '0 0 -3');
230 proj.flags = FL_PROJECTILE;
231 proj.missile_flags = MIF_SPLASH;
233 CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
235 MUTATOR_CALLHOOK(EditProjectile, self, proj);
240 METHOD(Vaporizer, wr_aim, void(entity thiswep))
242 if(self.WEP_AMMO(VAPORIZER) > 0)
243 self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false);
245 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
247 METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
249 float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
250 // if the laser uses load, we also consider its ammo for reloading
251 if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
252 Weapon w = get_weaponinfo(actor.weapon);
254 } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload
255 Weapon w = get_weaponinfo(actor.weapon);
258 if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
260 if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vaporizer, refire)))
262 W_Vaporizer_Attack(thiswep);
263 weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
266 if(fire2 || (fire1 && !actor.ammo_cells && autocvar_g_rm))
268 if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
270 bool rapid = autocvar_g_rm_laser_rapid;
271 if(actor.jump_interval <= time && !actor.held_down)
274 actor.held_down = true;
275 actor.jump_interval = time + autocvar_g_rm_laser_refire;
276 actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
278 W_RocketMinsta_Attack2();
280 else if(rapid && actor.jump_interval2 <= time && actor.held_down)
282 actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
284 W_RocketMinsta_Attack3();
285 //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
288 else if (actor.jump_interval <= time)
290 // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib)
291 actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor();
293 // decrease ammo for the laser?
294 if(WEP_CVAR_SEC(vaporizer, ammo))
295 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo));
297 // ugly instagib hack to reuse the fire mode of the laser
298 makevectors(actor.v_angle);
299 int oldwep = actor.weapon; // we can't avoid this hack
300 actor.weapon = WEP_BLASTER.m_id;
303 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
304 WEP_CVAR_SEC(vaporizer, shotangle),
305 WEP_CVAR_SEC(vaporizer, damage),
306 WEP_CVAR_SEC(vaporizer, edgedamage),
307 WEP_CVAR_SEC(vaporizer, radius),
308 WEP_CVAR_SEC(vaporizer, force),
309 WEP_CVAR_SEC(vaporizer, speed),
310 WEP_CVAR_SEC(vaporizer, spread),
311 WEP_CVAR_SEC(vaporizer, delay),
312 WEP_CVAR_SEC(vaporizer, lifetime)
314 actor.weapon = oldwep;
316 // now do normal refire
317 weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
321 actor.held_down = false;
323 METHOD(Vaporizer, wr_init, void(entity thiswep))
325 //W_Blaster(WR_INIT); // Samual: Is this really the proper thing to do? Didn't we already run this previously?
326 VAPORIZER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
328 METHOD(Vaporizer, wr_setup, void(entity thiswep))
330 self.ammo_field = WEP_AMMO(VAPORIZER);
331 self.vaporizer_lasthit = 0;
333 METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
335 float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
336 float ammo_amount = self.WEP_AMMO(VAPORIZER) >= vaporizer_ammo;
337 ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
340 METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep))
342 if(!WEP_CVAR_SEC(vaporizer, ammo))
344 float ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
345 ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
348 METHOD(Vaporizer, wr_config, void(entity thiswep))
350 VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
352 METHOD(Vaporizer, wr_resetplayer, void(entity thiswep))
354 self.vaporizer_lasthit = 0;
356 METHOD(Vaporizer, wr_reload, void(entity thiswep))
358 float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
360 if(WEP_CVAR_SEC(vaporizer, ammo))
361 used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo));
363 used_ammo = vaporizer_ammo;
365 W_Reload(self, used_ammo, SND(RELOAD));
367 METHOD(Vaporizer, wr_suicidemessage, int(entity thiswep))
369 return WEAPON_THINKING_WITH_PORTALS;
371 METHOD(Vaporizer, wr_killmessage, int(entity thiswep))
373 return WEAPON_VAPORIZER_MURDER;
379 METHOD(Vaporizer, wr_impacteffect, void(entity thiswep))
381 vector org2 = w_org + w_backoff * 6;
382 if(w_deathtype & HITTYPE_SECONDARY)
384 pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
385 if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
389 pointparticles(particleeffectnum(EFFECT_VORTEX_IMPACT), org2, '0 0 0', 1);
390 if(!w_issilent) { sound(self, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); }
393 METHOD(Vaporizer, wr_init, void(entity thiswep))
395 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
397 precache_pic("gfx/reticle_nex");
400 METHOD(Vaporizer, wr_zoomreticle, bool(entity thiswep))
402 if(button_zoom || zoomscript_caught)
404 reticle_image = "gfx/reticle_nex";
409 // no weapon specific image for this weapon