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)
/// \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).
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);
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; \
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,
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");
// 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
{
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); });
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;
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;
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;
}
this.ctf_flagdamaged_byworld = true;
else
{
- SetResource(this, RES_HEALTH, 0);
+ SetResourceExplicit(this, RES_HEALTH, 0);
ctf_CheckFlagReturn(this, RETURN_NEEDKILL);
}
return;
{
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;
}
{
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
{
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; }
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;
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;
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();
}
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
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)
{
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();
if(_tmp != GetResource(this, RES_HEALTH))
cpicon_damage(this, _tmp);
- SetResource(this, RES_HEALTH, _tmp);
+ SetResourceExplicit(this, RES_HEALTH, _tmp);
}
}
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();
if(_tmp != GetResource(this, RES_HEALTH))
generator_damage(this, _tmp);
- SetResource(this, RES_HEALTH, _tmp);
+ SetResourceExplicit(this, RES_HEALTH, _tmp);
}
}
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);
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;
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;
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);
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
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) {
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) {
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) {
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
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
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
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
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
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
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
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
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
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
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) {
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);
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);
{
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
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)
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;
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;
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);
}
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 == ""))
// 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)
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;
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;
{
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;
}
{
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);
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;
}
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 == "")
{
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;
}
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;
}
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;
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;
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); }
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;
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); }
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);
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); }
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); }
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];
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;
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); }
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
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;
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)
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));
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; }
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);
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) {
if(GetResource(proj, RES_HEALTH))
{
// disable health which in effect disables damage calculations
- SetResource(proj, RES_HEALTH, 0);
+ SetResourceExplicit(proj, RES_HEALTH, 0);
}
}
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;
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);
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?!
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
}
else
{
- SetResource(this, RES_HEALTH, -1);
+ SetResourceExplicit(this, RES_HEALTH, -1);
this.build_finished = 0;
}
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);
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;
}
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);
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;
}
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);
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;
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;
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;
}
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; }
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;
{
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;
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;
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);
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;
}
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);
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
}
{
#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;
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
}
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;
}
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;
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))
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);
_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);
}
}
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);
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;
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
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;
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);
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;
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);
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;
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;
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;
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;
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);
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;
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;
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);
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;
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;
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);
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);
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)
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;
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);
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)
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)
{
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;
// 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;
}
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;
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)
{
// 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;
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;
// 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;
}
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);
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);
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)
/// \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).