]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/electro.qc
Ensure headers are always #included
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / electro.qc
index 3e93644fb87e31f5f104a0cc5bdb1b4d2a865c25..bd6fb89694bda3bb0d4a265cc3d525c66218822d 100644 (file)
@@ -1,12 +1,13 @@
+#include "electro.qh"
 #ifndef IMPLEMENTATION
 CLASS(Electro, Weapon)
-/* ammotype  */ ATTRIB(Electro, ammo_field, .int, ammo_cells)
-/* impulse   */ ATTRIB(Electro, impulse, int, 5)
+/* ammotype  */ ATTRIB(Electro, ammo_field, .int, ammo_cells);
+/* impulse   */ ATTRIB(Electro, impulse, int, 5);
 /* flags     */ ATTRIB(Electro, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
 /* rating    */ ATTRIB(Electro, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
 /* color     */ ATTRIB(Electro, wpcolor, vector, '0 0.5 1');
 /* modelname */ ATTRIB(Electro, mdl, string, "electro");
-#ifndef MENUQC
+#ifdef GAMEQC
 /* model     */ ATTRIB(Electro, m_model, Model, MDL_ELECTRO_ITEM);
 #endif
 /* crosshair */ ATTRIB(Electro, w_crosshair, string, "gfx/crosshairelectro");
@@ -50,6 +51,7 @@ CLASS(Electro, Weapon)
                P(class, prefix, speed_up, float, SEC) \
                P(class, prefix, speed_z, float, SEC) \
                P(class, prefix, spread, float, BOTH) \
+               P(class, prefix, stick, float, SEC) \
                P(class, prefix, switchdelay_drop, float, NONE) \
                P(class, prefix, switchdelay_raise, float, NONE) \
                P(class, prefix, touchexplode, float, SEC) \
@@ -68,7 +70,7 @@ REGISTER_WEAPON(ELECTRO, electro, NEW(Electro));
 #ifdef SVQC
 .float electro_count;
 .float electro_secondarytime;
-void W_Electro_ExplodeCombo();
+void W_Electro_ExplodeCombo(entity this);
 #endif
 #endif
 #ifdef IMPLEMENTATION
@@ -104,7 +106,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
                        e.classname = "electro_orb_chain";
 
                        // now set the next one to trigger as well
-                       e.think = W_Electro_ExplodeCombo;
+                       setthink(e, W_Electro_ExplodeCombo);
 
                        // delay combo chains, looks cooler
                        e.nextthink =
@@ -122,93 +124,102 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
        }
 }
 
-void W_Electro_ExplodeCombo()
-{SELFPARAM();
-       W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
+void W_Electro_ExplodeCombo(entity this)
+{
+       W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
 
-       self.event_damage = func_null;
+       this.event_damage = func_null;
 
        RadiusDamage(
-               self,
-               self.realowner,
+               this,
+               this.realowner,
                WEP_CVAR(electro, combo_damage),
                WEP_CVAR(electro, combo_edgedamage),
                WEP_CVAR(electro, combo_radius),
-               world,
-               world,
+               NULL,
+               NULL,
                WEP_CVAR(electro, combo_force),
                WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
-               world
+               NULL
        );
 
-       remove(self);
+       delete(this);
 }
 
-void W_Electro_Explode()
-{SELFPARAM();
-       if(other.takedamage == DAMAGE_AIM)
-               if(IS_PLAYER(other))
-                       if(DIFF_TEAM(self.realowner, other))
-                               if(!IS_DEAD(other))
-                                       if(IsFlying(other))
-                                               Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
+void W_Electro_Explode(entity this, entity directhitentity)
+{
+       if(directhitentity.takedamage == DAMAGE_AIM)
+               if(IS_PLAYER(directhitentity))
+                       if(DIFF_TEAM(this.realowner, directhitentity))
+                               if(!IS_DEAD(directhitentity))
+                                       if(IsFlying(directhitentity))
+                                               Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
 
-       self.event_damage = func_null;
-       self.takedamage = DAMAGE_NO;
+       this.event_damage = func_null;
+       this.takedamage = DAMAGE_NO;
 
-       if(self.movetype == MOVETYPE_BOUNCE)
+       if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway?
        {
                RadiusDamage(
-                       self,
-                       self.realowner,
+                       this,
+                       this.realowner,
                        WEP_CVAR_SEC(electro, damage),
                        WEP_CVAR_SEC(electro, edgedamage),
                        WEP_CVAR_SEC(electro, radius),
-                       world,
-                       world,
+                       NULL,
+                       NULL,
                        WEP_CVAR_SEC(electro, force),
-                       self.projectiledeathtype,
-                       other
+                       this.projectiledeathtype,
+                       directhitentity
                );
        }
        else
        {
-               W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
+               W_Electro_TriggerCombo(this.origin, WEP_CVAR_PRI(electro, comboradius), this.realowner);
                RadiusDamage(
-                       self,
-                       self.realowner,
+                       this,
+                       this.realowner,
                        WEP_CVAR_PRI(electro, damage),
                        WEP_CVAR_PRI(electro, edgedamage),
                        WEP_CVAR_PRI(electro, radius),
-                       world,
-                       world,
+                       NULL,
+                       NULL,
                        WEP_CVAR_PRI(electro, force),
-                       self.projectiledeathtype,
-                       other
+                       this.projectiledeathtype,
+                       directhitentity
                );
        }
 
-       remove(self);
+       delete(this);
+}
+
+void W_Electro_Explode_use(entity this, entity actor, entity trigger)
+{
+       W_Electro_Explode(this, trigger);
 }
 
-void W_Electro_TouchExplode()
+void W_Electro_TouchExplode(entity this, entity toucher)
 {
-       PROJECTILE_TOUCH;
-       W_Electro_Explode();
+       PROJECTILE_TOUCH(this, toucher);
+       W_Electro_Explode(this, toucher);
 }
 
-void W_Electro_Bolt_Think()
-{SELFPARAM();
-       if(time >= self.ltime)
+
+void sys_phys_update_single(entity this);
+
+void W_Electro_Bolt_Think(entity this)
+{
+       // sys_phys_update_single(this);
+       if(time >= this.ltime)
        {
-               self.use();
+               this.use(this, NULL, NULL);
                return;
        }
 
        if(WEP_CVAR_PRI(electro, midaircombo_radius))
        {
                float found = 0;
-               entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
+               entity e = WarpZone_FindRadius(this.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
 
                // loop through nearby orbs and trigger them
                while(e)
@@ -216,12 +227,12 @@ void W_Electro_Bolt_Think()
                        if(e.classname == "electro_orb")
                        {
                                // change owner to whoever caused the combo explosion
-                               e.realowner = self.realowner;
+                               e.realowner = this.realowner;
                                e.takedamage = DAMAGE_NO;
                                e.classname = "electro_orb_chain";
 
                                // now set the next one to trigger as well
-                               e.think = W_Electro_ExplodeCombo;
+                               setthink(e, W_Electro_ExplodeCombo);
 
                                // delay combo chains, looks cooler
                                e.nextthink =
@@ -242,26 +253,28 @@ void W_Electro_Bolt_Think()
 
                // if we triggered an orb, should we explode? if not, lets try again next time
                if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
-                       { self.use(); }
+                       { this.use(this, NULL, NULL); }
                else
-                       { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
+                       { this.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), this.ltime); }
        }
-       else { self.nextthink = self.ltime; }
+       else { this.nextthink = this.ltime; }
+       // this.nextthink = time;
 }
 
-void W_Electro_Attack_Bolt(Weapon thiswep)
-{SELFPARAM();
+void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
+{
        entity proj;
 
-       W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo));
+       W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo));
 
        W_SetupShot_ProjectileSize(
-               self,
+               actor,
+               weaponentity,
                '0 0 -3',
                '0 0 -3',
                false,
                2,
-               SND(ELECTRO_FIRE),
+               SND_ELECTRO_FIRE,
                CH_WEAPON_A,
                WEP_CVAR_PRI(electro, damage)
        );
@@ -269,40 +282,84 @@ void W_Electro_Attack_Bolt(Weapon thiswep)
        Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        proj = new(electro_bolt);
-       proj.owner = proj.realowner = self;
+       proj.owner = proj.realowner = actor;
        proj.bot_dodge = true;
        proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
-       proj.use = W_Electro_Explode;
-       proj.think = W_Electro_Bolt_Think;
+       proj.use = W_Electro_Explode_use;
+       setthink(proj, W_Electro_Bolt_Think);
        proj.nextthink = time;
        proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
        PROJECTILE_MAKETRIGGER(proj);
        proj.projectiledeathtype = WEP_ELECTRO.m_id;
        setorigin(proj, w_shotorg);
 
-       proj.movetype = MOVETYPE_FLY;
+       // if (IS_CSQC)
+       set_movetype(proj, MOVETYPE_FLY);
        W_SetupProjVelocity_PRI(proj, electro);
        proj.angles = vectoangles(proj.velocity);
-       proj.touch = W_Electro_TouchExplode;
+       settouch(proj, W_Electro_TouchExplode);
        setsize(proj, '0 0 -3', '0 0 -3');
        proj.flags = FL_PROJECTILE;
+       IL_PUSH(g_projectiles, proj);
        proj.missile_flags = MIF_SPLASH;
 
        CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
 
-       MUTATOR_CALLHOOK(EditProjectile, self, proj);
+       MUTATOR_CALLHOOK(EditProjectile, actor, proj);
+       // proj.com_phys_pos = proj.origin;
+       // proj.com_phys_vel = proj.velocity;
+}
+
+void W_Electro_Orb_Stick(entity this, entity to)
+{
+       entity newproj = spawn();
+       newproj.classname = this.classname;
+
+       newproj.bot_dodge = this.bot_dodge;
+       newproj.bot_dodgerating = this.bot_dodgerating;
+
+       newproj.owner = this.owner;
+       newproj.realowner = this.realowner;
+       setsize(newproj, this.mins, this.maxs);
+       setorigin(newproj, this.origin);
+       setmodel(newproj, MDL_PROJECTILE_ELECTRO);
+       newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
+
+       newproj.takedamage = this.takedamage;
+       newproj.damageforcescale = this.damageforcescale;
+       newproj.health = this.health;
+       newproj.event_damage = this.event_damage;
+       newproj.spawnshieldtime = this.spawnshieldtime;
+       newproj.damagedbycontents = true;
+
+       set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
+       newproj.projectiledeathtype = this.projectiledeathtype;
+
+       settouch(newproj, func_null);
+       setthink(newproj, getthink(this));
+       newproj.nextthink = this.nextthink;
+       newproj.use = this.use;
+       newproj.flags = this.flags;
+
+       delete(this);
+
+       if(to)
+               SetMovetypeFollow(this, to);
 }
 
-void W_Electro_Orb_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
-       if(other.takedamage == DAMAGE_AIM)
-               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
+void W_Electro_Orb_Touch(entity this, entity toucher)
+{
+       PROJECTILE_TOUCH(this, toucher);
+       if(toucher.takedamage == DAMAGE_AIM)
+               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this, toucher); } }
        else
        {
-               //UpdateCSQCProjectile(self);
-               spamsound(self, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM);
-               self.projectiledeathtype |= HITTYPE_BOUNCE;
+               //UpdateCSQCProjectile(this);
+               spamsound(this, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM);
+               this.projectiledeathtype |= HITTYPE_BOUNCE;
+
+               if(WEP_CVAR_SEC(electro, stick))
+                       W_Electro_Orb_Stick(this, toucher);
        }
 }
 
@@ -327,7 +384,7 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float
                        // change owner to whoever caused the combo explosion
                        this.realowner = inflictor.realowner;
                        this.classname = "electro_orb_chain";
-                       this.think = W_Electro_ExplodeCombo;
+                       setthink(this, W_Electro_ExplodeCombo);
                        this.nextthink = time +
                                (
                                        // bound the length, inflictor may be in a galaxy far far away (warpzones)
@@ -342,23 +399,24 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float
                }
                else
                {
-                       this.use = W_Electro_Explode;
-                       this.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
+                       this.use = W_Electro_Explode_use;
+                       setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
                }
        }
 }
 
-void W_Electro_Attack_Orb(Weapon thiswep)
-{SELFPARAM();
-       W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo));
+void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
+{
+       W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo));
 
        W_SetupShot_ProjectileSize(
-               self,
-               '0 0 -4',
-               '0 0 -4',
+               actor,
+               weaponentity,
+               '-4 -4 -4',
+               '4 4 4',
                false,
                2,
-               SND(ELECTRO_FIRE2),
+               SND_ELECTRO_FIRE2,
                CH_WEAPON_A,
                WEP_CVAR_SEC(electro, damage)
        );
@@ -368,9 +426,9 @@ void W_Electro_Attack_Orb(Weapon thiswep)
        Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        entity proj = new(electro_orb);
-       proj.owner = proj.realowner = self;
-       proj.use = W_Electro_Explode;
-       proj.think = adaptor_think2use_hittype_splash;
+       proj.owner = proj.realowner = actor;
+       proj.use = W_Electro_Explode_use;
+       setthink(proj, adaptor_think2use_hittype_splash);
        proj.bot_dodge = true;
        proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
        proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
@@ -380,15 +438,16 @@ void W_Electro_Attack_Orb(Weapon thiswep)
 
        //proj.glow_size = 50;
        //proj.glow_color = 45;
-       proj.movetype = MOVETYPE_BOUNCE;
+       set_movetype(proj, MOVETYPE_BOUNCE);
        W_SetupProjVelocity_UP_SEC(proj, electro);
-       proj.touch = W_Electro_Orb_Touch;
-       setsize(proj, '0 0 -4', '0 0 -4');
+       settouch(proj, W_Electro_Orb_Touch);
+       setsize(proj, '-4 -4 -4', '4 4 4');
        proj.takedamage = DAMAGE_YES;
        proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
        proj.health = WEP_CVAR_SEC(electro, health);
        proj.event_damage = W_Electro_Orb_Damage;
        proj.flags = FL_PROJECTILE;
+       IL_PUSH(g_projectiles, proj);
        proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
 
        proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
@@ -405,17 +464,17 @@ void W_Electro_Attack_Orb(Weapon thiswep)
 
        CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
 
-       MUTATOR_CALLHOOK(EditProjectile, self, proj);
+       MUTATOR_CALLHOOK(EditProjectile, actor, proj);
 }
 
 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
-{SELFPARAM();
-       if(self.electro_count > 1)
-       if(self.BUTTON_ATCK2)
+{
+       if(actor.electro_count > 1)
+       if(PHYS_INPUT_BUTTON_ATCK2(actor))
        if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
        {
-               W_Electro_Attack_Orb(WEP_ELECTRO);
-               self.electro_count -= 1;
+               W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity);
+               actor.electro_count -= 1;
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                return;
        }
@@ -425,152 +484,152 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
 
 .float bot_secondary_electromooth;
 
-               METHOD(Electro, wr_aim, void(entity thiswep))
-               {
-                       self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
-                       if(vdist(self.origin - self.enemy.origin, >, 1000)) { self.bot_secondary_electromooth = 0; }
-                       if(self.bot_secondary_electromooth == 0)
-                       {
-                               float shoot;
-
-                               if(WEP_CVAR_PRI(electro, speed))
-                                       shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
-                               else
-                                       shoot = bot_aim(1000000, 0, 0.001, false);
-
-                               if(shoot)
-                               {
-                                       self.BUTTON_ATCK = true;
-                                       if(random() < 0.01) self.bot_secondary_electromooth = 1;
-                               }
-                       }
-                       else
-                       {
-                               if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
-                               {
-                                       self.BUTTON_ATCK2 = true;
-                                       if(random() < 0.03) self.bot_secondary_electromooth = 0;
-                               }
-                       }
-               }
-               METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
-               {
-                       if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
-                       {
-                               float ammo_amount = 0;
-                               if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo))
-                                       ammo_amount = 1;
-                               if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo))
-                                       ammo_amount += 1;
-
-                               if(!ammo_amount)
-                               {
-                                       thiswep.wr_reload(thiswep, actor, weaponentity);
-                                       return;
-                               }
-                       }
-
-                       if(fire & 1)
-                       {
-                               if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
-                               {
-                                               W_Electro_Attack_Bolt(thiswep);
-                                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
-                               }
-                       }
-                       else if(fire & 2)
-                       {
-                               if(time >= actor.electro_secondarytime)
-                               if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
-                               {
-                                       W_Electro_Attack_Orb(thiswep);
-                                       actor.electro_count = WEP_CVAR_SEC(electro, count);
-                                       weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
-                                       actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
-                               }
-                       }
-               }
-               METHOD(Electro, wr_checkammo1, bool(entity thiswep))
-               {
-                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
-                       ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
-                       return ammo_amount;
-               }
-               METHOD(Electro, wr_checkammo2, bool(entity thiswep))
-               {
-                       float ammo_amount;
-                       if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
-                       {
-                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
-                               ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
-                       }
-                       else
-                       {
-                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
-                               ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
-                       }
-                       return ammo_amount;
-               }
-               METHOD(Electro, wr_resetplayer, void(entity thiswep))
-               {
-                       self.electro_secondarytime = time;
-               }
-               METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
-               {
-                       W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
-               }
-               METHOD(Electro, wr_suicidemessage, int(entity thiswep))
-               {
-                       if(w_deathtype & HITTYPE_SECONDARY)
-                               return WEAPON_ELECTRO_SUICIDE_ORBS;
-                       else
-                               return WEAPON_ELECTRO_SUICIDE_BOLT;
-               }
-               METHOD(Electro, wr_killmessage, int(entity thiswep))
-               {
-                       if(w_deathtype & HITTYPE_SECONDARY)
-                       {
-                               return WEAPON_ELECTRO_MURDER_ORBS;
-                       }
-                       else
-                       {
-                               if(w_deathtype & HITTYPE_BOUNCE)
-                                       return WEAPON_ELECTRO_MURDER_COMBO;
-                               else
-                                       return WEAPON_ELECTRO_MURDER_BOLT;
-                       }
-               }
+METHOD(Electro, wr_aim, void(entity thiswep, entity actor))
+{
+    PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
+    if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
+    if(actor.bot_secondary_electromooth == 0)
+    {
+        float shoot;
+
+        if(WEP_CVAR_PRI(electro, speed))
+            shoot = bot_aim(actor, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
+        else
+            shoot = bot_aim(actor, 1000000, 0, 0.001, false);
+
+        if(shoot)
+        {
+            PHYS_INPUT_BUTTON_ATCK(actor) = true;
+            if(random() < 0.01) actor.bot_secondary_electromooth = 1;
+        }
+    }
+    else
+    {
+        if(bot_aim(actor, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
+        {
+            PHYS_INPUT_BUTTON_ATCK2(actor) = true;
+            if(random() < 0.03) actor.bot_secondary_electromooth = 0;
+        }
+    }
+}
+METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
+{
+    if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
+    {
+        float ammo_amount = 0;
+        if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo))
+            ammo_amount = 1;
+        if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo))
+            ammo_amount += 1;
+
+        if(!ammo_amount)
+        {
+            thiswep.wr_reload(thiswep, actor, weaponentity);
+            return;
+        }
+    }
+
+    if(fire & 1)
+    {
+        if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
+        {
+                W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
+                weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+        }
+    }
+    else if(fire & 2)
+    {
+        if(time >= actor.electro_secondarytime)
+        if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
+        {
+            W_Electro_Attack_Orb(thiswep, actor, weaponentity);
+            actor.electro_count = WEP_CVAR_SEC(electro, count);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
+            actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
+        }
+    }
+}
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
+{
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
+    ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
+    return ammo_amount;
+}
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
+{
+    float ammo_amount;
+    if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
+    {
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+        ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+    }
+    else
+    {
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
+        ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
+    }
+    return ammo_amount;
+}
+METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
+{
+    actor.electro_secondarytime = time;
+}
+METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
+{
+    W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
+}
+METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
+{
+    if(w_deathtype & HITTYPE_SECONDARY)
+        return WEAPON_ELECTRO_SUICIDE_ORBS;
+    else
+        return WEAPON_ELECTRO_SUICIDE_BOLT;
+}
+METHOD(Electro, wr_killmessage, Notification(entity thiswep))
+{
+    if(w_deathtype & HITTYPE_SECONDARY)
+    {
+        return WEAPON_ELECTRO_MURDER_ORBS;
+    }
+    else
+    {
+        if(w_deathtype & HITTYPE_BOUNCE)
+            return WEAPON_ELECTRO_MURDER_COMBO;
+        else
+            return WEAPON_ELECTRO_MURDER_BOLT;
+    }
+}
 
 #endif
 #ifdef CSQC
 
-               METHOD(Electro, wr_impacteffect, void(entity thiswep))
-               {
-                       vector org2;
-                       org2 = w_org + w_backoff * 6;
-                       if(w_deathtype & HITTYPE_SECONDARY)
-                       {
-                               pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
-                               if(!w_issilent)
-                                       sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
-                       }
-                       else
-                       {
-                               if(w_deathtype & HITTYPE_BOUNCE)
-                               {
-                                       // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
-                                       pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
-                                       if(!w_issilent)
-                                               sound(self, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
-                               }
-                               else
-                               {
-                                       pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
-                                       if(!w_issilent)
-                                               sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
-                               }
-                       }
-               }
+METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
+{
+    vector org2;
+    org2 = w_org + w_backoff * 6;
+    if(w_deathtype & HITTYPE_SECONDARY)
+    {
+        pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
+        if(!w_issilent)
+            sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
+    }
+    else
+    {
+        if(w_deathtype & HITTYPE_BOUNCE)
+        {
+            // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
+            pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
+            if(!w_issilent)
+                sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
+        }
+        else
+        {
+            pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
+            if(!w_issilent)
+                sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
+        }
+    }
+}
 
 #endif
 #endif