From: Mario Date: Mon, 3 Oct 2016 06:54:00 +0000 (+1000) Subject: Hold weapon clip on the weapon entity X-Git-Tag: xonotic-v0.8.2~326^2~76^2 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=29cced5bd174a8f030cebbc195b60ed3bcd512e3 Hold weapon clip on the weapon entity --- diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 0bd8ae98c8..6dd82109b3 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 8a1de98ada..05a036379c 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -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 { diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index b9d61ee931..bf37d12fec 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -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 { diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 8b09240b60..c1fdf55324 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -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); } diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 13a13927f6..1a74ca1bb9 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 33299f653d..732ad07645 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index e6c1f8d261..f459e949b8 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 161f402be0..93bc52491a 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 0116e7d39b..0c7a59d6ee 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index cff18ef705..c8d242fa41 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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))) { diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index dcb8a71216..ac64e1cc70 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 64242bed6c..2972106574 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -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 { diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 5439430432..ad93165d44 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 6a30a92f98..d9f1d9995a 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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))) diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 2ce5cb01b1..5e94532226 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -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)) diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index eca15feca0..4a185ecb3b 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -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 { diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index c721c0639e..71d36ab7ab 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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; diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 0d4d1e6204..a9b9e6e7e2 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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) diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index c68c452b9c..3b3e1b0e01 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -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)