From: Mario Date: Sat, 16 Jun 2018 18:15:25 +0000 (+1000) Subject: Clean up some unnecessary uses of SetResourceAmountExplicit X-Git-Tag: xonotic-v0.8.5~2030 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e0c217a67fdae8d5fc9cf94de996cb4724e9e668;p=xonotic%2Fxonotic-data.pk3dir.git Clean up some unnecessary uses of SetResourceAmountExplicit --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 2157770cf..15aedc732 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -469,7 +469,7 @@ void ons_ControlPoint_Icon_Think(entity this) _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE); _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE); - SetResourceAmountExplicit(this, RESOURCE_HEALTH, bound(0, GetResourceAmount(this, RESOURCE_HEALTH) + (_friendly_count - _enemy_count), this.max_health)); + GiveResourceWithLimit(this, RESOURCE_HEALTH, (_friendly_count - _enemy_count), this.max_health); this.SendFlags |= CPSF_STATUS; if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) { @@ -524,7 +524,7 @@ void ons_ControlPoint_Icon_BuildThink(entity this) if(!a) return; - SetResourceAmountExplicit(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH) + this.count); + GiveResource(this, RESOURCE_HEALTH, this.count); this.SendFlags |= CPSF_STATUS; diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 8497bde05..63f4418de 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -1009,7 +1009,7 @@ void Monster_Damage(entity this, entity inflictor, entity attacker, float damage if(take) { - SetResourceAmountExplicit(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH) - take); + TakeResource(this, RESOURCE_HEALTH, take); Monster_Sound(this, monstersound_pain, 1.2, true, CH_PAIN); } diff --git a/qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc b/qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc index 7cec1f790..319b51866 100644 --- a/qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc +++ b/qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc @@ -28,11 +28,11 @@ MUTATOR_HOOKFUNCTION(vh, GrappleHookThink) thehook.owner.damage_dealt += autocvar_g_vampirehook_damage; Damage(dmgent, thehook, thehook.owner, autocvar_g_vampirehook_damage, WEP_HOOK.m_id, DMG_NOWEP, thehook.origin, '0 0 0'); if(SAME_TEAM(thehook.owner, thehook.aiment)) - SetResourceAmountExplicit(thehook.aiment, RESOURCE_HEALTH, min(GetResourceAmount(thehook.aiment, RESOURCE_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max)); + GiveResourceWithLimit(thehook.aiment, RESOURCE_HEALTH, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max); else - SetResourceAmountExplicit(thehook.owner, RESOURCE_HEALTH, min(GetResourceAmount(thehook.owner, RESOURCE_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max)); + GiveResourceWithLimit(thehook.owner, RESOURCE_HEALTH, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max); if(dmgent == thehook.owner) - SetResourceAmountExplicit(dmgent, RESOURCE_HEALTH, GetResourceAmount(dmgent, RESOURCE_HEALTH) - autocvar_g_vampirehook_damage); // FIXME: friendly fire?!s + TakeResource(dmgent, RESOURCE_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?! } } diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 2bfc80bd0..2f4ebb1ff 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -792,7 +792,7 @@ void PM_jetpack(entity this, float maxspd_mod, float dt) #ifdef SVQC if (!(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO)) - SetResourceAmountExplicit(this, RESOURCE_FUEL, GetResourceAmount(this, RESOURCE_FUEL) - PHYS_JETPACK_FUEL(this) * dt * fvel * f); + TakeResource(this, RESOURCE_FUEL, PHYS_JETPACK_FUEL(this) * dt * fvel * f); ITEMS_STAT(this) |= IT_USING_JETPACK; diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index a94ea1763..da21a4bcb 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -558,17 +558,17 @@ bool bumblebee_pilot_frame(entity this, float dt) else if(IS_CLIENT(trace_ent)) { if(GetResourceAmount(trace_ent, RESOURCE_HEALTH) <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps) - SetResourceAmountExplicit(trace_ent, RESOURCE_HEALTH, min(GetResourceAmount(trace_ent, RESOURCE_HEALTH) + autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax)); + GiveResourceWithLimit(trace_ent, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax); if(GetResourceAmount(trace_ent, RESOURCE_ARMOR) <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps) - SetResourceAmountExplicit(trace_ent, RESOURCE_ARMOR, min(GetResourceAmount(trace_ent, RESOURCE_ARMOR) + autocvar_g_vehicle_bumblebee_healgun_aps * dt, autocvar_g_vehicle_bumblebee_healgun_amax)); + GiveResourceWithLimit(trace_ent, RESOURCE_ARMOR, autocvar_g_vehicle_bumblebee_healgun_aps * dt, autocvar_g_vehicle_bumblebee_healgun_amax); - SetResourceAmountExplicit(trace_ent, RESOURCE_HEALTH, min(GetResourceAmount(trace_ent, RESOURCE_HEALTH) + autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax)); + GiveResourceWithLimit(trace_ent, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax); } else if(IS_TURRET(trace_ent)) { if(GetResourceAmount(trace_ent, RESOURCE_HEALTH) <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps) - SetResourceAmountExplicit(trace_ent, RESOURCE_HEALTH, min(GetResourceAmount(trace_ent, RESOURCE_HEALTH) + autocvar_g_vehicle_bumblebee_healgun_hps * dt, trace_ent.max_health)); + GiveResourceWithLimit(trace_ent, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_healgun_hps * dt, trace_ent.max_health); //else ..hmmm what? ammo? trace_ent.SendFlags |= TNSF_STATUS; diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 166255c26..10080bbad 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -131,7 +131,7 @@ void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, flo return; // g_projectiles_damage says to halt if(this.realowner == attacker) - SetResourceAmountExplicit(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH) - (damage * 0.25)); + TakeResource(this, RESOURCE_HEALTH, (damage * 0.25)); else TakeResource(this, RESOURCE_HEALTH, damage);