2 REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro");
5 .float electro_secondarytime;
7 void W_Plasma_Explode_Combo (void);
9 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
12 e = findradius(org, rad);
15 if (e.classname == "plasma")
17 // see if there is line of sight to the combo ball
18 traceline(org, e.origin, MOVE_NOMONSTERS, e);
19 if (trace_fraction == 1 || trace_ent == e)
21 // change owner to whoever caused the combo explosion
23 e.takedamage = DAMAGE_NO;
24 e.classname = "plasma_chain";
25 e.think = W_Plasma_Explode_Combo;
26 e.nextthink = time + vlen(e.origin - org) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
33 void W_Plasma_Explode (void)
35 if(other.takedamage == DAMAGE_AIM)
36 if(other.classname == "player")
37 if(IsDifferentTeam(self.owner, other))
38 if(other.deadflag == DEAD_NO)
40 AnnounceTo(self.owner, "electrobitch");
42 self.event_damage = SUB_Null;
43 self.takedamage = DAMAGE_NO;
44 if (self.movetype == MOVETYPE_BOUNCE)
46 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);
50 W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_primary_comboradius"), self.owner);
51 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);
57 void W_Plasma_Explode_Combo (void)
60 W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_combo_comboradius"), self.owner);
62 self.event_damage = SUB_Null;
63 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
67 void W_Plasma_Touch (void)
70 if (other.takedamage == DAMAGE_AIM) {
73 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
74 self.projectiledeathtype |= HITTYPE_BOUNCE;
78 void W_Plasma_TouchExplode (void)
84 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
88 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
89 self.health = self.health - damage;
92 self.takedamage = DAMAGE_NO;
93 self.nextthink = time;
94 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
96 // change owner to whoever caused the combo explosion
97 self.owner = inflictor.owner;
98 self.classname = "plasma_chain";
99 self.think = W_Plasma_Explode_Combo;
100 self.nextthink = time + vlen(self.origin - inflictor.origin) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
104 self.use = W_Plasma_Explode;
105 self.think = adaptor_think2use;
110 void W_Electro_Attack()
114 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", cvar("g_balance_electro_primary_damage"));
116 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
119 proj.classname = "plasma_prim";
121 proj.bot_dodge = TRUE;
122 proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
123 proj.use = W_Plasma_Explode;
124 proj.think = adaptor_think2use;
125 proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
126 PROJECTILE_MAKETRIGGER(proj);
127 proj.projectiledeathtype = WEP_ELECTRO;
128 setorigin(proj, w_shotorg);
130 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
131 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
132 proj.movetype = MOVETYPE_FLY;
133 W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
134 proj.angles = vectoangles(proj.velocity);
135 proj.touch = W_Plasma_TouchExplode;
136 setsize(proj, '0 0 -3', '0 0 -3');
137 proj.flags = FL_PROJECTILE;
139 //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
142 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
145 void W_Electro_Attack2()
149 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire2.wav", cvar("g_balance_electro_secondary_damage"));
150 w_shotdir = v_forward; // no TrueAim for grenades please
152 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
155 proj.classname = "plasma";
157 proj.use = W_Plasma_Explode;
158 proj.think = adaptor_think2use;
159 proj.bot_dodge = TRUE;
160 proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
161 proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
162 PROJECTILE_MAKETRIGGER(proj);
163 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
164 setorigin(proj, w_shotorg);
166 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
167 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
168 //proj.glow_size = 50;
169 //proj.glow_color = 45;
170 proj.movetype = MOVETYPE_BOUNCE;
171 W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
172 proj.touch = W_Plasma_Touch;
173 setsize(proj, '0 0 -3', '0 0 -3');
174 proj.takedamage = DAMAGE_YES;
175 proj.damageforcescale = cvar("g_balance_electro_secondary_damageforcescale");
176 proj.health = cvar("g_balance_electro_secondary_health");
177 proj.event_damage = W_Plasma_Damage;
178 proj.flags = FL_PROJECTILE;
183 copyentity(proj, p2);
184 setmodel(p2, "models/ebomb.mdl");
185 setsize(p2, proj.mins, proj.maxs);
188 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
191 void spawnfunc_weapon_electro (void)
193 weapon_defaultspawnfunc(WEP_ELECTRO);
196 void w_electro_checkattack()
198 if(self.electro_count > 1)
199 if(self.BUTTON_ATCK2)
200 if(weapon_prepareattack(1, -1))
203 self.electro_count -= 1;
204 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
211 .float bot_secondary_electromooth;
212 float w_electro(float req)
216 self.BUTTON_ATCK=FALSE;
217 self.BUTTON_ATCK2=FALSE;
218 if(vlen(self.origin-self.enemy.origin) > 1000)
219 self.bot_secondary_electromooth = 0;
220 if(self.bot_secondary_electromooth == 0)
222 if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
224 self.BUTTON_ATCK = TRUE;
225 if(random() < 0.01) self.bot_secondary_electromooth = 1;
230 if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
232 self.BUTTON_ATCK2 = TRUE;
233 if(random() < 0.03) self.bot_secondary_electromooth = 0;
237 else if (req == WR_THINK)
239 if (self.BUTTON_ATCK)
240 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
243 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
245 if (self.BUTTON_ATCK2)
246 if (time >= self.electro_secondarytime)
247 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
250 self.electro_count = cvar("g_balance_electro_secondary_count");
251 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
252 self.electro_secondarytime = time + cvar("g_balance_electro_secondary_refire2");
255 else if (req == WR_PRECACHE)
257 precache_model ("models/weapons/g_electro.md3");
258 precache_model ("models/weapons/v_electro.md3");
259 precache_model ("models/weapons/h_electro.dpm");
260 precache_sound ("weapons/electro_bounce.wav");
261 precache_sound ("weapons/electro_fire.wav");
262 precache_sound ("weapons/electro_fire2.wav");
263 precache_sound ("weapons/electro_impact.wav");
264 precache_sound ("weapons/electro_impact_combo.wav");
266 else if (req == WR_SETUP)
267 weapon_setup(WEP_ELECTRO);
268 else if (req == WR_CHECKAMMO1)
269 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
270 else if (req == WR_CHECKAMMO2)
271 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
272 else if (req == WR_SUICIDEMESSAGE)
274 if(w_deathtype & HITTYPE_SECONDARY)
275 w_deathtypestring = "could not remember where they put plasma";
277 w_deathtypestring = "played with plasma";
279 else if (req == WR_KILLMESSAGE)
281 if(w_deathtype & HITTYPE_SECONDARY)
283 if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
284 w_deathtypestring = "just noticed #'s blue ball";
285 else // unchecked: BOUNCE
286 w_deathtypestring = "got in touch with #'s blue ball";
290 if(w_deathtype & HITTYPE_BOUNCE) // combo
291 w_deathtypestring = "felt the electrifying air of #'s combo";
292 else if(w_deathtype & HITTYPE_SPLASH)
293 w_deathtypestring = "got too close to #'s blue beam";
295 w_deathtypestring = "was blasted by #'s blue beam";
298 else if (req == WR_RESETPLAYER)
300 self.electro_secondarytime = time;