From: Mario Date: Mon, 3 Oct 2016 07:04:41 +0000 (+1000) Subject: Move weapon load to the weapon entity X-Git-Tag: xonotic-v0.8.2~326^2~75^2 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=88f270954b0d67db3347987fe122ca317da74093 Move weapon load to the weapon entity --- diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 6dd82109b3..b1fd56722f 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -845,7 +845,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) if(player.buffs & BUFF_AMMO.m_itemid) if(player.(weaponentity).clip_size) - player.(weaponentity).clip_load = player.(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + player.(weaponentity).clip_load = player.(weaponentity).(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) @@ -874,7 +874,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) 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; + player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; } BUFF_ONREM(BUFF_AMMO) diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index 7804c07329..8067f791a7 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -165,7 +165,13 @@ void NIX_GiveCurrentWeapon(entity this) // all weapons must be fully loaded when we spawn if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars - this.(weapon_load[nix_weapon]) = e.reloading_ammo; + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + this.(weaponentity).(weapon_load[nix_weapon]) = e.reloading_ammo; + } + } // vortex too if(WEP_CVAR(vortex, charge)) diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 05a036379c..30e6174adc 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -86,7 +86,7 @@ METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entit float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) - ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); return ammo_amount; } @@ -96,7 +96,7 @@ METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entit float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) - ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); return ammo_amount; } diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index bf37d12fec..b4dec46261 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -140,7 +140,7 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo); - ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo); return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index c453870127..b0eafdc081 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -844,7 +844,7 @@ METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponenti if(WEP_CVAR(arc, bolt)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo); - ammo_amount += actor.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo); return ammo_amount; } else diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index c1fdf55324..b820e94526 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -650,7 +650,7 @@ METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor, .entity weapon return true; float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo); - ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo); return ammo_amount; } METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -660,7 +660,7 @@ METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon return true; float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo); - ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo); return ammo_amount; } METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 1a74ca1bb9..db014bb861 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -546,7 +546,7 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea ammo_amount = false; if(WEP_CVAR(devastator, reload_ammo)) { - if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) + if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo)) ammo_amount = true; } else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo)) @@ -563,13 +563,13 @@ METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); - ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE")); return ammo_amount; } #else float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo); - ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo); return ammo_amount; #endif } diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 732ad07645..15387a9058 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -556,7 +556,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo); return ammo_amount; } METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -565,12 +565,12 @@ METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false. { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo); } else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo); - ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo); } return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index f459e949b8..a4bf9cfc19 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -323,7 +323,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) if(actor.items & IT_UNLIMITED_WEAPON_AMMO) enough_ammo = true; else if(autocvar_g_balance_hagar_reload_ammo) - enough_ammo = actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); + enough_ammo = actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); else enough_ammo = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo); @@ -508,13 +508,13 @@ METHOD(Hagar, wr_setup, void(entity thiswep, entity actor)) METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo); - ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo); return ammo_amount; } METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo); - ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo); return ammo_amount; } METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor)) diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 93bc52491a..ba2b7f3514 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -242,13 +242,13 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo); - ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo); return ammo_amount; } METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo); - ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo); return ammo_amount; } METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 0c7a59d6ee..009285b8c7 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -323,9 +323,9 @@ METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity wea if(WEP_CVAR(machinegun, reload_ammo)) { if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo); else - ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo); } return ammo_amount; } @@ -340,9 +340,9 @@ METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity wea if(WEP_CVAR(machinegun, reload_ammo)) { if(WEP_CVAR(machinegun, mode) == 1) - ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo); else - ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo); } return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index c8d242fa41..4f1ee2aef0 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -532,7 +532,7 @@ METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weap //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER) //{ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo); - ammo_amount += actor.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo); return ammo_amount; //} //return true; diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index ac64e1cc70..43119d45ae 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -384,13 +384,13 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo); - ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo); return ammo_amount; } METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo); - ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo); return ammo_amount; } METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 2972106574..c1835f1007 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -204,13 +204,13 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo); - ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo); return ammo_amount; } METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo); - ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo); return ammo_amount; } METHOD(Rifle, wr_resetplayer, void(entity thiswep, entity actor)) diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index ad93165d44..24158cc290 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -673,12 +673,12 @@ METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weapone if(WEP_CVAR(seeker, type) == 1) { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo); } else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } return ammo_amount; } @@ -688,12 +688,12 @@ METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapone if(WEP_CVAR(seeker, type) == 1) { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } else { ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo); } return ammo_amount; } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index d9f1d9995a..3dee669c41 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -288,7 +288,7 @@ METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor)) METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); - ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -302,7 +302,7 @@ METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapon case 2: // secondary triple shot { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo); - ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo); return ammo_amount; } default: return false; // secondary unavailable diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 5e94532226..c16371bea0 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -443,7 +443,7 @@ METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weap { float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo; - ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo; + ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo; return ammo_amount; } METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -451,7 +451,7 @@ METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weap if(!WEP_CVAR_SEC(vaporizer, ammo)) return true; float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo); - ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo); return ammo_amount; } METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor)) diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 4a185ecb3b..7adfd85101 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -297,7 +297,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity { 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.(weaponentity).clip_load; + actor.(weaponentity).(weapon_load[WEP_VORTEX.m_id]) = actor.(weaponentity).clip_load; } else { @@ -338,7 +338,7 @@ METHOD(Vortex, wr_setup, void(entity thiswep, entity actor)) METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo); - ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo)); + ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo)); return ammo_amount; } METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) @@ -347,7 +347,7 @@ METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapone { // don't allow charging if we don't have enough ammo float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo); - ammo_amount += actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo); return ammo_amount; } else diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 71d36ab7ab..159cd6e729 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -169,7 +169,7 @@ void havocbot_ai(entity this) if(this.(weaponentity).clip_load >= 0) // only if we're not reloading a weapon already { 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)) + if((this.weapons & (it.m_wepset)) && (it.spawnflags & WEP_FLAG_RELOADABLE) && (this.(weaponentity).weapon_load[it.m_id] < it.reloading_ammo)) this.(weaponentity).m_switchweapon = it; )); } @@ -996,10 +996,10 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon) return false; // if this weapon is scheduled for reloading, don't switch to it during combat - if (this.weapon_load[new_weapon] < 0) + .entity weaponentity = weaponentities[0]; // TODO: unhardcode + if (this.(weaponentity).weapon_load[new_weapon] < 0) { bool other_weapon_available = false; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode FOREACH(Weapons, it != WEP_Null, LAMBDA( if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity)) other_weapon_available = true; diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index a9b9e6e7e2..f936ef782d 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -671,7 +671,11 @@ void PutClientInServer(entity this) it.wr_resetplayer(it, this); // reload all reloadable weapons if (it.spawnflags & WEP_FLAG_RELOADABLE) { - this.weapon_load[it.m_id] = it.reloading_ammo; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + this.(weaponentity).weapon_load[it.m_id] = it.reloading_ammo; + } } )); diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index e0e1e9db66..10fead1a61 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -98,10 +98,10 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto { // if our weapon is loaded, give its load back to the player int i = own.(weaponentity).m_weapon.m_id; - if(own.(weapon_load[i]) > 0) + if(own.(weaponentity).(weapon_load[i]) > 0) { - own.(ammotype) += own.(weapon_load[i]); - own.(weapon_load[i]) = -1; // schedule the weapon for reloading + own.(ammotype) += own.(weaponentity).(weapon_load[i]); + own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading } wep.(ammotype) = 0; @@ -110,10 +110,10 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto { // if our weapon is loaded, give its load back to the player int i = own.(weaponentity).m_weapon.m_id; - if(own.(weapon_load[i]) > 0) + if(own.(weaponentity).(weapon_load[i]) > 0) { - own.(ammotype) += own.(weapon_load[i]); - own.(weapon_load[i]) = -1; // schedule the weapon for reloading + own.(ammotype) += own.(weaponentity).(weapon_load[i]); + own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading } thisammo = min(own.(ammotype), wep.(ammotype)); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 3b3e1b0e01..f02c8f9814 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -491,7 +491,7 @@ 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 { - this.clip_load = actor.(weapon_load[this.m_switchweapon.m_id]); + this.clip_load = actor.(weaponentity).(weapon_load[this.m_switchweapon.m_id]); this.clip_size = newwep.reloading_ammo; } else @@ -643,7 +643,7 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti if (wep.reloading_ammo) { actor.(weaponentity).clip_load -= ammo_use; - actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load; + actor.(weaponentity).(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load; } else if (wep.ammo_field != ammo_none) { @@ -687,7 +687,7 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int actor.(weaponentity).clip_load += load; actor.(actor.ammo_field) -= load; } - actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = actor.(weaponentity).clip_load; + actor.(weaponentity).(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, @@ -775,7 +775,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen 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; + this.clip_load = actor.(weaponentity).(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)