]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use the weapon entity as a parameter to ATTACK_FINISHED instead of the slot number...
authorMario <mario@smbclan.net>
Mon, 15 Oct 2018 14:50:58 +0000 (00:50 +1000)
committerMario <mario@smbclan.net>
Mon, 15 Oct 2018 14:50:58 +0000 (00:50 +1000)
14 files changed:
qcsrc/common/gamemodes/gamemode/assault/sv_assault.qh
qcsrc/common/mutators/mutator/overkill/okhmg.qc
qcsrc/common/mutators/mutator/overkill/okmachinegun.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/defs.qh
qcsrc/server/weapons/weaponsystem.qc

index 95b5b8ccf2ffc2ee5d2ed395c98f1c1376d57be9..fcfc78917f8239f64f2d72c3eee62ee5ed8511a3 100644 (file)
@@ -41,5 +41,8 @@ void(entity bot) havocbot_ast_reset_role;
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
 
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
 
+// assault game mode: Which team is attacking in this round?
+float assault_attacker_team;
+
 // predefined spawnfuncs
 void target_objective_decrease_activate(entity this);
 // predefined spawnfuncs
 void target_objective_decrease_activate(entity this);
index 003cd3abc6c258378eaf04be3eb2caa62cbf6b13..688928ce1425b23a4a1294de87788d66b1406b07 100644 (file)
@@ -51,8 +51,7 @@ void W_OverkillHeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
-       int slot = weaponslot(weaponentity);
-       ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(okhmg, refire) * W_WeaponRateFactor(actor);
+       ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(okhmg, refire) * W_WeaponRateFactor(actor);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okhmg, refire), W_OverkillHeavyMachineGun_Attack_Auto);
 }
 
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okhmg, refire), W_OverkillHeavyMachineGun_Attack_Auto);
 }
 
index 27502a75985dc28b90eb529ba3b787aec0fa3bdf..aa872f1541a64f052d79d7c73751a6c7e46a984c 100644 (file)
@@ -45,8 +45,7 @@ void W_OverkillMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weap
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
-       int slot = weaponslot(weaponentity);
-       ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(okmachinegun, refire) * W_WeaponRateFactor(actor);
+       ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(okmachinegun, refire) * W_WeaponRateFactor(actor);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okmachinegun, refire), W_OverkillMachineGun_Attack_Auto);
 }
 
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okmachinegun, refire), W_OverkillMachineGun_Attack_Auto);
 }
 
index 35bb1e3db197cc93b18ecf51c9cf166f98a62a5d..8f28ec83c3ab339eccd9a9ff6f27386388cffc20 100644 (file)
@@ -648,10 +648,9 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i
 
     if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
     {
 
     if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
     {
-       int slot = weaponslot(weaponentity);
         sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
         sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
-        ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
+        ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
     }
     actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
 
     }
     actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
 
index 1357fc5f2dbf8b4f028ca8161316149a92515f00..f8539b14c36b7eeb800830de893c625581e06337 100644 (file)
@@ -50,8 +50,7 @@ void W_Devastator_Explode(entity this, entity directhitentity)
                if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        this.realowner.cnt = thiswep.m_id;
                if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        this.realowner.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(this.realowner, slot) = time;
+                       ATTACK_FINISHED(this.realowner, weaponentity) = time;
                        this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
                        this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
@@ -144,8 +143,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
                if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        this.realowner.cnt = thiswep.m_id;
                if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        this.realowner.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(this.realowner, slot) = time;
+                       ATTACK_FINISHED(this.realowner, weaponentity) = time;
                        this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
                        this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
@@ -488,7 +486,7 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea
 {
     #if 0
     // don't switch while guiding a missile
 {
     #if 0
     // don't switch while guiding a missile
-    if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
+    if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
     {
         ammo_amount = false;
         if(WEP_CVAR(devastator, reload_ammo))
     {
         ammo_amount = false;
         if(WEP_CVAR(devastator, reload_ammo))
index 4d13e9cb7bccf68aa66902a2f5d4a5828eb38758..187ed765f46fc0cb60d41f139675d614ef936b3f 100644 (file)
@@ -379,8 +379,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
 
        W_Hagar_Attack(thiswep, actor, weaponentity);
 
 
        W_Hagar_Attack(thiswep, actor, weaponentity);
 
-       int slot = weaponslot(weaponentity);
-       ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor);
+       ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor);
        int theframe = WFRAME_FIRE1;
        entity this = actor.(weaponentity);
        if(this)
        int theframe = WFRAME_FIRE1;
        entity this = actor.(weaponentity);
        if(this)
index 9449a24f17268999441f4d5cdab8a969909c9b12..816ddae3655d523387571a2e9e23b850881be710 100644 (file)
@@ -134,8 +134,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
                        return;
                }
 
                        return;
                }
 
-               int slot = weaponslot(weaponentity);
-               ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
+               ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
                W_HLAC_Attack(thiswep, actor, weaponentity);
                actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
                W_HLAC_Attack(thiswep, actor, weaponentity);
                actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
index 190dddd394f0c2fb19df422b633c08d258bd2e63..607f1fcddfedfda1e80b7048aa0729fd7b22569d 100644 (file)
@@ -56,9 +56,8 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity we
                actor.punchangle_x = random() - 0.5;
                actor.punchangle_y = random() - 0.5;
        }
                actor.punchangle_x = random() - 0.5;
                actor.punchangle_y = random() - 0.5;
        }
-       int slot = weaponslot(weaponentity);
        // this attack_finished just enforces a cooldown at the end of a burst
        // this attack_finished just enforces a cooldown at the end of a burst
-       ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
+       ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
 
        if(actor.(weaponentity).misc_bulletcounter == 1)
                fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET);
 
        if(actor.(weaponentity).misc_bulletcounter == 1)
                fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET);
@@ -152,8 +151,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
        }
 
-       int slot = weaponslot(weaponentity);
-       ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
+       ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
 }
 
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
 }
 
@@ -182,8 +180,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
        actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
        if(actor.(weaponentity).misc_bulletcounter == 0)
        {
        actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
        if(actor.(weaponentity).misc_bulletcounter == 0)
        {
-               int slot = weaponslot(weaponentity);
-               ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor);
+               ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready);
        }
        else
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready);
        }
        else
index 29192ac58168c153ae2561b86ed128f9c20fe4da..6063c666eb5093b0aea9ba9af3b17730948f342d 100644 (file)
@@ -74,8 +74,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(own, slot) = time;
+                       ATTACK_FINISHED(own, weaponentity) = time;
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
@@ -106,8 +105,7 @@ void W_MineLayer_DoRemoteExplode(entity this)
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(own, slot) = time;
+                       ATTACK_FINISHED(own, weaponentity) = time;
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
@@ -464,9 +462,8 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
 }
 METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
 }
 METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
-    //int slot = 0; // TODO: unhardcode
     // actually do // don't switch while placing a mine
     // actually do // don't switch while placing a mine
-    //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
+    //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
     //{
         float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);
     //{
         float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);
index bf9900b97257f1a5846db7d82ed20a2feecff66a..d4d692ec70f0adeab3f7118961bd904dbb66d533 100644 (file)
@@ -47,10 +47,9 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent
        float r, af;
 
        Weapon sw = actor.(weaponentity).m_switchweapon; // make it not detect weapon changes as reason to abort firing
        float r, af;
 
        Weapon sw = actor.(weaponentity).m_switchweapon; // make it not detect weapon changes as reason to abort firing
-       int slot = weaponslot(weaponentity);
-       af = ATTACK_FINISHED(actor, slot);
+       af = ATTACK_FINISHED(actor, weaponentity);
        actor.(weaponentity).m_switchweapon = actor.(weaponentity).m_weapon;
        actor.(weaponentity).m_switchweapon = actor.(weaponentity).m_weapon;
-       ATTACK_FINISHED(actor, slot) = time;
+       ATTACK_FINISHED(actor, weaponentity) = time;
        r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
        if(actor.(weaponentity).m_switchweapon == actor.(weaponentity).m_weapon)
                actor.(weaponentity).m_switchweapon = sw;
        r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
        if(actor.(weaponentity).m_switchweapon == actor.(weaponentity).m_weapon)
                actor.(weaponentity).m_switchweapon = sw;
@@ -61,7 +60,7 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent
        }
        else
        {
        }
        else
        {
-               ATTACK_FINISHED(actor, slot) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
+               ATTACK_FINISHED(actor, weaponentity) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
        }
 }
 
        }
 }
 
index f5ba20c8a41b1acbe04a1368748eb8cbede98d30..63f1e0179442941435d9dfc6aeb30ef6e8c9d8c4 100644 (file)
@@ -1402,7 +1402,7 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
        // Should it do a weapon combo?
        float af, ct, combo_time, combo;
 
        // Should it do a weapon combo?
        float af, ct, combo_time, combo;
 
-       af = ATTACK_FINISHED(this, 0);
+       af = ATTACK_FINISHED(this, weaponentity);
        ct = autocvar_bot_ai_weapon_combo_threshold;
 
        // Bots with no skill will be 4 times more slower than "godlike" bots when doing weapon combos
        ct = autocvar_bot_ai_weapon_combo_threshold;
 
        // Bots with no skill will be 4 times more slower than "godlike" bots when doing weapon combos
index 48975b8367e58766668e59027e5e73000b9b4d51..555f6fc58a54c8e898f4472e7ee81577ea99b579 100644 (file)
@@ -1084,12 +1084,12 @@ float bot_cmd_debug_assert_canfire(entity this)
                        LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state");
                }
        }
                        LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state");
                }
        }
-       else if(ATTACK_FINISHED(this, slot) > time)
+       else if(ATTACK_FINISHED(this, weaponentity) > time)
        {
                if(f)
                {
                        this.colormod = '8 0 8';
        {
                if(f)
                {
                        this.colormod = '8 0 8';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left)");
                }
        }
        else if(this.(weaponentity).tuba_note)
                }
        }
        else if(this.(weaponentity).tuba_note)
@@ -1105,7 +1105,7 @@ float bot_cmd_debug_assert_canfire(entity this)
                if(!f)
                {
                        this.colormod = '8 8 0';
                if(!f)
                {
                        this.colormod = '8 8 0';
-                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left");
+                       LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left");
                }
        }
 
                }
        }
 
index 90bc1fb200a4cd3a2eaca29eae32b7a2983fe4f4..e667906f1dddb3351a48b6d9c5543fdadcf39f4d 100644 (file)
@@ -202,10 +202,7 @@ float bot_waypoints_for_items;
 #else
 #define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot])
 #endif
 #else
 #define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot])
 #endif
-#define ATTACK_FINISHED(ent, slot) ATTACK_FINISHED_FOR(ent, ent.(weaponentity).m_weapon.m_id, slot)
-
-// assault game mode: Which team is attacking in this round?
-float assault_attacker_team;
+#define ATTACK_FINISHED(ent, w) ATTACK_FINISHED_FOR(ent, ent.(w).m_weapon.m_id, weaponslot(w))
 
 // speedrun: when 1, player auto teleports back when capture timeout happens
 .float speedrunning;
 
 // speedrun: when 1, player auto teleports back when capture timeout happens
 .float speedrunning;
index c4b91b3b3931f759f02feae9ee107cee13039b18..4a45b257a5db060c8b68a98facfaac9dd3ca4e5a 100644 (file)
@@ -292,9 +292,8 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponenti
 
        if (attacktime >= 0)
        {
 
        if (attacktime >= 0)
        {
-               int slot = weaponslot(weaponentity);
                // don't fire if previous attack is not finished
                // don't fire if previous attack is not finished
-               if (ATTACK_FINISHED(actor, slot) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
+               if (ATTACK_FINISHED(actor, weaponentity) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
                entity this = actor.(weaponentity);
                // don't fire while changing weapon
                if (this.state != WS_READY) return false;
                entity this = actor.(weaponentity);
                // don't fire while changing weapon
                if (this.state != WS_READY) return false;
@@ -313,17 +312,17 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary,
        // if the weapon hasn't been firing continuously, reset the timer
        if (attacktime >= 0)
        {
        // if the weapon hasn't been firing continuously, reset the timer
        if (attacktime >= 0)
        {
-               int slot = weaponslot(weaponentity);
-               if (ATTACK_FINISHED(actor, slot) < time - this.weapon_frametime * 1.5)
+               if (ATTACK_FINISHED(actor, weaponentity) < time - this.weapon_frametime * 1.5)
                {
                {
-                       ATTACK_FINISHED(actor, slot) = time;
+                       ATTACK_FINISHED(actor, weaponentity) = time;
                        // dprint("resetting attack finished to ", ftos(time), "\n");
                }
                float arate = W_WeaponRateFactor(actor);
                        // dprint("resetting attack finished to ", ftos(time), "\n");
                }
                float arate = W_WeaponRateFactor(actor);
-               ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * arate;
+               ATTACK_FINISHED(actor, weaponentity) = ATTACK_FINISHED(actor, weaponentity) + attacktime * arate;
 
                if(autocvar_g_weaponswitch_debug_alternate && W_DualWielding(actor))
                {
 
                if(autocvar_g_weaponswitch_debug_alternate && W_DualWielding(actor))
                {
+                       int slot = weaponslot(weaponentity);
                        for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot)
                        {
                                if(slot == wepslot)
                        for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot)
                        {
                                if(slot == wepslot)
@@ -331,17 +330,17 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary,
                                .entity wepent = weaponentities[wepslot];
                                if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
                                {
                                .entity wepent = weaponentities[wepslot];
                                if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
                                {
-                                       if(ATTACK_FINISHED(actor, wepslot) > time + actor.(wepent).weapon_frametime * 0.5)
+                                       if(ATTACK_FINISHED(actor, wepent) > time + actor.(wepent).weapon_frametime * 0.5)
                                                continue; // still cooling down!
                                                continue; // still cooling down!
-                                       if (ATTACK_FINISHED(actor, wepslot) < time - actor.(wepent).weapon_frametime * 1.5)
-                                               ATTACK_FINISHED(actor, wepslot) = time;
-                                       ATTACK_FINISHED(actor, wepslot) = ATTACK_FINISHED(actor, wepslot) + (attacktime * arate) / MAX_WEAPONSLOTS;
+                                       if (ATTACK_FINISHED(actor, wepent) < time - actor.(wepent).weapon_frametime * 1.5)
+                                               ATTACK_FINISHED(actor, wepent) = time;
+                                       ATTACK_FINISHED(actor, wepent) = ATTACK_FINISHED(actor, wepent) + (attacktime * arate) / MAX_WEAPONSLOTS;
                                }
                        }
                }
        }
        this.bulletcounter += 1;
                                }
                        }
                }
        }
        this.bulletcounter += 1;
-       // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
+       // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, weaponentity)), "\n");
 }
 
 bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
 }
 
 bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
@@ -557,7 +556,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                entity oldwep = this.m_weapon;
 
                                // set up weapon switch think in the future, and start drop anim
                                entity oldwep = this.m_weapon;
 
                                // set up weapon switch think in the future, and start drop anim
-                               if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + this.weapon_frametime * 0.5)
+                               if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponentity) <= time + this.weapon_frametime * 0.5)
                                {
                                        sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
                                        this.state = WS_DROP;
                                {
                                        sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
                                        this.state = WS_DROP;
@@ -570,7 +569,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
 
        // LordHavoc: network timing test code
        // if (actor.button0)
 
        // LordHavoc: network timing test code
        // if (actor.button0)
-       //      print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, slot)), " >= ", ftos(this.weapon_nextthink), "\n");
+       //      print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, weaponentity)), " >= ", ftos(this.weapon_nextthink), "\n");
 
        Weapon w = this.m_weapon;
 
 
        Weapon w = this.m_weapon;
 
@@ -746,7 +745,7 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
        // so your weapon is disabled for a few seconds without reason
 
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
        // so your weapon is disabled for a few seconds without reason
 
-       // ATTACK_FINISHED(actor, slot) -= w_ent.reload_time - 1;
+       // ATTACK_FINISHED(actor, weaponentity) -= w_ent.reload_time - 1;
 
        w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
 }
 
        w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
 }
@@ -819,7 +818,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
        // so your weapon is disabled for a few seconds without reason
 
        // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
        // so your weapon is disabled for a few seconds without reason
 
-       // ATTACK_FINISHED(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + this.reload_time + 1;
+       // ATTACK_FINISHED(actor, weaponentity) = max(time, ATTACK_FINISHED(actor, weaponentity)) + this.reload_time + 1;
 
        weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, this.reload_time, W_ReloadedAndReady);
 
 
        weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, this.reload_time, W_ReloadedAndReady);