]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/electro.qc
Merge branch 'bones_was_here/gunoffset' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / electro.qc
index 9409819e9c15b8569fa5623ede91e841984224dc..97929c7dd3736ba0cf68514562ae32fc995954e0 100644 (file)
@@ -10,6 +10,13 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
        {
                if(e.classname == "electro_orb")
                {
+                       // check if the ball we are exploding is not owned by an
+                       // independent player which is not the player who shot the ball
+                       if(IS_INDEPENDENT_PLAYER(e.realowner) && own != e.realowner)
+                       {
+                               e = e.chain;
+                               continue;
+                       }
                        // do we allow thruwall triggering?
                        if(WEP_CVAR(electro, combo_comboradius_thruwall))
                        {
@@ -49,7 +56,7 @@ void W_Electro_ExplodeCombo(entity this)
        W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
 
        this.event_damage = func_null;
-       this.velocity = this.movedir; // particle fx and decals need .velocity
+       this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work
 
        RadiusDamage(
                this,
@@ -79,7 +86,7 @@ void W_Electro_Explode(entity this, entity directhitentity)
 
        this.event_damage = func_null;
        this.takedamage = DAMAGE_NO;
-       this.velocity = this.movedir; // particle fx and decals need .velocity
+       this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work
 
        if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway?
        {
@@ -130,7 +137,7 @@ void W_Electro_TouchExplode(entity this, entity toucher)
 }
 
 
-void sys_phys_update_single(entity this);
+//void sys_phys_update_single(entity this);
 
 void W_Electro_Bolt_Think(entity this)
 {
@@ -151,6 +158,13 @@ void W_Electro_Bolt_Think(entity this)
                {
                        if(e.classname == "electro_orb")
                        {
+                               // check if the ball we are exploding is not owned by an
+                               // independent player which is not the player who shot the ball
+                               if(IS_INDEPENDENT_PLAYER(e.realowner) && this.realowner != e.realowner)
+                               {
+                                       e = e.chain;
+                                       continue;
+                               }
                                bool explode;
                                if (this.owner == e.owner)
                                {
@@ -295,6 +309,7 @@ void W_Electro_Orb_Stick(entity this, entity to)
        setmodel(newproj, MDL_PROJECTILE_ELECTRO);
        setsize(newproj, this.mins, this.maxs);
        newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
+       newproj.traileffectnum = _particleeffectnum(EFFECT_TR_NEXUIZPLASMA.eent_eff_name);
 
        newproj.movedir = -trace_plane_normal;
 
@@ -311,7 +326,11 @@ void W_Electro_Orb_Stick(entity this, entity to)
        newproj.weaponentity_fld = this.weaponentity_fld;
 
        settouch(newproj, func_null);
-       newproj.death_time = this.death_time;
+       if(WEP_CVAR_SEC(electro, stick_lifetime) > 0){
+               newproj.death_time = time + WEP_CVAR_SEC(electro, stick_lifetime);
+       }else{
+               newproj.death_time = this.death_time;
+       }
        newproj.use = this.use;
        newproj.flags = this.flags;
        IL_PUSH(g_projectiles, newproj);
@@ -350,8 +369,13 @@ void W_Electro_Orb_Touch(entity this, entity toucher)
                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);
+               if(WEP_CVAR_SEC(electro, stick)){
+                       if(WEP_CVAR_SEC(electro, stick_lifetime) == 0){
+                               W_Electro_Explode(this, toucher);
+                       } else {
+                               W_Electro_Orb_Stick(this, toucher);
+                       }
+               }
        }
 }
 
@@ -467,10 +491,10 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
        {
                W_Electro_Attack_Orb(thiswep, actor, weaponentity);
                actor.(weaponentity).electro_count -= 1;
+               actor.(weaponentity).electro_secondarytime = time;
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                return;
        }
-       // WEAPONTODO: when the player releases the button, cut down the length of refire2?
        w_ready(thiswep, actor, weaponentity, fire);
 }
 
@@ -485,9 +509,9 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
         float shoot;
 
         if(WEP_CVAR_PRI(electro, speed))
-            shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
+            shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false, true);
         else
-            shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
+            shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
 
         if(shoot)
         {
@@ -497,7 +521,7 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
     }
     else
     {
-        if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
+        if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true, true))
         {
             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
             if(random() < 0.03) actor.bot_secondary_electromooth = 0;
@@ -523,21 +547,22 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit
 
     if(fire & 1)
     {
+        if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor))
         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);
+            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.(weaponentity).electro_secondarytime)
-        if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
+        if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire) * W_WeaponRateFactor(actor))
+        if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
         {
             W_Electro_Attack_Orb(thiswep, actor, weaponentity);
             actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
+            actor.(weaponentity).electro_secondarytime = time;
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
-            actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
         }
     }
 }
@@ -562,14 +587,6 @@ METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon
     }
     return ammo_amount;
 }
-METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
-{
-    for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       actor.(weaponentity).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);