]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/hmg.qc
Weapons: pass weaponentity field instead of slot
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / hmg.qc
index c7ae7d43b5aa84a7c9103c30c67b025dfb77db6f..a46f19eb0425265d51d865eff0d588fa188e34b1 100644 (file)
@@ -45,11 +45,11 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 
 spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); }
 
-void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int fire)
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
        if (!actor.BUTTON_ATCK)
        {
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -58,7 +58,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
-               w_ready(thiswep, actor, slot, fire);
+               w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
 
@@ -85,8 +85,9 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
        if (autocvar_g_casings >= 2) // casing code
                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);
 
+       int slot = weaponslot(weaponentity);
        ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor();
-       weapon_thinkf(actor, slot, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
+       weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
 }
 
                METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
@@ -96,7 +97,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
                }
-               METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, int slot, int fire))
+               METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
                {
                        if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
                                Weapon w = get_weaponinfo(actor.weapon);
@@ -104,10 +105,10 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int slot, int f
                        } else
                        {
                                if (fire & 1)
-                               if (weapon_prepareattack(thiswep, actor, slot, false, 0))
+                               if (weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
                                {
                                        actor.misc_bulletcounter = 0;
-                                       W_HeavyMachineGun_Attack_Auto(thiswep, actor, slot, fire);
+                                       W_HeavyMachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
                                }
                        }
                }