2 REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro");
6 .float electro_secondarytime;
8 void W_Plasma_Explode_Combo (void);
10 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
13 e = WarpZone_FindRadius(org, rad, TRUE);
16 if (e.classname == "plasma")
18 // change owner to whoever caused the combo explosion
20 e.takedamage = DAMAGE_NO;
21 e.classname = "plasma_chain";
22 e.think = W_Plasma_Explode_Combo;
23 e.nextthink = time + vlen(e.WarpZone_findradius_dist) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
29 void W_Plasma_Explode (void)
31 if(other.takedamage == DAMAGE_AIM)
32 if(other.classname == "player")
33 if(IsDifferentTeam(self.owner, other))
34 if(other.deadflag == DEAD_NO)
36 AnnounceTo(self.owner, "electrobitch");
38 self.event_damage = SUB_Null;
39 self.takedamage = DAMAGE_NO;
40 if (self.movetype == MOVETYPE_BOUNCE)
42 RadiusDamage (self, self.owner, cvar("g_balance_electro_secondary_damage"), cvar("g_balance_electro_secondary_edgedamage"), cvar("g_balance_electro_secondary_radius"), world, cvar("g_balance_electro_secondary_force"), self.projectiledeathtype, other);
46 W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_primary_comboradius"), self.owner);
47 RadiusDamage (self, self.owner, cvar("g_balance_electro_primary_damage"), cvar("g_balance_electro_primary_edgedamage"), cvar("g_balance_electro_primary_radius"), world, cvar("g_balance_electro_primary_force"), self.projectiledeathtype, other);
53 void W_Plasma_Explode_Combo (void)
55 W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_combo_comboradius"), self.owner);
57 self.event_damage = SUB_Null;
58 RadiusDamage (self, self.owner, cvar("g_balance_electro_combo_damage"), cvar("g_balance_electro_combo_edgedamage"), cvar("g_balance_electro_combo_radius"), world, cvar("g_balance_electro_combo_force"), WEP_ELECTRO | HITTYPE_BOUNCE, world); // use THIS type for a combo because primary can't bounce
62 void W_Plasma_Touch (void)
65 if (other.takedamage == DAMAGE_AIM) {
68 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
69 self.projectiledeathtype |= HITTYPE_BOUNCE;
73 void W_Plasma_TouchExplode (void)
79 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
83 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
84 self.health = self.health - damage;
87 self.takedamage = DAMAGE_NO;
88 self.nextthink = time;
89 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
91 // change owner to whoever caused the combo explosion
92 self.owner = inflictor.owner;
93 self.classname = "plasma_chain";
94 self.think = W_Plasma_Explode_Combo;
95 self.nextthink = time + min(cvar("g_balance_electro_combo_radius"), vlen(self.origin - inflictor.origin)) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
96 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bounding the length, because inflictor may be in a galaxy far far away (warpzones)
100 self.use = W_Plasma_Explode;
101 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
106 void W_Electro_Attack()
110 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", cvar("g_balance_electro_primary_damage"));
112 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
115 proj.classname = "plasma_prim";
117 proj.bot_dodge = TRUE;
118 proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
119 proj.use = W_Plasma_Explode;
120 proj.think = adaptor_think2use_hittype_splash;
121 proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
122 PROJECTILE_MAKETRIGGER(proj);
123 proj.projectiledeathtype = WEP_ELECTRO;
124 setorigin(proj, w_shotorg);
126 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
127 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
128 proj.movetype = MOVETYPE_FLY;
129 W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
130 proj.angles = vectoangles(proj.velocity);
131 proj.touch = W_Plasma_TouchExplode;
132 setsize(proj, '0 0 -3', '0 0 -3');
133 proj.flags = FL_PROJECTILE;
135 //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
138 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
141 void W_Electro_Attack2()
145 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire2.wav", cvar("g_balance_electro_secondary_damage"));
146 w_shotdir = v_forward; // no TrueAim for grenades please
148 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
151 proj.classname = "plasma";
153 proj.use = W_Plasma_Explode;
154 proj.think = adaptor_think2use_hittype_splash;
155 proj.bot_dodge = TRUE;
156 proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
157 proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
158 PROJECTILE_MAKETRIGGER(proj);
159 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
160 setorigin(proj, w_shotorg);
162 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
163 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
164 //proj.glow_size = 50;
165 //proj.glow_color = 45;
166 proj.movetype = MOVETYPE_BOUNCE;
167 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
168 proj.touch = W_Plasma_Touch;
169 setsize(proj, '0 0 -3', '0 0 -3');
170 proj.takedamage = DAMAGE_YES;
171 proj.damageforcescale = cvar("g_balance_electro_secondary_damageforcescale");
172 proj.health = cvar("g_balance_electro_secondary_health");
173 proj.event_damage = W_Plasma_Damage;
174 proj.flags = FL_PROJECTILE;
179 copyentity(proj, p2);
180 setmodel(p2, "models/ebomb.mdl");
181 setsize(p2, proj.mins, proj.maxs);
184 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
189 if (!self.owner.BUTTON_ATCK || self.owner.ammo_cells <= 0) // || (self.ammo_cells <= 0 && !(self.items & IT_UNLIMITED_WEAPON_AMMO)))
191 sound (self, CHAN_PROJECTILE, "sound/misc/null.wav", VOL_BASE, ATTN_NORM);
196 if (time - self.shot_spread + random() * 0.2 > 0)
198 self.shot_spread = time + 2;
199 sound (self, CHAN_PROJECTILE, "turrets/phaser.wav", VOL_BASE, ATTN_NORM);
202 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
203 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
205 self.nextthink = time + self.ticrate;
207 //w_deathtypestring = "was phased out of existence";
209 makevectors(self.owner.v_angle);
214 force = angle * cvar("g_balance_electro_primary_force");
216 traceline_antilag(self.owner, self.owner.origin, self.owner.origin + angle * cvar("g_balance_electro_primary_range"), FALSE, self.owner, ANTILAG_LATENCY(self.owner));
219 if(trace_fraction < 1)
221 Damage (trace_ent, self.owner, self.owner, cvar("g_balance_electro_primary_damage"), WEP_ELECTRO, trace_endpos, force);
222 trace_ent.velocity = trace_ent.velocity * cvar("g_balance_electro_primary_velocityfactor") + '0 0 1' * cvar("g_balance_electro_primary_force_up");
225 self.scale = vlen(self.owner.origin - trace_endpos) / 256 * (0.75 + 0.75 * random());
228 // experimental lightning gun
229 void W_Electro_Attack3 (void)
234 beam.ticrate = autocvar_sys_ticrate;
235 setmodel(beam,"models/turrets/phaser_beam.md3");
236 beam.effects = EF_LOWPRECISION;
237 beam.solid = SOLID_NOT;
238 beam.think = lgbeam_think;
239 beam.shot_spread = 0;
240 beam.scale = cvar("g_balance_electro_primary_range") / 256;
241 beam.nextthink = time;
243 beam.movetype = MOVETYPE_NONE;
244 beam.bot_dodge = TRUE;
245 beam.bot_dodgerating = cvar("g_balance_electro_primary_damage")/autocvar_sys_ticrate;
246 setattachment(beam, self.weaponentity, "shot");
249 void spawnfunc_weapon_electro (void)
251 weapon_defaultspawnfunc(WEP_ELECTRO);
254 void w_electro_checkattack()
256 if(self.electro_count > 1)
257 if(self.BUTTON_ATCK2)
258 if(weapon_prepareattack(1, -1))
261 self.electro_count -= 1;
262 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
269 .float bot_secondary_electromooth;
270 .float BUTTON_ATCK_prev;
271 float w_electro(float req)
275 self.BUTTON_ATCK=FALSE;
276 self.BUTTON_ATCK2=FALSE;
277 if(vlen(self.origin-self.enemy.origin) > 1000)
278 self.bot_secondary_electromooth = 0;
279 if(self.bot_secondary_electromooth == 0)
281 if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
283 self.BUTTON_ATCK = TRUE;
284 if(random() < 0.01) self.bot_secondary_electromooth = 1;
289 if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
291 self.BUTTON_ATCK2 = TRUE;
292 if(random() < 0.03) self.bot_secondary_electromooth = 0;
296 else if (req == WR_THINK)
298 if (self.BUTTON_ATCK)
299 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
301 if(cvar("g_balance_electro_lightning"))
303 if (self.BUTTON_ATCK_prev == 0)
312 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
314 if (self.BUTTON_ATCK2)
315 if (time >= self.electro_secondarytime)
316 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
319 self.electro_count = cvar("g_balance_electro_secondary_count");
320 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
321 self.electro_secondarytime = time + cvar("g_balance_electro_secondary_refire2");
324 else if (req == WR_PRECACHE)
326 precache_model ("models/weapons/g_electro.md3");
327 precache_model ("models/weapons/v_electro.md3");
328 precache_model ("models/weapons/h_electro.iqm");
329 precache_sound ("weapons/electro_bounce.wav");
330 precache_sound ("weapons/electro_fire.wav");
331 precache_sound ("weapons/electro_fire2.wav");
332 precache_sound ("weapons/electro_impact.wav");
333 precache_sound ("weapons/electro_impact_combo.wav");
334 if(cvar("g_balance_electro_lightning"))
335 precache_sound ("weapons/crylink_fire2.wav");
337 else if (req == WR_SETUP)
338 weapon_setup(WEP_ELECTRO);
339 else if (req == WR_CHECKAMMO1)
340 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
341 else if (req == WR_CHECKAMMO2)
342 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
343 else if (req == WR_RESETPLAYER)
345 self.electro_secondarytime = time;
347 self.BUTTON_ATCK_prev = self.BUTTON_ATCK;
352 float w_electro(float req)
354 if(req == WR_IMPACTEFFECT)
357 org2 = w_org + w_backoff * 6;
358 if(w_deathtype & HITTYPE_SECONDARY)
360 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
362 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
366 if(w_deathtype & HITTYPE_BOUNCE)
368 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
369 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
371 sound(self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
375 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
377 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
381 else if(req == WR_PRECACHE)
383 precache_sound("weapons/electro_impact.wav");
384 precache_sound("weapons/electro_impact_combo.wav");
386 else if (req == WR_SUICIDEMESSAGE)
388 if(w_deathtype & HITTYPE_SECONDARY)
389 w_deathtypestring = "could not remember where they put plasma";
391 w_deathtypestring = "played with plasma";
393 else if (req == WR_KILLMESSAGE)
395 if(w_deathtype & HITTYPE_SECONDARY)
397 if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
398 w_deathtypestring = "just noticed #'s blue ball";
399 else // unchecked: BOUNCE
400 w_deathtypestring = "got in touch with #'s blue ball";
404 if(w_deathtype & HITTYPE_BOUNCE) // combo
405 w_deathtypestring = "felt the electrifying air of #'s combo";
406 else if(w_deathtype & HITTYPE_SPLASH)
407 w_deathtypestring = "got too close to #'s blue beam";
409 w_deathtypestring = "was blasted by #'s blue beam";