entity player = M_ARGV(0, entity);
if(IS_PLAYER(player))
- if(player.health <= autocvar_g_bloodloss && !IS_DEAD(player))
+ if(GetResourceAmount(player, RESOURCE_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
{
PHYS_INPUT_BUTTON_CROUCH(player) = true;
{
entity player = M_ARGV(0, entity);
- if(player.health <= autocvar_g_bloodloss)
+ if(GetResourceAmount(player, RESOURCE_HEALTH) <= autocvar_g_bloodloss)
return true;
}
{
FOREACH_CLIENT(IS_PLAYER(it) && it != this && vdist(it.origin - this.origin, <=, autocvar_g_buffs_medic_heal_range),
{
- if(SAME_TEAM(it, this))
- if(it.health < autocvar_g_balance_health_regenstable)
+ if (!SAME_TEAM(it, this))
{
- Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
- it.health = bound(0, it.health + autocvar_g_buffs_medic_heal_amount, autocvar_g_balance_health_regenstable);
+ continue;
}
+ float hp = GetResourceAmount(it, RESOURCE_HEALTH);
+ if(hp >= autocvar_g_balance_health_regenstable)
+ {
+ continue;
+ }
+ Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
+ SetResourceAmount(it, RESOURCE_HEALTH, bound(0, hp + autocvar_g_buffs_medic_heal_amount, autocvar_g_balance_health_regenstable));
});
}
frag_damage *= autocvar_g_buffs_speed_damage_take;
if(frag_target.buffs & BUFF_MEDIC.m_itemid)
- if((frag_target.health - frag_damage) <= 0)
+ if((GetResourceAmount(frag_target, RESOURCE_HEALTH) - frag_damage) <= 0)
if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype))
if(frag_attacker)
if(random() <= autocvar_g_buffs_medic_survive_chance)
- frag_damage = max(5, frag_target.health - autocvar_g_buffs_medic_survive_health);
+ frag_damage = max(5, GetResourceAmount(frag_target, RESOURCE_HEALTH) - autocvar_g_buffs_medic_survive_health);
if(frag_target.buffs & BUFF_JUMP.m_itemid)
if(frag_deathtype == DEATH_FALL.m_id)
if(frag_target.takedamage)
if(DIFF_TEAM(frag_attacker, frag_target))
{
- frag_attacker.health = bound(0, frag_attacker.health + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, frag_target.health), g_pickup_healthsmall_max);
+ float hp = GetResourceAmount(frag_attacker, RESOURCE_HEALTH);
+ SetResourceAmount(frag_attacker, RESOURCE_HEALTH, bound(0, hp + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, GetResourceAmount(frag_target, RESOURCE_HEALTH)), g_pickup_healthsmall_max));
if(frag_target.armorvalue)
frag_attacker.armorvalue = bound(0, frag_attacker.armorvalue + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, frag_target.armorvalue), g_pickup_armorsmall_max);
}
if(player.vehicle)
Damage(player.vehicle, NULL, NULL, autocvar_g_campcheck_damage * 2, DEATH_CAMP.m_id, player.vehicle.origin, '0 0 0');
else
- Damage(player, NULL, NULL, bound(0, autocvar_g_campcheck_damage, player.health + player.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP.m_id, player.origin, '0 0 0');
+ Damage(player, NULL, NULL, bound(0, autocvar_g_campcheck_damage, GetResourceAmount(player, RESOURCE_HEALTH) + GetResourceAmount(player, RESOURCE_ARMOR) * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP.m_id, player.origin, '0 0 0');
}
player.campcheck_nextcheck = time + autocvar_g_campcheck_interval;
player.campcheck_traveled_distance = 0;
if(IS_DEAD(this) || game_stopped)
instagib_stop_countdown(this);
- else if (this.ammo_cells > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+ else if (GetResourceAmount(this, RESOURCE_CELLS) > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
instagib_stop_countdown(this);
else if(autocvar_g_rm && autocvar_g_rm_laser)
{
}
else
{
+ float hp = GetResourceAmount(this, RESOURCE_HEALTH);
this.instagib_needammo = true;
- if (this.health <= 5)
+ if (hp <= 5)
{
Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
}
- else if (this.health <= 10)
+ else if (hp <= 10)
{
Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_1);
}
- else if (this.health <= 20)
+ else if (hp <= 20)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_2);
}
- else if (this.health <= 30)
+ else if (hp <= 30)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_3);
}
- else if (this.health <= 40)
+ else if (hp <= 40)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_4);
}
- else if (this.health <= 50)
+ else if (hp <= 50)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_5);
}
- else if (this.health <= 60)
+ else if (hp <= 60)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_6);
}
- else if (this.health <= 70)
+ else if (hp <= 70)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_7);
}
- else if (this.health <= 80)
+ else if (hp <= 80)
{
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_8);
}
- else if (this.health <= 90)
+ else if (hp <= 90)
{
Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
if(!autocvar_g_instagib_friendlypush && SAME_TEAM(frag_target, frag_attacker))
frag_force = '0 0 0';
- if(frag_target.armorvalue)
+ float armor = GetResourceAmount(frag_target, RESOURCE_ARMOR);
+ if(armor)
{
- frag_target.armorvalue -= 1;
+ armor -= 1;
+ SetResourceAmount(frag_target, RESOURCE_ARMOR, armor);
frag_damage = 0;
frag_target.damage_dealt += 1;
frag_attacker.damage_dealt += 1;
- Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
+ Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, armor);
}
}
if(frag_target != frag_attacker)
{
- if(frag_damage <= 0 && frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
+ if(frag_damage <= 0 && GetResourceAmount(frag_target, RESOURCE_HEALTH) > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
if(!autocvar_g_instagib_blaster_keepforce)
frag_force = '0 0 0';
}
if(frag_mirrordamage > 0)
{
// just lose extra LIVES, don't kill the player for mirror damage
- if(frag_attacker.armorvalue > 0)
+ float armor = GetResourceAmount(frag_attacker, RESOURCE_ARMOR);
+ if(armor > 0)
{
- frag_attacker.armorvalue -= 1;
- Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
+ armor -= 1;
+ SetResourceAmount(frag_attacker, RESOURCE_ARMOR, armor);
+ Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, armor);
frag_attacker.damage_dealt += frag_mirrordamage;
}
frag_mirrordamage = 0;
if(item.weapon == WEP_VAPORIZER.m_id && item.classname == "droppedweapon")
{
- item.ammo_cells = autocvar_g_instagib_ammo_drop;
+ SetResourceAmount(item, RESOURCE_CELLS, autocvar_g_instagib_ammo_drop);
return false;
}
if(item.flags & FL_POWERUP)
return false;
- if(item.ammo_cells > autocvar_g_instagib_ammo_drop && item.classname != "item_minst_cells")
- item.ammo_cells = autocvar_g_instagib_ammo_drop;
+ float cells = GetResourceAmount(item, RESOURCE_CELLS);
+ if(cells > autocvar_g_instagib_ammo_drop && item.classname != "item_minst_cells")
+ SetResourceAmount(item, RESOURCE_CELLS, autocvar_g_instagib_ammo_drop);
- if(item.ammo_cells && !item.weapon)
+ if(cells && !item.weapon)
return false;
return true;
entity item = M_ARGV(0, entity);
entity toucher = M_ARGV(1, entity);
- if(item.ammo_cells)
+ if(GetResourceAmount(item, RESOURCE_CELLS))
{
// play some cool sounds ;)
+ float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
if (IS_CLIENT(toucher))
{
- if(toucher.health <= 5)
+ if(hp <= 5)
Send_Notification(NOTIF_ONE, toucher, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
- else if(toucher.health < 50)
+ else if(hp < 50)
Send_Notification(NOTIF_ONE, toucher, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
}
- if(toucher.health < 100)
- toucher.health = 100;
+ if(hp < 100)
+ SetResourceAmount(toucher, RESOURCE_HEALTH, 100);
return MUT_ITEMTOUCH_CONTINUE;
}
if(item.itemdef == ITEM_ExtraLife)
{
- toucher.armorvalue = bound(toucher.armorvalue, 999, toucher.armorvalue + autocvar_g_instagib_extralives);
+ GiveResource(toucher, RESOURCE_ARMOR, autocvar_g_instagib_extralives);
Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES);
return MUT_ITEMTOUCH_PICKUP;
}
float current_freeze_time = this.ltime - time - 0.1;
- FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0,
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResourceAmount(it, RESOURCE_HEALTH) > 0 && current_freeze_time > 0,
{
if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
if(!it.revival_time || ((time - it.revival_time) >= 1.5))
if ( health_factor > 0 )
{
maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
- if ( toucher.health < maxhealth )
+ float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
+ if (hp < maxhealth)
{
if ( this.nade_show_particles )
Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
- toucher.health = min(toucher.health+health_factor, maxhealth);
+ SetResourceAmount(toucher, RESOURCE_HEALTH, min(hp + health_factor, maxhealth));
}
toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
}
if(autocvar_g_nades_pickup)
if(time >= this.spawnshieldtime)
- if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much
+ if(!toucher.nade && GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
{
//setsize(this, '-2 -2 -2', '2 2 2');
//UpdateCSQCProjectile(this);
- if(this.health == this.max_health)
+ if(GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health)
{
spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
return;
if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
return;
- if(this.health == this.max_health)
+ float hp = GetResourceAmount(this, RESOURCE_HEALTH);
+ if(hp == this.max_health)
{
sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
this.nextthink = max(time + this.nade_lifetime, time);
setthink(this, nade_beep);
}
- this.health -= damage;
+ hp -= damage;
+ SetResourceAmount(this, RESOURCE_HEALTH, hp);
+
if ( this.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
this.realowner = attacker;
- if(this.health <= 0)
+ if(hp <= 0)
W_PrepareExplosionByDamage(this, attacker, nade_boom);
else
nade_burn_spawn(this);
settouch(_nade, nade_touch);
_nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
- _nade.health = autocvar_g_nades_nade_health;
+ SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
_nade.max_health = _nade.health;
_nade.takedamage = DAMAGE_AIM;
_nade.event_damage = nade_damage;
if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
{
player.revive_progress = bound(0, player.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
- player.health = max(1, player.revive_progress * start_health);
+ SetResourceAmount(player, RESOURCE_HEALTH, max(1, player.revive_progress * start_health));
if(player.revive_progress >= 1)
{
if(time - frag_inflictor.toss_time <= 0.1)
{
Unfreeze(frag_target);
- frag_target.health = autocvar_g_freezetag_revive_nade_health;
+ SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
M_ARGV(4, float) = 0;
M_ARGV(6, vector) = '0 0 0';
{
// as the PlayerSpawn hook will no longer run, NIX is turned off by this!
FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
- it.ammo_cells = start_ammo_cells;
- it.ammo_plasma = start_ammo_plasma;
- it.ammo_shells = start_ammo_shells;
- it.ammo_nails = start_ammo_nails;
- it.ammo_rockets = start_ammo_rockets;
- it.ammo_fuel = start_ammo_fuel;
+ SetResourceAmount(it, RESOURCE_SHELLS, start_ammo_shells);
+ SetResourceAmount(it, RESOURCE_BULLETS, start_ammo_nails);
+ SetResourceAmount(it, RESOURCE_ROCKETS, start_ammo_rockets);
+ SetResourceAmount(it, RESOURCE_CELLS, start_ammo_cells);
+ SetResourceAmount(it, RESOURCE_PLASMA, start_ammo_plasma);
+ SetResourceAmount(it, RESOURCE_FUEL, start_ammo_fuel);
it.weapons = start_weapons;
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
if(nix_nextchange != this.nix_lastchange_id) // this shall only be called once per round!
{
- this.ammo_shells = this.ammo_nails = this.ammo_rockets = this.ammo_cells = this.ammo_plasma = this.ammo_fuel = 0;
-
+ SetResourceAmount(this, RESOURCE_SHELLS, 0);
+ SetResourceAmount(this, RESOURCE_BULLETS, 0);
+ SetResourceAmount(this, RESOURCE_ROCKETS, 0);
+ SetResourceAmount(this, RESOURCE_CELLS, 0);
+ SetResourceAmount(this, RESOURCE_PLASMA, 0);
+ SetResourceAmount(this, RESOURCE_FUEL, 0);
if(this.items & IT_UNLIMITED_WEAPON_AMMO)
{
switch(e.ammo_field)
{
- case ammo_shells: this.ammo_shells = autocvar_g_pickup_shells_max; break;
- case ammo_nails: this.ammo_nails = autocvar_g_pickup_nails_max; break;
- case ammo_rockets: this.ammo_rockets = autocvar_g_pickup_rockets_max; break;
- case ammo_cells: this.ammo_cells = autocvar_g_pickup_cells_max; break;
- case ammo_plasma: this.ammo_plasma = autocvar_g_pickup_plasma_max; break;
- case ammo_fuel: this.ammo_fuel = autocvar_g_pickup_fuel_max; break;
+ case ammo_shells: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_pickup_shells_max); break;
+ case ammo_nails: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_pickup_nails_max); break;
+ case ammo_rockets: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_pickup_rockets_max); break;
+ case ammo_cells: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_pickup_cells_max); break;
+ case ammo_plasma: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_pickup_plasma_max); break;
+ case ammo_fuel: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_pickup_fuel_max); break;
}
}
else
{
switch(e.ammo_field)
{
- case ammo_shells: this.ammo_shells = autocvar_g_balance_nix_ammo_shells; break;
- case ammo_nails: this.ammo_nails = autocvar_g_balance_nix_ammo_nails; break;
- case ammo_rockets: this.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break;
- case ammo_cells: this.ammo_cells = autocvar_g_balance_nix_ammo_cells; break;
- case ammo_plasma: this.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break;
- case ammo_fuel: this.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break;
+ case ammo_shells: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammo_shells); break;
+ case ammo_nails: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammo_nails); break;
+ case ammo_rockets: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break;
+ case ammo_cells: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammo_cells); break;
+ case ammo_plasma: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammo_plasma); break;
+ case ammo_fuel: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammo_fuel); break;
}
}
{
switch(e.ammo_field)
{
- case ammo_shells: this.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break;
- case ammo_nails: this.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break;
- case ammo_rockets: this.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break;
- case ammo_cells: this.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break;
- case ammo_plasma: this.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break;
- case ammo_fuel: this.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break;
+ case ammo_shells: GiveResource(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammoincr_shells); break;
+ case ammo_nails: GiveResource(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammoincr_nails); break;
+ case ammo_rockets: GiveResource(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammoincr_rockets); break;
+ case ammo_cells: GiveResource(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammoincr_cells); break;
+ case ammo_plasma: GiveResource(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammoincr_plasma); break;
+ case ammo_fuel: GiveResource(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammoincr_fuel); break;
}
this.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
if(deathtype == DEATH_FIRE.m_id)
{
Send_Notification(NOTIF_ONE, attacker, MSG_CHOICE, CHOICE_FRAG_FIRE, targ.netname, kill_count_to_attacker, (IS_BOT_CLIENT(targ) ? -1 : CS(targ).ping));
- Send_Notification(NOTIF_ONE, targ, MSG_CHOICE, CHOICE_FRAGGED_FIRE, attacker.netname, kill_count_to_target, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping));
+ Send_Notification(NOTIF_ONE, targ, MSG_CHOICE, CHOICE_FRAGGED_FIRE, attacker.netname, kill_count_to_target, GetResourceAmount(attacker, RESOURCE_HEALTH), GetResourceAmount(attacker, RESOURCE_ARMOR), (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping));
return true;
}
CHOICE_TYPEFRAGGED,
attacker.netname,
kill_count_to_target,
- attacker.health,
- attacker.armorvalue,
+ GetResourceAmount(attacker, RESOURCE_HEALTH),
+ GetResourceAmount(attacker, RESOURCE_ARMOR),
(IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
);
}
CHOICE_FRAGGED,
attacker.netname,
kill_count_to_target,
- attacker.health,
- attacker.armorvalue,
+ GetResourceAmount(attacker, RESOURCE_HEALTH),
+ GetResourceAmount(attacker, RESOURCE_ARMOR),
(IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
);
}
STAT(FROZEN, targ) = frozen_type;
targ.revive_progress = ((frozen_type == 3) ? 1 : 0);
- targ.health = ((frozen_type == 3) ? targ_maxhealth : 1);
+ SetResourceAmount(targ, RESOURCE_HEALTH, ((frozen_type == 3) ? targ_maxhealth : 1));
targ.revive_speed = freeze_time;
if(targ.bot_attack)
IL_REMOVE(g_bot_targets, targ);
if(STAT(FROZEN, targ) && STAT(FROZEN, targ) != 3) // only reset health if target was frozen
{
- targ.health = ((IS_PLAYER(targ)) ? start_health : targ.max_health);
+ SetResourceAmount(targ, RESOURCE_HEALTH, ((IS_PLAYER(targ)) ? start_health : targ.max_health));
targ.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
}
// These are ALWAYS lethal
// No damage modification here
// Instead, prepare the victim for his death...
- targ.armorvalue = 0;
+ SetResourceAmount(targ, RESOURCE_ARMOR, 0);
targ.spawnshieldtime = 0;
- targ.health = 0.9; // this is < 1
+ SetResourceAmount(targ, RESOURCE_HEALTH, 0.9); // this is < 1
targ.flags -= targ.flags & FL_GODMODE;
damage = 100000;
}
if(damage >= autocvar_g_frozen_revive_falldamage)
{
Unfreeze(targ);
- targ.health = autocvar_g_frozen_revive_falldamage_health;
+ SetResourceAmount(targ, RESOURCE_HEALTH, autocvar_g_frozen_revive_falldamage_health);
Send_Effect(EFFECT_ICEORGLASS, targ.origin, '0 0 0', 3);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_FALL, targ.netname);
Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
/**/
MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);
+/** Called when the amount of resource of an entity changes. See RESOURCE_*
+constants for resource types. Return true to forbid the change. */
+#define EV_SetResourceAmount(i, o) \
+ /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** resource type */ i(int, MUTATOR_ARGV_1_int) \
+ /**/ o(int, MUTATOR_ARGV_1_int) \
+ /** amount */ i(float, MUTATOR_ARGV_2_float) \
+ /**/ o(float, MUTATOR_ARGV_2_float) \
+ /**/
+MUTATOR_HOOKABLE(SetResourceAmount, EV_SetResourceAmount);
+
/** Called when entity is being given some resource. See RESOURCE_* constants
for resource types. Return true to forbid giving. */
#define EV_GiveResource(i, o) \
void SetResourceAmount(entity e, int resource_type, float amount)
{
+ bool forbid = MUTATOR_CALLHOOK(SetResourceAmount, e, resource_type, amount);
+ if (forbid)
+ {
+ return;
+ }
+ resource_type = M_ARGV(1, int);
+ amount = M_ARGV(2, float);
.float resource_field = GetResourceField(resource_type);
if (e.(resource_field) == amount)
{