]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up some unnecessary uses of SetResourceAmountExplicit
authorMario <mario@smbclan.net>
Sat, 16 Jun 2018 18:15:25 +0000 (04:15 +1000)
committerMario <mario@smbclan.net>
Sat, 16 Jun 2018 18:15:25 +0000 (04:15 +1000)
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc
qcsrc/common/physics/player.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/weapons/weapon/seeker.qc

index 2157770cf7a0670345d157bce2c2432da5d7a24a..15aedc732d15c95283baf0c1f58cad87efc20022 100644 (file)
@@ -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;
 
index 8497bde05635172713919d0294da23937c01d30e..63f4418dec6cc4b7dae80cd7244fcdeaea254c22 100644 (file)
@@ -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);
        }
 
index 7cec1f7901d9dd73d0994b16bd5fb6bc84534fa6..319b518665fff22505ba0afaf5256187257b443c 100644 (file)
@@ -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?!
        }
 }
index 2bfc80bd0bc315395e10d0a40891bc52f1051ea3..2f4ebb1ff002c9c37278901d70a4838bb0e043e1 100644 (file)
@@ -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;
 
index a94ea1763b49d44214d43473491853d14f9e44bf..da21a4bcb42d5e599fc5fdf4aae1a4fbbb49b172 100644 (file)
@@ -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;
index 166255c26cfa915692b2b3afb24c9944fabbef8b..10080bbad275bd71b067ffcefcfd333b03998894 100644 (file)
@@ -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);