]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Revert e30214cf "Purge SetResourceAmountExplicit" because it breaks map vote and...
authorterencehill <piuntn@gmail.com>
Fri, 8 Feb 2019 19:13:41 +0000 (20:13 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 8 Feb 2019 19:13:41 +0000 (20:13 +0100)
63 files changed:
qcsrc/client/resources.qc
qcsrc/client/resources.qh
qcsrc/client/shownames.qc
qcsrc/common/ent_cs.qc
qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/items/item/ammo.qh
qcsrc/common/items/item/armor.qh
qcsrc/common/items/item/health.qh
qcsrc/common/items/item/jetpack.qh
qcsrc/common/mapobjects/func/breakable.qc
qcsrc/common/mapobjects/func/button.qc
qcsrc/common/mapobjects/func/door.qc
qcsrc/common/mapobjects/func/door_rotating.qc
qcsrc/common/mapobjects/func/door_secret.qc
qcsrc/common/mapobjects/trigger/heal.qc
qcsrc/common/mapobjects/trigger/multi.qc
qcsrc/common/mapobjects/trigger/secret.qc
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/shambler.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/monster/zombie.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/instagib/items.qh
qcsrc/common/mutators/mutator/invincibleproj/sv_invincibleproj.qc
qcsrc/common/mutators/mutator/nades/net.qc
qcsrc/common/mutators/mutator/overkill/okrpc.qc
qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/server/cheats.qc
qcsrc/server/client.qc
qcsrc/server/compat/quake3.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_hook.qc
qcsrc/server/g_world.qc
qcsrc/server/mapvoting.qc
qcsrc/server/player.qc
qcsrc/server/portals.qc
qcsrc/server/resources.qc
qcsrc/server/resources.qh

index 7d498c3f6d093baadc410bdac9b790e5c73b6aff..88a1fffc931c2cb23ebe36c9ff00432d189c054b 100644 (file)
@@ -10,9 +10,20 @@ float GetResource(entity e, int res_type)
        return e.(GetResourceField(res_type));
 }
 
+bool SetResourceExplicit(entity e, int res_type, float amount)
+{
+       .float res_field = GetResourceField(res_type);
+       if (e.(res_field) != amount)
+       {
+               e.(res_field) = amount;
+               return true;
+       }
+       return false;
+}
+
 void SetResource(entity e, int res_type, float amount)
 {
-       e.(GetResourceField(res_type)) = amount;
+       SetResourceExplicit(e, res_type, amount);
 }
 
 void TakeResource(entity receiver, int res_type, float amount)
index 939d12c172f267f94bd2c027ead67f74776d959e..4b0eaa8e75efaa3250a235d6229178682d7ee15a 100644 (file)
 /// \return Current amount of resource the given entity has.
 float GetResource(entity e, int res_type);
 
+/// \brief Sets the resource amount of an entity without calling any hooks.
+/// \param[in,out] e Entity to adjust.
+/// \param[in] res_type Type of the resource (a RES_* constant).
+/// \param[in] amount Amount of resource to set.
+/// \return Boolean for whether the ammo amount was changed
+bool SetResourceExplicit(entity e, int res_type, float amount);
+
 /// \brief Sets the current amount of resource the given entity will have.
 /// \param[in,out] e Entity to adjust.
 /// \param[in] res_type Type of the resource (a RES_* constant).
index 8d15fbc57b725313869a54a0c8c11cf0dbb651a2..74136906e4c6a955c1bace120df660ea08dcdc68 100644 (file)
@@ -206,13 +206,13 @@ void Draw_ShowNames_All()
                if (entcs.m_entcs_private)
                {
                        it.healthvalue = entcs.healthvalue;
-                       SetResource(it, RES_ARMOR, GetResource(entcs, RES_ARMOR));
+                       SetResourceExplicit(it, RES_ARMOR, GetResource(entcs, RES_ARMOR));
                        it.sameteam = true;
                }
                else
                {
                        it.healthvalue = 0;
-                       SetResource(it, RES_ARMOR, 0);
+                       SetResourceExplicit(it, RES_ARMOR, 0);
                        it.sameteam = false;
                }
                bool dead = entcs_IsDead(i) || entcs_IsSpectating(i);
index c32b45339512203755edcf3cd9feae9d21a8eea4..23790b5e4898ea31cf34bf4a0789ba4abb3d06d1 100644 (file)
@@ -77,7 +77,7 @@ void entcs_force_origin(entity player)
        bool id##_check(entity ent, entity player) { \
                return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \
        } \
-       void id##_set(entity ent, entity player) { SetResource(ent, checkprop, GetResource(player, checkprop)); } \
+       void id##_set(entity ent, entity player) { SetResourceExplicit(ent, checkprop, GetResource(player, checkprop)); } \
        void id##_send(int chan, entity ent) { LAMBDA(svsend); } \
        REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \
                this.m_public = ispublic; \
@@ -123,7 +123,7 @@ ENTCS_PROP_RESOURCE(HEALTH, false, RES_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
 
 ENTCS_PROP_RESOURCE(ARMOR, false, RES_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
        { WriteByte(chan, bound(0, GetResource(ent, RES_ARMOR) / DEC_FACTOR, 255)); },
-       { SetResource(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
+       { SetResourceExplicit(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
 #undef DEC_FACTOR
 
 ENTCS_PROP(NAME, true, netname, ENTCS_SET_MUTABLE_STRING,
index 211bfb5bfa017371782ef3a159cbe081ad379714..14266c8a74f9b2db36171e00faac3b7b41ed2d0c 100644 (file)
@@ -17,7 +17,7 @@ STATIC_INIT(g_assault)
 void assault_objective_use(entity this, entity actor, entity trigger)
 {
        // activate objective
-       SetResource(this, RES_HEALTH, 100);
+       SetResourceExplicit(this, RES_HEALTH, 100);
        //print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
        //print("Activator is ", actor.classname, "\n");
 
@@ -39,7 +39,7 @@ vector target_objective_spawn_evalfunc(entity this, entity player, entity spot,
 // and when a new round starts
 void assault_objective_reset(entity this)
 {
-       SetResource(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
+       SetResourceExplicit(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
 }
 
 // decrease the health of targeted objectives
@@ -72,7 +72,7 @@ void assault_objective_decrease_use(entity this, entity actor, entity trigger)
                {
                        GameRules_scoring_add_team(actor, SCORE, hlth);
                        GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
-                       SetResource(this.enemy, RES_HEALTH, -1);
+                       SetResourceExplicit(this.enemy, RES_HEALTH, -1);
 
                        if(this.enemy.message)
                                FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); });
@@ -323,7 +323,7 @@ spawnfunc(target_objective_decrease)
                this.dmg = 101;
 
        this.use = assault_objective_decrease_use;
-       SetResource(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
+       SetResourceExplicit(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
        this.max_health = ASSAULT_VALUE_INACTIVE;
        this.enemy = NULL;
 
index 79ecf5fe07c2764f6720c53016298f3358430efc..6dd1b1e9020ae9b18ddc39479472e8b371a4b8b9 100644 (file)
@@ -341,7 +341,7 @@ void ctf_Handle_Drop(entity flag, entity player, int droptype)
        set_movetype(flag, MOVETYPE_TOSS);
        flag.takedamage = DAMAGE_YES;
        flag.angles = '0 0 0';
-       SetResource(flag, RES_HEALTH, flag.max_flag_health);
+       SetResourceExplicit(flag, RES_HEALTH, flag.max_flag_health);
        flag.ctf_droptime = time;
        flag.ctf_dropper = player;
        flag.ctf_status = FLAG_DROPPED;
@@ -679,7 +679,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype)
        switch(pickuptype)
        {
                case PICKUP_BASE: flag.ctf_pickuptime = time; break; // used for timing runs
-               case PICKUP_DROPPED: SetResource(flag, RES_HEALTH, flag.max_flag_health); break; // reset health/return timelimit
+               case PICKUP_DROPPED: SetResourceExplicit(flag, RES_HEALTH, flag.max_flag_health); break; // reset health/return timelimit
                default: break;
        }
 
@@ -876,7 +876,7 @@ void ctf_FlagDamage(entity this, entity inflictor, entity attacker, float damage
                        this.ctf_flagdamaged_byworld = true;
                else
                {
-                       SetResource(this, RES_HEALTH, 0);
+                       SetResourceExplicit(this, RES_HEALTH, 0);
                        ctf_CheckFlagReturn(this, RETURN_NEEDKILL);
                }
                return;
@@ -947,7 +947,7 @@ void ctf_FlagThink(entity this)
                        {
                                if((vdist(this.origin - this.ctf_spawnorigin, <=, autocvar_g_ctf_flag_return_dropped)) || (autocvar_g_ctf_flag_return_dropped == -1))
                                {
-                                       SetResource(this, RES_HEALTH, 0);
+                                       SetResourceExplicit(this, RES_HEALTH, 0);
                                        ctf_CheckFlagReturn(this, RETURN_DROPPED);
                                        return;
                                }
@@ -971,7 +971,7 @@ void ctf_FlagThink(entity this)
                {
                        if(this.speedrunning && ctf_captimerecord && (time >= this.ctf_pickuptime + ctf_captimerecord))
                        {
-                               SetResource(this, RES_HEALTH, 0);
+                               SetResourceExplicit(this, RES_HEALTH, 0);
                                ctf_CheckFlagReturn(this, RETURN_SPEEDRUN);
 
                                CS(this.owner).impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
@@ -1040,7 +1040,7 @@ METHOD(Flag, giveTo, bool(Flag this, entity flag, entity toucher))
        {
                if(!autocvar_g_ctf_flag_return_damage_delay)
                {
-                       SetResource(flag, RES_HEALTH, 0);
+                       SetResourceExplicit(flag, RES_HEALTH, 0);
                        ctf_CheckFlagReturn(flag, RETURN_NEEDKILL);
                }
                if(!flag.ctf_flagdamaged_byworld) { return; }
@@ -1164,7 +1164,7 @@ void ctf_RespawnFlag(entity flag)
 
        set_movetype(flag, ((flag.noalign) ? MOVETYPE_NONE : MOVETYPE_TOSS));
        flag.takedamage = DAMAGE_NO;
-       SetResource(flag, RES_HEALTH, flag.max_flag_health);
+       SetResourceExplicit(flag, RES_HEALTH, flag.max_flag_health);
        flag.solid = SOLID_TRIGGER;
        flag.velocity = '0 0 0';
        flag.angles = flag.mangle;
@@ -1251,7 +1251,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        flag.takedamage = DAMAGE_NO;
        flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale;
        flag.max_flag_health = ((autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health) ? autocvar_g_ctf_flag_health : 100);
-       SetResource(flag, RES_HEALTH, flag.max_flag_health);
+       SetResourceExplicit(flag, RES_HEALTH, flag.max_flag_health);
        flag.event_damage = ctf_FlagDamage;
        flag.pushable = true;
        flag.teleportable = TELEPORT_NORMAL;
index ad0d8878c7aa7ee178f5b03657b34c20bf1e9e96..c42c7443ba252a997d778f9c731132a292bc3857 100644 (file)
@@ -330,7 +330,7 @@ void ft_RemovePlayer(entity this)
                freezetag_LastPlayerForTeam_Notify(this);
        Unfreeze(this, false);
 
-       SetResource(this, RES_HEALTH, 0); // neccessary to correctly count alive players
+       SetResourceExplicit(this, RES_HEALTH, 0); // neccessary to correctly count alive players
        freezetag_count_alive_players();
 }
 
@@ -502,7 +502,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                if (STAT(FROZEN, player) == FROZEN_NORMAL)
                {
                        STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
-                       SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+                       SetResourceExplicit(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
                }
                else if (!STAT(FROZEN, player))
                        STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
@@ -510,7 +510,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
        else if (STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us
        {
                STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
-               SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+               SetResourceExplicit(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
 
                if(STAT(REVIVE_PROGRESS, player) >= 1)
                {
index ef217242b1f6d78189b9ab242f7b1fc278d244f3..2e05794da592540de8ff1794900eb7fa2d370ec3 100644 (file)
@@ -165,7 +165,7 @@ NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
                this.origin = ReadVector();
                setorigin(this, this.origin);
 
-               SetResource(this, RES_HEALTH, ReadByte());
+               SetResourceExplicit(this, RES_HEALTH, ReadByte());
                this.max_health = ReadByte();
                this.count = ReadByte();
                this.team = ReadByte();
@@ -192,6 +192,6 @@ NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
                if(_tmp != GetResource(this, RES_HEALTH))
                        cpicon_damage(this, _tmp);
 
-               SetResource(this, RES_HEALTH, _tmp);
+               SetResourceExplicit(this, RES_HEALTH, _tmp);
        }
 }
index db861a355774d9212806556c8f2d96a884163258..3a72c8d497d089417b33b18e6d4524741f6aea50 100644 (file)
@@ -195,7 +195,7 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
                this.origin = ReadVector();
                setorigin(this, this.origin);
 
-               SetResource(this, RES_HEALTH, ReadByte());
+               SetResourceExplicit(this, RES_HEALTH, ReadByte());
                this.max_health = ReadByte();
                this.count = ReadByte();
                this.team = ReadByte();
@@ -222,6 +222,6 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
                if(_tmp != GetResource(this, RES_HEALTH))
                        generator_damage(this, _tmp);
 
-               SetResource(this, RES_HEALTH, _tmp);
+               SetResourceExplicit(this, RES_HEALTH, _tmp);
        }
 }
index 23ca66de3f762c00e514694aa75b424966a5d85a..d4303efbd97124579a115c916b86aee7a0a54056 100644 (file)
@@ -540,7 +540,7 @@ void ons_ControlPoint_Icon_BuildThink(entity this)
 
        if (GetResource(this, RES_HEALTH) >= this.max_health)
        {
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
                this.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
                setthink(this, ons_ControlPoint_Icon_Think);
                sound(this, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
@@ -588,7 +588,7 @@ void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
 
        e.owner = cp;
        e.max_health = autocvar_g_onslaught_cp_health;
-       SetResource(e, RES_HEALTH, autocvar_g_onslaught_cp_buildhealth);
+       SetResourceExplicit(e, RES_HEALTH, autocvar_g_onslaught_cp_buildhealth);
        e.solid = SOLID_NOT;
        e.takedamage = DAMAGE_AIM;
        e.bot_attack = true;
@@ -998,7 +998,7 @@ void ons_GeneratorThink(entity this)
 void ons_GeneratorReset(entity this)
 {
        this.team = this.team_saved;
-       SetResource(this, RES_HEALTH, autocvar_g_onslaught_gen_health);
+       SetResourceExplicit(this, RES_HEALTH, autocvar_g_onslaught_gen_health);
        this.lasthealth = this.max_health = autocvar_g_onslaught_gen_health;
        this.takedamage = DAMAGE_AIM;
        this.bot_attack = true;
@@ -1066,7 +1066,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        IL_PUSH(g_saved_team, gen);
        set_movetype(gen, MOVETYPE_NONE);
        gen.lasthealth = gen.max_health = autocvar_g_onslaught_gen_health;
-       SetResource(gen, RES_HEALTH, autocvar_g_onslaught_gen_health);
+       SetResourceExplicit(gen, RES_HEALTH, autocvar_g_onslaught_gen_health);
        gen.takedamage = DAMAGE_AIM;
        gen.bot_attack = true;
        IL_PUSH(g_bot_targets, gen);
index c38c5d9823b389ef3bc509adee9aaaba117f6559..936d42f1f2a3b00e65f23f31e3ac76406ac21306 100644 (file)
@@ -49,7 +49,7 @@ PROPERTY(int, g_pickup_nails);
 void ammo_bullets_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_BULLETS))
-        SetResource(item, RES_BULLETS, g_pickup_nails);
+        SetResourceExplicit(item, RES_BULLETS, g_pickup_nails);
 }
 #endif
 
@@ -83,7 +83,7 @@ PROPERTY(int, g_pickup_cells);
 void ammo_cells_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_CELLS))
-        SetResource(item, RES_CELLS, g_pickup_cells);
+        SetResourceExplicit(item, RES_CELLS, g_pickup_cells);
 }
 #endif
 REGISTER_ITEM(Cells, Ammo) {
@@ -113,7 +113,7 @@ PROPERTY(int, g_pickup_plasma);
 void ammo_plasma_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_PLASMA))
-        SetResource(item, RES_PLASMA, g_pickup_plasma);
+        SetResourceExplicit(item, RES_PLASMA, g_pickup_plasma);
 }
 #endif
 REGISTER_ITEM(Plasma, Ammo) {
@@ -143,7 +143,7 @@ PROPERTY(int, g_pickup_rockets);
 void ammo_rockets_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_ROCKETS))
-        SetResource(item, RES_ROCKETS, g_pickup_rockets);
+        SetResourceExplicit(item, RES_ROCKETS, g_pickup_rockets);
 }
 #endif
 REGISTER_ITEM(Rockets, Ammo) {
@@ -173,7 +173,7 @@ PROPERTY(int, g_pickup_shells);
 void ammo_shells_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_SHELLS))
-        SetResource(item, RES_SHELLS, g_pickup_shells);
+        SetResourceExplicit(item, RES_SHELLS, g_pickup_shells);
 }
 #endif
 
index 4b206d1b377dd8a97f348d4bb194805e4f4fb88e..be6c52af59389d37ade902bd65e1db1ff541f0d6 100644 (file)
@@ -27,7 +27,7 @@ void item_armorsmall_init(Pickup this, entity item)
     if(!item.max_armorvalue)
         item.max_armorvalue = g_pickup_armorsmall_max;
     if(!GetResource(item, RES_ARMOR))
-        SetResource(item, RES_ARMOR, g_pickup_armorsmall);
+        SetResourceExplicit(item, RES_ARMOR, g_pickup_armorsmall);
 }
 #endif
 
@@ -65,7 +65,7 @@ void item_armormedium_init(Pickup this, entity item)
     if(!item.max_armorvalue)
         item.max_armorvalue = g_pickup_armormedium_max;
     if(!GetResource(item, RES_ARMOR))
-        SetResource(item, RES_ARMOR, g_pickup_armormedium);
+        SetResourceExplicit(item, RES_ARMOR, g_pickup_armormedium);
 }
 #endif
 
@@ -103,7 +103,7 @@ void item_armorbig_init(Pickup this, entity item)
     if(!item.max_armorvalue)
         item.max_armorvalue = g_pickup_armorbig_max;
     if(!GetResource(item, RES_ARMOR))
-        SetResource(item, RES_ARMOR, g_pickup_armorbig);
+        SetResourceExplicit(item, RES_ARMOR, g_pickup_armorbig);
 }
 #endif
 
@@ -143,7 +143,7 @@ void item_armormega_init(Pickup this, entity item)
     if(!item.max_armorvalue)
         item.max_armorvalue = g_pickup_armormega_max;
     if(!GetResource(item, RES_ARMOR))
-        SetResource(item, RES_ARMOR, g_pickup_armormega);
+        SetResourceExplicit(item, RES_ARMOR, g_pickup_armormega);
 }
 #endif
 
index a2f33fb46078be748bdb312c4f591bb37bf2c185..14e942a085a1f01e9cfd1e54d05d09daf227d49b 100644 (file)
@@ -27,7 +27,7 @@ void item_healthsmall_init(Pickup this, entity item)
     if(!item.max_health)
         item.max_health = g_pickup_healthsmall_max;
     if(!GetResource(item, RES_HEALTH))
-        SetResource(item, RES_HEALTH, g_pickup_healthsmall);
+        SetResourceExplicit(item, RES_HEALTH, g_pickup_healthsmall);
 }
 #endif
 
@@ -65,7 +65,7 @@ void item_healthmedium_init(Pickup this, entity item)
     if(!item.max_health)
         item.max_health = g_pickup_healthmedium_max;
     if(!GetResource(item, RES_HEALTH))
-        SetResource(item, RES_HEALTH, g_pickup_healthmedium);
+        SetResourceExplicit(item, RES_HEALTH, g_pickup_healthmedium);
 }
 #endif
 
@@ -103,7 +103,7 @@ void item_healthbig_init(Pickup this, entity item)
     if(!item.max_health)
         item.max_health = g_pickup_healthbig_max;
     if(!GetResource(item, RES_HEALTH))
-        SetResource(item, RES_HEALTH, g_pickup_healthbig);
+        SetResourceExplicit(item, RES_HEALTH, g_pickup_healthbig);
 }
 #endif
 
@@ -143,7 +143,7 @@ void item_healthmega_init(Pickup this, entity item)
     if(!item.max_health)
         item.max_health = g_pickup_healthmega_max;
     if(!GetResource(item, RES_HEALTH))
-        SetResource(item, RES_HEALTH, g_pickup_healthmega);
+        SetResourceExplicit(item, RES_HEALTH, g_pickup_healthmega);
 }
 #endif
 
index 33680e832c75a26df3bc86473224fa5bc0aac876..8440975d02d4fe5096f6763c926eb7ba71e32a88 100644 (file)
@@ -20,7 +20,7 @@ PROPERTY(int, g_pickup_fuel_jetpack);
 void powerup_jetpack_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_FUEL))
-        SetResource(item, RES_FUEL, g_pickup_fuel_jetpack);
+        SetResourceExplicit(item, RES_FUEL, g_pickup_fuel_jetpack);
 }
 #endif
 
@@ -58,7 +58,7 @@ PROPERTY(int, g_pickup_fuel);
 void ammo_fuel_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_FUEL))
-        SetResource(item, RES_FUEL, g_pickup_fuel);
+        SetResourceExplicit(item, RES_FUEL, g_pickup_fuel);
 }
 #endif
 REGISTER_ITEM(JetpackFuel, Ammo) {
index a1b8c76ba42c49e736f5e742cdb1a787c4fbc3ab..32926d4908cfa8fff4941f31773a3725ccb90bbc 100644 (file)
@@ -129,7 +129,7 @@ void func_breakable_look_restore(entity this)
 
 void func_breakable_behave_destroyed(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        this.takedamage = DAMAGE_NO;
        if(this.bot_attack)
                IL_REMOVE(g_bot_targets, this);
@@ -157,7 +157,7 @@ void func_breakable_think(entity this)
 void func_breakable_destroy(entity this, entity actor, entity trigger);
 void func_breakable_behave_restore(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        if(this.sprite)
        {
                WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
@@ -316,7 +316,7 @@ spawnfunc(func_breakable)
 {
        float n, i;
        if(!GetResource(this, RES_HEALTH))
-               SetResource(this, RES_HEALTH, 100);
+               SetResourceExplicit(this, RES_HEALTH, 100);
        this.max_health = GetResource(this, RES_HEALTH);
 
        // yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
index f21d37fd29fce615a6f4a68300452278b49d1f4d..56bfd4148d70bf7cde682bec1c83d4fb0f633d3a 100644 (file)
@@ -83,7 +83,7 @@ void button_blocked(entity this, entity blocker)
 
 void button_fire(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        this.takedamage = DAMAGE_NO;    // will be reset upon return
 
        if (this.state == STATE_UP || this.state == STATE_TOP)
@@ -100,7 +100,7 @@ void button_fire(entity this)
 
 void button_reset(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        setorigin(this, this.pos1);
        this.frame = 0;                 // use normal textures
        this.state = STATE_BOTTOM;
index 47fda80f55f1b2591b407c032a203d392bfb6979..aa5b54a60ed4ba7ce22dbd761d2321610f989392 100644 (file)
@@ -113,7 +113,7 @@ void door_go_down(entity this)
        if (this.max_health)
        {
                this.takedamage = DAMAGE_YES;
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
        }
 
        this.state = STATE_DOWN;
@@ -275,7 +275,7 @@ void door_damage(entity this, entity inflictor, entity attacker, float damage, i
 
        if (GetResource(this, RES_HEALTH) <= 0)
        {
-               SetResource(this.owner, RES_HEALTH, this.owner.max_health);
+               SetResourceExplicit(this.owner, RES_HEALTH, this.owner.max_health);
                this.owner.takedamage = DAMAGE_NO;      // will be reset upon return
                door_use(this.owner, attacker, NULL);
        }
@@ -475,7 +475,7 @@ void LinkDoors(entity this)
        for(t = this; ; t = t.enemy)
        {
                if(GetResource(t, RES_HEALTH) && !GetResource(this, RES_HEALTH))
-                       SetResource(this, RES_HEALTH, GetResource(t, RES_HEALTH));
+                       SetResourceExplicit(this, RES_HEALTH, GetResource(t, RES_HEALTH));
                if((t.targetname != "") && (this.targetname == ""))
                        this.targetname = t.targetname;
                if((t.message != "") && (this.message == ""))
@@ -499,7 +499,7 @@ void LinkDoors(entity this)
        // distribute health, targetname, message
        for(t = this; t; t = t.enemy)
        {
-               SetResource(t, RES_HEALTH, GetResource(this, RES_HEALTH));
+               SetResourceExplicit(t, RES_HEALTH, GetResource(this, RES_HEALTH));
                t.targetname = this.targetname;
                t.message = this.message;
                if(t.enemy == this)
index 9b355707b49010dea1f83257d53487da1a8d66a3..29fd1d05f95fd611bb5cb78a0b286045852aa545 100644 (file)
@@ -58,7 +58,7 @@ void door_rotating_go_down(entity this)
        if (this.max_health)
        {
                this.takedamage = DAMAGE_YES;
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
        }
 
        this.state = STATE_DOWN;
index 4697cc46cac4f1f9f8de4d2494084ec98ee3696e..c008e500dc1215a638c5c58215a4f1702890ec63 100644 (file)
@@ -13,7 +13,7 @@ void fd_secret_use(entity this, entity actor, entity trigger)
        float temp;
        string message_save;
 
-       SetResource(this, RES_HEALTH, 10000);
+       SetResourceExplicit(this, RES_HEALTH, 10000);
        if(!this.bot_attack)
                IL_PUSH(g_bot_targets, this);
        this.bot_attack = true;
@@ -122,7 +122,7 @@ void fd_secret_done(entity this)
 {
        if (this.spawnflags&DOOR_SECRET_YES_SHOOT)
        {
-               SetResource(this, RES_HEALTH, 10000);
+               SetResourceExplicit(this, RES_HEALTH, 10000);
                this.takedamage = DAMAGE_YES;
                //this.th_pain = fd_secret_use;
        }
@@ -168,7 +168,7 @@ void secret_reset(entity this)
 {
        if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
        {
-               SetResource(this, RES_HEALTH, 10000);
+               SetResourceExplicit(this, RES_HEALTH, 10000);
                this.takedamage = DAMAGE_YES;
        }
        setorigin(this, this.oldorigin);
@@ -253,7 +253,7 @@ spawnfunc(func_door_secret)
        if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
        {
                //this.canteamdamage = true; // TODO
-               SetResource(this, RES_HEALTH, 10000);
+               SetResourceExplicit(this, RES_HEALTH, 10000);
                this.takedamage = DAMAGE_YES;
                this.event_damage = fd_secret_damage;
        }
index dd1cf4015b290548d25ec64d1c5b6360964ee5b6..94abd4041d3d1ff9a1a6f24f5a7db8284819244e 100644 (file)
@@ -37,7 +37,7 @@ void trigger_heal_init(entity this)
        if(!this.delay)
                this.delay = 1;
        if(!GetResource(this, RES_HEALTH))
-               SetResource(this, RES_HEALTH, 10); // TODO: use a special field for this, it doesn't have actual health!
+               SetResourceExplicit(this, RES_HEALTH, 10); // TODO: use a special field for this, it doesn't have actual health!
        if(!this.max_health)
                this.max_health = 200; // max health topoff for field
        if(this.noise == "")
index f999083aafca87eda2c25f02d5081e58e5ef4144..c71dc3794822d5f41094411a7a6f3242b904219f 100644 (file)
@@ -7,7 +7,7 @@ void multi_wait(entity this)
 {
        if (this.max_health)
        {
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
                this.takedamage = DAMAGE_YES;
                this.solid = SOLID_BBOX;
        }
@@ -135,7 +135,7 @@ void multi_reset(entity this)
                settouch(this, multi_touch);
        if (this.max_health)
        {
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
                this.takedamage = DAMAGE_YES;
                this.solid = SOLID_BBOX;
        }
index 8422a01b1a77cf3234191b60fe44278fc5e5b9a9..e532f713c4c582705ca22632f89b48c18ca11319 100644 (file)
@@ -73,7 +73,7 @@ spawnfunc(trigger_secret)
        this.targetname = "";
 
        // you can't just shoot a room to find it, can you?
-       SetResource(this, RES_HEALTH, 0);
+       SetResourceExplicit(this, RES_HEALTH, 0);
 
        // a secret can not be delayed
        this.delay = 0;
index bdbae245f5c2c205a27f9615fc6c094a86810d55..86e780e0a4657aa523489eb0b9ad82bc7bf9f698 100644 (file)
@@ -325,14 +325,14 @@ void M_Mage_Attack_Teleport(entity this, entity targ)
 void M_Mage_Defend_Shield_Remove(entity this)
 {
        this.effects &= ~(EF_ADDITIVE | EF_BLUE);
-       SetResource(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+       SetResourceExplicit(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
 }
 
 void M_Mage_Defend_Shield(entity this)
 {
        this.effects |= (EF_ADDITIVE | EF_BLUE);
        this.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay);
-       SetResource(this, RES_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
+       SetResourceExplicit(this, RES_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
        this.mage_shield_time = time + (autocvar_g_monster_mage_shield_time);
        setanim(this, this.anim_shoot, true, true, true);
        this.attack_finished_single[0] = time + 1;
@@ -469,7 +469,7 @@ METHOD(Mage, mr_anim, bool(Mage this, entity actor))
 METHOD(Mage, mr_setup, bool(Mage this, entity actor))
 {
     TC(Mage, this);
-    if(!GetResource(this, RES_HEALTH)) SetResource(actor, RES_HEALTH, autocvar_g_monster_mage_health);
+    if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_mage_health);
     if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); }
     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); }
     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_mage_speed_stop); }
index 043a8649857518376c51656014d2840c2c213b03..9390f5d23a74dcc0249f4d395caf2119d944ed30 100644 (file)
@@ -136,7 +136,7 @@ void M_Shambler_Attack_Lightning(entity this)
        settouch(gren, M_Shambler_Attack_Lightning_Touch);
 
        gren.takedamage = DAMAGE_YES;
-       SetResource(gren, RES_HEALTH, 50);
+       SetResourceExplicit(gren, RES_HEALTH, 50);
        gren.damageforcescale = 0;
        gren.event_damage = M_Shambler_Attack_Lightning_Damage;
        gren.damagedbycontents = true;
@@ -246,7 +246,7 @@ METHOD(Shambler, mr_anim, bool(Shambler this, entity actor))
 METHOD(Shambler, mr_setup, bool(Shambler this, entity actor))
 {
     TC(Shambler, this);
-    if(!GetResource(this, RES_HEALTH)) SetResource(actor, RES_HEALTH, autocvar_g_monster_shambler_health);
+    if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_shambler_health);
     if(!actor.attack_range) actor.attack_range = 150;
     if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); }
     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_shambler_speed_run); }
index 7cff3d447483e4cd49fd7e17c4e52513b2a48d0d..52bf37f7d2608f175ddc373c060d95c90c28990f 100644 (file)
@@ -151,7 +151,7 @@ void M_Spider_Attack_Web(entity this)
        setsize(proj, '-4 -4 -4', '4 4 4');
        proj.takedamage = DAMAGE_NO;
        proj.damageforcescale = 0;
-       SetResource(proj, RES_HEALTH, 500);
+       SetResourceExplicit(proj, RES_HEALTH, 500);
        proj.event_damage = func_null;
        proj.flags = FL_PROJECTILE;
        IL_PUSH(g_projectiles, proj);
@@ -227,7 +227,7 @@ METHOD(Spider, mr_anim, bool(Spider this, entity actor))
 METHOD(Spider, mr_setup, bool(Spider this, entity actor))
 {
     TC(Spider, this);
-    if(!GetResource(this, RES_HEALTH)) SetResource(actor, RES_HEALTH, autocvar_g_monster_spider_health);
+    if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_spider_health);
     if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
index 5f471bc9ee2aec69a132c1ad17a8f00ecb5a76d0..8a4ad160560fa87583ab87a6dd861c7c0f274d54 100644 (file)
@@ -152,7 +152,7 @@ METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
 METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
 {
     TC(Wyvern, this);
-    if(!GetResource(this, RES_HEALTH)) SetResource(actor, RES_HEALTH, autocvar_g_monster_wyvern_health);
+    if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_wyvern_health);
     if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
index 4f0d9802815b6ad6d952e007bc67f6b59af2b0e9..3b2c0451b89a8657afd9d681c3cd39a97a48d744 100644 (file)
@@ -78,12 +78,12 @@ void M_Zombie_Defend_Block_End(entity this)
                return;
 
        setanim(this, this.anim_blockend, false, true, true);
-       SetResource(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+       SetResourceExplicit(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
 }
 
 bool M_Zombie_Defend_Block(entity this)
 {
-       SetResource(this, RES_ARMOR, 0.9);
+       SetResourceExplicit(this, RES_ARMOR, 0.9);
        this.state = MONSTER_ATTACK_MELEE; // freeze monster
        this.attack_finished_single[0] = time + 2.1;
        this.anim_finished = this.attack_finished_single[0];
@@ -148,7 +148,7 @@ METHOD(Zombie, mr_pain, float(Zombie this, entity actor, float damage_take, enti
 METHOD(Zombie, mr_death, bool(Zombie this, entity actor))
 {
     TC(Zombie, this);
-    SetResource(actor, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+    SetResourceExplicit(actor, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
 
     setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true);
     return true;
@@ -180,7 +180,7 @@ METHOD(Zombie, mr_anim, bool(Zombie this, entity actor))
 METHOD(Zombie, mr_setup, bool(Zombie this, entity actor))
 {
     TC(Zombie, this);
-    if(!GetResource(actor, RES_HEALTH)) SetResource(actor, RES_HEALTH, autocvar_g_monster_zombie_health);
+    if(!GetResource(actor, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_zombie_health);
     if(!actor.speed) { actor.speed = (autocvar_g_monster_zombie_speed_walk); }
     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_zombie_speed_run); }
     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_zombie_speed_stop); }
index fa1ecb07b0105cff66c2a0871b352e2b3cf9a6e4..97a68b5f8f92877e95d115b0bf6c50d03b804088 100644 (file)
@@ -531,7 +531,7 @@ void Monster_Dead_Fade(entity this)
                this.takedamage = DAMAGE_NO;
                setorigin(this, this.pos1);
                this.angles = this.pos2;
-               SetResource(this, RES_HEALTH, this.max_health);
+               SetResourceExplicit(this, RES_HEALTH, this.max_health);
                setmodel(this, MDL_Null);
        }
        else
@@ -898,7 +898,7 @@ void Monster_Reset(entity this)
 
        Unfreeze(this, false); // remove any icy remains
 
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        this.velocity = '0 0 0';
        this.enemy = NULL;
        this.goalentity = NULL;
@@ -1164,7 +1164,7 @@ void Monster_Frozen_Think(entity this)
        if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + this.ticrate * this.revive_speed, 1);
-               SetResource(this, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
+               SetResourceExplicit(this, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
                this.iceblock.alpha = bound(0.2, 1 - STAT(REVIVE_PROGRESS, this), 1);
 
                if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
@@ -1176,7 +1176,7 @@ void Monster_Frozen_Think(entity this)
        else if (STAT(FROZEN, this) == FROZEN_TEMP_DYING)
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - this.ticrate * this.revive_speed, 1);
-               SetResource(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+               SetResourceExplicit(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
 
                if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
                        WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
@@ -1254,8 +1254,8 @@ bool Monster_Spawn_Setup(entity this)
        mon.mr_setup(mon, this);
 
        // ensure some basic needs are met
-       if(!GetResource(this, RES_HEALTH)) { SetResource(this, RES_HEALTH, 100); }
-       if(!GetResource(this, RES_ARMOR)) { SetResource(this, RES_ARMOR, bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9)); }
+       if(!GetResource(this, RES_HEALTH)) { SetResourceExplicit(this, RES_HEALTH, 100); }
+       if(!GetResource(this, RES_ARMOR)) { SetResourceExplicit(this, RES_ARMOR, bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9)); }
        if(!this.target_range) { this.target_range = autocvar_g_monsters_target_range; }
        if(!this.respawntime) { this.respawntime = autocvar_g_monsters_respawn_delay; }
        if(!this.monster_moveflags) { this.monster_moveflags = MONSTER_MOVE_WANDER; }
@@ -1265,7 +1265,7 @@ bool Monster_Spawn_Setup(entity this)
        if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
        {
                Monster_Miniboss_Check(this);
-               SetResource(this, RES_HEALTH, GetResource(this, RES_HEALTH) * MONSTER_SKILLMOD(this));
+               SetResourceExplicit(this, RES_HEALTH, GetResource(this, RES_HEALTH) * MONSTER_SKILLMOD(this));
 
                if(!this.skin)
                        this.skin = rint(random() * 4);
index cd0d81918004363ddf0a77b1db58c3eefb7d2483..abc57a4a03a9b85472370221d452094dad77689d 100644 (file)
@@ -19,7 +19,7 @@ int autocvar_g_instagib_ammo_drop;
 void ammo_vaporizercells_init(Pickup this, entity item)
 {
     if(!GetResource(item, RES_CELLS))
-        SetResource(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
+        SetResourceExplicit(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
 }
 #endif
 REGISTER_ITEM(VaporizerCells, Ammo) {
index dd088d78f25c401f1565ec416b17d3b28837bdb0..de49df26b40ef95c43d49f25421e18764c7d927c 100644 (file)
@@ -10,7 +10,7 @@ MUTATOR_HOOKFUNCTION(invincibleprojectiles, EditProjectile)
        if(GetResource(proj, RES_HEALTH))
        {
                // disable health which in effect disables damage calculations
-               SetResource(proj, RES_HEALTH, 0);
+               SetResourceExplicit(proj, RES_HEALTH, 0);
        }
 }
 
index bc96ec8ecdd6a11918598650ef9f28474f63f5fd..02c5df7a3fd3db6d44296d16068b41e72ed694fe 100644 (file)
@@ -32,7 +32,7 @@ void orb_setup(entity e)
 
        e.draw = orb_draw;
        IL_PUSH(g_drawables, e);
-       SetResource(e, RES_HEALTH, 255);
+       SetResourceExplicit(e, RES_HEALTH, 255);
        set_movetype(e, MOVETYPE_NONE);
        e.solid = SOLID_NOT;
        e.drawmask = MASK_NORMAL;
index d599cf799de7564bd8b4cc1242eb68391cb61a17..fa4ffc4b5e2709b294f4399cb9a515deb0a5d215 100644 (file)
@@ -100,7 +100,7 @@ void W_OverkillRocketPropelledChainsaw_Attack(Weapon thiswep, entity actor, .ent
 
        missile.takedamage = DAMAGE_YES;
        missile.damageforcescale = WEP_CVAR_PRI(okrpc, damageforcescale);
-       SetResource(missile, RES_HEALTH, WEP_CVAR_PRI(okrpc, health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_PRI(okrpc, health));
        missile.event_damage = W_OverkillRocketPropelledChainsaw_Damage;
        missile.damagedbycontents = true;
        IL_PUSH(g_damagedbycontents, missile);
index 76ae0caa88f478dac90ed2d8f60ea0f624870414..b30df3790a4da0073d3a6921a0336c4dd0387108 100644 (file)
@@ -30,7 +30,7 @@ MUTATOR_HOOKFUNCTION(vh, GrappleHookThink)
                entity targ = ((SAME_TEAM(thehook.owner, thehook.aiment)) ? thehook.aiment : thehook.owner);
                // TODO: we can't do this due to an issue with globals and the mutator arguments
                //Heal(targ, thehook.owner, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
-               SetResource(targ, RES_HEALTH, min(GetResource(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
+               SetResourceExplicit(targ, RES_HEALTH, min(GetResource(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
 
                if(dmgent == thehook.owner)
                        TakeResource(dmgent, RES_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
index cc8b61abed976d9c19e42b02a9cb44b9357199a1..c2984aea5a9851858aee92f5aad256ea5028d714 100644 (file)
@@ -130,7 +130,7 @@ void Ent_WaypointSprite(entity this, bool isnew)
         int t = ReadByte();
         if (t < 192)
         {
-            SetResource(this, RES_HEALTH, t / 191.0);
+            SetResourceExplicit(this, RES_HEALTH, t / 191.0);
             this.build_finished = 0;
         }
         else
@@ -146,7 +146,7 @@ void Ent_WaypointSprite(entity this, bool isnew)
     }
     else
     {
-        SetResource(this, RES_HEALTH, -1);
+        SetResourceExplicit(this, RES_HEALTH, -1);
         this.build_finished = 0;
     }
 
@@ -652,14 +652,14 @@ void Draw_WaypointSprite(entity this)
         if (time < this.build_finished + 0.25)
         {
             if (time < this.build_started)
-                SetResource(this, RES_HEALTH, this.build_starthealth);
+                SetResourceExplicit(this, RES_HEALTH, this.build_starthealth);
             else if (time < this.build_finished)
-                SetResource(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
+                SetResourceExplicit(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
             else
-                SetResource(this, RES_HEALTH, 1);
+                SetResourceExplicit(this, RES_HEALTH, 1);
         }
         else
-            SetResource(this, RES_HEALTH, -1);
+            SetResourceExplicit(this, RES_HEALTH, -1);
     }
 
     o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
@@ -832,7 +832,7 @@ void WaypointSprite_UpdateHealth(entity e, float f)
     float step = e.max_health / 40;
     if ((floor(f / step) != floor(GetResource(e, RES_HEALTH) / step)) || e.pain_finished)
     {
-        SetResource(e, RES_HEALTH, f);
+        SetResourceExplicit(e, RES_HEALTH, f);
         e.pain_finished = 0;
         e.SendFlags |= 0x80;
     }
index fd37564a881eead341452a6d2c8646afc15a160a..f9374497c8114f35346cedc0e13a46a47817ce45 100644 (file)
@@ -224,7 +224,7 @@ void turret_construct(entity this, bool isnew)
        set_movetype(this.tur_head, MOVETYPE_NOCLIP);
        set_movetype(this, MOVETYPE_NOCLIP);
        this.tur_head.angles                    = this.angles;
-       SetResource(this, RES_HEALTH, 255);
+       SetResourceExplicit(this, RES_HEALTH, 255);
        this.solid                                              = SOLID_BBOX;
        this.tur_head.solid                             = SOLID_NOT;
        set_movetype(this, MOVETYPE_NOCLIP);
@@ -433,7 +433,7 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
                else if(myhp && myhp < _tmp)
                        this.helpme = 0; // we're being healed, don't spam help me waypoints
 
-               SetResource(this, RES_HEALTH, _tmp);
+               SetResourceExplicit(this, RES_HEALTH, _tmp);
        }
        return true;
 }
index 26918c9aad169be9c455fd84506c12baf160167a..09eed0ea597c7690a1b10b468d814749bcc60549 100644 (file)
@@ -185,7 +185,7 @@ void turret_die(entity this)
        this.event_heal = func_null;
        this.takedamage                  = DAMAGE_NO;
 
-       SetResource(this, RES_HEALTH, 0);
+       SetResourceExplicit(this, RES_HEALTH, 0);
 
 // Go boom
        //RadiusDamage (this,this, min(this.ammo,50),min(this.ammo,50) * 0.25,250,NULL,min(this.ammo,50)*5,DEATH_TURRET,NULL);
@@ -286,7 +286,7 @@ void turret_respawn(entity this)
        this.avelocity                          = '0 0 0';
        this.tur_head.avelocity         = this.avelocity;
        this.tur_head.angles            = this.idle_aim;
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        this.enemy                                      = NULL;
        this.volly_counter                      = this.shot_volly;
        this.ammo                                       = this.ammo_max;
@@ -399,7 +399,7 @@ void load_unit_settings(entity ent, bool is_reload)
                ent.tur_head.angles = '0 0 0';
        }
 
-       SetResource(ent, RES_HEALTH, cvar(strcat(sbase,"_health")) * ent.turret_scale_health);
+       SetResourceExplicit(ent, RES_HEALTH, cvar(strcat(sbase,"_health")) * ent.turret_scale_health);
        ent.respawntime = cvar(strcat(sbase,"_respawntime")) * ent.turret_scale_respawn;
 
        ent.shot_dmg             = cvar(strcat(sbase,"_shot_dmg")) * ent.turret_scale_damage;
@@ -498,7 +498,7 @@ entity turret_projectile(entity actor, Sound _snd, float _size, float _health, f
        PROJECTILE_MAKETRIGGER(proj);
        if(_health)
        {
-               SetResource(proj, RES_HEALTH, _health);
+               SetResourceExplicit(proj, RES_HEALTH, _health);
                proj.takedamage  = DAMAGE_YES;
                proj.event_damage  = turret_projectile_damage;
        }
@@ -1311,7 +1311,7 @@ bool turret_initialize(entity this, Turret tur)
 
        if(!this.team || !teamplay)             { this.team = FLOAT_MAX; }
        if(!this.ticrate)                               { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
-       if(!GetResource(this, RES_HEALTH)) { SetResource(this, RES_HEALTH, 1000); }
+       if(!GetResource(this, RES_HEALTH)) { SetResourceExplicit(this, RES_HEALTH, 1000); }
        if(!this.shot_refire)                   { this.shot_refire = 1; }
        if(!this.tur_shotorg)                   { this.tur_shotorg = '50 0 50'; }
        if(!this.turret_flags)                  { this.turret_flags = TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER; }
index 89eaa994b51319afbc878540ae68fa78b7898a83..2718b1dc48e5c2051c36dfb687e31536a44c01bf 100644 (file)
@@ -218,7 +218,7 @@ void walker_fire_rocket(entity this, vector org)
     rocket.bot_dodgerating     = 50;
     rocket.takedamage           = DAMAGE_YES;
     rocket.damageforcescale   = 2;
-    SetResource(rocket, RES_HEALTH, 25);
+    SetResourceExplicit(rocket, RES_HEALTH, 25);
     rocket.tur_shotorg         = randomvec() * 512;
     rocket.cnt                         = time + 1;
     rocket.enemy                         = this.enemy;
index 52b70a43055ac40941ae73424fd6be3c2b79a2b8..9a85e11455210ff3e14723792e638b8780bbcb2e 100644 (file)
@@ -282,7 +282,7 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
        {
                proj.takedamage    = DAMAGE_AIM;
                proj.event_damage        = vehicles_projectile_damage;
-               SetResource(proj, RES_HEALTH, _health);
+               SetResourceExplicit(proj, RES_HEALTH, _health);
        }
        else
                proj.flags |= FL_NOTARGET;
index 1dadc70a6e50b1f42b80de58fa10f0b9b828e462..a83b0928f347851f7fb1b9b11921d2ad02b92306 100644 (file)
@@ -802,7 +802,7 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
 
     Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(instance.origin, 16), '0 0 0', 1);
 
-    SetResource(instance, RES_HEALTH, 0);
+    SetResourceExplicit(instance, RES_HEALTH, 0);
     instance.event_damage      = func_null;
     instance.solid                     = SOLID_NOT;
     instance.takedamage                = DAMAGE_NO;
@@ -887,7 +887,7 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance))
     if(!autocvar_g_vehicle_bumblebee_swim)
        instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
 
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
     instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
     instance.solid = SOLID_BBOX;
     set_movetype(instance, MOVETYPE_TOSS);
@@ -914,7 +914,7 @@ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance))
 
     instance.vehicle_exit = bumblebee_exit;
     instance.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
     instance.max_health = GetResource(instance, RES_HEALTH);
     instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
 }
index 9b8c34bb58a549252f0be998ca7c8c96f3e85be2..109eab0ca2dc1edfac58daf0741d402a22da02b7 100644 (file)
@@ -544,7 +544,7 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance))
 
     setthink(instance, racer_think);
     instance.nextthink   = time;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
     instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
 
     set_movetype(instance, MOVETYPE_TOSS);
@@ -557,7 +557,7 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance))
     instance.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
     instance.bouncestop = autocvar_g_vehicle_racer_bouncestop;
     instance.damageforcescale = 0.5;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
     instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
 #endif
 }
@@ -566,7 +566,7 @@ METHOD(Racer, vr_death, void(Racer thisveh, entity instance))
 {
 #ifdef SVQC
     setSendEntity(instance, func_null); // stop networking this racer (for now)
-    SetResource(instance, RES_HEALTH, 0);
+    SetResourceExplicit(instance, RES_HEALTH, 0);
     instance.event_damage      = func_null;
     instance.solid                     = SOLID_CORPSE;
     instance.takedamage                = DAMAGE_NO;
@@ -625,7 +625,7 @@ METHOD(Racer, vr_setup, void(Racer thisveh, entity instance))
         instance.vehicle_flags |= VHF_HEALTHREGEN;
 
     instance.respawntime = autocvar_g_vehicle_racer_respawntime;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
     instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
     instance.max_health = GetResource(instance, RES_HEALTH);
 #endif
index 3fdd86f25e4c3578c280007d4bf5d536399baae0..b672d348b48e0c0064605cb601315c0e9b971153 100644 (file)
@@ -609,7 +609,7 @@ METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
 }
 METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
 {
-       SetResource(instance, RES_HEALTH, 0);
+       SetResourceExplicit(instance, RES_HEALTH, 0);
     instance.event_damage              = func_null;
     instance.solid                             = SOLID_CORPSE;
     instance.takedamage                        = DAMAGE_NO;
@@ -701,7 +701,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
     }
 
     instance.frame               = 0;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
     set_movetype(instance, MOVETYPE_TOSS);
     instance.solid               = SOLID_SLIDEBOX;
@@ -720,7 +720,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
     instance.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
     instance.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
     instance.damageforcescale = 0.25;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
 }
 METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
@@ -739,7 +739,7 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
 
     instance.vehicle_exit = raptor_exit;
     instance.respawntime = autocvar_g_vehicle_raptor_respawntime;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
     instance.max_health = GetResource(instance, RES_HEALTH);
 
index 9d716aae2a4c12f7510fcb6dcc763802e98bf295..66b5bec883392c1527a1adb229e209c798355996 100644 (file)
@@ -74,7 +74,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weapone
             _flare.solid = SOLID_CORPSE;
             _flare.takedamage = DAMAGE_YES;
             _flare.event_damage = raptor_flare_damage;
-            SetResource(_flare, RES_HEALTH, 20);
+            SetResourceExplicit(_flare, RES_HEALTH, 20);
             _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
             settouch(_flare, raptor_flare_touch);
         }
index c65c057e8a82c6709e10f6d21eb632de0d570285..3f023729f2a69bfd640378a99d765deee6ade4c7 100644 (file)
@@ -540,7 +540,7 @@ METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance))
 }
 METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
 {
-       SetResource(instance, RES_HEALTH, 0);
+       SetResourceExplicit(instance, RES_HEALTH, 0);
     instance.event_damage              = func_null;
     instance.takedamage                        = DAMAGE_NO;
     settouch(instance, func_null);
@@ -582,7 +582,7 @@ METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance))
     setorigin(instance, instance.pos1 + '0 0 128');
     instance.angles = instance.pos2;
     instance.damageforcescale = 0.03;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
     instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
 
     instance.PlayerPhysplug = spiderbot_frame;
@@ -599,7 +599,7 @@ METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
         instance.vehicle_flags |= VHF_HEALTHREGEN;
 
     instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
-    SetResource(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
     instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
     instance.max_health = GetResource(instance, RES_HEALTH);
     instance.pushable = true; // spiderbot can use jumppads
index 0c31aefb9a0d5a49749e71b1e21142da88f18266..6efb21495bbaed25831066aba3eddc9c91c24c18 100644 (file)
@@ -140,7 +140,7 @@ void W_Arc_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
        missile.bot_dodgerating = WEP_CVAR(arc, bolt_damage);
 
        missile.takedamage = DAMAGE_YES;
-       SetResource(missile, RES_HEALTH, WEP_CVAR(arc, bolt_health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(arc, bolt_health));
        missile.damageforcescale = WEP_CVAR(arc, bolt_damageforcescale);
        missile.event_damage = W_Arc_Bolt_Damage;
        missile.damagedbycontents = true;
index 1569ba59cefea82d3ecb51aee9997ced564822ed..5654488ddb065d4e9aeb49b8f95cda1889de2132 100644 (file)
@@ -322,7 +322,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int
 
        missile.takedamage = DAMAGE_YES;
        missile.damageforcescale = WEP_CVAR(devastator, damageforcescale);
-       SetResource(missile, RES_HEALTH, WEP_CVAR(devastator, health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(devastator, health));
        missile.event_damage = W_Devastator_Damage;
        missile.damagedbycontents = true;
        IL_PUSH(g_damagedbycontents, missile);
index 3d9b9fa6e2668ecc9c25ae4ee97359c14266ccb9..2ba6b5da18628bc669f6de77668c32c23738ea11 100644 (file)
@@ -258,7 +258,7 @@ void W_Electro_Orb_Stick(entity this, entity to)
 
        newproj.takedamage = this.takedamage;
        newproj.damageforcescale = this.damageforcescale;
-       SetResource(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
+       SetResourceExplicit(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
        newproj.event_damage = this.event_damage;
        newproj.spawnshieldtime = this.spawnshieldtime;
        newproj.damagedbycontents = true;
@@ -381,7 +381,7 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
        setsize(proj, '-4 -4 -4', '4 4 4');
        proj.takedamage = DAMAGE_YES;
        proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
-       SetResource(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
+       SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
        proj.event_damage = W_Electro_Orb_Damage;
        proj.flags = FL_PROJECTILE;
        IL_PUSH(g_projectiles, proj);
index 05d8b1ee394f831f68f1754bdcf2a0e38ec06676..6b52ba32abba8d81cf8a0714e820af6895c197b4 100644 (file)
@@ -147,7 +147,7 @@ void W_Fireball_Attack1(entity actor, .entity weaponentity)
        proj.use = W_Fireball_Explode_use;
        setthink(proj, W_Fireball_Think);
        proj.nextthink = time;
-       SetResource(proj, RES_HEALTH, WEP_CVAR_PRI(fireball, health));
+       SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_PRI(fireball, health));
        proj.team = actor.team;
        proj.event_damage = W_Fireball_Damage;
        proj.takedamage = DAMAGE_YES;
index dc9f7f0f9689f0052d022bf3c3de75bfeee21300..20c588715a5a13d6ebf496964cd8bff7c4b3e682 100644 (file)
@@ -91,7 +91,7 @@ void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
 
        missile.takedamage = DAMAGE_YES;
-       SetResource(missile, RES_HEALTH, WEP_CVAR_PRI(hagar, health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_PRI(hagar, health));
        missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
        missile.event_damage = W_Hagar_Damage;
        missile.damagedbycontents = true;
@@ -137,7 +137,7 @@ void W_Hagar_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
 
        missile.takedamage = DAMAGE_YES;
-       SetResource(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
        missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
        missile.event_damage = W_Hagar_Damage;
        missile.damagedbycontents = true;
@@ -200,7 +200,7 @@ void W_Hagar_Attack2_Load_Release(Weapon thiswep, entity actor, .entity weaponen
                missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
 
                missile.takedamage = DAMAGE_YES;
-               SetResource(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
+               SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
                missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
                missile.event_damage = W_Hagar_Damage;
                missile.damagedbycontents = true;
index da0daac945732ed3407c988ca49e2f9757768dcc..d8cebd740ac49fc3daf8ec2c5d5111e30f27a740 100644 (file)
@@ -54,7 +54,7 @@ void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage,
        if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
                return; // g_projectiles_damage says to halt
 
-       SetResource(this, RES_HEALTH, GetResource(this, RES_HEALTH));
+       SetResourceExplicit(this, RES_HEALTH, GetResource(this, RES_HEALTH));
 
        if(GetResource(this, RES_HEALTH) <= 0)
                W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
@@ -88,7 +88,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        settouch(gren, W_Hook_Touch2);
 
        gren.takedamage = DAMAGE_YES;
-       SetResource(gren, RES_HEALTH, WEP_CVAR_SEC(hook, health));
+       SetResourceExplicit(gren, RES_HEALTH, WEP_CVAR_SEC(hook, health));
        gren.damageforcescale = WEP_CVAR_SEC(hook, damageforcescale);
        gren.event_damage = W_Hook_Damage;
        gren.damagedbycontents = true;
index 7e54c3c4301578db20b0eb4923413f3f63e34f96..7f60c5b571d90c84b9d8ff52717c19462300d89d 100644 (file)
@@ -27,7 +27,7 @@ void W_MineLayer_Stick(entity this, entity to)
 
        newmine.takedamage = this.takedamage;
        newmine.damageforcescale = this.damageforcescale;
-       SetResource(newmine, RES_HEALTH, GetResource(this, RES_HEALTH));
+       SetResourceExplicit(newmine, RES_HEALTH, GetResource(this, RES_HEALTH));
        newmine.event_damage = this.event_damage;
        newmine.spawnshieldtime = this.spawnshieldtime;
        newmine.damagedbycontents = true;
@@ -289,7 +289,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        mine.takedamage = DAMAGE_YES;
        mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale);
-       SetResource(mine, RES_HEALTH, WEP_CVAR(minelayer, health));
+       SetResourceExplicit(mine, RES_HEALTH, WEP_CVAR(minelayer, health));
        mine.event_damage = W_MineLayer_Damage;
        mine.damagedbycontents = true;
        IL_PUSH(g_damagedbycontents, mine);
index 7d92f290851443aac33da3447fab8155e973573f..904f0c12838ff37b775847a0f4541d560406abd9 100644 (file)
@@ -176,7 +176,7 @@ void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        settouch(gren, W_Mortar_Grenade_Touch1);
 
        gren.takedamage = DAMAGE_YES;
-       SetResource(gren, RES_HEALTH, WEP_CVAR_PRI(mortar, health));
+       SetResourceExplicit(gren, RES_HEALTH, WEP_CVAR_PRI(mortar, health));
        gren.damageforcescale = WEP_CVAR_PRI(mortar, damageforcescale);
        gren.event_damage = W_Mortar_Grenade_Damage;
        gren.damagedbycontents = true;
@@ -227,7 +227,7 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        settouch(gren, W_Mortar_Grenade_Touch2);
 
        gren.takedamage = DAMAGE_YES;
-       SetResource(gren, RES_HEALTH, WEP_CVAR_SEC(mortar, health));
+       SetResourceExplicit(gren, RES_HEALTH, WEP_CVAR_SEC(mortar, health));
        gren.damageforcescale = WEP_CVAR_SEC(mortar, damageforcescale);
        gren.event_damage = W_Mortar_Grenade_Damage;
        gren.damagedbycontents = true;
index 54cbdc293b6d77a040602847b06fe6ab54cf8d1c..f8c2be1d50777e1cea209366fe830aee87381009 100644 (file)
@@ -190,7 +190,7 @@ void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, v
        missile.scale           = 2;
        missile.takedamage      = DAMAGE_YES;
        missile.weaponentity_fld = weaponentity;
-       SetResource(missile, RES_HEALTH, WEP_CVAR(seeker, missile_health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(seeker, missile_health));
        missile.damageforcescale = WEP_CVAR(seeker, missile_damageforcescale);
        missile.damagedbycontents = true;
        IL_PUSH(g_damagedbycontents, missile);
@@ -506,7 +506,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity)
 
        missile.takedamage       = DAMAGE_YES;
        missile.event_damage     = W_Seeker_Tag_Damage;
-       SetResource(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
+       SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
        missile.damageforcescale = WEP_CVAR(seeker, tag_damageforcescale);
 
        setorigin(missile, w_shotorg);
index 18d12815a0ec2ddf57150985aadc8c26d6d9459d..c2dbb741137651e6d9136febd727661abd765c8b 100644 (file)
@@ -355,7 +355,7 @@ float CheatCommand(entity this, int argc)
                                        entity e = spawn();
                                        e.model = strzone(argv(1));
                                        e.mdl = "rocket_explode";
-                                       SetResource(e, RES_HEALTH, 1000);
+                                       SetResourceExplicit(e, RES_HEALTH, 1000);
                                        setorigin(e, trace_endpos);
                                        e.effects = EF_NOMODELFLAGS;
                                        if(f == 1)
index 4a03c3cb4370666758778414f9e19f8839a4e562..f8d10564591b96aca42b9cb13a2d15595b5986d5 100644 (file)
@@ -311,14 +311,14 @@ void PutObserverInServer(entity this)
        if(this.damagedbycontents)
                IL_REMOVE(g_damagedbycontents, this);
        this.damagedbycontents = false;
-       SetResource(this, RES_HEALTH, FRAGS_SPECTATOR);
+       SetResourceExplicit(this, RES_HEALTH, FRAGS_SPECTATOR);
        SetSpectatee_status(this, etof(this));
        this.takedamage = DAMAGE_NO;
        this.solid = SOLID_NOT;
        set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
        this.flags = FL_CLIENT | FL_NOTARGET;
        this.effects = 0;
-       SetResource(this, RES_ARMOR, autocvar_g_balance_armor_start); // was 666?!
+       SetResourceExplicit(this, RES_ARMOR, autocvar_g_balance_armor_start); // was 666?!
        this.pauserotarmor_finished = 0;
        this.pauserothealth_finished = 0;
        this.pauseregen_finished = 0;
@@ -1657,15 +1657,15 @@ void SpectateCopy(entity this, entity spectatee)
        MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
        PS(this) = PS(spectatee);
        this.armortype = spectatee.armortype;
-       SetResource(this, RES_ARMOR, GetResource(spectatee, RES_ARMOR));
-       SetResource(this, RES_CELLS, GetResource(spectatee, RES_CELLS));
-       SetResource(this, RES_PLASMA, GetResource(spectatee, RES_PLASMA));
-       SetResource(this, RES_SHELLS, GetResource(spectatee, RES_SHELLS));
-       SetResource(this, RES_BULLETS, GetResource(spectatee, RES_BULLETS));
-       SetResource(this, RES_ROCKETS, GetResource(spectatee, RES_ROCKETS));
-       SetResource(this, RES_FUEL, GetResource(spectatee, RES_FUEL));
+       SetResourceExplicit(this, RES_ARMOR, GetResource(spectatee, RES_ARMOR));
+       SetResourceExplicit(this, RES_CELLS, GetResource(spectatee, RES_CELLS));
+       SetResourceExplicit(this, RES_PLASMA, GetResource(spectatee, RES_PLASMA));
+       SetResourceExplicit(this, RES_SHELLS, GetResource(spectatee, RES_SHELLS));
+       SetResourceExplicit(this, RES_BULLETS, GetResource(spectatee, RES_BULLETS));
+       SetResourceExplicit(this, RES_ROCKETS, GetResource(spectatee, RES_ROCKETS));
+       SetResourceExplicit(this, RES_FUEL, GetResource(spectatee, RES_FUEL));
        this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
-       SetResource(this, RES_HEALTH, GetResource(spectatee, RES_HEALTH));
+       SetResourceExplicit(this, RES_HEALTH, GetResource(spectatee, RES_HEALTH));
        CS(this).impulse = 0;
        this.items = spectatee.items;
        STAT(LAST_PICKUP, this) = STAT(LAST_PICKUP, spectatee);
@@ -2429,7 +2429,7 @@ void PlayerPreThink (entity this)
                if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + frametime * this.revive_speed, 1);
-                       SetResource(this, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
+                       SetResourceExplicit(this, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
                        this.iceblock.alpha = bound(0.2, 1 - STAT(REVIVE_PROGRESS, this), 1);
 
                        if (STAT(REVIVE_PROGRESS, this) >= 1)
@@ -2438,7 +2438,7 @@ void PlayerPreThink (entity this)
                else if (STAT(FROZEN, this) == FROZEN_TEMP_DYING)
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - frametime * this.revive_speed, 1);
-                       SetResource(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+                       SetResourceExplicit(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
 
                        if (GetResource(this, RES_HEALTH) < 1)
                        {
index 5fdd924891316d3a51363250d241a423e770a824..112a7f039d95cee3c5ab34820011a0a1a7dd20d4 100644 (file)
@@ -142,33 +142,33 @@ void target_give_init(entity this)
        IL_EACH(g_items, it.targetname == this.target,
        {
                if (it.classname == "weapon_devastator") {
-                       SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "devastator");
                }
                else if (it.classname == "weapon_vortex") {
-                       SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "vortex");
                }
                else if (it.classname == "weapon_electro") {
-                       SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "electro");
                }
                else if (it.classname == "weapon_hagar") {
-                       SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "hagar");
                }
                else if (it.classname == "weapon_crylink") {
-                       SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "crylink");
                }
                else if (it.classname == "weapon_mortar") {
-                       SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
+                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
                        this.netname = cons(this.netname, "mortar");
                }
                else if (it.classname == "item_armor_mega")
-                       SetResource(this, RES_ARMOR, 100);
+                       SetResourceExplicit(this, RES_ARMOR, 100);
                else if (it.classname == "item_health_mega")
-                       SetResource(this, RES_HEALTH, 200);
+                       SetResourceExplicit(this, RES_HEALTH, 200);
                //remove(it); // removing ents in init functions causes havoc, workaround:
         setthink(it, SUB_Remove);
         it.nextthink = time;
index 01b4926ecd743c04c21c54a2b02fba7c853c64e6..ee911d5b65e8ac849db044c6a9accfcfcd94f690 100644 (file)
@@ -595,9 +595,9 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                // These are ALWAYS lethal
                // No damage modification here
                // Instead, prepare the victim for his death...
-               SetResource(targ, RES_ARMOR, 0);
+               SetResourceExplicit(targ, RES_ARMOR, 0);
                targ.spawnshieldtime = 0;
-               SetResource(targ, RES_HEALTH, 0.9); // this is < 1
+               SetResourceExplicit(targ, RES_HEALTH, 0.9); // this is < 1
                targ.flags -= targ.flags & FL_GODMODE;
                damage = 100000;
        }
index e00096344df75f1b4c8bf39354c4721f2ca1f1eb..ffb19f17a1041e0048bf12b9b3e7beeb31920539 100644 (file)
@@ -397,7 +397,7 @@ void FireGrapplingHook(entity actor, .entity weaponentity)
 
        missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION;
 
-       SetResource(missile, RES_HEALTH, autocvar_g_balance_grapplehook_health);
+       SetResourceExplicit(missile, RES_HEALTH, autocvar_g_balance_grapplehook_health);
        missile.event_damage = GrapplingHook_Damage;
        missile.takedamage = DAMAGE_AIM;
        missile.damageforcescale = 0;
index c9560d8e7ee5960c036790b2a0f088eb0ac5fd50..849162d1108c7c0335da64b489b6fe73b93ed2e7 100644 (file)
@@ -1523,7 +1523,7 @@ void FixIntermissionClient(entity e)
        if(!e.autoscreenshot) // initial call
        {
                e.autoscreenshot = time + 0.8;  // used for autoscreenshot
-               SetResource(e, RES_HEALTH, -2342);
+               SetResourceExplicit(e, RES_HEALTH, -2342);
                // first intermission phase; voting phase has positive health (used to decide whether to send SVC_FINALE or not)
                for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
index eec081075d867e4242ed3fb9cb0330df6dcdb470..ceb2cdd07850a884875e4895d71f614e3de7867e 100644 (file)
@@ -593,7 +593,7 @@ void MapVote_Tick()
                // hide scoreboard again
                if(GetResource(it, RES_HEALTH) != 2342)
                {
-                       SetResource(it, RES_HEALTH, 2342);
+                       SetResourceExplicit(it, RES_HEALTH, 2342);
                        CS(it).impulse = 0;
 
                        msg_entity = it;
index ce36cdfae2317edf032293c71e2f33e0c6e03dc6..ed1d938a294128758632d7e5be46caf7c5519fb5 100644 (file)
@@ -93,8 +93,8 @@ void CopyBody(entity this, float keepvelocity)
        clone.dphitcontentsmask = this.dphitcontentsmask;
        clone.death_time = this.death_time;
        clone.pain_finished = this.pain_finished;
-       SetResource(clone, RES_HEALTH, GetResource(this, RES_HEALTH));
-       SetResource(clone, RES_ARMOR, GetResource(this, RES_ARMOR));
+       SetResourceExplicit(clone, RES_HEALTH, GetResource(this, RES_HEALTH));
+       SetResourceExplicit(clone, RES_ARMOR, GetResource(this, RES_ARMOR));
        clone.armortype = this.armortype;
        clone.model = this.model;
        clone.modelindex = this.modelindex;
index fb09d352b2ec365e2a450b14d51a56d34d93c410..6f128716365933599e271f4294ef295a779ef8b8 100644 (file)
@@ -199,8 +199,8 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        // reset fade counter
        teleporter.portal_wants_to_vanish = 0;
        teleporter.fade_time = ((autocvar_g_balance_portal_lifetime >= 0) ? time + autocvar_g_balance_portal_lifetime : 0);
-       SetResource(teleporter, RES_HEALTH, autocvar_g_balance_portal_health);
-       SetResource(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
+       SetResourceExplicit(teleporter, RES_HEALTH, autocvar_g_balance_portal_health);
+       SetResourceExplicit(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
 
        return 1;
 }
@@ -639,7 +639,7 @@ entity Portal_Spawn(entity own, vector org, vector ang)
        portal.takedamage = DAMAGE_AIM;
        portal.event_damage = Portal_Damage;
        portal.fade_time = ((autocvar_g_balance_portal_lifetime >= 0) ? time + autocvar_g_balance_portal_lifetime : 0);
-       SetResource(portal, RES_HEALTH, autocvar_g_balance_portal_health);
+       SetResourceExplicit(portal, RES_HEALTH, autocvar_g_balance_portal_health);
        setmodel(portal, MDL_PORTAL);
        portal.savemodelindex = portal.modelindex;
        setcefc(portal, Portal_Customize);
index 4ff31c3c066e191341a231836075eebc683c84a9..6e63b2e3ee687a8750836eca16b643b175bb52ab 100644 (file)
@@ -76,6 +76,17 @@ float GetResource(entity e, int res_type)
        return e.(GetResourceField(res_type));
 }
 
+bool SetResourceExplicit(entity e, int res_type, float amount)
+{
+       .float res_field = GetResourceField(res_type);
+       if (e.(res_field) != amount)
+       {
+               e.(res_field) = amount;
+               return true;
+       }
+       return false;
+}
+
 void SetResource(entity e, int res_type, float amount)
 {
        bool forbid = MUTATOR_CALLHOOK(SetResource, e, res_type, amount);
@@ -92,10 +103,9 @@ void SetResource(entity e, int res_type, float amount)
                amount_wasted = amount - max_amount;
                amount = max_amount;
        }
-       .float res_field = GetResourceField(res_type);
-       if (e.(res_field) != amount)
+       bool changed = SetResourceExplicit(e, res_type, amount);
+       if (changed)
        {
-               e.(res_field) = amount;
                MUTATOR_CALLHOOK(ResourceAmountChanged, e, res_type, amount);
        }
        if (amount_wasted == 0)
index b5e188b62062b8bba29cd4049f818485a346a766..f93db58fc324387b97b50e69da7e8f3319049a9d 100644 (file)
@@ -21,6 +21,13 @@ float GetResourceLimit(entity e, int res_type);
 /// \return Current amount of resource the given entity has.
 float GetResource(entity e, int res_type);
 
+/// \brief Sets the resource amount of an entity without calling any hooks.
+/// \param[in,out] e Entity to adjust.
+/// \param[in] res_type Type of the resource (a RES_* constant).
+/// \param[in] amount Amount of resource to set.
+/// \return Boolean for whether the ammo amount was changed
+bool SetResourceExplicit(entity e, int res_type, float amount);
+
 /// \brief Sets the current amount of resource the given entity will have.
 /// \param[in,out] e Entity to adjust.
 /// \param[in] res_type Type of the resource (a RES_* constant).