1 #include "vaporizer.qh"
3 REGISTER_NET_TEMP(TE_CSQC_VAPORBEAMPARTICLE)
6 void SendCSQCVaporizerBeamParticle(entity player, int hit) {
8 v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
9 WriteHeader(MSG_BROADCAST, TE_CSQC_VAPORBEAMPARTICLE);
10 WriteVector(MSG_BROADCAST, w_shotorg);
11 WriteVector(MSG_BROADCAST, v);
12 WriteByte(MSG_BROADCAST, hit);
13 WriteByte(MSG_BROADCAST, etof(player));
14 WriteByte(MSG_BROADCAST, player.team);
17 bool autocvar_cl_vaporizerbeam_particle = false;
18 float autocvar_cl_vaporizerbeam_lifetime = 0.8;
19 float autocvar_cl_vaporizerbeam_colorboost = 0.7;
21 string Draw_VaporizerBeam_trace_callback_tex;
22 float Draw_VaporizerBeam_trace_callback_rnd;
23 vector Draw_VaporizerBeam_trace_callback_rgb;
24 float Draw_VaporizerBeam_trace_callback_a;
25 void Draw_VaporizerBeam_trace_callback(vector start, vector hit, vector end)
29 vorg = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
30 for(i = 0; i < Draw_VaporizerBeam_trace_callback_a; ++i)
31 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);
32 Draw_VaporizerBeam_trace_callback_rnd += 0.25 * vlen(hit - start) / 8;
36 void VaporizerBeam_Draw(entity this)
38 //draw either the old v2.3 beam or the new beam
39 particles_alphamin = particles_alphamax = particles_fade = 1;
41 string tex = "particles/lgbeam";
43 tex = "particles/gauntletbeam";
45 //entity e = CSQCModel_server2csqc(this.sv_entnum - 1);
48 rgb = colormapPaletteColor(entcs_GetClientColors(this.sv_entnum - 1) & 0x0F, true);
53 rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
55 float fail = (this.nextthink - time);
57 Draw_VaporizerBeam_trace_callback_tex = tex;
58 Draw_VaporizerBeam_trace_callback_rnd = 0;
59 Draw_VaporizerBeam_trace_callback_rgb = rgb;
60 Draw_VaporizerBeam_trace_callback_a = bound(0, fail, 1);
61 WarpZone_TraceBox_ThroughZone(this.vorg1, '0 0 0', '0 0 0', this.vorg2, MOVE_NOTHING, NULL, NULL, Draw_VaporizerBeam_trace_callback);
62 Draw_VaporizerBeam_trace_callback_tex = string_null;
64 /*if(!MUTATOR_CALLHOOK(Particles_VaporizerBeam, this.vorg1, this.vorg2))
65 if(autocvar_cl_particles_oldvortexbeam)
66 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
68 WarpZone_TrailParticles_WithMultiplier(NULL, particleeffectnum(EFFECT_VORTEX_BEAM), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);*/
71 NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
73 Net_Accept(vortex_beam);
74 setthink(this, SUB_Remove);
75 this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
76 this.draw = VaporizerBeam_Draw;
77 if (isNew) IL_PUSH(g_drawables, this);
78 this.drawmask = MASK_NORMAL;
80 this.vorg1 = ReadVector();
81 this.vorg2 = ReadVector();
82 this.cnt = ReadByte();
83 int myowner = ReadByte();
84 this.owner = playerslots[myowner - 1];
85 this.sv_entnum = myowner;
86 this.team = ReadByte() - 1;
88 //pointparticles(EFFECT_VORTEX_MUZZLEFLASH, this.vorg1, normalize(this.vorg2 - this.vorg1) * 1000, 1);
90 if(autocvar_cl_vaporizerbeam_particle)
92 WarpZone_TrailParticles(NULL, particleeffectnum(((this.cnt) ? EFFECT_VAPORIZER_HIT(this.team) : EFFECT_VAPORIZER(this.team))), this.vorg1, this.vorg2);
93 this.draw = func_null;
94 this.drawmask = MASK_NORMAL;
104 void W_RocketMinsta_Explosion(entity actor, .entity weaponentity, vector loc)
106 if(accuracy_canbegooddamage(actor))
107 accuracy_add(actor, WEP_DEVASTATOR, autocvar_g_rm_damage, 0);
108 entity dmgent = spawn();
109 dmgent.owner = dmgent.realowner = actor;
110 setorigin(dmgent, loc);
111 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, weaponentity, NULL);
115 void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
117 bool flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last
118 float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
120 W_SetupShot(actor, weaponentity, true, 0, SND_Null, CH_WEAPON_A, vaporizer_damage, thiswep.m_id);
121 // handle sound separately so we can change the volume
122 // added bonus: no longer plays the strength sound (strength gives no bonus to instakill anyway)
123 sound (actor, CH_WEAPON_A, SND_MINSTANEXFIRE, VOL_BASE * 0.8, ATTEN_NORM);
127 FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, vaporizer_damage, true, WEP_CVAR_PRI(vaporizer, force), 0, 0, 0, 0, thiswep.m_id);
129 // do this now, as goodhits is disabled below
130 vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
131 W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, normalize(v - w_shotorg));
132 SendCSQCVaporizerBeamParticle(actor, impressive_hits);
135 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
136 if(impressive_hits && actor.vaporizer_lasthit)
138 Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
139 impressive_hits = 0; // only every second time
142 actor.vaporizer_lasthit = impressive_hits;
145 if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
146 W_RocketMinsta_Explosion(actor, weaponentity, trace_endpos);
148 W_DecreaseAmmo(thiswep, actor, ((autocvar_g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)), weaponentity);
151 void W_RocketMinsta_Laser_Damage(entity this, entity directhitentity)
153 int laser_count = max(1, this.rm_laser_count);
154 float laser_force = autocvar_g_rm_laser_force / laser_count;
155 float laser_damage = autocvar_g_rm_laser_damage / laser_count;
156 RadiusDamage(this, this.realowner, laser_damage, laser_damage, autocvar_g_rm_laser_radius, NULL, NULL, laser_force, this.projectiledeathtype, this.weaponentity_fld, directhitentity);
159 void W_RocketMinsta_Laser_Explode(entity this, entity directhitentity)
161 if(directhitentity.takedamage == DAMAGE_AIM)
162 if(IS_PLAYER(directhitentity))
163 if(DIFF_TEAM(this.realowner, directhitentity))
164 if(!IS_DEAD(directhitentity))
165 if(IsFlying(directhitentity))
166 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
168 this.event_damage = func_null;
169 this.takedamage = DAMAGE_NO;
170 W_RocketMinsta_Laser_Damage(this, directhitentity);
174 void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger)
176 W_RocketMinsta_Laser_Explode(this, trigger); // we probably don't want trigger used here, but this matches closest to old behaviour
179 void W_RocketMinsta_Laser_Touch(entity this, entity toucher)
181 PROJECTILE_TOUCH(this, toucher);
182 //W_RocketMinsta_Laser_Explode ();
183 W_RocketMinsta_Laser_Damage(this, toucher);
187 // mode 0 fires many projectiles
188 // mode 1 fires 1 projectile
189 void W_RocketMinsta_Attack(entity actor, .entity weaponentity, int mode)
191 makevectors(actor.v_angle);
194 int laser_count = max(1, autocvar_g_rm_laser_count);
195 int total = (mode == 0) ? laser_count : 1;
196 Sound snd = (mode == 0) ? SND_CRYLINK_FIRE : SND_ELECTRO_FIRE2;
197 W_SetupShot_ProjectileSize(actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, snd, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
199 // uses electro effects
200 W_MuzzleFlash(WEP_ELECTRO, actor, weaponentity, w_shotorg, w_shotdir);
202 for (int counter = 0; counter < total; counter++)
204 proj = new(plasma_prim);
205 proj.owner = proj.realowner = actor;
206 proj.bot_dodge = true;
207 proj.bot_dodgerating = autocvar_g_rm_laser_damage;
208 proj.use = W_RocketMinsta_Laser_Explode_use;
209 setthink(proj, adaptor_think2use_hittype_splash);
210 proj.nextthink = time + autocvar_g_rm_laser_lifetime;
211 PROJECTILE_MAKETRIGGER(proj);
212 proj.projectiledeathtype = WEP_ELECTRO.m_id;
213 proj.weaponentity_fld = weaponentity;
214 setorigin(proj, w_shotorg);
216 proj.rm_laser_count = total;
218 //W_SetupProjectileVelocity(proj, autocvar_g_rm_laser_speed, spread * (rndspread ? random() : 1) * autocvar_g_rm_laser_speed);
220 set_movetype(proj, MOVETYPE_BOUNCEMISSILE);
223 float spread = autocvar_g_rm_laser_spread * (autocvar_g_rm_laser_spread_random ? random() : 1);
224 //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser);
225 proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * spread) * cvar("g_rm_laser_speed");
226 proj.velocity.z += cvar("g_rm_laser_zspread") * (random() - 0.5);
229 proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
230 proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true);
231 proj.angles = vectoangles(proj.velocity);
232 settouch(proj, W_RocketMinsta_Laser_Touch);
233 setsize(proj, '0 0 -3', '0 0 -3');
234 proj.flags = FL_PROJECTILE;
235 IL_PUSH(g_projectiles, proj);
236 IL_PUSH(g_bot_dodge, proj);
237 proj.missile_flags = MIF_SPLASH;
239 CSQCProjectile(proj, true, PROJECTILE_ROCKETMINSTA_LASER, true);
241 MUTATOR_CALLHOOK(EditProjectile, actor, proj);
245 METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
247 if((actor.items & IT_UNLIMITED_AMMO) || GetResource(actor, thiswep.ammo_type) > 0)
248 PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false, true);
250 PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false, true); // WEAPONTODO: replace with proper vaporizer cvars
252 METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
254 float vaporizer_ammo = ((autocvar_g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
255 // if the laser uses load, we also consider its ammo for reloading
256 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
257 thiswep.wr_reload(thiswep, actor, weaponentity);
258 actor.(weaponentity).hagar_load = false; // rocket minsta exclusive var
260 } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.(weaponentity).clip_load < vaporizer_ammo) { // forced reload
261 thiswep.wr_reload(thiswep, actor, weaponentity);
262 actor.(weaponentity).hagar_load = false; // rocket minsta exclusive var
265 if((fire & 1) && (GetResource(actor, RES_CELLS) || !autocvar_g_rm) && !weaponLocked(actor))
267 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
269 W_Vaporizer_Attack(thiswep, actor, weaponentity);
270 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
273 if((fire & 2) || ((fire & 1) && !GetResource(actor, RES_CELLS) && autocvar_g_rm))
275 if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
277 bool rapid = autocvar_g_rm_laser_rapid;
278 //hagar_load was previously named held_down
279 if(actor.(weaponentity).jump_interval <= time && !actor.(weaponentity).hagar_load)
282 actor.(weaponentity).hagar_load = true;
283 actor.(weaponentity).jump_interval = time + autocvar_g_rm_laser_refire;
284 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
286 W_RocketMinsta_Attack(actor, weaponentity, 0);
288 else if(rapid && actor.(weaponentity).jump_interval2 <= time && actor.(weaponentity).hagar_load)
290 actor.(weaponentity).jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
292 W_RocketMinsta_Attack(actor, weaponentity, 1);
293 //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
296 else if (actor.(weaponentity).jump_interval <= time)
298 // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib)
299 actor.(weaponentity).jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(actor);
301 // decrease ammo for the laser?
302 if(WEP_CVAR_SEC(vaporizer, ammo))
303 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo), weaponentity);
305 makevectors(actor.v_angle);
306 W_Blaster_Attack(actor, weaponentity, WEP_BLASTER.m_id | HITTYPE_SECONDARY);
308 // now do normal refire
309 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready);
313 actor.(weaponentity).hagar_load = false;
315 METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
317 actor.vaporizer_lasthit = 0;
319 METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
321 float vaporizer_ammo = ((autocvar_g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
322 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= vaporizer_ammo;
323 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= vaporizer_ammo;
326 METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
328 if(!WEP_CVAR_SEC(vaporizer, ammo))
330 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vaporizer, ammo);
331 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
334 METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor))
336 actor.vaporizer_lasthit = 0;
338 METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
340 float vaporizer_ammo = ((autocvar_g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
342 if(WEP_CVAR_SEC(vaporizer, ammo))
343 used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo));
345 used_ammo = vaporizer_ammo;
347 W_Reload(actor, weaponentity, used_ammo, SND_RELOAD);
349 METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep))
351 return WEAPON_THINKING_WITH_PORTALS;
353 METHOD(Vaporizer, wr_killmessage, Notification(entity thiswep))
355 return WEAPON_VAPORIZER_MURDER;
361 METHOD(Vaporizer, wr_impacteffect, void(entity thiswep, entity actor))
363 vector org2 = w_org + w_backoff * 2;
364 if(w_deathtype & HITTYPE_SECONDARY)
366 pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
367 if(!w_issilent) { sound(actor, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
371 pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
372 if(!w_issilent) { sound(actor, CH_SHOTS, SND_NEXIMPACT, VOL_BASE, ATTN_NORM); }
375 METHOD(Vaporizer, wr_init, void(entity thiswep))
377 if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
379 precache_pic("gfx/reticle_nex");
382 METHOD(Vaporizer, wr_zoom, bool(entity thiswep, entity actor))
384 if(button_zoom || zoomscript_caught)
390 // no weapon specific image for this weapon