3 /* WEP_##id */ ELECTRO,
4 /* function */ w_electro,
5 /* ammotype */ IT_CELLS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* netname */ "electro",
11 /* fullname */ _("Electro")
15 var float autocvar_g_balance_electro_combo_comboradius_thruwall = 200;
19 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
22 .float electro_secondarytime;
24 void W_Plasma_Explode_Combo (void);
26 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
29 e = WarpZone_FindRadius(org, rad, !autocvar_g_balance_electro_combo_comboradius_thruwall);
32 if (e.classname == "plasma")
34 // change owner to whoever caused the combo explosion
35 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
37 if((trace_fraction == 1) || (autocvar_g_balance_electro_combo_comboradius_thruwall >= vlen(e.WarpZone_findradius_dist)))
40 e.takedamage = DAMAGE_NO;
41 e.classname = "plasma_chain";
42 e.think = W_Plasma_Explode_Combo;
43 e.nextthink = time + vlen(e.WarpZone_findradius_dist) / autocvar_g_balance_electro_combo_speed; // delay combo chains, looks cooler
50 void W_Plasma_Explode (void)
52 if(other.takedamage == DAMAGE_AIM)
54 if(DIFF_TEAM(self.realowner, other))
55 if(other.deadflag == DEAD_NO)
57 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
59 self.event_damage = func_null;
60 self.takedamage = DAMAGE_NO;
61 if (self.movetype == MOVETYPE_BOUNCE)
63 RadiusDamage(self, self.realowner, autocvar_g_balance_electro_secondary_damage, autocvar_g_balance_electro_secondary_edgedamage, autocvar_g_balance_electro_secondary_radius, world, world, autocvar_g_balance_electro_secondary_force, self.projectiledeathtype, other);
67 W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_primary_comboradius, self.realowner);
68 RadiusDamage (self, self.realowner, autocvar_g_balance_electro_primary_damage, autocvar_g_balance_electro_primary_edgedamage, autocvar_g_balance_electro_primary_radius, world, world, autocvar_g_balance_electro_primary_force, self.projectiledeathtype, other);
74 void W_Plasma_Explode_Combo (void)
76 W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_combo_comboradius, self.realowner);
78 self.event_damage = func_null;
79 RadiusDamage (self, self.realowner, autocvar_g_balance_electro_combo_damage, autocvar_g_balance_electro_combo_edgedamage, autocvar_g_balance_electro_combo_radius, world, world, autocvar_g_balance_electro_combo_force, WEP_ELECTRO | HITTYPE_BOUNCE, world); // use THIS type for a combo because primary can't bounce
84 void W_Plasma_Touch (void)
86 //self.velocity = self.velocity * 0.1;
89 if (other.takedamage == DAMAGE_AIM) {
92 //UpdateCSQCProjectile(self);
93 spamsound (self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
94 self.projectiledeathtype |= HITTYPE_BOUNCE;
98 void W_Plasma_TouchExplode (void)
104 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
109 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
110 float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
112 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
113 return; // g_projectiles_damage says to halt
115 self.health = self.health - damage;
116 if (self.health <= 0)
118 self.takedamage = DAMAGE_NO;
119 self.nextthink = time;
122 // change owner to whoever caused the combo explosion
123 self.realowner = inflictor.realowner;
124 self.classname = "plasma_chain";
125 self.think = W_Plasma_Explode_Combo;
126 self.nextthink = time + min(autocvar_g_balance_electro_combo_radius, vlen(self.origin - inflictor.origin)) / autocvar_g_balance_electro_combo_speed; // delay combo chains, looks cooler
127 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bounding the length, because inflictor may be in a galaxy far far away (warpzones)
131 self.use = W_Plasma_Explode;
132 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
137 void W_Electro_Attack()
141 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_reload_ammo);
143 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, autocvar_g_balance_electro_primary_damage);
145 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
148 proj.classname = "plasma_prim";
149 proj.owner = proj.realowner = self;
150 proj.bot_dodge = TRUE;
151 proj.bot_dodgerating = autocvar_g_balance_electro_primary_damage;
152 proj.use = W_Plasma_Explode;
153 proj.think = adaptor_think2use_hittype_splash;
154 proj.nextthink = time + autocvar_g_balance_electro_primary_lifetime;
155 PROJECTILE_MAKETRIGGER(proj);
156 proj.projectiledeathtype = WEP_ELECTRO;
157 setorigin(proj, w_shotorg);
159 proj.movetype = MOVETYPE_FLY;
160 W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
161 proj.angles = vectoangles(proj.velocity);
162 proj.touch = W_Plasma_TouchExplode;
163 setsize(proj, '0 0 -3', '0 0 -3');
164 proj.flags = FL_PROJECTILE;
165 proj.missile_flags = MIF_SPLASH;
167 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
169 other = proj; MUTATOR_CALLHOOK(EditProjectile);
172 void W_Electro_Attack2()
176 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_secondary_ammo, autocvar_g_balance_electro_reload_ammo);
178 W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, autocvar_g_balance_electro_secondary_damage);
180 w_shotdir = v_forward; // no TrueAim for grenades please
182 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
185 proj.classname = "plasma";
186 proj.owner = proj.realowner = self;
187 proj.use = W_Plasma_Explode;
188 proj.think = adaptor_think2use_hittype_splash;
189 proj.bot_dodge = TRUE;
190 proj.bot_dodgerating = autocvar_g_balance_electro_secondary_damage;
191 proj.nextthink = time + autocvar_g_balance_electro_secondary_lifetime;
192 PROJECTILE_MAKETRIGGER(proj);
193 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
194 setorigin(proj, w_shotorg);
196 //proj.glow_size = 50;
197 //proj.glow_color = 45;
198 proj.movetype = MOVETYPE_BOUNCE;
199 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
200 proj.touch = W_Plasma_Touch;
201 setsize(proj, '0 0 -4', '0 0 -4');
202 proj.takedamage = DAMAGE_YES;
203 proj.damageforcescale = autocvar_g_balance_electro_secondary_damageforcescale;
204 proj.health = autocvar_g_balance_electro_secondary_health;
205 proj.event_damage = W_Plasma_Damage;
206 proj.flags = FL_PROJECTILE;
207 proj.damagedbycontents = (autocvar_g_balance_electro_secondary_damagedbycontents);
209 proj.bouncefactor = autocvar_g_balance_electro_secondary_bouncefactor;
210 proj.bouncestop = autocvar_g_balance_electro_secondary_bouncestop;
211 proj.missile_flags = MIF_SPLASH | MIF_ARC;
216 copyentity(proj, p2);
217 setmodel(p2, "models/ebomb.mdl");
218 setsize(p2, proj.mins, proj.maxs);
221 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
223 other = proj; MUTATOR_CALLHOOK(EditProjectile);
226 void w_electro_checkattack()
228 if(self.electro_count > 1)
229 if(self.BUTTON_ATCK2)
230 if(weapon_prepareattack(1, -1))
233 self.electro_count -= 1;
234 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
241 .float bot_secondary_electromooth;
242 float w_electro(float req)
249 self.BUTTON_ATCK=FALSE;
250 self.BUTTON_ATCK2=FALSE;
251 if(vlen(self.origin-self.enemy.origin) > 1000)
252 self.bot_secondary_electromooth = 0;
253 if(self.bot_secondary_electromooth == 0)
257 if(autocvar_g_balance_electro_primary_speed)
258 shoot = bot_aim(autocvar_g_balance_electro_primary_speed, 0, autocvar_g_balance_electro_primary_lifetime, FALSE);
260 shoot = bot_aim(1000000, 0, 0.001, FALSE);
264 self.BUTTON_ATCK = TRUE;
265 if(random() < 0.01) self.bot_secondary_electromooth = 1;
270 if(bot_aim(autocvar_g_balance_electro_secondary_speed, autocvar_g_balance_mortar_secondary_speed_up, autocvar_g_balance_electro_secondary_lifetime, TRUE)) // WHAT THE ACTUAL FUUUUUUUUUCK?!?!? WEAPONTODO
272 self.BUTTON_ATCK2 = TRUE;
273 if(random() < 0.03) self.bot_secondary_electromooth = 0;
281 if(autocvar_g_balance_electro_reload_ammo) // forced reload
284 if(self.clip_load >= autocvar_g_balance_electro_primary_ammo)
286 if(self.clip_load >= autocvar_g_balance_electro_secondary_ammo)
291 WEP_ACTION(self.weapon, WR_RELOAD);
297 if (self.BUTTON_ATCK)
299 if(weapon_prepareattack(0, autocvar_g_balance_electro_primary_refire))
302 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
305 else if(self.BUTTON_ATCK2)
307 if (time >= self.electro_secondarytime)
308 if (weapon_prepareattack(1, autocvar_g_balance_electro_secondary_refire))
311 self.electro_count = autocvar_g_balance_electro_secondary_count;
312 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
313 self.electro_secondarytime = time + autocvar_g_balance_electro_secondary_refire2 * W_WeaponRateFactor();
321 precache_model ("models/weapons/g_electro.md3");
322 precache_model ("models/weapons/v_electro.md3");
323 precache_model ("models/weapons/h_electro.iqm");
324 precache_sound ("weapons/electro_bounce.wav");
325 precache_sound ("weapons/electro_fire.wav");
326 precache_sound ("weapons/electro_fire2.wav");
327 precache_sound ("weapons/electro_impact.wav");
328 precache_sound ("weapons/electro_impact_combo.wav");
333 self.current_ammo = ammo_cells;
338 ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
339 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_primary_ammo;
344 if(autocvar_g_balance_electro_combo_safeammocheck) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
346 ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
347 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
351 ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
352 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo;
358 self.electro_secondarytime = time;
363 W_Reload(min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo), "weapons/reload.wav");
366 case WR_SUICIDEMESSAGE:
368 if(w_deathtype & HITTYPE_SECONDARY)
369 return WEAPON_ELECTRO_SUICIDE_ORBS;
371 return WEAPON_ELECTRO_SUICIDE_BOLT;
375 if(w_deathtype & HITTYPE_SECONDARY)
377 return WEAPON_ELECTRO_MURDER_ORBS;
381 if(w_deathtype & HITTYPE_BOUNCE)
382 return WEAPON_ELECTRO_MURDER_COMBO;
384 return WEAPON_ELECTRO_MURDER_BOLT;
392 float w_electro(float req)
396 case WR_IMPACTEFFECT:
399 org2 = w_org + w_backoff * 6;
400 if(w_deathtype & HITTYPE_SECONDARY)
402 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
404 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
408 if(w_deathtype & HITTYPE_BOUNCE)
410 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
411 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
413 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
417 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
419 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
427 precache_sound("weapons/electro_impact.wav");
428 precache_sound("weapons/electro_impact_combo.wav");