From fb6ec15079507c22d75d7c10967236c362ea99fb Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Jun 2018 19:24:43 +1000 Subject: [PATCH] Replace some ammo field references with resources --- qcsrc/common/monsters/monster/mage.qc | 23 ++++++++++++++----- qcsrc/common/t_items.qc | 24 ++++++++++---------- qcsrc/server/bot/default/havocbot/roles.qc | 10 ++++----- qcsrc/server/cheats.qc | 25 +++++++++++---------- qcsrc/server/client.qc | 26 +++++++++++----------- 5 files changed, 60 insertions(+), 48 deletions(-) diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 82b7d273c..b8b647bef 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -101,7 +101,15 @@ bool M_Mage_Defend_Heal_Check(entity this, entity targ) switch(this.skin) { case 0: return (targ.health < autocvar_g_balance_health_regenstable); - case 1: return ((targ.ammo_cells && targ.ammo_cells < g_pickup_cells_max) || (targ.ammo_plasma && targ.ammo_plasma < g_pickup_plasma_max) || (targ.ammo_rockets && targ.ammo_rockets < g_pickup_rockets_max) || (targ.ammo_nails && targ.ammo_nails < g_pickup_nails_max) || (targ.ammo_shells && targ.ammo_shells < g_pickup_shells_max)); + case 1: + { + return ((GetResourceAmount(targ, RESOURCE_CELLS) && GetResourceAmount(targ, RESOURCE_CELLS) < g_pickup_cells_max) + || (GetResourceAmount(targ, RESOURCE_PLASMA) && GetResourceAmount(targ, RESOURCE_PLASMA) < g_pickup_plasma_max) + || (GetResourceAmount(targ, RESOURCE_ROCKETS) && GetResourceAmount(targ, RESOURCE_ROCKETS) < g_pickup_rockets_max) + || (GetResourceAmount(targ, RESOURCE_BULLETS) && GetResourceAmount(targ, RESOURCE_BULLETS) < g_pickup_nails_max) + || (GetResourceAmount(targ, RESOURCE_SHELLS) && GetResourceAmount(targ, RESOURCE_SHELLS) < g_pickup_shells_max) + ); + } case 2: return (targ.armorvalue < autocvar_g_balance_armor_regenstable); case 3: return (targ.health > 0); } @@ -230,13 +238,16 @@ void M_Mage_Defend_Heal(entity this) fx = EFFECT_HEALING; break; case 1: - if(it.ammo_cells) it.ammo_cells = bound(it.ammo_cells, it.ammo_cells + 1, g_pickup_cells_max); - if(it.ammo_plasma) it.ammo_plasma = bound(it.ammo_plasma, it.ammo_plasma + 1, g_pickup_plasma_max); - if(it.ammo_rockets) it.ammo_rockets = bound(it.ammo_rockets, it.ammo_rockets + 1, g_pickup_rockets_max); - if(it.ammo_shells) it.ammo_shells = bound(it.ammo_shells, it.ammo_shells + 2, g_pickup_shells_max); - if(it.ammo_nails) it.ammo_nails = bound(it.ammo_nails, it.ammo_nails + 5, g_pickup_nails_max); + { + float tmpfld; + tmpfld = GetResourceAmount(it, RESOURCE_CELLS); if(tmpfld) SetResourceAmount(it, RESOURCE_CELLS, bound(tmpfld, tmpfld + 1, g_pickup_cells_max)); + tmpfld = GetResourceAmount(it, RESOURCE_PLASMA); if(tmpfld) SetResourceAmount(it, RESOURCE_PLASMA, bound(tmpfld, tmpfld + 1, g_pickup_plasma_max)); + tmpfld = GetResourceAmount(it, RESOURCE_ROCKETS); if(tmpfld) SetResourceAmount(it, RESOURCE_ROCKETS, bound(tmpfld, tmpfld + 1, g_pickup_rockets_max)); + tmpfld = GetResourceAmount(it, RESOURCE_SHELLS); if(tmpfld) SetResourceAmount(it, RESOURCE_SHELLS, bound(tmpfld, tmpfld + 2, g_pickup_shells_max)); + tmpfld = GetResourceAmount(it, RESOURCE_BULLETS); if(tmpfld) SetResourceAmount(it, RESOURCE_BULLETS, bound(tmpfld, tmpfld + 5, g_pickup_nails_max)); fx = EFFECT_AMMO_REGEN; break; + } case 2: if(it.armorvalue < autocvar_g_balance_armor_regenstable) { diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 5a849ee14..1426beb60 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -1103,23 +1103,23 @@ float ammo_pickupevalfunc(entity player, entity item) float noammorating = 0.5; - if ((need_shells) && (item.ammo_shells) && (player.ammo_shells < g_pickup_shells_max)) - c = item.ammo_shells / max(noammorating, player.ammo_shells); + if ((need_shells) && (item.ammo_shells) && (GetResourceAmount(player, RESOURCE_SHELLS) < g_pickup_shells_max)) + c = item.ammo_shells / max(noammorating, GetResourceAmount(player, RESOURCE_SHELLS)); - if ((need_nails) && (item.ammo_nails) && (player.ammo_nails < g_pickup_nails_max)) - c = item.ammo_nails / max(noammorating, player.ammo_nails); + if ((need_nails) && (item.ammo_nails) && (GetResourceAmount(player, RESOURCE_BULLETS) < g_pickup_nails_max)) + c = item.ammo_nails / max(noammorating, GetResourceAmount(player, RESOURCE_BULLETS)); - if ((need_rockets) && (item.ammo_rockets) && (player.ammo_rockets < g_pickup_rockets_max)) - c = item.ammo_rockets / max(noammorating, player.ammo_rockets); + if ((need_rockets) && (item.ammo_rockets) && (GetResourceAmount(player, RESOURCE_ROCKETS) < g_pickup_rockets_max)) + c = item.ammo_rockets / max(noammorating, GetResourceAmount(player, RESOURCE_ROCKETS)); - if ((need_cells) && (item.ammo_cells) && (player.ammo_cells < g_pickup_cells_max)) - c = item.ammo_cells / max(noammorating, player.ammo_cells); + if ((need_cells) && (item.ammo_cells) && (GetResourceAmount(player, RESOURCE_CELLS) < g_pickup_cells_max)) + c = item.ammo_cells / max(noammorating, GetResourceAmount(player, RESOURCE_CELLS)); - if ((need_plasma) && (item.ammo_plasma) && (player.ammo_plasma < g_pickup_plasma_max)) - c = item.ammo_plasma / max(noammorating, player.ammo_plasma); + if ((need_plasma) && (item.ammo_plasma) && (GetResourceAmount(player, RESOURCE_PLASMA) < g_pickup_plasma_max)) + c = item.ammo_plasma / max(noammorating, GetResourceAmount(player, RESOURCE_PLASMA)); - if ((need_fuel) && (item.ammo_fuel) && (player.ammo_fuel < g_pickup_fuel_max)) - c = item.ammo_fuel / max(noammorating, player.ammo_fuel); + if ((need_fuel) && (item.ammo_fuel) && (GetResourceAmount(player, RESOURCE_FUEL) < g_pickup_fuel_max)) + c = item.ammo_fuel / max(noammorating, GetResourceAmount(player, RESOURCE_FUEL)); rating *= min(c, 2); if(wpn) diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 4c70c1b1b..80a0f8003 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -52,11 +52,11 @@ bool havocbot_goalrating_item_can_be_left_to_teammate(entity this, entity player if (item.health && player.health <= this.health) {return true;} if (item.armorvalue && player.armorvalue <= this.armorvalue) {return true;} if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;} - if (item.ammo_shells && player.ammo_shells <= this.ammo_shells) {return true;} - if (item.ammo_nails && player.ammo_nails <= this.ammo_nails) {return true;} - if (item.ammo_rockets && player.ammo_rockets <= this.ammo_rockets) {return true;} - if (item.ammo_cells && player.ammo_cells <= this.ammo_cells) {return true;} - if (item.ammo_plasma && player.ammo_plasma <= this.ammo_plasma) {return true;} + if (item.ammo_shells && GetResourceAmount(player, RESOURCE_SHELLS) <= GetResourceAmount(this, RESOURCE_SHELLS)) {return true;} + if (item.ammo_nails && GetResourceAmount(player, RESOURCE_BULLETS) <= GetResourceAmount(this, RESOURCE_BULLETS)) {return true;} + if (item.ammo_rockets && GetResourceAmount(player, RESOURCE_ROCKETS) <= GetResourceAmount(this, RESOURCE_ROCKETS)) {return true;} + if (item.ammo_cells && GetResourceAmount(player, RESOURCE_CELLS) <= GetResourceAmount(this, RESOURCE_CELLS)) {return true;} + if (item.ammo_plasma && GetResourceAmount(player, RESOURCE_PLASMA) <= GetResourceAmount(this, RESOURCE_PLASMA)) {return true;} if (item.itemdef.instanceOfPowerup) {return true;} return false; diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 0b3c1b27d..9751c6cf2 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -3,6 +3,7 @@ #include #include #include +#include #include "g_damage.qh" #include "race.qh" @@ -152,12 +153,12 @@ float CheatImpulse(entity this, int imp) this.personal.origin = this.origin; this.personal.v_angle = this.v_angle; this.personal.velocity = this.velocity; - this.personal.ammo_rockets = this.ammo_rockets; - this.personal.ammo_nails = this.ammo_nails; - this.personal.ammo_cells = this.ammo_cells; - this.personal.ammo_plasma = this.ammo_plasma; - this.personal.ammo_shells = this.ammo_shells; - this.personal.ammo_fuel = this.ammo_fuel; + SetResourceAmount(this.personal, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS)); + SetResourceAmount(this.personal, RESOURCE_BULLETS, GetResourceAmount(this, RESOURCE_BULLETS)); + SetResourceAmount(this.personal, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS)); + SetResourceAmount(this.personal, RESOURCE_PLASMA, GetResourceAmount(this, RESOURCE_PLASMA)); + SetResourceAmount(this.personal, RESOURCE_SHELLS, GetResourceAmount(this, RESOURCE_SHELLS)); + SetResourceAmount(this.personal, RESOURCE_FUEL, GetResourceAmount(this, RESOURCE_FUEL)); this.personal.health = max(1, this.health); this.personal.armorvalue = this.armorvalue; STAT(WEAPONS, this.personal) = STAT(WEAPONS, this); @@ -211,12 +212,12 @@ float CheatImpulse(entity this, int imp) MUTATOR_CALLHOOK(AbortSpeedrun, this); } - this.ammo_rockets = this.personal.ammo_rockets; - this.ammo_nails = this.personal.ammo_nails; - this.ammo_cells = this.personal.ammo_cells; - this.ammo_plasma = this.personal.ammo_plasma; - this.ammo_shells = this.personal.ammo_shells; - this.ammo_fuel = this.personal.ammo_fuel; + SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this.personal, RESOURCE_ROCKETS)); + SetResourceAmount(this, RESOURCE_BULLETS, GetResourceAmount(this.personal, RESOURCE_BULLETS)); + SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this.personal, RESOURCE_CELLS)); + SetResourceAmount(this, RESOURCE_PLASMA, GetResourceAmount(this.personal, RESOURCE_PLASMA)); + SetResourceAmount(this, RESOURCE_SHELLS, GetResourceAmount(this.personal, RESOURCE_SHELLS)); + SetResourceAmount(this, RESOURCE_FUEL, GetResourceAmount(this.personal, RESOURCE_FUEL)); this.health = this.personal.health; this.armorvalue = this.personal.armorvalue; STAT(WEAPONS, this) = STAT(WEAPONS, this.personal); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 1bd7edcd9..dd23c7b99 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -557,22 +557,22 @@ void PutPlayerInServer(entity this) this.effects = EF_TELEPORT_BIT | EF_RESTARTANIM_BIT; if (warmup_stage) { - this.ammo_shells = warmup_start_ammo_shells; - this.ammo_nails = warmup_start_ammo_nails; - this.ammo_rockets = warmup_start_ammo_rockets; - this.ammo_cells = warmup_start_ammo_cells; - this.ammo_plasma = warmup_start_ammo_plasma; - this.ammo_fuel = warmup_start_ammo_fuel; + SetResourceAmount(this, RESOURCE_SHELLS, warmup_start_ammo_shells); + SetResourceAmount(this, RESOURCE_BULLETS, warmup_start_ammo_nails); + SetResourceAmount(this, RESOURCE_ROCKETS, warmup_start_ammo_rockets); + SetResourceAmount(this, RESOURCE_CELLS, warmup_start_ammo_cells); + SetResourceAmount(this, RESOURCE_PLASMA, warmup_start_ammo_plasma); + SetResourceAmount(this, RESOURCE_FUEL, warmup_start_ammo_fuel); this.health = warmup_start_health; this.armorvalue = warmup_start_armorvalue; STAT(WEAPONS, this) = WARMUP_START_WEAPONS; } else { - this.ammo_shells = start_ammo_shells; - this.ammo_nails = start_ammo_nails; - this.ammo_rockets = start_ammo_rockets; - this.ammo_cells = start_ammo_cells; - this.ammo_plasma = start_ammo_plasma; - this.ammo_fuel = start_ammo_fuel; + SetResourceAmount(this, RESOURCE_SHELLS, start_ammo_shells); + SetResourceAmount(this, RESOURCE_BULLETS, start_ammo_nails); + SetResourceAmount(this, RESOURCE_ROCKETS, start_ammo_rockets); + SetResourceAmount(this, RESOURCE_CELLS, start_ammo_cells); + SetResourceAmount(this, RESOURCE_PLASMA, start_ammo_plasma); + SetResourceAmount(this, RESOURCE_FUEL, start_ammo_fuel); this.health = start_health; this.armorvalue = start_armorvalue; STAT(WEAPONS, this) = start_weapons; @@ -1772,7 +1772,7 @@ void SpectateCopy(entity this, entity spectatee) PS(this) = PS(spectatee); this.armortype = spectatee.armortype; this.armorvalue = spectatee.armorvalue; - this.ammo_cells = spectatee.ammo_cells; + this.ammo_cells = spectatee.ammo_cells; // TODO: these will be a part of inventory, so no need to worry about setting them later! this.ammo_plasma = spectatee.ammo_plasma; this.ammo_shells = spectatee.ammo_shells; this.ammo_nails = spectatee.ammo_nails; -- 2.39.2