Hold weapon clip on the weapon entity
authorMario <mario@smbclan.net>
Mon, 3 Oct 2016 06:54:00 +0000 (16:54 +1000)
committerMario <mario@smbclan.net>
Mon, 3 Oct 2016 06:54:00 +0000 (16:54 +1000)
19 files changed:
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.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/mortar.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/client.qc
qcsrc/server/weapons/weaponsystem.qc

index 0bd8ae98c88f55356c1db2574f964c5c77f3c3ae..6dd82109b32de17854265aa298be74f3f7c70b6a 100644 (file)
@@ -844,8 +844,8 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
        if(player.buffs & BUFF_AMMO.m_itemid)
-       if(player.clip_size)
-               player.clip_load = player.(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.clip_size;
+       if(player.(weaponentity).clip_size)
+               player.(weaponentity).clip_load = player.(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
 
        if((player.buffs & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid))
        if(player.alpha != autocvar_g_buffs_invisible_alpha)
@@ -872,9 +872,9 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                        player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO);
                        player.items |= IT_UNLIMITED_WEAPON_AMMO;
 
-                       if(player.clip_load)
-                               player.buff_ammo_prev_clipload = player.clip_load;
-                       player.clip_load = player.(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.clip_size;
+                       if(player.(weaponentity).clip_load)
+                               player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load;
+                       player.(weaponentity).clip_load = player.(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size;
                }
 
                BUFF_ONREM(BUFF_AMMO)
@@ -884,8 +884,8 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                        else
                                player.items &= ~IT_UNLIMITED_WEAPON_AMMO;
 
-                       if(player.buff_ammo_prev_clipload)
-                               player.clip_load = player.buff_ammo_prev_clipload;
+                       if(player.(weaponentity).buff_ammo_prev_clipload)
+                               player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload;
                }
 
                BUFF_ONADD(BUFF_INVISIBLE)
index 8a1de98ada5cbb2f1fd3ec8a11dc8bf6333e88ea..05a036379c01f032ecab23150fba56e693eba3b7 100644 (file)
@@ -68,7 +68,7 @@ METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor))
 
 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
+    if(WEP_CVAR(hmg, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(hmg, ammo)) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
     {
index b9d61ee931ee4e216a83953c1cededcaa7b4c698..bf37d12fecf9262526ab9b08da2ea8096a57bd5c 100644 (file)
@@ -117,7 +117,7 @@ METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
 
 METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) {
+    if(WEP_CVAR(rpc, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(rpc, ammo)) {
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
     {
index 8b09240b6089ea8f75e48ca733aa0f4a9b610e93..c1fdf553246fd194fe6d44b9647f3894e33df726 100644 (file)
@@ -588,7 +588,7 @@ METHOD(Crylink, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
+    if(autocvar_g_balance_crylink_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     }
 
index 13a13927f611f28d3596bb22eda582f95856cc8a..1a74ca1bb91df18aa3459b30b42b9e743e2ee224 100644 (file)
@@ -498,7 +498,7 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
 
 METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
+    if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else {
        int slot = weaponslot(weaponentity);
index 33299f653d66dfcc59d394928350ab82eb466fbb..732ad0764592af4d8cd1a923284ff18b42577fda 100644 (file)
@@ -521,9 +521,9 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit
     if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
     {
         float ammo_amount = 0;
-        if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo))
+        if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo))
             ammo_amount = 1;
-        if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo))
+        if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo))
             ammo_amount += 1;
 
         if(!ammo_amount)
index e6c1f8d2617dbdeaa068fe1c6f92d30bf8fb0eac..f459e949b81acec28b5c4cb693129cc431eddc85 100644 (file)
@@ -465,7 +465,7 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
 
     if(loadable_secondary)
         W_Hagar_Attack2_Load(thiswep, actor, weaponentity); // must always run each frame
-    if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
+    if(autocvar_g_balance_hagar_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     }
     else if((fire & 1) && !actor.(weaponentity).hagar_load && !actor.(weaponentity).hagar_loadblock) // not while secondary is loaded or awaiting reset
index 161f402be02833b4d4117bf5f9098dc8d2f91bc7..93bc52491a097ccc57c7fb6cc3ef645bbbfd2a33 100644 (file)
@@ -218,7 +218,7 @@ METHOD(HLAC, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
+    if(autocvar_g_balance_hlac_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else if(fire & 1)
     {
index 0116e7d39bc5beeac839d588867f231853d52e51..0c7a59d6ee09cf1547fb8b036d5d18ac5cfd5d1f 100644 (file)
@@ -263,7 +263,7 @@ METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload
+    if(WEP_CVAR(machinegun, reload_ammo) && actor.(weaponentity).clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
     if(WEP_CVAR(machinegun, mode) == 1)
index cff18ef705eb500ca216a7bbf06173dc5272a191..c8d242fa41ea19e8f22c83d460dea9f64d99eafb 100644 (file)
@@ -503,7 +503,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
+    if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
     {
         // not if we're holding the minelayer without enough ammo, but can detonate existing mines
         if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
index dcb8a7121638eebf6f9b66be54ff50c023f1e482..ac64e1cc7009dd183f232dfe1fe15c8b13fa269d 100644 (file)
@@ -348,7 +348,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor))
     */
 METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload
+    if(autocvar_g_balance_mortar_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else if(fire & 1)
     {
index 64242bed6c86eadbc4313238454c2db38f3b529a..2972106574172133dbb58cb739051fcd34e621b0 100644 (file)
@@ -168,7 +168,7 @@ METHOD(Rifle, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
+    if(autocvar_g_balance_rifle_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
     {
index 5439430432f28085c473311a5ce56c6bbdaa7585..ad93165d44caea81e4dc17df59a9b4cfa2002e3d 100644 (file)
@@ -625,7 +625,7 @@ METHOD(Seeker, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
+    if(autocvar_g_balance_seeker_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else if(fire & 1)
     {
index 6a30a92f982216ec5e72384a2ef176caa5c2ce24..d9f1d9995a1dde48cd79f2e3a0a4397540f83740 100644 (file)
@@ -236,7 +236,7 @@ METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(shotgun, reload_ammo) && actor.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload
+    if(WEP_CVAR(shotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload
     {
         // don't force reload an empty shotgun if its melee attack is active
         if(WEP_CVAR(shotgun, secondary) < 2) {
@@ -272,7 +272,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
             }
         }
     }
-    if(actor.clip_load >= 0) // we are not currently reloading
+    if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
     if(WEP_CVAR(shotgun, secondary) == 1)
     if(((fire & 1) && actor.(thiswep.ammo_field) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
     if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire)))
index 2ce5cb01b110d2cabdc0afd856d8d66e591354db..5e9453222636503af78868229c6b707e51c6afe1 100644 (file)
@@ -363,9 +363,9 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
 {
     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
     // if the laser uses load, we also consider its ammo for reloading
-    if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
+    if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.(weaponentity).clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
-    } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload
+    } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.(weaponentity).clip_load < vaporizer_ammo) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     }
     if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
index eca15feca0e4401bd036f1783608410289ba9125..4a185ecb3b3c953dde0c8a1605c97409719bde14 100644 (file)
@@ -244,7 +244,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
     if(weaponslot(weaponentity) == 0)
         actor.vortex_chargepool_ammo = actor.(weaponentity).vortex_chargepool_ammo;
 
-    if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
+    if(autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     } else
     {
@@ -291,13 +291,13 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
                                 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
                                 if(autocvar_g_balance_vortex_reload_ammo)
                                 {
-                                    dt = min(dt, (actor.clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
+                                    dt = min(dt, (actor.(weaponentity).clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
                                     dt = max(0, dt);
                                     if(dt > 0)
                                     {
-                                        actor.clip_load = max(WEP_CVAR_SEC(vortex, ammo), actor.clip_load - WEP_CVAR_SEC(vortex, ammo) * dt);
+                                        actor.(weaponentity).clip_load = max(WEP_CVAR_SEC(vortex, ammo), actor.(weaponentity).clip_load - WEP_CVAR_SEC(vortex, ammo) * dt);
                                     }
-                                    actor.(weapon_load[WEP_VORTEX.m_id]) = actor.clip_load;
+                                    actor.(weapon_load[WEP_VORTEX.m_id]) = actor.(weaponentity).clip_load;
                                 }
                                 else
                                 {
index c721c0639ed134df077cf5223494d0c3b056d812..71d36ab7ab8f08e2e13bc4e4a05a9089fae0a0e8 100644 (file)
@@ -156,17 +156,18 @@ void havocbot_ai(entity this)
        // if the bot is not attacking, consider reloading weapons
        if (!(this.aistatus & AI_STATUS_ATTACKING))
        {
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+
                // we are currently holding a weapon that's not fully loaded, reload it
                if(skill >= 2) // bots can only reload the held weapon on purpose past this skill
-               if(this.clip_load < this.clip_size)
+               if(this.(weaponentity).clip_load < this.(weaponentity).clip_size)
                        this.impulse = 20; // "press" the reload button, not sure if this is done right
 
                // if we're not reloading a weapon, switch to any weapon in our invnetory that's not fully loaded to reload it next
                // the code above executes next frame, starting the reloading then
                if(skill >= 5) // bots can only look for unloaded weapons past this skill
-               if(this.clip_load >= 0) // only if we're not reloading a weapon already
+               if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already
                {
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        FOREACH(Weapons, it != WEP_Null, LAMBDA(
                                if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.weapon_load[it.m_id] < it.reloading_ammo))
                                        this.(weaponentity).m_switchweapon = it;
index 0d4d1e6204001e9ffbee8e26c95ea20a5b6d527d..a9b9e6e7e265b7480d0432dc0908bcbaebb61659 100644 (file)
@@ -2432,6 +2432,12 @@ void PlayerPreThink (entity this)
                        {
                                .entity weaponentity = weaponentities[slot];
                                W_WeaponFrame(this, weaponentity);
+
+                               if(slot == 0)
+                               {
+                                       this.clip_load = this.(weaponentity).clip_load;
+                                       this.clip_size = this.(weaponentity).clip_size;
+                               }
                        }
 
                        this.items_added = 0;
@@ -2506,9 +2512,12 @@ void PlayerPreThink (entity this)
 
        // WEAPONTODO: Move into weaponsystem somehow
        // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
-       .entity weaponentity = weaponentities[0];
-       if (this.(weaponentity).m_weapon == WEP_Null)
-               this.clip_load = this.clip_size = 0;
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity).m_weapon == WEP_Null)
+                       this.(weaponentity).clip_load = this.(weaponentity).clip_size = 0;
+       }
 }
 
 void DrownPlayer(entity this)
index c68c452b9cb48d250cae21acee102bcf6418d13a..3b3e1b0e01892bed75eb766bff52783610ec16cd 100644 (file)
@@ -491,12 +491,12 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                // set our clip load to the load of the weapon we switched to, if it's reloadable
                                if ((newwep.spawnflags & WEP_FLAG_RELOADABLE) && newwep.reloading_ammo)  // prevent accessing undefined cvars
                                {
-                                       actor.clip_load = actor.(weapon_load[this.m_switchweapon.m_id]);
-                                       actor.clip_size = newwep.reloading_ammo;
+                                       this.clip_load = actor.(weapon_load[this.m_switchweapon.m_id]);
+                                       this.clip_size = newwep.reloading_ammo;
                                }
                                else
                                {
-                                       actor.clip_load = actor.clip_size = 0;
+                                       this.clip_load = this.clip_size = 0;
                                }
 
                                weapon_thinkf(actor, weaponentity, WFRAME_IDLE, newwep.switchdelay_raise, w_ready);
@@ -642,8 +642,8 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti
        // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
        if (wep.reloading_ammo)
        {
-               actor.clip_load -= ammo_use;
-               actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.clip_load;
+               actor.(weaponentity).clip_load -= ammo_use;
+               actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load;
        }
        else if (wep.ammo_field != ammo_none)
        {
@@ -673,27 +673,27 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int
 {
        // finish the reloading process, and do the ammo transfer
 
-       actor.clip_load = actor.old_clip_load;  // restore the ammo counter, in case we still had ammo in the weapon before reloading
+       actor.(weaponentity).clip_load = actor.(weaponentity).old_clip_load;  // restore the ammo counter, in case we still had ammo in the weapon before reloading
 
        // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load
-       if (!actor.reload_ammo_min || actor.items & IT_UNLIMITED_WEAPON_AMMO || actor.ammo_field == ammo_none)
+       if (!actor.(weaponentity).reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || actor.ammo_field == ammo_none)
        {
-               actor.clip_load = actor.reload_ammo_amount;
+               actor.(weaponentity).clip_load = actor.(weaponentity).reload_ammo_amount;
        }
        else
        {
                // make sure we don't add more ammo than we have
-               float load = min(actor.reload_ammo_amount - actor.clip_load, actor.(actor.ammo_field));
-               actor.clip_load += load;
+               float load = min(actor.(weaponentity).reload_ammo_amount - actor.(weaponentity).clip_load, actor.(actor.ammo_field));
+               actor.(weaponentity).clip_load += load;
                actor.(actor.ammo_field) -= load;
        }
-       actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.clip_load;
+       actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load;
 
        // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
        // 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) -= actor.reload_time - 1;
+       // ATTACK_FINISHED(actor, slot) -= actor.(weaponentity).reload_time - 1;
 
        Weapon wpn = Weapons_from(actor.(weaponentity).m_weapon.m_id);
        w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
@@ -707,9 +707,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
 
        if (MUTATOR_CALLHOOK(W_Reload, actor)) return;
 
-       actor.reload_ammo_min = sent_ammo_min;
-       actor.reload_ammo_amount = e.reloading_ammo;
-       actor.reload_time = e.reloading_time;
+       actor.(weaponentity).reload_ammo_min = sent_ammo_min;
+       actor.(weaponentity).reload_ammo_amount = e.reloading_ammo;
+       actor.(weaponentity).reload_time = e.reloading_time;
        if (actor.reload_sound) strunzone(actor.reload_sound);
        actor.reload_sound = strzone(Sound_fixpath(sent_sound));
 
@@ -722,15 +722,15 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
        }
 
        // return if reloading is disabled for this weapon
-       if (!actor.reload_ammo_amount) return;
+       if (!actor.(weaponentity).reload_ammo_amount) return;
 
        // our weapon is fully loaded, no need to reload
-       if (actor.clip_load >= actor.reload_ammo_amount) return;
+       if (actor.(weaponentity).clip_load >= actor.(weaponentity).reload_ammo_amount) return;
 
        // no ammo, so nothing to load
        if (actor.ammo_field != ammo_none)
        {
-               if (!actor.(actor.ammo_field) && actor.reload_ammo_min)
+               if (!actor.(actor.ammo_field) && actor.(weaponentity).reload_ammo_min)
                {
                        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                        {
@@ -744,7 +744,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen
                                Weapon w = actor.(weaponentity).m_weapon;
                                if (!(w.wr_checkammo1(w, actor, weaponentity) + w.wr_checkammo2(w, actor, weaponentity)))
                                {
-                                       actor.clip_load = -1;  // reload later
+                                       actor.(weaponentity).clip_load = -1;  // reload later
                                        W_SwitchToOtherWeapon(actor, weaponentity);
                                }
                                return;
@@ -769,13 +769,13 @@ 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
 
-       // ATTACK_FINISHED(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + actor.reload_time + 1;
+       // ATTACK_FINISHED(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + actor.(weaponentity).reload_time + 1;
 
-       weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady);
+       weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, actor.(weaponentity).reload_time, W_ReloadedAndReady);
 
-       if (actor.clip_load < 0) actor.clip_load = 0;
-       actor.old_clip_load = actor.clip_load;
-       actor.clip_load = actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = -1;
+       if (this.clip_load < 0) this.clip_load = 0;
+       this.old_clip_load = this.clip_load;
+       this.clip_load = actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = -1;
 }
 
 void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)