void DrawAmmoItem(vector myPos, vector mySize, int ammoType, bool isCurrent, bool isInfinite)
{
TC(bool, isCurrent); TC(bool, isInfinite);
- if(ammoType == RESOURCE_NONE)
+ if(ammoType == RES_NONE)
return;
// Initialize variables
int ammo;
if(autocvar__hud_configure)
{
- isCurrent = (ammoType == RESOURCE_ROCKETS); // Rockets always current
+ isCurrent = (ammoType == RES_ROCKETS); // Rockets always current
ammo = 60;
}
else
{
if(autocvar__hud_configure)
{
- DrawAmmoItem(pos, ammo_size, RESOURCE_ROCKETS, true, false);
+ DrawAmmoItem(pos, ammo_size, RES_ROCKETS, true, false);
}
else
{
IL_EACH(g_radaricons, it.teamradar_icon, {
if ( hud_panel_radar_mouse )
- if ( GetResourceAmount(it, RESOURCE_HEALTH) >= 0 )
+ if ( GetResourceAmount(it, RES_HEALTH) >= 0 )
if ( it.team == myteam + 1 || ISGAMETYPE(RACE) || !teamplay )
{
vector coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(it.origin));
}
// draw ammo status bar
- if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RESOURCE_NONE))
+ if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RES_NONE))
{
float ammo_full;
a = getstati(GetAmmoStat(it.ammo_type)); // how much ammo do we have?
{
switch (it.ammo_type)
{
- case RESOURCE_SHELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
- case RESOURCE_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
- case RESOURCE_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
- case RESOURCE_CELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
- case RESOURCE_PLASMA: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break;
- case RESOURCE_FUEL: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
+ case RES_SHELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
+ case RES_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
+ case RES_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
+ case RES_CELLS: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
+ case RES_PLASMA: ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma; break;
+ case RES_FUEL: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
default: ammo_full = 60;
}
vector Rotate(vector v, float a);
-#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResourceAmount((s), RESOURCE_HEALTH) <= 0))
+#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResourceAmount((s), RES_HEALTH) <= 0))
// decolorizes and team colors the player name when needed
/// \brief Source file that contains implementation of the resource system.
/// \copyright GNU GPLv2 or any later version.
-float GetResourceAmount(entity e, int resource_type)
+float GetResourceAmount(entity e, int res_type)
{
- .float resource_field = GetResourceField(resource_type);
- return e.(resource_field);
+ return e.(GetResourceField(res_type));
}
-void SetResourceAmount(entity e, int resource_type, float amount)
+void SetResourceAmount(entity e, int res_type, float amount)
{
- .float resource_field = GetResourceField(resource_type);
- e.(resource_field) = amount;
+ e.(GetResourceField(res_type)) = amount;
}
-void TakeResource(entity receiver, int resource_type, float amount)
+void TakeResource(entity receiver, int res_type, float amount)
{
if (amount == 0)
{
return;
}
- SetResourceAmount(receiver, resource_type,
- GetResourceAmount(receiver, resource_type) - amount);
+ SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) - amount);
}
-void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit)
+void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
if (amount == 0)
{
return;
}
- float current_amount = GetResourceAmount(receiver, resource_type);
+ float current_amount = GetResourceAmount(receiver, res_type);
if (current_amount - amount < limit)
{
amount = limit + current_amount;
}
- TakeResource(receiver, resource_type, amount);
+ TakeResource(receiver, res_type, amount);
}
-int GetResourceType(.float resource_field)
+int GetResourceType(.float res_field)
{
- switch (resource_field)
+ switch (res_field)
{
- case health: { return RESOURCE_HEALTH; }
- case armorvalue: { return RESOURCE_ARMOR; }
- case ammo_shells: { return RESOURCE_SHELLS; }
- case ammo_nails: { return RESOURCE_BULLETS; }
- case ammo_rockets: { return RESOURCE_ROCKETS; }
- case ammo_cells: { return RESOURCE_CELLS; }
- case ammo_plasma: { return RESOURCE_PLASMA; }
- case ammo_fuel: { return RESOURCE_FUEL; }
+ case health: { return RES_HEALTH; }
+ case armorvalue: { return RES_ARMOR; }
+ case ammo_shells: { return RES_SHELLS; }
+ case ammo_nails: { return RES_BULLETS; }
+ case ammo_rockets: { return RES_ROCKETS; }
+ case ammo_cells: { return RES_CELLS; }
+ case ammo_plasma: { return RES_PLASMA; }
+ case ammo_fuel: { return RES_FUEL; }
}
error("GetResourceType: Invalid field.");
return 0;
}
-.float GetResourceField(int resource_type)
+.float GetResourceField(int res_type)
{
- switch (resource_type)
+ switch (res_type)
{
- case RESOURCE_HEALTH: { return health; }
- case RESOURCE_ARMOR: { return armorvalue; }
- case RESOURCE_SHELLS: { return ammo_shells; }
- case RESOURCE_BULLETS: { return ammo_nails; }
- case RESOURCE_ROCKETS: { return ammo_rockets; }
- case RESOURCE_CELLS: { return ammo_cells; }
- case RESOURCE_PLASMA: { return ammo_plasma; }
- case RESOURCE_FUEL: { return ammo_fuel; }
+ case RES_HEALTH: { return health; }
+ case RES_ARMOR: { return armorvalue; }
+ case RES_SHELLS: { return ammo_shells; }
+ case RES_BULLETS: { return ammo_nails; }
+ case RES_ROCKETS: { return ammo_rockets; }
+ case RES_CELLS: { return ammo_cells; }
+ case RES_PLASMA: { return ammo_plasma; }
+ case RES_FUEL: { return ammo_fuel; }
}
error("GetResourceField: Invalid resource type.");
return health;
/// \brief Returns the current amount of resource the given entity has.
/// \param[in] e Entity to check.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \return Current amount of resource the given entity has.
-float GetResourceAmount(entity e, int resource_type);
+float GetResourceAmount(entity e, int res_type);
/// \brief Sets the current amount of resource the given entity will have.
/// \param[in,out] e Entity to adjust.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to set.
/// \return No return.
-void SetResourceAmount(entity e, int resource_type, float amount);
+void SetResourceAmount(entity e, int res_type, float amount);
/// \brief Takes an entity some resource.
/// \param[in,out] receiver Entity to take resource from.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to take.
/// \return No return.
-void TakeResource(entity receiver, int resource_type, float amount);
+void TakeResource(entity receiver, int res_type, float amount);
/// \brief Takes an entity some resource but not less than a limit.
/// \param[in,out] receiver Entity to take resource from.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to take.
/// \param[in] limit Limit of resources to take.
/// \return No return.
-void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit);
+void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
// ===================== Legacy and/or internal API ===========================
/// \brief Converts an entity field to resource type.
-/// \param[in] resource_field Entity field to convert.
-/// \return Resource type (a RESOURCE_* constant).
-int GetResourceType(.float resource_field);
+/// \param[in] res_field Entity field to convert.
+/// \return Resource type (a RES_* constant).
+int GetResourceType(.float res_field);
-/// \brief Converts resource type (a RESOURCE_* constant) to entity field.
-/// \param[in] resource_type Type of the resource.
+/// \brief Converts resource type (a RES_* constant) to entity field.
+/// \param[in] res_type Type of the resource.
/// \return Entity field for that resource.
-.float GetResourceField(int resource_type);
+.float GetResourceField(int res_type);
/// \brief Legacy fields for the resources. To be removed.
.float health;
this.healthvalue / autocvar_hud_panel_healtharmor_maxhealth, false, 1, '1 0 0', a,
DRAWFLAG_NORMAL);
}
- if (GetResourceAmount(this, RESOURCE_ARMOR) > 0)
+ if (GetResourceAmount(this, RES_ARMOR) > 0)
{
HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize.x, sz, "nametag_statusbar",
- GetResourceAmount(this, RESOURCE_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor, false, 0, '0 1 0', a,
+ GetResourceAmount(this, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor, false, 0, '0 1 0', a,
DRAWFLAG_NORMAL);
}
}
if (entcs.m_entcs_private)
{
it.healthvalue = entcs.healthvalue;
- SetResourceAmount(it, RESOURCE_ARMOR, GetResourceAmount(entcs, RESOURCE_ARMOR));
+ SetResourceAmount(it, RES_ARMOR, GetResourceAmount(entcs, RES_ARMOR));
it.sameteam = true;
}
else
{
it.healthvalue = 0;
- SetResourceAmount(it, RESOURCE_ARMOR, 0);
+ SetResourceAmount(it, RES_ARMOR, 0);
it.sameteam = false;
}
bool dead = entcs_IsDead(i) || entcs_IsSpectating(i);
CONSTRUCT(DebugText3d);
this.origin = pos;
this.message = strzone(msg);
- SetResourceAmount(this, RESOURCE_HEALTH, align);
+ SetResourceAmount(this, RES_HEALTH, align);
this.hit_time = time;
this.fade_rate = fade_rate_;
this.velocity = vel;
if (screen_pos.z < 0) return; // behind camera
screen_pos.z = 0;
- float align = GetResourceAmount(this, RESOURCE_HEALTH);
+ float align = GetResourceAmount(this, RES_HEALTH);
string msg;
vector msg_pos;
// FIXME: use a better scale?
#define DEC_FACTOR 10
-ENTCS_PROP_RESOURCE(HEALTH, false, RESOURCE_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
- { WriteByte(chan, bound(0, GetResourceAmount(ent, RESOURCE_HEALTH) / DEC_FACTOR, 255)); },
+ENTCS_PROP_RESOURCE(HEALTH, false, RES_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
+ { WriteByte(chan, bound(0, GetResourceAmount(ent, RES_HEALTH) / DEC_FACTOR, 255)); },
{ ent.healthvalue = ReadByte() * DEC_FACTOR; })
-ENTCS_PROP_RESOURCE(ARMOR, false, RESOURCE_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
- { WriteByte(chan, bound(0, GetResourceAmount(ent, RESOURCE_ARMOR) / DEC_FACTOR, 255)); },
- { SetResourceAmount(ent, RESOURCE_ARMOR, ReadByte() * DEC_FACTOR); })
+ENTCS_PROP_RESOURCE(ARMOR, false, RES_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
+ { WriteByte(chan, bound(0, GetResourceAmount(ent, RES_ARMOR) / DEC_FACTOR, 255)); },
+ { SetResourceAmount(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
- SetResourceAmount(this, RESOURCE_HEALTH, 100);
+ SetResourceAmount(this, RES_HEALTH, 100);
//print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
//print("Activator is ", actor.classname, "\n");
vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
{
- float hlth = GetResourceAmount(this, RESOURCE_HEALTH);
+ float hlth = GetResourceAmount(this, RES_HEALTH);
if (hlth < 0 || hlth >= ASSAULT_VALUE_INACTIVE)
return '-1 0 0';
return current;
// and when a new round starts
void assault_objective_reset(entity this)
{
- SetResourceAmount(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE);
+ SetResourceAmount(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
}
// decrease the health of targeted objectives
else
return; // already activated! cannot activate again!
- float hlth = GetResourceAmount(this.enemy, RESOURCE_HEALTH);
+ float hlth = GetResourceAmount(this.enemy, RES_HEALTH);
if (hlth < ASSAULT_VALUE_INACTIVE)
{
if (hlth - this.dmg > 0.5)
{
GameRules_scoring_add_team(actor, SCORE, this.dmg);
- TakeResource(this.enemy, RESOURCE_HEALTH, this.dmg);
+ TakeResource(this.enemy, RES_HEALTH, this.dmg);
}
else
{
GameRules_scoring_add_team(actor, SCORE, hlth);
GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
- SetResourceAmount(this.enemy, RESOURCE_HEALTH, -1);
+ SetResourceAmount(this.enemy, RES_HEALTH, -1);
if(this.enemy.message)
FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); });
bool assault_decreaser_sprite_visible(entity this, entity player, entity view)
{
- if(GetResourceAmount(this.assault_decreaser.enemy, RESOURCE_HEALTH) >= ASSAULT_VALUE_INACTIVE)
+ if(GetResourceAmount(this.assault_decreaser.enemy, RES_HEALTH) >= ASSAULT_VALUE_INACTIVE)
return false;
return true;
{
WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy);
WaypointSprite_UpdateMaxHealth(spr, it.max_health);
- WaypointSprite_UpdateHealth(spr, GetResourceAmount(it, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(spr, GetResourceAmount(it, RES_HEALTH));
it.sprite = spr;
}
else
void assault_wall_think(entity this)
{
- if(GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 0)
+ if(GetResourceAmount(this.enemy, RES_HEALTH) < 0)
{
this.model = "";
this.solid = SOLID_NOT;
this.dmg = 101;
this.use = assault_objective_decrease_use;
- SetResourceAmount(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE);
+ SetResourceAmount(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
this.max_health = ASSAULT_VALUE_INACTIVE;
this.enemy = NULL;
// destructible walls that can be used to trigger target_objective_decrease
bool destructible_heal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
- float hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
+ float hlth = GetResourceAmount(targ, RES_HEALTH);
if (hlth <= 0 || hlth >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.sprite)
{
- WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RES_HEALTH));
}
func_breakable_colormod(targ);
return true;
entity destr = it;
IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
{
- float hlth = GetResourceAmount(it.enemy, RESOURCE_HEALTH);
+ float hlth = GetResourceAmount(it.enemy, RES_HEALTH);
if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE)
{
found = true;
entity frag_attacker = M_ARGV(1, entity);
entity frag_target = M_ARGV(2, entity);
float frag_damage = M_ARGV(7, float);
- float damage_take = bound(0, M_ARGV(4, float), GetResourceAmount(frag_target, RESOURCE_HEALTH));
- float damage_save = bound(0, M_ARGV(5, float), GetResourceAmount(frag_target, RESOURCE_ARMOR));
+ float damage_take = bound(0, M_ARGV(4, float), GetResourceAmount(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResourceAmount(frag_target, RES_ARMOR));
float excess = max(0, frag_damage - damage_take - damage_save);
{
WaypointSprite_Spawn(WP_FlagCarrier, 0, 0, player, FLAG_WAYPOINT_OFFSET, NULL, player.team, player, wps_flagcarrier, true, RADARICON_FLAG);
WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, 2 * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
- WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResourceAmount(player, RESOURCE_HEALTH), GetResourceAmount(player, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResourceAmount(player, RES_HEALTH), GetResourceAmount(player, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, WPCOLOR_FLAGCARRIER(player.team));
if(player.flagcarried && CTF_SAMETEAM(player, player.flagcarried))
set_movetype(flag, MOVETYPE_TOSS);
flag.takedamage = DAMAGE_YES;
flag.angles = '0 0 0';
- SetResourceAmount(flag, RESOURCE_HEALTH, flag.max_flag_health);
+ SetResourceAmount(flag, RES_HEALTH, flag.max_flag_health);
flag.ctf_droptime = time;
flag.ctf_dropper = player;
flag.ctf_status = FLAG_DROPPED;
if(autocvar_g_ctf_flag_return_time || (autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health))
{
WaypointSprite_UpdateMaxHealth(flag.wps_flagdropped, flag.max_flag_health);
- WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResourceAmount(flag, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResourceAmount(flag, RES_HEALTH));
}
player.throw_antispam = time + autocvar_g_ctf_pass_wait;
switch(pickuptype)
{
case PICKUP_BASE: flag.ctf_pickuptime = time; break; // used for timing runs
- case PICKUP_DROPPED: SetResourceAmount(flag, RESOURCE_HEALTH, flag.max_flag_health); break; // reset health/return timelimit
+ case PICKUP_DROPPED: SetResourceAmount(flag, RES_HEALTH, flag.max_flag_health); break; // reset health/return timelimit
default: break;
}
{
if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING))
{
- if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResourceAmount(flag, RESOURCE_HEALTH)); }
+ if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResourceAmount(flag, RES_HEALTH)); }
- if((GetResourceAmount(flag, RESOURCE_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time))
+ if((GetResourceAmount(flag, RES_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time))
{
switch(returntype)
{
this.ctf_flagdamaged_byworld = true;
else
{
- SetResourceAmount(this, RESOURCE_HEALTH, 0);
+ SetResourceAmount(this, RES_HEALTH, 0);
ctf_CheckFlagReturn(this, RETURN_NEEDKILL);
}
return;
if(autocvar_g_ctf_flag_return_damage)
{
// reduce health and check if it should be returned
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
ctf_CheckFlagReturn(this, RETURN_DAMAGE);
return;
}
{
if((vdist(this.origin - this.ctf_spawnorigin, <=, autocvar_g_ctf_flag_return_dropped)) || (autocvar_g_ctf_flag_return_dropped == -1))
{
- SetResourceAmount(this, RESOURCE_HEALTH, 0);
+ SetResourceAmount(this, RES_HEALTH, 0);
ctf_CheckFlagReturn(this, RETURN_DROPPED);
return;
}
}
if(this.ctf_flagdamaged_byworld)
{
- TakeResource(this, RESOURCE_HEALTH, ((this.max_flag_health / autocvar_g_ctf_flag_return_damage_delay) * FLAG_THINKRATE));
+ TakeResource(this, RES_HEALTH, ((this.max_flag_health / autocvar_g_ctf_flag_return_damage_delay) * FLAG_THINKRATE));
ctf_CheckFlagReturn(this, RETURN_NEEDKILL);
return;
}
else if(autocvar_g_ctf_flag_return_time)
{
- TakeResource(this, RESOURCE_HEALTH, ((this.max_flag_health / autocvar_g_ctf_flag_return_time) * FLAG_THINKRATE));
+ TakeResource(this, RES_HEALTH, ((this.max_flag_health / autocvar_g_ctf_flag_return_time) * FLAG_THINKRATE));
ctf_CheckFlagReturn(this, RETURN_TIMEOUT);
return;
}
{
if(this.speedrunning && ctf_captimerecord && (time >= this.ctf_pickuptime + ctf_captimerecord))
{
- SetResourceAmount(this, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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)
{
- SetResourceAmount(flag, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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;
- SetResourceAmount(flag, RESOURCE_HEALTH, flag.max_flag_health);
+ SetResourceAmount(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);
- SetResourceAmount(flag, RESOURCE_HEALTH, flag.max_flag_health);
+ SetResourceAmount(flag, RES_HEALTH, flag.max_flag_health);
flag.event_damage = ctf_FlagDamage;
flag.pushable = true;
flag.teleportable = TELEPORT_NORMAL;
{
// adjust rating of our flag carrier depending on his health
head = head.tag_entity;
- float f = bound(0, (GetResourceAmount(head, RESOURCE_HEALTH) + GetResourceAmount(head, RESOURCE_ARMOR)) / 100, 2) - 1;
+ float f = bound(0, (GetResourceAmount(head, RES_HEALTH) + GetResourceAmount(head, RES_ARMOR)) / 100, 2) - 1;
ratingscale += ratingscale * f * 0.1;
}
navigation_routerating(this, head, ratingscale, 10000);
// update the health of the flag carrier waypointsprite
if(player.wps_flagcarrier)
- WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResourceAmount(player, RESOURCE_HEALTH), GetResourceAmount(player, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResourceAmount(player, RES_HEALTH), GetResourceAmount(player, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
}
MUTATOR_HOOKFUNCTION(ctf, Damage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc
}
else if(frag_target.flagcarried && !IS_DEAD(frag_target) && CTF_DIFFTEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
{
- if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > healtharmor_maxdamage(GetResourceAmount(frag_target, RESOURCE_HEALTH), GetResourceAmount(frag_target, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x
+ if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > healtharmor_maxdamage(GetResourceAmount(frag_target, RES_HEALTH), GetResourceAmount(frag_target, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x
&& time > frag_target.wps_helpme_time + autocvar_g_ctf_flagcarrier_auto_helpme_time)
{
frag_target.wps_helpme_time = time;
{
if(!IS_PLAYER(toucher))
return;
- if(GetResourceAmount(toucher, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(toucher, RES_HEALTH) < 1)
return;
if(round_handler_IsActive() && !round_handler_IsRoundStarted())
FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it),
{
++total_players;
- if (GetResourceAmount(it, RESOURCE_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
+ if (GetResourceAmount(it, RES_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
{
continue;
}
{
entity last_pl = NULL;
FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
- if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResourceAmount(it, RESOURCE_HEALTH) >= 1)
+ if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResourceAmount(it, RES_HEALTH) >= 1)
{
if (!last_pl)
last_pl = it;
navigation_routerating(this, it, ratingscale, 2000);
}
else if (best_dist2
- && GetResourceAmount(it, RESOURCE_HEALTH) < GetResourceAmount(this, RESOURCE_HEALTH) + 30
+ && GetResourceAmount(it, RES_HEALTH) < GetResourceAmount(this, RES_HEALTH) + 30
&& vlen2(it.origin - org) < best_dist2)
{
// If teamate is not frozen still seek them out as fight better
freezetag_LastPlayerForTeam_Notify(this);
Unfreeze(this, false);
- SetResourceAmount(this, RESOURCE_HEALTH, 0); // neccessary to correctly count alive players
+ SetResourceAmount(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);
- SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+ SetResourceAmount(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);
- SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+ SetResourceAmount(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
if(STAT(REVIVE_PROGRESS, player) >= 1)
{
Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : CS(frag_target).ping));
Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target,
- GetResourceAmount(frag_attacker, RESOURCE_HEALTH), GetResourceAmount(frag_attacker, RESOURCE_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
+ GetResourceAmount(frag_attacker, RES_HEALTH), GetResourceAmount(frag_attacker, RES_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
return true;
}
float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
- IL_EACH(g_monsters, GetResourceAmount(it, RESOURCE_HEALTH) > 0,
+ IL_EACH(g_monsters, GetResourceAmount(it, RES_HEALTH) > 0,
{
if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
++supermonster_count;
}
if (!IS_PLAYER(toucher))
return;
- if(GetResourceAmount(toucher, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(toucher, RES_HEALTH) < 1)
return;
if(!this.cnt)
this.nextthink = time + autocvar_g_nexball_delay_idle;
}
if(!this.cnt && IS_PLAYER(toucher) && !STAT(FROZEN, toucher) && !IS_DEAD(toucher) && (toucher != this.nb_dropper || time > this.nb_droptime + autocvar_g_nexball_delay_collect))
{
- if(GetResourceAmount(toucher, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(toucher, RES_HEALTH) < 1)
return;
LogNB("caught", toucher);
GiveBall(toucher, this);
this.cp_bob_spd = this.cp_bob_spd + 1.875 * frametime;
this.colormod = '1 1 1' * (2 - bound(0, (this.pain_finished - time) / 10, 1));
- if(!this.iscaptured) this.alpha = GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health;
+ if(!this.iscaptured) this.alpha = GetResourceAmount(this, RES_HEALTH) / this.max_health;
if(this.iscaptured)
{
this.origin = ReadVector();
setorigin(this, this.origin);
- SetResourceAmount(this, RESOURCE_HEALTH, ReadByte());
+ SetResourceAmount(this, RES_HEALTH, ReadByte());
this.max_health = ReadByte();
this.count = ReadByte();
this.team = ReadByte();
this.iscaptured = ReadByte();
if(!this.count)
- this.count = (GetResourceAmount(this, RESOURCE_HEALTH) - this.max_health) * frametime;
+ this.count = (GetResourceAmount(this, RES_HEALTH) - this.max_health) * frametime;
cpicon_changeteam(this);
cpicon_construct(this, isnew);
_tmp = ReadByte();
- if(_tmp != GetResourceAmount(this, RESOURCE_HEALTH))
+ if(_tmp != GetResourceAmount(this, RES_HEALTH))
cpicon_damage(this, _tmp);
- SetResourceAmount(this, RESOURCE_HEALTH, _tmp);
+ SetResourceAmount(this, RES_HEALTH, _tmp);
}
}
if(time < this.move_time)
return;
- if(GetResourceAmount(this, RESOURCE_HEALTH) > 0)
+ if(GetResourceAmount(this, RES_HEALTH) > 0)
{
// damaged fx (less probable the more damaged is the generator)
- if(random() < 0.9 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health)
+ if(random() < 0.9 - GetResourceAmount(this, RES_HEALTH) / this.max_health)
if(random() < 0.01)
{
pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
this.origin = ReadVector();
setorigin(this, this.origin);
- SetResourceAmount(this, RESOURCE_HEALTH, ReadByte());
+ SetResourceAmount(this, RES_HEALTH, ReadByte());
this.max_health = ReadByte();
this.count = ReadByte();
this.team = ReadByte();
_tmp = ReadByte();
- if(_tmp != GetResourceAmount(this, RESOURCE_HEALTH))
+ if(_tmp != GetResourceAmount(this, RES_HEALTH))
generator_damage(this, _tmp);
- SetResourceAmount(this, RESOURCE_HEALTH, _tmp);
+ SetResourceAmount(this, RES_HEALTH, _tmp);
}
}
entity gen = NULL;
if(ons_roundlost)
{
- IL_EACH(g_onsgenerators, GetResourceAmount(it, RESOURCE_HEALTH) <= 0,
+ IL_EACH(g_onsgenerators, GetResourceAmount(it, RES_HEALTH) <= 0,
{
gen = it;
break;
{
WriteVector(MSG_ENTITY, this.origin);
- WriteByte(MSG_ENTITY, GetResourceAmount(this, RESOURCE_HEALTH));
+ WriteByte(MSG_ENTITY, GetResourceAmount(this, RES_HEALTH));
WriteByte(MSG_ENTITY, this.max_health);
WriteByte(MSG_ENTITY, this.count);
WriteByte(MSG_ENTITY, this.team);
{
WriteByte(MSG_ENTITY, this.team);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
{
WriteVector(MSG_ENTITY, this.origin);
- WriteByte(MSG_ENTITY, GetResourceAmount(this, RESOURCE_HEALTH));
+ WriteByte(MSG_ENTITY, GetResourceAmount(this, RES_HEALTH));
WriteByte(MSG_ENTITY, this.max_health);
WriteByte(MSG_ENTITY, this.count);
WriteByte(MSG_ENTITY, this.team);
{
WriteByte(MSG_ENTITY, this.team);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
ons_notification_time[this.team] = time;
}
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
if(this.owner.iscaptured)
- WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RES_HEALTH));
else
- WaypointSprite_UpdateBuildFinished(this.owner.sprite, time + (this.max_health - GetResourceAmount(this, RESOURCE_HEALTH)) / (this.count / ONS_CP_THINKRATE));
+ WaypointSprite_UpdateBuildFinished(this.owner.sprite, time + (this.max_health - GetResourceAmount(this, RES_HEALTH)) / (this.count / ONS_CP_THINKRATE));
this.pain_finished = time + 1;
// particles on every hit
pointparticles(EFFECT_SPARKS, hitloc, force*-1, 1);
else
sound(this, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE+0.3, ATTEN_NORM);
- if (GetResourceAmount(this, RESOURCE_HEALTH) < 0)
+ if (GetResourceAmount(this, RES_HEALTH) < 0)
{
sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
bool ons_ControlPoint_Icon_Heal(entity targ, entity inflictor, float amount, float limit)
{
- float hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
+ float hlth = GetResourceAmount(targ, RES_HEALTH);
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
if (hlth <= 0 || hlth >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
- hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
+ hlth = GetResourceAmount(targ, RES_HEALTH);
if(targ.owner.iscaptured)
WaypointSprite_UpdateHealth(targ.owner.sprite, hlth);
else
_friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
_enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
- GiveResourceWithLimit(this, RESOURCE_HEALTH, (_friendly_count - _enemy_count), this.max_health);
+ GiveResourceWithLimit(this, RES_HEALTH, (_friendly_count - _enemy_count), this.max_health);
this.SendFlags |= CPSF_STATUS;
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, DMG_NOWEP, this.origin, '0 0 0');
return;
if (time > this.pain_finished + 5)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) < this.max_health)
+ if(GetResourceAmount(this, RES_HEALTH) < this.max_health)
{
- GiveResourceWithLimit(this, RESOURCE_HEALTH, this.count, this.max_health);
- WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ GiveResourceWithLimit(this, RES_HEALTH, this.count, this.max_health);
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RES_HEALTH));
}
}
}
// damaged fx
- if(random() < 0.6 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health)
+ if(random() < 0.6 - GetResourceAmount(this, RES_HEALTH) / this.max_health)
{
Send_Effect(EFFECT_ELECTRIC_SPARKS, this.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
if(!a)
return;
- GiveResource(this, RESOURCE_HEALTH, this.count);
+ GiveResource(this, RES_HEALTH, this.count);
this.SendFlags |= CPSF_STATUS;
- if (GetResourceAmount(this, RESOURCE_HEALTH) >= this.max_health)
+ if (GetResourceAmount(this, RES_HEALTH) >= this.max_health)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(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);
Send_Effect(EFFECT_CAP(this.owner.team), this.owner.origin, '0 0 0', 1);
WaypointSprite_UpdateMaxHealth(this.owner.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RES_HEALTH));
if(IS_PLAYER(this.owner.ons_toucher))
{
if(this.owner.model != MDL_ONS_CP_PAD2.model_str())
setmodel(this.owner, MDL_ONS_CP_PAD2);
- if(random() < 0.9 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health)
+ if(random() < 0.9 - GetResourceAmount(this, RES_HEALTH) / this.max_health)
Send_Effect(EFFECT_RAGE, this.origin + 10 * randomvec(), '0 0 -1', 1);
}
e.owner = cp;
e.max_health = autocvar_g_onslaught_cp_health;
- SetResourceAmount(e, RESOURCE_HEALTH, autocvar_g_onslaught_cp_buildhealth);
+ SetResourceAmount(e, RES_HEALTH, autocvar_g_onslaught_cp_buildhealth);
e.solid = SOLID_NOT;
e.takedamage = DAMAGE_AIM;
e.bot_attack = true;
e.event_heal = ons_ControlPoint_Icon_Heal;
e.team = player.team;
e.colormap = 1024 + (e.team - 1) * 17;
- e.count = (e.max_health - GetResourceAmount(e, RESOURCE_HEALTH)) * ONS_CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
+ e.count = (e.max_health - GetResourceAmount(e, RES_HEALTH)) * ONS_CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
sound(e, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILD, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_FLAG_TOUCH(player.team), e.origin, '0 0 0', 1);
- WaypointSprite_UpdateBuildFinished(cp.sprite, time + (e.max_health - GetResourceAmount(e, RESOURCE_HEALTH)) / (e.count / ONS_CP_THINKRATE));
+ WaypointSprite_UpdateBuildFinished(cp.sprite, time + (e.max_health - GetResourceAmount(e, RES_HEALTH)) / (e.count / ONS_CP_THINKRATE));
WaypointSprite_UpdateRule(cp.sprite,cp.team,SPRITERULE_TEAMPLAY);
cp.sprite.SendFlags |= 16;
else
{
WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
- WaypointSprite_UpdateHealth(e.sprite, GetResourceAmount(e.goalentity, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(e.sprite, GetResourceAmount(e.goalentity, RES_HEALTH));
}
}
if(e.lastshielded)
play2team(this.team, SND(ONS_GENERATOR_UNDERATTACK));
}
}
- TakeResource(this, RESOURCE_HEALTH, damage);
- float hlth = GetResourceAmount(this, RESOURCE_HEALTH);
+ TakeResource(this, RES_HEALTH, damage);
+ float hlth = GetResourceAmount(this, RES_HEALTH);
WaypointSprite_UpdateHealth(this.sprite, hlth);
// choose an animation frame based on health
this.frame = 10 * bound(0, (1 - hlth / this.max_health), 1);
bool ons_GeneratorHeal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
- float hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
+ float hlth = GetResourceAmount(targ, RES_HEALTH);
if (hlth <= 0 || hlth >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
- hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
+ hlth = GetResourceAmount(targ, RES_HEALTH);
WaypointSprite_UpdateHealth(targ.sprite, hlth);
targ.frame = 10 * bound(0, (1 - hlth / targ.max_health), 1);
targ.lasthealth = hlth;
void ons_GeneratorReset(entity this)
{
this.team = this.team_saved;
- SetResourceAmount(this, RESOURCE_HEALTH, autocvar_g_onslaught_gen_health);
+ SetResourceAmount(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;
this.SendFlags |= GSF_STATUS;
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
WaypointSprite_UpdateRule(this.sprite,this.team,SPRITERULE_TEAMPLAY);
onslaught_updatelinks();
IL_PUSH(g_saved_team, gen);
set_movetype(gen, MOVETYPE_NONE);
gen.lasthealth = gen.max_health = autocvar_g_onslaught_gen_health;
- SetResourceAmount(gen, RESOURCE_HEALTH, autocvar_g_onslaught_gen_health);
+ SetResourceAmount(gen, RES_HEALTH, autocvar_g_onslaught_gen_health);
gen.takedamage = DAMAGE_AIM;
gen.bot_attack = true;
IL_PUSH(g_bot_targets, gen);
WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE);
WaypointSprite_UpdateRule(gen.sprite, gen.team, SPRITERULE_TEAMPLAY);
WaypointSprite_UpdateMaxHealth(gen.sprite, gen.max_health);
- WaypointSprite_UpdateHealth(gen.sprite, GetResourceAmount(gen, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(gen.sprite, GetResourceAmount(gen, RES_HEALTH));
InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
}
for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext)
{
++total_generators;
- if (GetResourceAmount(e, RESOURCE_HEALTH) < 1)
+ if (GetResourceAmount(e, RES_HEALTH) < 1)
{
continue;
}
{
entity source_point = ons_Nearest_ControlPoint(player, player.origin, autocvar_g_onslaught_teleport_radius);
- if ( !source_point && GetResourceAmount(player, RESOURCE_HEALTH) > 0 )
+ if ( !source_point && GetResourceAmount(player, RES_HEALTH) > 0 )
{
sprint(player, "\nYou need to be next to a control point\n");
return true;
return true;
}
- if ( GetResourceAmount(player, RESOURCE_HEALTH) <= 0 )
+ if ( GetResourceAmount(player, RES_HEALTH) <= 0 )
{
player.ons_spawn_by = closest_target;
player.respawn_flags = player.respawn_flags | RESPAWN_FORCE;
{
entity wp_owner = wp.owner;
entity e = WaypointSprite_getviewentity(to);
- if(SAME_TEAM(e, wp_owner) && GetResourceAmount(wp_owner.goalentity, RESOURCE_HEALTH) >= wp_owner.goalentity.max_health) { wp_flag |= 2; }
+ if(SAME_TEAM(e, wp_owner) && GetResourceAmount(wp_owner.goalentity, RES_HEALTH) >= wp_owner.goalentity.max_health) { wp_flag |= 2; }
if(!ons_ControlPoint_Attackable(wp_owner, e.team)) { wp_flag |= 2; }
}
if(wp.owner.classname == "onslaught_generator")
{
entity wp_owner = wp.owner;
- if(wp_owner.isshielded && GetResourceAmount(wp_owner, RESOURCE_HEALTH) >= wp_owner.max_health) { wp_flag |= 2; }
- if(GetResourceAmount(wp_owner, RESOURCE_HEALTH) <= 0) { wp_flag |= 2; }
+ if(wp_owner.isshielded && GetResourceAmount(wp_owner, RES_HEALTH) >= wp_owner.max_health) { wp_flag |= 2; }
+ if(GetResourceAmount(wp_owner, RES_HEALTH) <= 0) { wp_flag |= 2; }
}
}
PROPERTY(int, g_pickup_nails);
void ammo_bullets_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_BULLETS))
- SetResourceAmount(item, RESOURCE_BULLETS, g_pickup_nails);
+ if(!GetResourceAmount(item, RES_BULLETS))
+ SetResourceAmount(item, RES_BULLETS, g_pickup_nails);
}
#endif
PROPERTY(int, g_pickup_cells);
void ammo_cells_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_CELLS))
- SetResourceAmount(item, RESOURCE_CELLS, g_pickup_cells);
+ if(!GetResourceAmount(item, RES_CELLS))
+ SetResourceAmount(item, RES_CELLS, g_pickup_cells);
}
#endif
REGISTER_ITEM(Cells, Ammo) {
PROPERTY(int, g_pickup_plasma);
void ammo_plasma_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_PLASMA))
- SetResourceAmount(item, RESOURCE_PLASMA, g_pickup_plasma);
+ if(!GetResourceAmount(item, RES_PLASMA))
+ SetResourceAmount(item, RES_PLASMA, g_pickup_plasma);
}
#endif
REGISTER_ITEM(Plasma, Ammo) {
PROPERTY(int, g_pickup_rockets);
void ammo_rockets_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_ROCKETS))
- SetResourceAmount(item, RESOURCE_ROCKETS, g_pickup_rockets);
+ if(!GetResourceAmount(item, RES_ROCKETS))
+ SetResourceAmount(item, RES_ROCKETS, g_pickup_rockets);
}
#endif
REGISTER_ITEM(Rockets, Ammo) {
PROPERTY(int, g_pickup_shells);
void ammo_shells_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_SHELLS))
- SetResourceAmount(item, RESOURCE_SHELLS, g_pickup_shells);
+ if(!GetResourceAmount(item, RES_SHELLS))
+ SetResourceAmount(item, RES_SHELLS, g_pickup_shells);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armorsmall_max;
- if(!GetResourceAmount(item, RESOURCE_ARMOR))
- SetResourceAmount(item, RESOURCE_ARMOR, g_pickup_armorsmall);
+ if(!GetResourceAmount(item, RES_ARMOR))
+ SetResourceAmount(item, RES_ARMOR, g_pickup_armorsmall);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armormedium_max;
- if(!GetResourceAmount(item, RESOURCE_ARMOR))
- SetResourceAmount(item, RESOURCE_ARMOR, g_pickup_armormedium);
+ if(!GetResourceAmount(item, RES_ARMOR))
+ SetResourceAmount(item, RES_ARMOR, g_pickup_armormedium);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armorbig_max;
- if(!GetResourceAmount(item, RESOURCE_ARMOR))
- SetResourceAmount(item, RESOURCE_ARMOR, g_pickup_armorbig);
+ if(!GetResourceAmount(item, RES_ARMOR))
+ SetResourceAmount(item, RES_ARMOR, g_pickup_armorbig);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armormega_max;
- if(!GetResourceAmount(item, RESOURCE_ARMOR))
- SetResourceAmount(item, RESOURCE_ARMOR, g_pickup_armormega);
+ if(!GetResourceAmount(item, RES_ARMOR))
+ SetResourceAmount(item, RES_ARMOR, g_pickup_armormega);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthsmall_max;
- if(!GetResourceAmount(item, RESOURCE_HEALTH))
- SetResourceAmount(item, RESOURCE_HEALTH, g_pickup_healthsmall);
+ if(!GetResourceAmount(item, RES_HEALTH))
+ SetResourceAmount(item, RES_HEALTH, g_pickup_healthsmall);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthmedium_max;
- if(!GetResourceAmount(item, RESOURCE_HEALTH))
- SetResourceAmount(item, RESOURCE_HEALTH, g_pickup_healthmedium);
+ if(!GetResourceAmount(item, RES_HEALTH))
+ SetResourceAmount(item, RES_HEALTH, g_pickup_healthmedium);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthbig_max;
- if(!GetResourceAmount(item, RESOURCE_HEALTH))
- SetResourceAmount(item, RESOURCE_HEALTH, g_pickup_healthbig);
+ if(!GetResourceAmount(item, RES_HEALTH))
+ SetResourceAmount(item, RES_HEALTH, g_pickup_healthbig);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthmega_max;
- if(!GetResourceAmount(item, RESOURCE_HEALTH))
- SetResourceAmount(item, RESOURCE_HEALTH, g_pickup_healthmega);
+ if(!GetResourceAmount(item, RES_HEALTH))
+ SetResourceAmount(item, RES_HEALTH, g_pickup_healthmega);
}
#endif
PROPERTY(int, g_pickup_fuel_jetpack);
void powerup_jetpack_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_FUEL))
- SetResourceAmount(item, RESOURCE_FUEL, g_pickup_fuel_jetpack);
+ if(!GetResourceAmount(item, RES_FUEL))
+ SetResourceAmount(item, RES_FUEL, g_pickup_fuel_jetpack);
}
#endif
PROPERTY(int, g_pickup_fuel);
void ammo_fuel_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_FUEL))
- SetResourceAmount(item, RESOURCE_FUEL, g_pickup_fuel);
+ if(!GetResourceAmount(item, RES_FUEL))
+ SetResourceAmount(item, RES_FUEL, g_pickup_fuel);
}
#endif
REGISTER_ITEM(JetpackFuel, Ammo) {
float h;
if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE))
return;
- h = GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health;
+ h = GetResourceAmount(this, RES_HEALTH) / this.max_health;
if(h < 0.25)
this.colormod = '1 0 0';
else if(h <= 0.75)
void func_breakable_behave_destroyed(entity this)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(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)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
if(this.sprite)
{
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
}
if(!(this.spawnflags & BREAKABLE_NODAMAGE))
{
if(attacker.team == this.team)
return;
this.pain_finished = time;
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
if(this.sprite)
{
WaypointSprite_Ping(this.sprite);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
}
func_breakable_colormod(this);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
debrisforce = force;
spawnfunc(func_breakable)
{
float n, i;
- if(!GetResourceAmount(this, RESOURCE_HEALTH))
- SetResourceAmount(this, RESOURCE_HEALTH, 100);
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ if(!GetResourceAmount(this, RES_HEALTH))
+ SetResourceAmount(this, RES_HEALTH, 100);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
// yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
if(!this.debrismovetype) this.debrismovetype = MOVETYPE_BOUNCE;
this.state = STATE_DOWN;
SUB_CalcMove (this, this.pos1, TSPEED_LINEAR, this.speed, button_done);
this.frame = 0; // use normal textures
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
this.takedamage = DAMAGE_YES; // can be shot again
this.wait_remaining = -1;
this.activation_time = -1;
void button_fire(entity this)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(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)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
setorigin(this, this.pos1);
this.frame = 0; // use normal textures
this.state = STATE_BOTTOM;
this.active = ACTIVE_ACTIVE;
setthink(this, func_null);
this.nextthink = 0;
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
this.takedamage = DAMAGE_YES; // can be shot again
}
return;
if (this.spawnflags & BUTTON_DONTACCUMULATEDMG)
{
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= damage)
+ if (GetResourceAmount(this, RES_HEALTH) <= damage)
{
this.enemy = attacker;
button_fire(this);
}
else
{
- TakeResource(this, RESOURCE_HEALTH, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.enemy = attacker;
button_fire(this);
// if (this.health == 0) // all buttons are now shootable
// this.health = 10;
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
{
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
this.event_damage = button_damage;
this.takedamage = DAMAGE_YES;
}
if (this.max_health)
{
this.takedamage = DAMAGE_YES;
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
}
this.state = STATE_DOWN;
if(this.spawnflags & NOSPLASH)
if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
return;
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
if (this.itemkeys)
{
return;
}
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
{
- SetResourceAmount(this.owner, RESOURCE_HEALTH, this.owner.max_health);
+ SetResourceAmount(this.owner, RES_HEALTH, this.owner.max_health);
this.owner.takedamage = DAMAGE_NO; // will be reset upon return
door_use(this.owner, attacker, NULL);
}
void door_trigger_touch(entity this, entity toucher)
{
- if (GetResourceAmount(toucher, RESOURCE_HEALTH) < 1)
+ if (GetResourceAmount(toucher, RES_HEALTH) < 1)
#ifdef SVQC
if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher)))
#elif defined(CSQC)
{
this.owner = this.enemy = this;
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
return;
IFTARGETED
return;
cmaxs = this.absmax;
for(t = this; ; t = t.enemy)
{
- if(GetResourceAmount(t, RESOURCE_HEALTH) && !GetResourceAmount(this, RESOURCE_HEALTH))
- SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(t, RESOURCE_HEALTH));
+ if(GetResourceAmount(t, RES_HEALTH) && !GetResourceAmount(this, RES_HEALTH))
+ SetResourceAmount(this, RES_HEALTH, GetResourceAmount(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)
{
- SetResourceAmount(t, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH));
+ SetResourceAmount(t, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
t.targetname = this.targetname;
t.message = this.message;
if(t.enemy == this)
// shootable, or triggered doors just needed the owner/enemy links,
// they don't spawn a field
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
return;
IFTARGETED
return;
// common code for func_door and func_door_rotating spawnfuncs
void door_init_shared(entity this)
{
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
// unlock sound
if(this.noise == "")
this.state = STATE_BOTTOM;
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
{
//this.canteamdamage = true; // TODO
this.takedamage = DAMAGE_YES;
if (this.max_health)
{
this.takedamage = DAMAGE_YES;
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
}
this.state = STATE_DOWN;
float temp;
string message_save;
- SetResourceAmount(this, RESOURCE_HEALTH, 10000);
+ SetResourceAmount(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)
{
- SetResourceAmount(this, RESOURCE_HEALTH, 10000);
+ SetResourceAmount(this, RES_HEALTH, 10000);
this.takedamage = DAMAGE_YES;
//this.th_pain = fd_secret_use;
}
{
if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
{
- SetResourceAmount(this, RESOURCE_HEALTH, 10000);
+ SetResourceAmount(this, RES_HEALTH, 10000);
this.takedamage = DAMAGE_YES;
}
setorigin(this, this.oldorigin);
if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
{
//this.canteamdamage = true; // TODO
- SetResourceAmount(this, RESOURCE_HEALTH, 10000);
+ SetResourceAmount(this, RES_HEALTH, 10000);
this.takedamage = DAMAGE_YES;
this.event_damage = fd_secret_damage;
}
if (!toucher.iscreature)
return;
- if (GetResourceAmount(toucher, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(toucher, RES_HEALTH) <= 0)
return;
#elif defined(CSQC)
if (!IS_PLAYER(toucher))
if (!toucher.iscreature)
return;
- if (GetResourceAmount(toucher, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(toucher, RES_HEALTH) <= 0)
return;
#elif defined(CSQC)
if (!IS_PLAYER(toucher))
{
TDEATHLOOP(player.origin)
{
- if (IS_PLAYER(player) && GetResourceAmount(player, RESOURCE_HEALTH) >= 1)
+ if (IS_PLAYER(player) && GetResourceAmount(player, RES_HEALTH) >= 1)
{
if (!(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team))
{
if(IS_PLAYER(head))
- if(GetResourceAmount(head, RESOURCE_HEALTH) >= 1)
+ if(GetResourceAmount(head, RES_HEALTH) >= 1)
++tdeath_hit;
Damage (head, teleporter, telefragger, 10000, DEATH_TELEFRAG.m_id, DMG_NOWEP, head.origin, '0 0 0');
}
toucher.triggerhealtime = time + this.delay;
bool playthesound = (this.spawnflags & HEAL_SOUND_ALWAYS);
- bool healed = Heal(toucher, this, GetResourceAmount(this, RESOURCE_HEALTH), this.max_health);
+ bool healed = Heal(toucher, this, GetResourceAmount(this, RES_HEALTH), this.max_health);
if(playthesound || healed)
_sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
this.active = ACTIVE_ACTIVE;
if(!this.delay)
this.delay = 1;
- if(!GetResourceAmount(this, RESOURCE_HEALTH))
- SetResourceAmount(this, RESOURCE_HEALTH, 10); // TODO: use a special field for this, it doesn't have actual health!
+ if(!GetResourceAmount(this, RES_HEALTH))
+ SetResourceAmount(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)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
this.takedamage = DAMAGE_YES;
this.solid = SOLID_BBOX;
}
if(this.team)
if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != attacker.team))
return;
- TakeResource(this, RESOURCE_HEALTH, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.enemy = attacker;
this.goalentity = inflictor;
settouch(this, multi_touch);
if (this.max_health)
{
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
this.takedamage = DAMAGE_YES;
this.solid = SOLID_BBOX;
}
this.team_saved = this.team;
IL_PUSH(g_saved_team, this);
- if (GetResourceAmount(this, RESOURCE_HEALTH))
+ if (GetResourceAmount(this, RES_HEALTH))
{
if (this.spawnflags & SPAWNFLAG_NOTOUCH)
objerror (this, "health and notouch don't make sense\n");
this.canteamdamage = true;
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
this.event_damage = multi_eventdamage;
this.takedamage = DAMAGE_YES;
this.solid = SOLID_BBOX;
this.targetname = "";
// you can't just shoot a room to find it, can you?
- SetResourceAmount(this, RESOURCE_HEALTH, 0);
+ SetResourceAmount(this, RES_HEALTH, 0);
// a secret can not be delayed
this.delay = 0;
this.swamp_lifetime -= 1;
//Slug dead? then remove curses.
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.owner.in_swamp = 0;
delete(this);
{
if(targ == NULL)
return false;
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(targ, RES_HEALTH) <= 0)
return false;
if(DIFF_TEAM(targ, this) && targ != this.monster_follow)
return false;
if(STAT(FROZEN, targ))
return false;
if(!IS_PLAYER(targ))
- return (IS_MONSTER(targ) && GetResourceAmount(targ, RESOURCE_HEALTH) < targ.max_health);
+ return (IS_MONSTER(targ) && GetResourceAmount(targ, RES_HEALTH) < targ.max_health);
if(targ.items & ITEM_Shield.m_itemid)
return false;
switch(this.skin)
{
- case 0: return (GetResourceAmount(targ, RESOURCE_HEALTH) < autocvar_g_balance_health_regenstable);
+ case 0: return (GetResourceAmount(targ, RES_HEALTH) < autocvar_g_balance_health_regenstable);
case 1:
{
- return ((GetResourceAmount(targ, RESOURCE_CELLS) && GetResourceAmount(targ, RESOURCE_CELLS) < g_pickup_cells_max)
- || (GetResourceAmount(targ, RESOURCE_PLASMA) && GetResourceAmount(targ, RESOURCE_PLASMA) < g_pickup_plasma_max)
- || (GetResourceAmount(targ, RESOURCE_ROCKETS) && GetResourceAmount(targ, RESOURCE_ROCKETS) < g_pickup_rockets_max)
- || (GetResourceAmount(targ, RESOURCE_BULLETS) && GetResourceAmount(targ, RESOURCE_BULLETS) < g_pickup_nails_max)
- || (GetResourceAmount(targ, RESOURCE_SHELLS) && GetResourceAmount(targ, RESOURCE_SHELLS) < g_pickup_shells_max)
+ return ((GetResourceAmount(targ, RES_CELLS) && GetResourceAmount(targ, RES_CELLS) < g_pickup_cells_max)
+ || (GetResourceAmount(targ, RES_PLASMA) && GetResourceAmount(targ, RES_PLASMA) < g_pickup_plasma_max)
+ || (GetResourceAmount(targ, RES_ROCKETS) && GetResourceAmount(targ, RES_ROCKETS) < g_pickup_rockets_max)
+ || (GetResourceAmount(targ, RES_BULLETS) && GetResourceAmount(targ, RES_BULLETS) < g_pickup_nails_max)
+ || (GetResourceAmount(targ, RES_SHELLS) && GetResourceAmount(targ, RES_SHELLS) < g_pickup_shells_max)
);
}
- case 2: return (GetResourceAmount(targ, RESOURCE_ARMOR) < autocvar_g_balance_armor_regenstable);
- case 3: return (GetResourceAmount(targ, RESOURCE_HEALTH) > 0);
+ case 2: return (GetResourceAmount(targ, RES_ARMOR) < autocvar_g_balance_armor_regenstable);
+ case 3: return (GetResourceAmount(targ, RES_HEALTH) > 0);
}
return false;
// copied from W_Seeker_Think
void M_Mage_Attack_Spike_Think(entity this)
{
- if (time > this.ltime || (this.enemy && GetResourceAmount(this.enemy, RESOURCE_HEALTH) <= 0) || GetResourceAmount(this.owner, RESOURCE_HEALTH) <= 0) {
+ if (time > this.ltime || (this.enemy && GetResourceAmount(this.enemy, RES_HEALTH) <= 0) || GetResourceAmount(this.owner, RES_HEALTH) <= 0) {
this.projectiledeathtype |= HITTYPE_SPLASH;
M_Mage_Attack_Spike_Explode(this, NULL);
}
}
case 1:
{
- if(GetResourceAmount(this, RESOURCE_CELLS)) GiveResourceWithLimit(it, RESOURCE_CELLS, 1, g_pickup_cells_max);
- if(GetResourceAmount(this, RESOURCE_PLASMA)) GiveResourceWithLimit(it, RESOURCE_PLASMA, 1, g_pickup_plasma_max);
- if(GetResourceAmount(this, RESOURCE_ROCKETS)) GiveResourceWithLimit(it, RESOURCE_ROCKETS, 1, g_pickup_rockets_max);
- if(GetResourceAmount(this, RESOURCE_SHELLS)) GiveResourceWithLimit(it, RESOURCE_SHELLS, 2, g_pickup_shells_max);
- if(GetResourceAmount(this, RESOURCE_BULLETS)) GiveResourceWithLimit(it, RESOURCE_BULLETS, 5, g_pickup_nails_max);
+ if(GetResourceAmount(this, RES_CELLS)) GiveResourceWithLimit(it, RES_CELLS, 1, g_pickup_cells_max);
+ if(GetResourceAmount(this, RES_PLASMA)) GiveResourceWithLimit(it, RES_PLASMA, 1, g_pickup_plasma_max);
+ if(GetResourceAmount(this, RES_ROCKETS)) GiveResourceWithLimit(it, RES_ROCKETS, 1, g_pickup_rockets_max);
+ if(GetResourceAmount(this, RES_SHELLS)) GiveResourceWithLimit(it, RES_SHELLS, 2, g_pickup_shells_max);
+ if(GetResourceAmount(this, RES_BULLETS)) GiveResourceWithLimit(it, RES_BULLETS, 5, g_pickup_nails_max);
// TODO: fuel?
fx = EFFECT_AMMO_REGEN;
break;
}
case 2:
- if(GetResourceAmount(it, RESOURCE_ARMOR) < autocvar_g_balance_armor_regenstable)
+ if(GetResourceAmount(it, RES_ARMOR) < autocvar_g_balance_armor_regenstable)
{
- GiveResourceWithLimit(it, RESOURCE_ARMOR, autocvar_g_monster_mage_heal_allies, autocvar_g_balance_armor_regenstable);
+ GiveResourceWithLimit(it, RES_ARMOR, autocvar_g_monster_mage_heal_allies, autocvar_g_balance_armor_regenstable);
fx = EFFECT_ARMOR_REPAIR;
}
break;
case 3:
float hp = ((it == this) ? autocvar_g_monster_mage_heal_self : autocvar_g_monster_mage_heal_allies);
- TakeResource(it, RESOURCE_HEALTH, hp); // TODO: use regular damage functions? needs a way to bypass friendly fire checks
+ TakeResource(it, RES_HEALTH, hp); // TODO: use regular damage functions? needs a way to bypass friendly fire checks
fx = EFFECT_RAGE;
break;
}
else
{
Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
- Heal(it, this, autocvar_g_monster_mage_heal_allies, RESOURCE_LIMIT_NONE);
+ Heal(it, this, autocvar_g_monster_mage_heal_allies, RES_LIMIT_NONE);
if(!(it.spawnflags & MONSTERFLAG_INVINCIBLE) && it.sprite)
- WaypointSprite_UpdateHealth(it.sprite, GetResourceAmount(it, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(it.sprite, GetResourceAmount(it, RES_HEALTH));
}
});
void M_Mage_Defend_Shield_Remove(entity this)
{
this.effects &= ~(EF_ADDITIVE | EF_BLUE);
- SetResourceAmount(this, RESOURCE_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResourceAmount(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);
- SetResourceAmount(this, RESOURCE_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
+ SetResourceAmount(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;
});
}
- if(GetResourceAmount(actor, RESOURCE_HEALTH) < (autocvar_g_monster_mage_heal_minhealth) || need_help)
+ if(GetResourceAmount(actor, RES_HEALTH) < (autocvar_g_monster_mage_heal_minhealth) || need_help)
if(time >= actor.attack_finished_single[0])
if(random() < 0.5)
M_Mage_Defend_Heal(actor);
- if(time >= actor.mage_shield_time && GetResourceAmount(actor, RESOURCE_ARMOR))
+ if(time >= actor.mage_shield_time && GetResourceAmount(actor, RES_ARMOR))
M_Mage_Defend_Shield_Remove(actor);
if(actor.enemy)
- if(GetResourceAmount(actor, RESOURCE_HEALTH) < actor.max_health)
+ if(GetResourceAmount(actor, RES_HEALTH) < actor.max_health)
if(time >= actor.mage_shield_delay)
if(random() < 0.5)
M_Mage_Defend_Shield(actor);
METHOD(Mage, mr_setup, bool(Mage this, entity actor))
{
TC(Mage, this);
- if(!GetResourceAmount(this, RESOURCE_HEALTH)) SetResourceAmount(actor, RESOURCE_HEALTH, autocvar_g_monster_mage_health);
+ if(!GetResourceAmount(this, RES_HEALTH)) SetResourceAmount(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); }
void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
settouch(gren, M_Shambler_Attack_Lightning_Touch);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RESOURCE_HEALTH, 50);
+ SetResourceAmount(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(!GetResourceAmount(this, RESOURCE_HEALTH)) SetResourceAmount(actor, RESOURCE_HEALTH, autocvar_g_monster_shambler_health);
+ if(!GetResourceAmount(this, RES_HEALTH)) SetResourceAmount(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); }
Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, DMG_NOWEP, NULL);
- FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResourceAmount(it, RESOURCE_HEALTH) > 0 && it.monsterid != MON_SPIDER.monsterid,
+ FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResourceAmount(it, RES_HEALTH) > 0 && it.monsterid != MON_SPIDER.monsterid,
{
it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
});
setsize(proj, '-4 -4 -4', '4 4 4');
proj.takedamage = DAMAGE_NO;
proj.damageforcescale = 0;
- SetResourceAmount(proj, RESOURCE_HEALTH, 500);
+ SetResourceAmount(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(!GetResourceAmount(this, RESOURCE_HEALTH)) SetResourceAmount(actor, RESOURCE_HEALTH, autocvar_g_monster_spider_health);
+ if(!GetResourceAmount(this, RES_HEALTH)) SetResourceAmount(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(!GetResourceAmount(this, RESOURCE_HEALTH)) SetResourceAmount(actor, RESOURCE_HEALTH, autocvar_g_monster_wyvern_health);
+ if(!GetResourceAmount(this, RES_HEALTH)) SetResourceAmount(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); }
void M_Zombie_Attack_Leap_Touch(entity this, entity toucher)
{
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
return;
vector angles_face;
void M_Zombie_Defend_Block_End(entity this)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
setanim(this, this.anim_blockend, false, true, true);
- SetResourceAmount(this, RESOURCE_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResourceAmount(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
}
bool M_Zombie_Defend_Block(entity this)
{
- SetResourceAmount(this, RESOURCE_ARMOR, 0.9);
+ SetResourceAmount(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];
{
case MONSTER_ATTACK_MELEE:
{
- if(random() < 0.3 && GetResourceAmount(actor, RESOURCE_HEALTH) < 75 && GetResourceAmount(actor.enemy, RESOURCE_HEALTH) > 10)
+ if(random() < 0.3 && GetResourceAmount(actor, RES_HEALTH) < 75 && GetResourceAmount(actor.enemy, RES_HEALTH) > 10)
return M_Zombie_Defend_Block(actor);
float anim_chance = random();
METHOD(Zombie, mr_death, bool(Zombie this, entity actor))
{
TC(Zombie, this);
- SetResourceAmount(actor, RESOURCE_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResourceAmount(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(!GetResourceAmount(actor, RESOURCE_HEALTH)) SetResourceAmount(actor, RESOURCE_HEALTH, autocvar_g_monster_zombie_health);
+ if(!GetResourceAmount(actor, RES_HEALTH)) SetResourceAmount(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); }
|| (game_stopped)
|| (targ.items & IT_INVISIBILITY)
|| (IS_SPEC(targ) || IS_OBSERVER(targ)) // don't attack spectators
- || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(this, RESOURCE_HEALTH) <= 0))
+ || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(this, RES_HEALTH) <= 0))
|| (this.monster_follow == targ || targ.monster_follow == this)
|| (!IS_VEHICLE(targ) && (targ.flags & FL_NOTARGET))
|| (!autocvar_g_monsters_typefrag && PHYS_INPUT_BUTTON_CHAT(targ))
return false; // already attacking
if(!IS_ONGROUND(this))
return false; // not on the ground
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0 || IS_DEAD(this))
+ if(GetResourceAmount(this, RES_HEALTH) <= 0 || IS_DEAD(this))
return false; // called when dead?
if(time < this.attack_finished_single[0])
return false; // still attacking
// g_monsters_miniboss_chance cvar or spawnflags 64 causes a monster to be a miniboss
if ((this.spawnflags & MONSTERFLAG_MINIBOSS) || (chance < autocvar_g_monsters_miniboss_chance))
{
- GiveResource(this, RESOURCE_HEALTH, autocvar_g_monsters_miniboss_healthboost);
+ GiveResource(this, RES_HEALTH, autocvar_g_monsters_miniboss_healthboost);
this.effects |= EF_RED;
if(!this.weapon)
this.weapon = WEP_VORTEX.m_id;
this.takedamage = DAMAGE_NO;
setorigin(this, this.pos1);
this.angles = this.pos2;
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
setmodel(this, MDL_Null);
}
else
// cases where the enemy may have changed their state (don't need to check everything here)
if((!this.enemy)
- || (IS_DEAD(this.enemy) || GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 1)
+ || (IS_DEAD(this.enemy) || GetResourceAmount(this.enemy, RES_HEALTH) < 1)
|| (STAT(FROZEN, this.enemy))
|| (this.enemy.flags & FL_NOTARGET)
|| (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
Unfreeze(this, false); // remove any icy remains
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
this.velocity = '0 0 0';
this.enemy = NULL;
this.goalentity = NULL;
void Monster_Dead_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= -50) // 100 health until gone?
+ if(GetResourceAmount(this, RES_HEALTH) <= -50) // 100 health until gone?
{
Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
if(deathtype == DEATH_FALL.m_id && this.draggedby != NULL)
return;
- vector v = healtharmor_applydamage(100, GetResourceAmount(this, RESOURCE_ARMOR) / 100, deathtype, damage);
+ vector v = healtharmor_applydamage(100, GetResourceAmount(this, RES_ARMOR) / 100, deathtype, damage);
float take = v.x;
//float save = v.y;
if(take)
{
- TakeResource(this, RESOURCE_HEALTH, take);
+ TakeResource(this, RES_HEALTH, take);
Monster_Sound(this, monstersound_pain, 1.2, true, CH_PAIN);
}
if(this.sprite)
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
this.dmg_time = time;
Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, this, attacker);
}
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
if(deathtype == DEATH_KILL.m_id)
this.candrop = false; // killed by mobkill command
SUB_UseTargets(this, attacker, this.enemy);
this.target2 = this.oldtarget2; // reset to original target on death, incase we respawn
- Monster_Dead(this, attacker, (GetResourceAmount(this, RESOURCE_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id));
+ Monster_Dead(this, attacker, (GetResourceAmount(this, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id));
WaypointSprite_Kill(this.sprite);
MUTATOR_CALLHOOK(MonsterDies, this, attacker, deathtype);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
+ if(GetResourceAmount(this, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
{
Violence_GibSplash(this, 1, 0.5, attacker);
bool Monster_Heal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit)
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
+ if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.sprite)
- WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RES_HEALTH));
return true;
}
if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
{
STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + this.ticrate * this.revive_speed, 1);
- SetResourceAmount(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
+ SetResourceAmount(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)
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
if(STAT(REVIVE_PROGRESS, this) >= 1)
Unfreeze(this, false);
else if (STAT(FROZEN, this) == FROZEN_TEMP_DYING)
{
STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - this.ticrate * this.revive_speed, 1);
- SetResourceAmount(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+ SetResourceAmount(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, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(this, RES_HEALTH) < 1)
{
Unfreeze(this, false);
if(this.event_damage)
if(this.monster_lifetime && time >= this.monster_lifetime)
{
- Damage(this, this, this, GetResourceAmount(this, RESOURCE_HEALTH) + this.max_health, DEATH_KILL.m_id, DMG_NOWEP, this.origin, this.origin);
+ Damage(this, this, this, GetResourceAmount(this, RES_HEALTH) + this.max_health, DEATH_KILL.m_id, DMG_NOWEP, this.origin, this.origin);
return;
}
mon.mr_setup(mon, this);
// ensure some basic needs are met
- if(!GetResourceAmount(this, RESOURCE_HEALTH)) { SetResourceAmount(this, RESOURCE_HEALTH, 100); }
- if(!GetResourceAmount(this, RESOURCE_ARMOR)) { SetResourceAmount(this, RESOURCE_ARMOR, bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9)); }
+ if(!GetResourceAmount(this, RES_HEALTH)) { SetResourceAmount(this, RES_HEALTH, 100); }
+ if(!GetResourceAmount(this, RES_ARMOR)) { SetResourceAmount(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);
- SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH) * MONSTER_SKILLMOD(this));
+ SetResourceAmount(this, RES_HEALTH, GetResourceAmount(this, RES_HEALTH) * MONSTER_SKILLMOD(this));
if(!this.skin)
this.skin = rint(random() * 4);
}
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
this.pain_finished = this.nextthink;
if(IS_PLAYER(this.monster_follow))
if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE))
{
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
}
}
entity player = M_ARGV(0, entity);
if(IS_PLAYER(player))
- if(GetResourceAmount(player, RESOURCE_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
+ if(GetResourceAmount(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
{
PHYS_INPUT_BUTTON_CROUCH(player) = true;
{
entity player = M_ARGV(0, entity);
- if(GetResourceAmount(player, RESOURCE_HEALTH) <= autocvar_g_bloodloss)
+ if(GetResourceAmount(player, RES_HEALTH) <= autocvar_g_bloodloss)
return true;
}
{
continue;
}
- float hp = GetResourceAmount(it, RESOURCE_HEALTH);
+ float hp = GetResourceAmount(it, RES_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));
+ SetResourceAmount(it, RES_HEALTH, bound(0, hp + autocvar_g_buffs_medic_heal_amount, autocvar_g_balance_health_regenstable));
});
}
frag_damage *= autocvar_g_buffs_speed_damage_take;
if(STAT(BUFFS, frag_target) & BUFF_MEDIC.m_itemid)
- if((GetResourceAmount(frag_target, RESOURCE_HEALTH) - frag_damage) <= 0)
+ if((GetResourceAmount(frag_target, RES_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, GetResourceAmount(frag_target, RESOURCE_HEALTH) - autocvar_g_buffs_medic_survive_health);
+ frag_damage = max(5, GetResourceAmount(frag_target, RES_HEALTH) - autocvar_g_buffs_medic_survive_health);
if(STAT(BUFFS, frag_target) & BUFF_JUMP.m_itemid)
if(frag_deathtype == DEATH_FALL.m_id)
if(DIFF_TEAM(frag_attacker, frag_target))
{
float amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
- GetResourceAmount(frag_target, RESOURCE_HEALTH));
- GiveResourceWithLimit(frag_attacker, RESOURCE_HEALTH, amount, g_pickup_healthsmall_max);
- if (GetResourceAmount(frag_target, RESOURCE_ARMOR))
+ GetResourceAmount(frag_target, RES_HEALTH));
+ GiveResourceWithLimit(frag_attacker, RES_HEALTH, amount, g_pickup_healthsmall_max);
+ if (GetResourceAmount(frag_target, RES_ARMOR))
{
amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
- GetResourceAmount(frag_target, RESOURCE_ARMOR));
- GiveResourceWithLimit(frag_attacker, RESOURCE_ARMOR, amount, g_pickup_armorsmall_max);
+ GetResourceAmount(frag_target, RES_ARMOR));
+ GiveResourceWithLimit(frag_attacker, RES_ARMOR, amount, g_pickup_armorsmall_max);
}
}
if(player.vehicle)
Damage(player.vehicle, NULL, NULL, autocvar_g_campcheck_damage * 2, DEATH_CAMP.m_id, DMG_NOWEP, player.vehicle.origin, '0 0 0');
else
- 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, DMG_NOWEP, player.origin, '0 0 0');
+ Damage(player, NULL, NULL, bound(0, autocvar_g_campcheck_damage, GetResourceAmount(player, RES_HEALTH) + GetResourceAmount(player, RES_ARMOR) * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP.m_id, DMG_NOWEP, player.origin, '0 0 0');
}
player.campcheck_nextcheck = time + autocvar_g_campcheck_interval;
player.campcheck_traveled_distance = 0;
int autocvar_g_instagib_ammo_drop;
void ammo_vaporizercells_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RESOURCE_CELLS))
- SetResourceAmount(item, RESOURCE_CELLS, autocvar_g_instagib_ammo_drop);
+ if(!GetResourceAmount(item, RES_CELLS))
+ SetResourceAmount(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
}
#endif
REGISTER_ITEM(VaporizerCells, Ammo) {
if(IS_DEAD(this) || game_stopped)
instagib_stop_countdown(this);
- else if (GetResourceAmount(this, RESOURCE_CELLS) > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+ else if (GetResourceAmount(this, RES_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);
+ float hp = GetResourceAmount(this, RES_HEALTH);
this.instagib_needammo = true;
if (hp <= 5)
{
if(!autocvar_g_instagib_friendlypush && SAME_TEAM(frag_target, frag_attacker))
frag_force = '0 0 0';
- float armor = GetResourceAmount(frag_target, RESOURCE_ARMOR);
+ float armor = GetResourceAmount(frag_target, RES_ARMOR);
if(armor)
{
armor -= 1;
- SetResourceAmount(frag_target, RESOURCE_ARMOR, armor);
+ SetResourceAmount(frag_target, RES_ARMOR, armor);
frag_damage = 0;
frag_target.damage_dealt += 1;
frag_attacker.damage_dealt += 1;
if(frag_target != frag_attacker)
{
- if(frag_damage <= 0 && GetResourceAmount(frag_target, RESOURCE_HEALTH) > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
+ if(frag_damage <= 0 && GetResourceAmount(frag_target, RES_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
- float armor = GetResourceAmount(frag_attacker, RESOURCE_ARMOR);
+ float armor = GetResourceAmount(frag_attacker, RES_ARMOR);
if(armor > 0)
{
armor -= 1;
- SetResourceAmount(frag_attacker, RESOURCE_ARMOR, armor);
+ SetResourceAmount(frag_attacker, RES_ARMOR, armor);
Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, armor);
frag_attacker.damage_dealt += frag_mirrordamage;
}
if(item.weapon == WEP_VAPORIZER.m_id && Item_IsLoot(item))
{
- SetResourceAmount(item, RESOURCE_CELLS, autocvar_g_instagib_ammo_drop);
+ SetResourceAmount(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
return false;
}
if(item.flags & FL_POWERUP)
return false;
- float cells = GetResourceAmount(item, RESOURCE_CELLS);
+ float cells = GetResourceAmount(item, RES_CELLS);
if(cells > autocvar_g_instagib_ammo_drop && item.classname != "item_vaporizer_cells")
- SetResourceAmount(item, RESOURCE_CELLS, autocvar_g_instagib_ammo_drop);
+ SetResourceAmount(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
if(cells && !item.weapon)
return false;
entity item = M_ARGV(0, entity);
entity toucher = M_ARGV(1, entity);
- if(GetResourceAmount(item, RESOURCE_CELLS))
+ if(GetResourceAmount(item, RES_CELLS))
{
// play some cool sounds ;)
- float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
+ float hp = GetResourceAmount(toucher, RES_HEALTH);
if (IS_CLIENT(toucher))
{
if(hp <= 5)
}
if(hp < 100)
- SetResourceAmount(toucher, RESOURCE_HEALTH, 100);
+ SetResourceAmount(toucher, RES_HEALTH, 100);
return MUT_ITEMTOUCH_CONTINUE;
}
if(item.itemdef == ITEM_ExtraLife)
{
- GiveResource(toucher, RESOURCE_ARMOR, autocvar_g_instagib_extralives);
+ GiveResource(toucher, RES_ARMOR, autocvar_g_instagib_extralives);
Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES);
return MUT_ITEMTOUCH_PICKUP;
}
{
entity proj = M_ARGV(1, entity);
- if(GetResourceAmount(proj, RESOURCE_HEALTH))
+ if(GetResourceAmount(proj, RES_HEALTH))
{
// disable health which in effect disables damage calculations
- SetResourceAmount(proj, RESOURCE_HEALTH, 0);
+ SetResourceAmount(proj, RES_HEALTH, 0);
}
}
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) && GetResourceAmount(it, RESOURCE_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, RES_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;
- float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
+ float hp = GetResourceAmount(toucher, RES_HEALTH);
if (hp < maxhealth)
{
if (this.nade_show_particles)
{
Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
}
- GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
+ GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
}
}
else if ( health_factor < 0 )
if(autocvar_g_nades_pickup)
if(time >= this.spawnshieldtime)
- if(!toucher.nade && GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
+ if(!toucher.nade && GetResourceAmount(this, RES_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(GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health)
+ if(GetResourceAmount(this, RES_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;
- float hp = GetResourceAmount(this, RESOURCE_HEALTH);
+ float hp = GetResourceAmount(this, RES_HEALTH);
if(hp == this.max_health)
{
sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
}
hp -= damage;
- SetResourceAmount(this, RESOURCE_HEALTH, hp);
+ SetResourceAmount(this, RES_HEALTH, hp);
if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
settouch(_nade, nade_touch);
_nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
- SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
- _nade.max_health = GetResourceAmount(_nade, RESOURCE_HEALTH);
+ SetResourceAmount(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
+ _nade.max_health = GetResourceAmount(_nade, RES_HEALTH);
_nade.takedamage = DAMAGE_AIM;
_nade.event_damage = nade_damage;
setcefc(_nade, func_null);
if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // 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);
- SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
+ SetResourceAmount(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
if(STAT(REVIVE_PROGRESS, player) >= 1)
{
if(time - frag_inflictor.toss_time <= 0.1)
{
Unfreeze(frag_target, false);
- SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
+ SetResourceAmount(frag_target, RES_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';
e.draw = orb_draw;
IL_PUSH(g_drawables, e);
- SetResourceAmount(e, RESOURCE_HEALTH, 255);
+ SetResourceAmount(e, RES_HEALTH, 255);
set_movetype(e, MOVETYPE_NONE);
e.solid = SOLID_NOT;
e.drawmask = MASK_NORMAL;
{
// as the PlayerSpawn hook will no longer run, NIX is turned off by this!
FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
- 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);
+ SetResourceAmount(it, RES_SHELLS, start_ammo_shells);
+ SetResourceAmount(it, RES_BULLETS, start_ammo_nails);
+ SetResourceAmount(it, RES_ROCKETS, start_ammo_rockets);
+ SetResourceAmount(it, RES_CELLS, start_ammo_cells);
+ SetResourceAmount(it, RES_PLASMA, start_ammo_plasma);
+ SetResourceAmount(it, RES_FUEL, start_ammo_fuel);
STAT(WEAPONS, it) = 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!
{
- 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);
+ SetResourceAmount(this, RES_SHELLS, 0);
+ SetResourceAmount(this, RES_BULLETS, 0);
+ SetResourceAmount(this, RES_ROCKETS, 0);
+ SetResourceAmount(this, RES_CELLS, 0);
+ SetResourceAmount(this, RES_PLASMA, 0);
+ SetResourceAmount(this, RES_FUEL, 0);
if(this.items & IT_UNLIMITED_WEAPON_AMMO)
{
switch (wpn.ammo_type)
{
- case RESOURCE_SHELLS: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_pickup_shells_max); break;
- case RESOURCE_BULLETS: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_pickup_nails_max); break;
- case RESOURCE_ROCKETS: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_pickup_rockets_max); break;
- case RESOURCE_CELLS: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_pickup_cells_max); break;
- case RESOURCE_PLASMA: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_pickup_plasma_max); break;
- case RESOURCE_FUEL: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_pickup_fuel_max); break;
+ case RES_SHELLS: SetResourceAmount(this, RES_SHELLS, autocvar_g_pickup_shells_max); break;
+ case RES_BULLETS: SetResourceAmount(this, RES_BULLETS, autocvar_g_pickup_nails_max); break;
+ case RES_ROCKETS: SetResourceAmount(this, RES_ROCKETS, autocvar_g_pickup_rockets_max); break;
+ case RES_CELLS: SetResourceAmount(this, RES_CELLS, autocvar_g_pickup_cells_max); break;
+ case RES_PLASMA: SetResourceAmount(this, RES_PLASMA, autocvar_g_pickup_plasma_max); break;
+ case RES_FUEL: SetResourceAmount(this, RES_FUEL, autocvar_g_pickup_fuel_max); break;
}
}
else
{
switch (wpn.ammo_type)
{
- case RESOURCE_SHELLS: SetResourceAmount(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammo_shells); break;
- case RESOURCE_BULLETS: SetResourceAmount(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammo_nails); break;
- case RESOURCE_ROCKETS: SetResourceAmount(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break;
- case RESOURCE_CELLS: SetResourceAmount(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammo_cells); break;
- case RESOURCE_PLASMA: SetResourceAmount(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammo_plasma); break;
- case RESOURCE_FUEL: SetResourceAmount(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammo_fuel); break;
+ case RES_SHELLS: SetResourceAmount(this, RES_SHELLS, autocvar_g_balance_nix_ammo_shells); break;
+ case RES_BULLETS: SetResourceAmount(this, RES_BULLETS, autocvar_g_balance_nix_ammo_nails); break;
+ case RES_ROCKETS: SetResourceAmount(this, RES_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break;
+ case RES_CELLS: SetResourceAmount(this, RES_CELLS, autocvar_g_balance_nix_ammo_cells); break;
+ case RES_PLASMA: SetResourceAmount(this, RES_PLASMA, autocvar_g_balance_nix_ammo_plasma); break;
+ case RES_FUEL: SetResourceAmount(this, RES_FUEL, autocvar_g_balance_nix_ammo_fuel); break;
}
}
{
switch (wpn.ammo_type)
{
- case RESOURCE_SHELLS: GiveResource(this, RESOURCE_SHELLS, autocvar_g_balance_nix_ammoincr_shells); break;
- case RESOURCE_BULLETS: GiveResource(this, RESOURCE_BULLETS, autocvar_g_balance_nix_ammoincr_nails); break;
- case RESOURCE_ROCKETS: GiveResource(this, RESOURCE_ROCKETS, autocvar_g_balance_nix_ammoincr_rockets); break;
- case RESOURCE_CELLS: GiveResource(this, RESOURCE_CELLS, autocvar_g_balance_nix_ammoincr_cells); break;
- case RESOURCE_PLASMA: GiveResource(this, RESOURCE_PLASMA, autocvar_g_balance_nix_ammoincr_plasma); break;
- case RESOURCE_FUEL: GiveResource(this, RESOURCE_FUEL, autocvar_g_balance_nix_ammoincr_fuel); break;
+ case RES_SHELLS: GiveResource(this, RES_SHELLS, autocvar_g_balance_nix_ammoincr_shells); break;
+ case RES_BULLETS: GiveResource(this, RES_BULLETS, autocvar_g_balance_nix_ammoincr_nails); break;
+ case RES_ROCKETS: GiveResource(this, RES_ROCKETS, autocvar_g_balance_nix_ammoincr_rockets); break;
+ case RES_CELLS: GiveResource(this, RES_CELLS, autocvar_g_balance_nix_ammoincr_cells); break;
+ case RES_PLASMA: GiveResource(this, RES_PLASMA, autocvar_g_balance_nix_ammoincr_plasma); break;
+ case RES_FUEL: GiveResource(this, RES_FUEL, autocvar_g_balance_nix_ammoincr_fuel); break;
}
this.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
CLASS(OverkillHeavyMachineGun, Weapon)
/* spawnfunc */ ATTRIB(OverkillHeavyMachineGun, m_canonical_spawnfunc, string, "weapon_okhmg");
-/* ammotype */ ATTRIB(OverkillHeavyMachineGun, ammo_type, int, RESOURCE_BULLETS);
+/* ammotype */ ATTRIB(OverkillHeavyMachineGun, ammo_type, int, RES_BULLETS);
/* impulse */ ATTRIB(OverkillHeavyMachineGun, impulse, int, 3);
/* flags */ ATTRIB(OverkillHeavyMachineGun, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_SUPERWEAPON);
/* rating */ ATTRIB(OverkillHeavyMachineGun, bot_pickupbasevalue, float, 10000);
CLASS(OverkillMachineGun, Weapon)
/* spawnfunc */ ATTRIB(OverkillMachineGun, m_canonical_spawnfunc, string, "weapon_okmachinegun");
-/* ammotype */ ATTRIB(OverkillMachineGun, ammo_type, int, RESOURCE_BULLETS);
+/* ammotype */ ATTRIB(OverkillMachineGun, ammo_type, int, RES_BULLETS);
/* impulse */ ATTRIB(OverkillMachineGun, impulse, int, 3);
/* flags */ ATTRIB(OverkillMachineGun, spawnflags, int, WEP_FLAG_HIDDEN | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_PENETRATEWALLS | WEP_FLAG_MUTATORBLOCKED);
/* rating */ ATTRIB(OverkillMachineGun, bot_pickupbasevalue, float, 7000);
CLASS(OverkillNex, Weapon)
/* spawnfunc */ ATTRIB(OverkillNex, m_canonical_spawnfunc, string, "weapon_oknex");
-/* ammotype */ ATTRIB(OverkillNex, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(OverkillNex, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(OverkillNex, impulse, int, 7);
/* flags */ ATTRIB(OverkillNex, spawnflags, int, WEP_FLAG_HIDDEN | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_MUTATORBLOCKED);
/* rating */ ATTRIB(OverkillNex, bot_pickupbasevalue, float, 8000);
void W_OverkillRocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_OverkillRocketPropelledChainsaw_Explode_think);
}
missile.takedamage = DAMAGE_YES;
missile.damageforcescale = WEP_CVAR_PRI(okrpc, damageforcescale);
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR_PRI(okrpc, health));
+ SetResourceAmount(missile, RES_HEALTH, WEP_CVAR_PRI(okrpc, health));
missile.event_damage = W_OverkillRocketPropelledChainsaw_Damage;
missile.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, missile);
CLASS(OverkillRocketPropelledChainsaw, Weapon)
/* spawnfunc */ ATTRIB(OverkillRocketPropelledChainsaw, m_canonical_spawnfunc, string, "weapon_okrpc");
-/* ammotype */ ATTRIB(OverkillRocketPropelledChainsaw, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(OverkillRocketPropelledChainsaw, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(OverkillRocketPropelledChainsaw, impulse, int, 9);
/* flags */ ATTRIB(OverkillRocketPropelledChainsaw, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_SUPERWEAPON);
/* rating */ ATTRIB(OverkillRocketPropelledChainsaw, bot_pickupbasevalue, float, 10000);
CLASS(OverkillShotgun, Weapon)
/* spawnfunc */ ATTRIB(OverkillShotgun, m_canonical_spawnfunc, string, "weapon_okshotgun");
-/* ammotype */ ATTRIB(OverkillShotgun, ammo_type, int, RESOURCE_SHELLS);
+/* ammotype */ ATTRIB(OverkillShotgun, ammo_type, int, RES_SHELLS);
/* impulse */ ATTRIB(OverkillShotgun, impulse, int, 2);
/* flags */ ATTRIB(OverkillShotgun, spawnflags, int, WEP_FLAG_HIDDEN | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_MUTATORBLOCKED);
/* rating */ ATTRIB(OverkillShotgun, bot_pickupbasevalue, float, 6000);
if (PHYS_INPUT_BUTTON_CHAT(it)) continue;
if (DIFF_TEAM(player, it)) continue;
- if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && GetResourceAmount(it, RESOURCE_HEALTH) < autocvar_g_balance_health_regenstable) continue;
+ if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && GetResourceAmount(it, RES_HEALTH) < autocvar_g_balance_health_regenstable) continue;
if (IS_DEAD(it)) continue;
if (time < it.msnt_timer) continue;
if (time < it.spawnshieldtime) continue;
if(frag_target != frag_attacker)
if(!IS_DEAD(frag_target))
{
- GiveResource(frag_attacker, RESOURCE_HEALTH,
- bound(0, damage_take, GetResourceAmount(frag_target, RESOURCE_HEALTH)));
+ GiveResource(frag_attacker, RES_HEALTH,
+ bound(0, damage_take, GetResourceAmount(frag_target, RES_HEALTH)));
}
}
if(!STAT(FROZEN, thehook.aiment))
if(time >= game_starttime)
if(DIFF_TEAM(thehook.owner, thehook.aiment) || autocvar_g_vampirehook_teamheal)
- if(GetResourceAmount(thehook.aiment, RESOURCE_HEALTH) > 0)
+ if(GetResourceAmount(thehook.aiment, RES_HEALTH) > 0)
if(autocvar_g_vampirehook_damage)
{
thehook.last_dmg = time + autocvar_g_vampirehook_damagerate;
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);
- SetResourceAmount(targ, RESOURCE_HEALTH, min(GetResourceAmount(targ, RESOURCE_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
+ SetResourceAmount(targ, RES_HEALTH, min(GetResourceAmount(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
if(dmgent == thehook.owner)
- TakeResource(dmgent, RESOURCE_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
+ TakeResource(dmgent, RES_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
}
}
{
if (this.max_health)
{
- WriteByte(MSG_ENTITY, (GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 191.0);
+ WriteByte(MSG_ENTITY, (GetResourceAmount(this, RES_HEALTH) / this.max_health) * 191.0);
}
else
{
int t = ReadByte();
if (t < 192)
{
- SetResourceAmount(this, RESOURCE_HEALTH, t / 191.0);
+ SetResourceAmount(this, RES_HEALTH, t / 191.0);
this.build_finished = 0;
}
else
t = (t - 192) * 256 + ReadByte();
this.build_started = servertime;
if (this.build_finished)
- this.build_starthealth = bound(0, GetResourceAmount(this, RESOURCE_HEALTH), 1);
+ this.build_starthealth = bound(0, GetResourceAmount(this, RES_HEALTH), 1);
else
this.build_starthealth = 0;
this.build_finished = servertime + t / 32;
}
else
{
- SetResourceAmount(this, RESOURCE_HEALTH, -1);
+ SetResourceAmount(this, RES_HEALTH, -1);
this.build_finished = 0;
}
LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it", spriteimage);
}
- float health_val = GetResourceAmount(this, RESOURCE_HEALTH);
+ float health_val = GetResourceAmount(this, RES_HEALTH);
float blink_time = (health_val >= 0) ? (health_val * 10) : time;
if (blink_time - floor(blink_time) > 0.5)
{
if (time < this.build_finished + 0.25)
{
if (time < this.build_started)
- SetResourceAmount(this, RESOURCE_HEALTH, this.build_starthealth);
+ SetResourceAmount(this, RES_HEALTH, this.build_starthealth);
else if (time < this.build_finished)
- SetResourceAmount(this, RESOURCE_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
+ SetResourceAmount(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
else
- SetResourceAmount(this, RESOURCE_HEALTH, 1);
+ SetResourceAmount(this, RES_HEALTH, 1);
}
else
- SetResourceAmount(this, RESOURCE_HEALTH, -1);
+ SetResourceAmount(this, RES_HEALTH, -1);
}
o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
}
draw_beginBoldFont();
- if (GetResourceAmount(this, RESOURCE_HEALTH) >= 0)
+ if (GetResourceAmount(this, RES_HEALTH) >= 0)
{
float align = 0, marg;
if (this.build_finished)
drawhealthbar(
o,
0,
- GetResourceAmount(this, RESOURCE_HEALTH),
+ GetResourceAmount(this, RES_HEALTH),
'0 0 0',
'0 0 0',
SPRITE_HEALTHBAR_WIDTH * t,
{
f = bound(0, f, e.max_health);
float step = e.max_health / 40;
- if ((floor(f / step) != floor(GetResourceAmount(e, RESOURCE_HEALTH) / step)) || e.pain_finished)
+ if ((floor(f / step) != floor(GetResourceAmount(e, RES_HEALTH) / step)) || e.pain_finished)
{
- SetResourceAmount(e, RESOURCE_HEALTH, f);
+ SetResourceAmount(e, RES_HEALTH, f);
e.pain_finished = 0;
e.SendFlags |= 0x80;
}
{
WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
entity e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', NULL, carrier.team, carrier, waypointsprite_attachedforcarrier, false, icon);
- if (GetResourceAmount(carrier, RESOURCE_HEALTH))
+ if (GetResourceAmount(carrier, RES_HEALTH))
{
WaypointSprite_UpdateMaxHealth(e, 2 * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
- WaypointSprite_UpdateHealth(e, healtharmor_maxdamage(GetResourceAmount(carrier, RESOURCE_HEALTH), GetResourceAmount(carrier, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(e, healtharmor_maxdamage(GetResourceAmount(carrier, RES_HEALTH), GetResourceAmount(carrier, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
}
return e;
}
Weapon wep = Weapons_from(f1);
switch (wep.ammo_type)
{
- case RESOURCE_SHELLS: ammoitems = ITEM_Shells.m_name; break;
- case RESOURCE_BULLETS: ammoitems = ITEM_Bullets.m_name; break;
- case RESOURCE_ROCKETS: ammoitems = ITEM_Rockets.m_name; break;
- case RESOURCE_CELLS: ammoitems = ITEM_Cells.m_name; break;
- case RESOURCE_PLASMA: ammoitems = ITEM_Plasma.m_name; break;
- case RESOURCE_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break;
+ case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break;
+ case RES_BULLETS: ammoitems = ITEM_Bullets.m_name; break;
+ case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name; break;
+ case RES_CELLS: ammoitems = ITEM_Cells.m_name; break;
+ case RES_PLASMA: ammoitems = ITEM_Plasma.m_name; break;
+ case RES_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break;
default: return ""; // doesn't use ammo
}
return sprintf(_(" with %d %s"), f2, ammoitems);
#ifdef SVQC
if (!(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
- TakeResource(this, RESOURCE_FUEL, PHYS_JETPACK_FUEL(this) * dt * fvel * f);
+ TakeResource(this, RES_FUEL, PHYS_JETPACK_FUEL(this) * dt * fvel * f);
ITEMS_STAT(this) |= IT_USING_JETPACK;
/// \copyright GNU GPLv2 or any later version.
/// \brief Unconditional maximum amount of resources the entity can have.
-const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
-const int RESOURCE_LIMIT_NONE = -1;
+const int RES_AMOUNT_HARD_LIMIT = 999;
+const int RES_LIMIT_NONE = -1;
/// \brief Describes the available resource types.
enum
{
- RESOURCE_NONE, ///< Indicates the lack of resource. Use with caution.
- RESOURCE_HEALTH, ///< Health.
- RESOURCE_ARMOR, ///< Armor.
- RESOURCE_SHELLS, ///< Shells (used by shotgun).
- RESOURCE_BULLETS, ///< Bullets (used by machinegun, rifle, HMG)
- RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc).
- RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc)
- RESOURCE_PLASMA, ///< Plasma (unused).
- RESOURCE_FUEL ///< Fuel (used by jetpack).
+ RES_NONE, ///< Indicates the lack of resource. Use with caution.
+ RES_HEALTH, ///< Health.
+ RES_ARMOR, ///< Armor.
+ RES_SHELLS, ///< Shells (used by shotgun).
+ RES_BULLETS, ///< Bullets (used by machinegun, rifle, HMG)
+ RES_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc).
+ RES_CELLS, ///< Cells (used by electro, crylink, vortex, etc)
+ RES_PLASMA, ///< Plasma (unused).
+ RES_FUEL ///< Fuel (used by jetpack).
};
return;
}
STAT(WEAPONS, receiver) |= RandomSelection_chosen_ent.m_wepset;
- if (RandomSelection_chosen_ent.ammo_type == RESOURCE_NONE)
+ if (RandomSelection_chosen_ent.ammo_type == RES_NONE)
{
continue;
}
}
}
-float Item_GiveAmmoTo(entity item, entity player, int resource_type, float ammomax)
+float Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
{
- float amount = GetResourceAmount(item, resource_type);
+ float amount = GetResourceAmount(item, res_type);
if (amount == 0)
{
return false;
}
- float player_amount = GetResourceAmount(player, resource_type);
+ float player_amount = GetResourceAmount(player, res_type);
if (item.spawnshieldtime)
{
if ((player_amount >= ammomax) && (item.pickup_anyway <= 0))
{
return false;
}
- GiveOrTakeResourceWithLimit(player, resource_type, amount, ammomax);
+ GiveOrTakeResourceWithLimit(player, res_type, amount, ammomax);
return true;
}
if (g_weapon_stay != 2)
{
return false;
}
- GiveOrTakeResourceWithLimit(player, resource_type, amount, min(amount, ammomax));
+ GiveOrTakeResourceWithLimit(player, res_type, amount, min(amount, ammomax));
return true;
}
}
}
}
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_HEALTH, item.max_health);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_ARMOR, item.max_armorvalue);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_SHELLS, g_pickup_shells_max);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_BULLETS, g_pickup_nails_max);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_ROCKETS, g_pickup_rockets_max);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_CELLS, g_pickup_cells_max);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_PLASMA, g_pickup_plasma_max);
- pickedup |= Item_GiveAmmoTo(item, player, RESOURCE_FUEL, g_pickup_fuel_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_HEALTH, item.max_health);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_ARMOR, item.max_armorvalue);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_SHELLS, g_pickup_shells_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_BULLETS, g_pickup_nails_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_ROCKETS, g_pickup_rockets_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max);
+ pickedup |= Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max);
if (item.itemdef.instanceOfWeaponPickup)
{
WepSet w;
if(item.itemdef.instanceOfWeaponPickup)
{
entity ammo = NULL;
- if(GetResourceAmount(item, RESOURCE_SHELLS)) { need_shells = true; ammo = ITEM_Shells; }
- else if(GetResourceAmount(item, RESOURCE_BULLETS)) { need_nails = true; ammo = ITEM_Bullets; }
- else if(GetResourceAmount(item, RESOURCE_ROCKETS)) { need_rockets = true; ammo = ITEM_Rockets; }
- else if(GetResourceAmount(item, RESOURCE_CELLS)) { need_cells = true; ammo = ITEM_Cells; }
- else if(GetResourceAmount(item, RESOURCE_PLASMA)) { need_plasma = true; ammo = ITEM_Plasma; }
- else if(GetResourceAmount(item, RESOURCE_FUEL)) { need_fuel = true; ammo = ITEM_JetpackFuel; }
+ if(GetResourceAmount(item, RES_SHELLS)) { need_shells = true; ammo = ITEM_Shells; }
+ else if(GetResourceAmount(item, RES_BULLETS)) { need_nails = true; ammo = ITEM_Bullets; }
+ else if(GetResourceAmount(item, RES_ROCKETS)) { need_rockets = true; ammo = ITEM_Rockets; }
+ else if(GetResourceAmount(item, RES_CELLS)) { need_cells = true; ammo = ITEM_Cells; }
+ else if(GetResourceAmount(item, RES_PLASMA)) { need_plasma = true; ammo = ITEM_Plasma; }
+ else if(GetResourceAmount(item, RES_FUEL)) { need_fuel = true; ammo = ITEM_JetpackFuel; }
if(!ammo)
return 0;
switch(it.ammo_type)
{
- case RESOURCE_SHELLS: need_shells = true; break;
- case RESOURCE_BULLETS: need_nails = true; break;
- case RESOURCE_ROCKETS: need_rockets = true; break;
- case RESOURCE_CELLS: need_cells = true; break;
- case RESOURCE_PLASMA: need_plasma = true; break;
- case RESOURCE_FUEL: need_fuel = true; break;
+ case RES_SHELLS: need_shells = true; break;
+ case RES_BULLETS: need_nails = true; break;
+ case RES_ROCKETS: need_rockets = true; break;
+ case RES_CELLS: need_cells = true; break;
+ case RES_PLASMA: need_plasma = true; break;
+ case RES_FUEL: need_fuel = true; break;
}
});
rating = item.bot_pickupbasevalue;
float noammorating = 0.5;
- if ((need_shells) && GetResourceAmount(item, RESOURCE_SHELLS) && (GetResourceAmount(player, RESOURCE_SHELLS) < g_pickup_shells_max))
- c = GetResourceAmount(item, RESOURCE_SHELLS) / max(noammorating, GetResourceAmount(player, RESOURCE_SHELLS));
+ if ((need_shells) && GetResourceAmount(item, RES_SHELLS) && (GetResourceAmount(player, RES_SHELLS) < g_pickup_shells_max))
+ c = GetResourceAmount(item, RES_SHELLS) / max(noammorating, GetResourceAmount(player, RES_SHELLS));
- if ((need_nails) && GetResourceAmount(item, RESOURCE_BULLETS) && (GetResourceAmount(player, RESOURCE_BULLETS) < g_pickup_nails_max))
- c = GetResourceAmount(item, RESOURCE_BULLETS) / max(noammorating, GetResourceAmount(player, RESOURCE_BULLETS));
+ if ((need_nails) && GetResourceAmount(item, RES_BULLETS) && (GetResourceAmount(player, RES_BULLETS) < g_pickup_nails_max))
+ c = GetResourceAmount(item, RES_BULLETS) / max(noammorating, GetResourceAmount(player, RES_BULLETS));
- if ((need_rockets) && GetResourceAmount(item, RESOURCE_ROCKETS) && (GetResourceAmount(player, RESOURCE_ROCKETS) < g_pickup_rockets_max))
- c = GetResourceAmount(item, RESOURCE_ROCKETS) / max(noammorating, GetResourceAmount(player, RESOURCE_ROCKETS));
+ if ((need_rockets) && GetResourceAmount(item, RES_ROCKETS) && (GetResourceAmount(player, RES_ROCKETS) < g_pickup_rockets_max))
+ c = GetResourceAmount(item, RES_ROCKETS) / max(noammorating, GetResourceAmount(player, RES_ROCKETS));
- if ((need_cells) && GetResourceAmount(item, RESOURCE_CELLS) && (GetResourceAmount(player, RESOURCE_CELLS) < g_pickup_cells_max))
- c = GetResourceAmount(item, RESOURCE_CELLS) / max(noammorating, GetResourceAmount(player, RESOURCE_CELLS));
+ if ((need_cells) && GetResourceAmount(item, RES_CELLS) && (GetResourceAmount(player, RES_CELLS) < g_pickup_cells_max))
+ c = GetResourceAmount(item, RES_CELLS) / max(noammorating, GetResourceAmount(player, RES_CELLS));
- if ((need_plasma) && GetResourceAmount(item, RESOURCE_PLASMA) && (GetResourceAmount(player, RESOURCE_PLASMA) < g_pickup_plasma_max))
- c = GetResourceAmount(item, RESOURCE_PLASMA) / max(noammorating, GetResourceAmount(player, RESOURCE_PLASMA));
+ if ((need_plasma) && GetResourceAmount(item, RES_PLASMA) && (GetResourceAmount(player, RES_PLASMA) < g_pickup_plasma_max))
+ c = GetResourceAmount(item, RES_PLASMA) / max(noammorating, GetResourceAmount(player, RES_PLASMA));
- if ((need_fuel) && GetResourceAmount(item, RESOURCE_FUEL) && (GetResourceAmount(player, RESOURCE_FUEL) < g_pickup_fuel_max))
- c = GetResourceAmount(item, RESOURCE_FUEL) / max(noammorating, GetResourceAmount(player, RESOURCE_FUEL));
+ if ((need_fuel) && GetResourceAmount(item, RES_FUEL) && (GetResourceAmount(player, RES_FUEL) < g_pickup_fuel_max))
+ c = GetResourceAmount(item, RES_FUEL) / max(noammorating, GetResourceAmount(player, RES_FUEL));
rating *= min(c, 2);
if(wpn)
float c = 0;
float rating = item.bot_pickupbasevalue;
- float itemarmor = GetResourceAmount(item, RESOURCE_ARMOR);
- float itemhealth = GetResourceAmount(item, RESOURCE_HEALTH);
+ float itemarmor = GetResourceAmount(item, RES_ARMOR);
+ float itemhealth = GetResourceAmount(item, RES_HEALTH);
if(item.item_group)
{
itemhealth *= min(4, item.item_group_count);
}
- if (itemarmor && (GetResourceAmount(player, RESOURCE_ARMOR) < item.max_armorvalue))
- c = itemarmor / max(1, GetResourceAmount(player, RESOURCE_ARMOR) * 2/3 + GetResourceAmount(player, RESOURCE_HEALTH) * 1/3);
+ if (itemarmor && (GetResourceAmount(player, RES_ARMOR) < item.max_armorvalue))
+ c = itemarmor / max(1, GetResourceAmount(player, RES_ARMOR) * 2/3 + GetResourceAmount(player, RES_HEALTH) * 1/3);
- if (itemhealth && (GetResourceAmount(player, RESOURCE_HEALTH) < item.max_health))
- c = itemhealth / max(1, GetResourceAmount(player, RESOURCE_HEALTH));
+ if (itemhealth && (GetResourceAmount(player, RES_HEALTH) < item.max_health))
+ c = itemhealth / max(1, GetResourceAmount(player, RES_HEALTH));
rating *= min(2, c);
return rating;
if(def.instanceOfPowerup)
this.ItemStatus |= ITS_ANIMATE1;
- if(GetResourceAmount(this, RESOURCE_ARMOR) || GetResourceAmount(this, RESOURCE_HEALTH))
+ if(GetResourceAmount(this, RES_ARMOR) || GetResourceAmount(this, RES_HEALTH))
this.ItemStatus |= ITS_ANIMATE2;
}
this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, this.superweapons_finished * boolean(this.items & IT_SUPERWEAPON), "superweapons");
this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, boolean(this.items & ITEM_Jetpack.m_itemid), "jetpack");
this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, boolean(this.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
- if(GetResourceAmount(this, RESOURCE_SHELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_SHELLS)), "shells");
- if(GetResourceAmount(this, RESOURCE_BULLETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_BULLETS)), "nails");
- if(GetResourceAmount(this, RESOURCE_ROCKETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_ROCKETS)), "rockets");
- if(GetResourceAmount(this, RESOURCE_CELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_CELLS)), "cells");
- if(GetResourceAmount(this, RESOURCE_PLASMA) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_PLASMA)), "plasma");
- if(GetResourceAmount(this, RESOURCE_FUEL) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_FUEL)), "fuel");
- if(GetResourceAmount(this, RESOURCE_HEALTH) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_HEALTH)), "health");
- if(GetResourceAmount(this, RESOURCE_ARMOR) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RESOURCE_ARMOR)), "armor");
+ if(GetResourceAmount(this, RES_SHELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_SHELLS)), "shells");
+ if(GetResourceAmount(this, RES_BULLETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_BULLETS)), "nails");
+ if(GetResourceAmount(this, RES_ROCKETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_ROCKETS)), "rockets");
+ if(GetResourceAmount(this, RES_CELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_CELLS)), "cells");
+ if(GetResourceAmount(this, RES_PLASMA) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_PLASMA)), "plasma");
+ if(GetResourceAmount(this, RES_FUEL) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_FUEL)), "fuel");
+ if(GetResourceAmount(this, RES_HEALTH) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_HEALTH)), "health");
+ if(GetResourceAmount(this, RES_ARMOR) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResourceAmount(this, RES_ARMOR)), "armor");
FOREACH(Buffs, it != BUFF_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(BUFFS, this) & (it.m_itemid)), it.m_name));
FOREACH(Weapons, it != WEP_Null, this.netname = sprintf("%s %s%d %s", this.netname, itemprefix, !!(STAT(WEAPONS, this) & (it.m_wepset)), it.netname));
}
else if(v0 > v1)
e.(regenfield) = max(e.(regenfield), time + regentime);
}
-bool GiveResourceValue(entity e, int resource_type, int op, int val)
+bool GiveResourceValue(entity e, int res_type, int op, int val)
{
- int v0 = GetResourceAmount(e, resource_type);
+ int v0 = GetResourceAmount(e, res_type);
switch (op)
{
- case OP_SET:
- SetResourceAmount(e, resource_type, val);
- break;
- case OP_MIN:
- SetResourceAmount(e, resource_type, max(v0, val)); // min 100 cells = at least 100 cells
- break;
- case OP_MAX:
- SetResourceAmount(e, resource_type, min(v0, val));
- break;
- case OP_PLUS:
- SetResourceAmount(e, resource_type, v0 + val);
- break;
- case OP_MINUS:
- SetResourceAmount(e, resource_type, v0 - val);
- break;
+ // min 100 cells = at least 100 cells
+ case OP_SET: SetResourceAmount(e, res_type, val); break;
+ case OP_MIN: SetResourceAmount(e, res_type, max(v0, val)); break;
+ case OP_MAX: SetResourceAmount(e, res_type, min(v0, val)); break;
+ case OP_PLUS: SetResourceAmount(e, res_type, v0 + val); break;
+ case OP_MINUS: SetResourceAmount(e, res_type, v0 - val); break;
}
- int v1 = GetResourceAmount(e, resource_type);
+ int v1 = GetResourceAmount(e, res_type);
return v0 != v1;
}
PREGIVE(e, strength_finished);
PREGIVE(e, invincible_finished);
PREGIVE(e, superweapons_finished);
- PREGIVE_RESOURCE(e, RESOURCE_BULLETS);
- PREGIVE_RESOURCE(e, RESOURCE_CELLS);
- PREGIVE_RESOURCE(e, RESOURCE_PLASMA);
- PREGIVE_RESOURCE(e, RESOURCE_SHELLS);
- PREGIVE_RESOURCE(e, RESOURCE_ROCKETS);
- PREGIVE_RESOURCE(e, RESOURCE_FUEL);
- PREGIVE_RESOURCE(e, RESOURCE_ARMOR);
- PREGIVE_RESOURCE(e, RESOURCE_HEALTH);
+ PREGIVE_RESOURCE(e, RES_BULLETS);
+ PREGIVE_RESOURCE(e, RES_CELLS);
+ PREGIVE_RESOURCE(e, RES_PLASMA);
+ PREGIVE_RESOURCE(e, RES_SHELLS);
+ PREGIVE_RESOURCE(e, RES_ROCKETS);
+ PREGIVE_RESOURCE(e, RES_FUEL);
+ PREGIVE_RESOURCE(e, RES_ARMOR);
+ PREGIVE_RESOURCE(e, RES_HEALTH);
for(i = beginarg; i < endarg; ++i)
{
got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
case "all":
got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
- got += GiveResourceValue(e, RESOURCE_HEALTH, op, val);
- got += GiveResourceValue(e, RESOURCE_ARMOR, op, val);
+ got += GiveResourceValue(e, RES_HEALTH, op, val);
+ got += GiveResourceValue(e, RES_ARMOR, op, val);
case "allweapons":
FOREACH(Weapons, it != WEP_Null && !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), got += GiveWeapon(e, it.m_id, op, val));
//case "allbuffs": // all buffs makes a player god, do not want!
//FOREACH(Buffs, it != BUFF_Null, got += GiveBuff(e, it.m_itemid, op, val));
case "allammo":
- got += GiveResourceValue(e, RESOURCE_CELLS, op, val);
- got += GiveResourceValue(e, RESOURCE_PLASMA, op, val);
- got += GiveResourceValue(e, RESOURCE_SHELLS, op, val);
- got += GiveResourceValue(e, RESOURCE_BULLETS, op, val);
- got += GiveResourceValue(e, RESOURCE_ROCKETS, op, val);
- got += GiveResourceValue(e, RESOURCE_FUEL, op, val);
+ got += GiveResourceValue(e, RES_CELLS, op, val);
+ got += GiveResourceValue(e, RES_PLASMA, op, val);
+ got += GiveResourceValue(e, RES_SHELLS, op, val);
+ got += GiveResourceValue(e, RES_BULLETS, op, val);
+ got += GiveResourceValue(e, RES_ROCKETS, op, val);
+ got += GiveResourceValue(e, RES_FUEL, op, val);
break;
case "unlimited_ammo":
got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
got += GiveValue(e, superweapons_finished, op, val);
break;
case "cells":
- got += GiveResourceValue(e, RESOURCE_CELLS, op, val);
+ got += GiveResourceValue(e, RES_CELLS, op, val);
break;
case "plasma":
- got += GiveResourceValue(e, RESOURCE_PLASMA, op, val);
+ got += GiveResourceValue(e, RES_PLASMA, op, val);
break;
case "shells":
- got += GiveResourceValue(e, RESOURCE_SHELLS, op, val);
+ got += GiveResourceValue(e, RES_SHELLS, op, val);
break;
case "nails":
case "bullets":
- got += GiveResourceValue(e, RESOURCE_BULLETS, op, val);
+ got += GiveResourceValue(e, RES_BULLETS, op, val);
break;
case "rockets":
- got += GiveResourceValue(e, RESOURCE_ROCKETS, op, val);
+ got += GiveResourceValue(e, RES_ROCKETS, op, val);
break;
case "health":
- got += GiveResourceValue(e, RESOURCE_HEALTH, op, val);
+ got += GiveResourceValue(e, RES_HEALTH, op, val);
break;
case "armor":
- got += GiveResourceValue(e, RESOURCE_ARMOR, op, val);
+ got += GiveResourceValue(e, RES_ARMOR, op, val);
break;
case "fuel":
- got += GiveResourceValue(e, RESOURCE_FUEL, op, val);
+ got += GiveResourceValue(e, RES_FUEL, op, val);
break;
default:
FOREACH(Buffs, it != BUFF_Null && Buff_UndeprecateName(cmd) == it.m_name,
POSTGIVE_VALUE(e, strength_finished, 1, SND_POWERUP, SND_POWEROFF);
POSTGIVE_VALUE(e, invincible_finished, 1, SND_Shield, SND_POWEROFF);
//POSTGIVE_VALUE(e, superweapons_finished, 1, SND_Null, SND_Null);
- POSTGIVE_RESOURCE(e, RESOURCE_BULLETS, 0, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE(e, RESOURCE_CELLS, 0, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE(e, RESOURCE_PLASMA, 0, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE(e, RESOURCE_SHELLS, 0, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE(e, RESOURCE_ROCKETS, 0, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE_ROT(e, RESOURCE_FUEL, 1, pauserotfuel_finished, autocvar_g_balance_pause_fuel_rot, pauseregen_finished, autocvar_g_balance_pause_fuel_regen, SND_ITEMPICKUP, SND_Null);
- POSTGIVE_RESOURCE_ROT(e, RESOURCE_ARMOR, 1, pauserotarmor_finished, autocvar_g_balance_pause_armor_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_ARMOR25, SND_Null);
- POSTGIVE_RESOURCE_ROT(e, RESOURCE_HEALTH, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null);
+ POSTGIVE_RESOURCE(e, RES_BULLETS, 0, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RESOURCE(e, RES_CELLS, 0, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RESOURCE(e, RES_PLASMA, 0, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RESOURCE(e, RES_SHELLS, 0, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RESOURCE(e, RES_ROCKETS, 0, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RES_ROT(e, RES_FUEL, 1, pauserotfuel_finished, autocvar_g_balance_pause_fuel_rot, pauseregen_finished, autocvar_g_balance_pause_fuel_regen, SND_ITEMPICKUP, SND_Null);
+ POSTGIVE_RES_ROT(e, RES_ARMOR, 1, pauserotarmor_finished, autocvar_g_balance_pause_armor_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_ARMOR25, SND_Null);
+ POSTGIVE_RES_ROT(e, RES_HEALTH, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null);
if(e.superweapons_finished <= 0)
if(STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)
void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
entity ammo_entity);
-float Item_GiveAmmoTo(entity item, entity player, int resource_type, float ammomax);
+float Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax);
float Item_GiveTo(entity item, entity player);
#define POSTGIVE_WEAPON(e,b,snd_incr,snd_decr) GiveSound((e), !!(save_weapons & WepSet_FromWeapon(b)), !!(STAT(WEAPONS, e) & WepSet_FromWeapon(b)), 0, snd_incr, snd_decr)
#define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr)
#define POSTGIVE_RESOURCE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, GetResourceAmount((e), (f)), t, snd_incr, snd_decr)
-#define POSTGIVE_RESOURCE_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e),save_##f,GetResourceAmount((e),(f)),rotfield,rottime,regenfield,regentime);GiveSound((e),save_##f,GetResourceAmount((e),(f)),t,snd_incr,snd_decr)
+#define POSTGIVE_RES_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e),save_##f,GetResourceAmount((e),(f)),rotfield,rottime,regenfield,regentime);GiveSound((e),save_##f,GetResourceAmount((e),(f)),t,snd_incr,snd_decr)
#define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
#define POSTGIVE_VALUE_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e), save_##f, (e).f, rotfield, rottime, regenfield, regentime); GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
this.tur_head.angles += dt * this.tur_head.avelocity;
- if (GetResourceAmount(this, RESOURCE_HEALTH) < 127)
+ if (GetResourceAmount(this, RES_HEALTH) < 127)
{
dt = random();
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 85)
+ if(GetResourceAmount(this, RES_HEALTH) < 85)
if(dt < 0.01)
pointparticles(EFFECT_SMOKE_LARGE, (this.origin + (randomvec() * 80)), '0 0 0', 1);
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 32)
+ if(GetResourceAmount(this, RES_HEALTH) < 32)
if(dt < 0.015)
pointparticles(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
drawhealthbar(
o,
0,
- GetResourceAmount(this, RESOURCE_HEALTH) / 255,
+ GetResourceAmount(this, RES_HEALTH) / 255,
'0 0 0',
'0 0 0',
0.5 * SPRITE_HEALTHBAR_WIDTH * t,
set_movetype(this.tur_head, MOVETYPE_NOCLIP);
set_movetype(this, MOVETYPE_NOCLIP);
this.tur_head.angles = this.angles;
- SetResourceAmount(this, RESOURCE_HEALTH, 255);
+ SetResourceAmount(this, RES_HEALTH, 255);
this.solid = SOLID_BBOX;
this.tur_head.solid = SOLID_NOT;
set_movetype(this, MOVETYPE_NOCLIP);
}
_tmp = ReadByte();
- float myhp = GetResourceAmount(this, RESOURCE_HEALTH);
+ float myhp = GetResourceAmount(this, RES_HEALTH);
if(_tmp == 0 && myhp != 0)
turret_die(this);
else if(myhp && myhp > _tmp)
else if(myhp && myhp < _tmp)
this.helpme = 0; // we're being healed, don't spam help me waypoints
- SetResourceAmount(this, RESOURCE_HEALTH, _tmp);
+ SetResourceAmount(this, RES_HEALTH, _tmp);
}
return true;
}
this.event_heal = func_null;
this.takedamage = DAMAGE_NO;
- SetResourceAmount(this, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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);
return;
}
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
// thorw head slightly off aim when hit?
if (this.damage_flags & TFL_DMG_HEADSHAKE)
if (this.turret_flags & TUR_FLAG_MOVE)
this.velocity = this.velocity + vforce;
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.event_damage = func_null;
this.tur_head.event_damage = func_null;
bool turret_heal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit)
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
+ if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
targ.SendFlags |= TNSF_STATUS;
return true;
}
this.avelocity = '0 0 0';
this.tur_head.avelocity = this.avelocity;
this.tur_head.angles = this.idle_aim;
- SetResourceAmount(this, RESOURCE_HEALTH, this.max_health);
+ SetResourceAmount(this, RES_HEALTH, this.max_health);
this.enemy = NULL;
this.volly_counter = this.shot_volly;
this.ammo = this.ammo_max;
{
WriteByte(MSG_ENTITY, this.team);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
ent.tur_head.angles = '0 0 0';
}
- SetResourceAmount(ent, RESOURCE_HEALTH, cvar(strcat(sbase,"_health")) * ent.turret_scale_health);
+ SetResourceAmount(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;
void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector vforce)
{
this.velocity += vforce;
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
//this.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, this.owner, turret_projectile_explode);
}
PROJECTILE_MAKETRIGGER(proj);
if(_health)
{
- SetResourceAmount(proj, RESOURCE_HEALTH, _health);
+ SetResourceAmount(proj, RES_HEALTH, _health);
proj.takedamage = DAMAGE_YES;
proj.event_damage = turret_projectile_damage;
}
return -5;
// Cant touch this
- if (GetResourceAmount(e_target, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(e_target, RES_HEALTH) <= 0)
return -6;
else if (STAT(FROZEN, e_target))
return -6;
if(!this.team || !teamplay) { this.team = FLOAT_MAX; }
if(!this.ticrate) { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
- if(!GetResourceAmount(this, RESOURCE_HEALTH)) { SetResourceAmount(this, RESOURCE_HEALTH, 1000); }
+ if(!GetResourceAmount(this, RES_HEALTH)) { SetResourceAmount(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; }
this.effects = EF_NODRAW;
this.netname = tur.turret_name;
this.ticrate = bound(sys_frametime, this.ticrate, 60);
- this.max_health = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.max_health = GetResourceAmount(this, RES_HEALTH);
this.target_validate_flags = this.target_select_flags;
this.ammo = this.ammo_max;
this.ammo_recharge *= this.ticrate;
setorigin(this, this.origin + this.velocity * dt);
this.tur_head.angles += dt * this.tur_head.avelocity;
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 127)
+ if(GetResourceAmount(this, RES_HEALTH) < 127)
if(random() < 0.05)
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
return false;
// Cant touch this
- if ((targ.takedamage == DAMAGE_NO) || (GetResourceAmount(targ, RESOURCE_HEALTH) < 0))
+ if ((targ.takedamage == DAMAGE_NO) || (GetResourceAmount(targ, RES_HEALTH) < 0))
return false;
// player
void walker_rocket_damage(entity this, entity inflictor, entity attacker, float damage, float deathtype, .entity weaponentity, vector hitloc, vector vforce)
{
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.velocity = this.velocity + vforce;
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, this.owner, walker_rocket_explode);
}
rocket.bot_dodgerating = 50;
rocket.takedamage = DAMAGE_YES;
rocket.damageforcescale = 2;
- SetResourceAmount(rocket, RESOURCE_HEALTH, 25);
+ SetResourceAmount(rocket, RES_HEALTH, 25);
rocket.tur_shotorg = randomvec() * 512;
rocket.cnt = time + 1;
rocket.enemy = this.enemy;
setorigin(this, this.origin + this.velocity * dt);
this.tur_head.angles += dt * this.tur_head.avelocity;
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 127)
+ if(GetResourceAmount(this, RES_HEALTH) < 127)
if(random() < 0.15)
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
if(inflictor.owner == this.owner)
return;
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.velocity += force;
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(this, RES_HEALTH) < 1)
{
this.takedamage = DAMAGE_NO;
this.event_damage = func_null;
{
proj.takedamage = DAMAGE_AIM;
proj.event_damage = vehicles_projectile_damage;
- SetResourceAmount(proj, RESOURCE_HEALTH, _health);
+ SetResourceAmount(proj, RES_HEALTH, _health);
}
else
proj.flags |= FL_NOTARGET;
if(timer + rpause < time)
{
if(_healthscale)
- regen = regen * (GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health);
+ regen = regen * (GetResourceAmount(this, RES_HEALTH) / this.max_health);
this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max);
void vehicles_painframe(entity this)
{
- int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 100));
+ int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 100));
if(myhealth <= 50)
if(this.pain_frame < time)
if(this.vehicle_shield < 0)
{
- TakeResource(this, RESOURCE_HEALTH, fabs(this.vehicle_shield));
+ TakeResource(this, RES_HEALTH, fabs(this.vehicle_shield));
this.vehicle_shieldent.colormod = '2 0 0';
this.vehicle_shield = 0;
this.vehicle_shieldent.alpha = 0.75;
}
else
{
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
if(sound_allowed(MSG_BROADCAST, attacker))
spamsound (this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
else
this.velocity += force;
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
if(this.owner)
{
bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit)
+ float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
+ if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.owner)
- targ.owner.vehicle_health = (GetResourceAmount(targ, RESOURCE_HEALTH) / targ.max_health) * 100;
+ targ.owner.vehicle_health = (GetResourceAmount(targ, RES_HEALTH) / targ.max_health) * 100;
return true;
}
gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire;
}
- VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RES_HEALTH);
if(vehic.vehicle_flags & VHF_HASSHIELD)
VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee);
vehicles_regen(this, this.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, dt, true);
if(this.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen_resource(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, dt, false, RESOURCE_HEALTH);
+ vehicles_regen_resource(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, dt, false, RES_HEALTH);
if(this.vehicle_flags & VHF_ENERGYREGEN)
vehicles_regen(this, this.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, dt, false);
{
if(autocvar_g_vehicle_bumblebee_healgun_hps)
{
- float hplimit = ((IS_PLAYER(trace_ent)) ? autocvar_g_vehicle_bumblebee_healgun_hmax : RESOURCE_LIMIT_NONE);
+ float hplimit = ((IS_PLAYER(trace_ent)) ? autocvar_g_vehicle_bumblebee_healgun_hmax : RES_LIMIT_NONE);
Heal(trace_ent, this, autocvar_g_vehicle_bumblebee_healgun_hps * dt, hplimit);
}
if(IS_VEHICLE(trace_ent))
{
- if(autocvar_g_vehicle_bumblebee_healgun_sps && GetResourceAmount(trace_ent, RESOURCE_HEALTH) <= trace_ent.max_health)
+ if(autocvar_g_vehicle_bumblebee_healgun_sps && GetResourceAmount(trace_ent, RES_HEALTH) <= trace_ent.max_health)
trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * dt, trace_ent.tur_head.max_health);
}
else if(IS_CLIENT(trace_ent))
{
- if(GetResourceAmount(trace_ent, RESOURCE_ARMOR) <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
- GiveResourceWithLimit(trace_ent, RESOURCE_ARMOR, autocvar_g_vehicle_bumblebee_healgun_aps * dt, autocvar_g_vehicle_bumblebee_healgun_amax);
+ if(GetResourceAmount(trace_ent, RES_ARMOR) <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
+ GiveResourceWithLimit(trace_ent, RES_ARMOR, autocvar_g_vehicle_bumblebee_healgun_aps * dt, autocvar_g_vehicle_bumblebee_healgun_amax);
}
}
}
}
*/
- VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RES_HEALTH);
VEHICLE_UPDATE_PLAYER(this, vehic, energy, bumblebee);
this.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(instance.origin, 16), '0 0 0', 1);
- SetResourceAmount(instance, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_health);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_health);
- instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH);
+ SetResourceAmount(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
+ instance.max_health = GetResourceAmount(instance, RES_HEALTH);
instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
}
vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, dt, true);
if(vehic.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt, false, RESOURCE_HEALTH);
+ vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt, false, RES_HEALTH);
if(vehic.vehicle_flags & VHF_ENERGYREGEN)
vehicles_regen(vehic, vehic.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, dt, false);
- VEHICLE_UPDATE_PLAYER_RESOURCE(player, vehic, health, racer, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(player, vehic, health, racer, RES_HEALTH);
VEHICLE_UPDATE_PLAYER(player, vehic, energy, racer);
if(vehic.vehicle_flags & VHF_HASSHIELD)
{
#ifdef SVQC
set_movetype(instance, MOVETYPE_BOUNCE);
- instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_racer_health) * 100;
+ instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_racer_health) * 100;
instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
if(instance.owner.flagcarried)
setthink(instance, racer_think);
instance.nextthink = time;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResourceAmount(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)
- SetResourceAmount(instance, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResourceAmount(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
- instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH);
+ instance.max_health = GetResourceAmount(instance, RES_HEALTH);
#endif
#ifdef CSQC
vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true);
if(vehic.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RESOURCE_HEALTH);
+ vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RES_HEALTH);
if(vehic.vehicle_flags & VHF_ENERGYREGEN)
vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false);
}
- VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
if(vehic.vehicle_flags & VHF_HASSHIELD)
VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true);
if(vehic.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RESOURCE_HEALTH);
+ vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RES_HEALTH);
if(vehic.vehicle_flags & VHF_ENERGYREGEN)
vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false);
this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
- VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
if(vehic.vehicle_flags & VHF_HASSHIELD)
VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
instance.owner.PlayerPhysplug = raptor_takeoff;
set_movetype(instance, MOVETYPE_BOUNCEMISSILE);
instance.solid = SOLID_SLIDEBOX;
- instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
+ instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work
instance.tur_head.exteriormodeltoclient = instance.owner;
}
METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
{
- SetResourceAmount(instance, RESOURCE_HEALTH, 0);
+ SetResourceAmount(instance, RES_HEALTH, 0);
instance.event_damage = func_null;
instance.solid = SOLID_CORPSE;
instance.takedamage = DAMAGE_NO;
}
instance.frame = 0;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResourceAmount(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
- instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH);
+ instance.max_health = GetResourceAmount(instance, RES_HEALTH);
if(!autocvar_g_vehicle_raptor_swim)
instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
_flare.solid = SOLID_CORPSE;
_flare.takedamage = DAMAGE_YES;
_flare.event_damage = raptor_flare_damage;
- SetResourceAmount(_flare, RESOURCE_HEALTH, 20);
+ SetResourceAmount(_flare, RES_HEALTH, 20);
_flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
settouch(_flare, raptor_flare_touch);
}
void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- TakeResource(this, RESOURCE_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
delete(this);
}
vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, dt, true);
if(vehic.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false, RESOURCE_HEALTH);
+ vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false, RES_HEALTH);
PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
//this.vehicle_ammo2 = vehic.tur_head.frame;
this.oldorigin = this.origin; // negate fall damage
this.velocity = vehic.velocity;
- VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, spiderbot, RESOURCE_HEALTH);
+ VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, spiderbot, RES_HEALTH);
if(vehic.vehicle_flags & VHF_HASSHIELD)
VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot);
STAT(VEHICLESTAT_W2MODE, instance) = SBRM_GUIDE;
set_movetype(instance, MOVETYPE_WALK);
CSQCVehicleSetup(instance.owner, 0);
- instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100;
+ instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100;
instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
if(instance.owner.flagcarried)
}
METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
{
- SetResourceAmount(instance, RESOURCE_HEALTH, 0);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_spiderbot_health);
+ SetResourceAmount(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;
- SetResourceAmount(instance, RESOURCE_HEALTH, autocvar_g_vehicle_spiderbot_health);
+ SetResourceAmount(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
- instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH);
+ instance.max_health = GetResourceAmount(instance, RES_HEALTH);
instance.pushable = true; // spiderbot can use jumppads
}
{
switch (ammotype)
{
- case RESOURCE_SHELLS: return ITEM_Shells.m_icon;
- case RESOURCE_BULLETS: return ITEM_Bullets.m_icon;
- case RESOURCE_ROCKETS: return ITEM_Rockets.m_icon;
- case RESOURCE_CELLS: return ITEM_Cells.m_icon;
- case RESOURCE_PLASMA: return ITEM_Plasma.m_icon;
- case RESOURCE_FUEL: return ITEM_JetpackFuel.m_icon;
+ case RES_SHELLS: return ITEM_Shells.m_icon;
+ case RES_BULLETS: return ITEM_Bullets.m_icon;
+ case RES_ROCKETS: return ITEM_Rockets.m_icon;
+ case RES_CELLS: return ITEM_Cells.m_icon;
+ case RES_PLASMA: return ITEM_Plasma.m_icon;
+ case RES_FUEL: return ITEM_JetpackFuel.m_icon;
default: return ""; // wtf, no ammo type?
}
}
{
switch (i)
{
- case 0: return RESOURCE_SHELLS;
- case 1: return RESOURCE_BULLETS;
- case 2: return RESOURCE_ROCKETS;
- case 3: return RESOURCE_CELLS;
- case 4: return RESOURCE_PLASMA;
- case 5: return RESOURCE_FUEL;
- default: return RESOURCE_NONE;
+ case 0: return RES_SHELLS;
+ case 1: return RES_BULLETS;
+ case 2: return RES_ROCKETS;
+ case 3: return RES_CELLS;
+ case 4: return RES_PLASMA;
+ case 5: return RES_FUEL;
+ default: return RES_NONE;
}
}
{
switch (ammotype)
{
- case RESOURCE_SHELLS: return STAT_SHELLS;
- case RESOURCE_BULLETS: return STAT_NAILS;
- case RESOURCE_ROCKETS: return STAT_ROCKETS;
- case RESOURCE_CELLS: return STAT_CELLS;
- case RESOURCE_PLASMA: return STAT_PLASMA.m_id;
- case RESOURCE_FUEL: return STAT_FUEL.m_id;
+ case RES_SHELLS: return STAT_SHELLS;
+ case RES_BULLETS: return STAT_NAILS;
+ case RES_ROCKETS: return STAT_ROCKETS;
+ case RES_CELLS: return STAT_CELLS;
+ case RES_PLASMA: return STAT_PLASMA.m_id;
+ case RES_FUEL: return STAT_FUEL.m_id;
default: return -1;
}
}
/** control what happens when this weapon is spawned */
METHOD(Weapon, m_spawnfunc_hookreplace, Weapon(Weapon this, entity e)) { return this; }
/** M: ammotype : main ammo type */
- ATTRIB(Weapon, ammo_type, int, RESOURCE_NONE);
+ ATTRIB(Weapon, ammo_type, int, RES_NONE);
/** M: impulse : weapon impulse */
ATTRIB(Weapon, impulse, int, -1);
/** M: flags : WEPSPAWNFLAG_... combined */
void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1))
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
missile.bot_dodgerating = WEP_CVAR(arc, bolt_damage);
missile.takedamage = DAMAGE_YES;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR(arc, bolt_health));
+ SetResourceAmount(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;
{
float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps));
float rootarmor = ((burst) ? WEP_CVAR(arc, burst_healing_aps) : WEP_CVAR(arc, beam_healing_aps));
- float hplimit = ((IS_PLAYER(trace_ent)) ? WEP_CVAR(arc, beam_healing_hmax) : RESOURCE_LIMIT_NONE);
+ float hplimit = ((IS_PLAYER(trace_ent)) ? WEP_CVAR(arc, beam_healing_hmax) : RES_LIMIT_NONE);
Heal(trace_ent, own, (roothealth * coefficient), hplimit);
if(IS_PLAYER(trace_ent) && rootarmor)
{
- if(GetResourceAmount(trace_ent, RESOURCE_ARMOR) <= WEP_CVAR(arc, beam_healing_amax))
+ if(GetResourceAmount(trace_ent, RES_ARMOR) <= WEP_CVAR(arc, beam_healing_amax))
{
- GiveResourceWithLimit(trace_ent, RESOURCE_ARMOR, (rootarmor * coefficient), WEP_CVAR(arc, beam_healing_amax));
+ GiveResourceWithLimit(trace_ent, RES_ARMOR, (rootarmor * coefficient), WEP_CVAR(arc, beam_healing_amax));
trace_ent.pauserotarmor_finished = max(
trace_ent.pauserotarmor_finished,
time + autocvar_g_balance_pause_armor_rot
CLASS(Arc, Weapon)
/* spawnfunc */ ATTRIB(Arc, m_canonical_spawnfunc, string, "weapon_arc");
-/* ammotype */ ATTRIB(Arc, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(Arc, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(Arc, impulse, int, 3);
/* flags */ ATTRIB(Arc, spawnflags, int, WEP_TYPE_HITSCAN);
/* rating */ ATTRIB(Arc, bot_pickupbasevalue, float, 8000);
CLASS(Blaster, Weapon)
/* spawnfunc */ ATTRIB(Blaster, m_canonical_spawnfunc, string, "weapon_blaster");
-/* ammotype */ //ATTRIB(Blaster, ammo_type, int, RESOURCE_NONE);
+/* ammotype */ //ATTRIB(Blaster, ammo_type, int, RES_NONE);
/* impulse */ ATTRIB(Blaster, impulse, int, 1);
/* flags */ ATTRIB(Blaster, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Blaster, bot_pickupbasevalue, float, 0);
CLASS(Crylink, Weapon)
/* spawnfunc */ ATTRIB(Crylink, m_canonical_spawnfunc, string, "weapon_crylink");
-/* ammotype */ ATTRIB(Crylink, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(Crylink, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(Crylink, impulse, int, 6);
/* flags */ ATTRIB(Crylink, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH | WEP_FLAG_CANCLIMB);
/* rating */ ATTRIB(Crylink, bot_pickupbasevalue, float, 6000);
void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think);
}
missile.takedamage = DAMAGE_YES;
missile.damageforcescale = WEP_CVAR(devastator, damageforcescale);
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR(devastator, health));
+ SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(devastator, health));
missile.event_damage = W_Devastator_Damage;
missile.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, missile);
// but don't fire a new shot at the same time!
if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events
PHYS_INPUT_BUTTON_ATCK2(actor) = true;
- if((skill > 6.5) && (selfdamage > GetResourceAmount(actor, RESOURCE_HEALTH)))
+ if((skill > 6.5) && (selfdamage > GetResourceAmount(actor, RES_HEALTH)))
PHYS_INPUT_BUTTON_ATCK2(actor) = false;
//if(PHYS_INPUT_BUTTON_ATCK2(actor) == true)
// dprint(ftos(desirabledamage),"\n");
CLASS(Devastator, Weapon)
/* spawnfunc */ ATTRIB(Devastator, m_canonical_spawnfunc, string, "weapon_devastator");
-/* ammotype */ ATTRIB(Devastator, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(Devastator, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(Devastator, impulse, int, 9);
/* flags */ ATTRIB(Devastator, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Devastator, bot_pickupbasevalue, float, 8000);
newproj.takedamage = this.takedamage;
newproj.damageforcescale = this.damageforcescale;
- SetResourceAmount(newproj, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH));
+ SetResourceAmount(newproj, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
newproj.event_damage = this.event_damage;
newproj.spawnshieldtime = this.spawnshieldtime;
newproj.damagedbycontents = true;
void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
// note: combos are usually triggered by W_Electro_TriggerCombo, not damage
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.takedamage = DAMAGE_NO;
this.nextthink = time;
setsize(proj, '-4 -4 -4', '4 4 4');
proj.takedamage = DAMAGE_YES;
proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
- SetResourceAmount(proj, RESOURCE_HEALTH, WEP_CVAR_SEC(electro, health));
+ SetResourceAmount(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
proj.event_damage = W_Electro_Orb_Damage;
proj.flags = FL_PROJECTILE;
IL_PUSH(g_projectiles, proj);
CLASS(Electro, Weapon)
/* spawnfunc */ ATTRIB(Electro, m_canonical_spawnfunc, string, "weapon_electro");
-/* ammotype */ ATTRIB(Electro, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(Electro, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(Electro, impulse, int, 5);
/* flags */ ATTRIB(Electro, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Electro, bot_pickupbasevalue, float, 5000);
this.takedamage = DAMAGE_NO;
// 1. dist damage
- d = (GetResourceAmount(this.realowner, RESOURCE_HEALTH) + GetResourceAmount(this.realowner, RESOURCE_ARMOR));
+ d = (GetResourceAmount(this.realowner, RES_HEALTH) + GetResourceAmount(this.realowner, RES_ARMOR));
RadiusDamage(this, this.realowner, WEP_CVAR_PRI(fireball, damage), WEP_CVAR_PRI(fireball, edgedamage), WEP_CVAR_PRI(fireball, radius), NULL, NULL, WEP_CVAR_PRI(fireball, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity);
- if(GetResourceAmount(this.realowner, RESOURCE_HEALTH) + GetResourceAmount(this.realowner, RESOURCE_ARMOR) >= d)
+ if(GetResourceAmount(this.realowner, RES_HEALTH) + GetResourceAmount(this.realowner, RES_ARMOR) >= d)
if(!this.cnt)
{
modeleffect_spawn("models/sphere/sphere.md3", 0, 0, this.origin, '0 0 0', '0 0 0', '0 0 0', 0, WEP_CVAR_PRI(fireball, bfgradius), 0.2, 0.05, 0.25);
void W_Fireball_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
{
this.cnt = 1;
W_PrepareExplosionByDamage(this, attacker, W_Fireball_Explode_think);
proj.use = W_Fireball_Explode_use;
setthink(proj, W_Fireball_Think);
proj.nextthink = time;
- SetResourceAmount(proj, RESOURCE_HEALTH, WEP_CVAR_PRI(fireball, health));
+ SetResourceAmount(proj, RES_HEALTH, WEP_CVAR_PRI(fireball, health));
proj.team = actor.team;
proj.event_damage = W_Fireball_Damage;
proj.takedamage = DAMAGE_YES;
CLASS(Fireball, Weapon)
/* spawnfunc */ ATTRIB(Fireball, m_canonical_spawnfunc, string, "weapon_fireball");
-/* ammotype */ //ATTRIB(Fireball, ammo_type, int, RESOURCE_NONE);
+/* ammotype */ //ATTRIB(Fireball, ammo_type, int, RES_NONE);
/* impulse */ ATTRIB(Fireball, impulse, int, 9);
/* flags */ ATTRIB(Fireball, spawnflags, int, WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH | WEP_FLAG_NODUAL);
/* rating */ ATTRIB(Fireball, bot_pickupbasevalue, float, 5000);
void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
float is_linkexplode = ( ((inflictor.owner != NULL) ? (inflictor.owner == this.owner) : true)
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, is_linkexplode))
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
missile.takedamage = DAMAGE_YES;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR_PRI(hagar, health));
+ SetResourceAmount(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;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR_SEC(hagar, health));
+ SetResourceAmount(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;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR_SEC(hagar, health));
+ SetResourceAmount(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
missile.event_damage = W_Hagar_Damage;
missile.damagedbycontents = true;
CLASS(Hagar, Weapon)
/* spawnfunc */ ATTRIB(Hagar, m_canonical_spawnfunc, string, "weapon_hagar");
-/* ammotype */ ATTRIB(Hagar, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(Hagar, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(Hagar, impulse, int, 8);
/* flags */ ATTRIB(Hagar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Hagar, bot_pickupbasevalue, float, 6000);
CLASS(HLAC, Weapon)
/* spawnfunc */ ATTRIB(HLAC, m_canonical_spawnfunc, string, "weapon_hlac");
-/* ammotype */ ATTRIB(HLAC, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(HLAC, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(HLAC, impulse, int, 6);
/* flags */ ATTRIB(HLAC, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(HLAC, bot_pickupbasevalue, float, 4000);
void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH));
+ SetResourceAmount(this, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
}
settouch(gren, W_Hook_Touch2);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RESOURCE_HEALTH, WEP_CVAR_SEC(hook, health));
+ SetResourceAmount(gren, RES_HEALTH, WEP_CVAR_SEC(hook, health));
gren.damageforcescale = WEP_CVAR_SEC(hook, damageforcescale);
gren.event_damage = W_Hook_Damage;
gren.damagedbycontents = true;
{
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
- if( GetResourceAmount(actor, RESOURCE_FUEL) >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel )
+ if( GetResourceAmount(actor, RES_FUEL) >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel )
{
W_DecreaseAmmo(thiswep, actor, (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel, weaponentity);
actor.(weaponentity).hook_time_fueldecrease = time;
}
else
{
- SetResourceAmount(actor, RESOURCE_FUEL, 0);
+ SetResourceAmount(actor, RES_FUEL, 0);
actor.(weaponentity).hook_state |= HOOK_REMOVING;
if(actor.(weaponentity).m_weapon != WEP_Null) // offhand
W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
if (!thiswep.ammo_factor) return true;
if(actor.(weaponentity).hook)
- return GetResourceAmount(actor, RESOURCE_FUEL) > 0;
+ return GetResourceAmount(actor, RES_FUEL) > 0;
- return GetResourceAmount(actor, RESOURCE_FUEL) >= WEP_CVAR_PRI(hook, ammo);
+ return GetResourceAmount(actor, RES_FUEL) >= WEP_CVAR_PRI(hook, ammo);
}
METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity))
{
CLASS(Hook, Weapon)
/* spawnfunc */ ATTRIB(Hook, m_canonical_spawnfunc, string, "weapon_hook");
-/* ammotype */ ATTRIB(Hook, ammo_type, int, RESOURCE_FUEL);
+/* ammotype */ ATTRIB(Hook, ammo_type, int, RES_FUEL);
/* impulse */ ATTRIB(Hook, impulse, int, 0);
/* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Hook, bot_pickupbasevalue, float, 0);
CLASS(MachineGun, Weapon)
/* spawnfunc */ ATTRIB(MachineGun, m_canonical_spawnfunc, string, "weapon_machinegun");
-/* ammotype */ ATTRIB(MachineGun, ammo_type, int, RESOURCE_BULLETS);
+/* ammotype */ ATTRIB(MachineGun, ammo_type, int, RES_BULLETS);
/* impulse */ ATTRIB(MachineGun, impulse, int, 3);
/* flags */ ATTRIB(MachineGun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_PENETRATEWALLS);
/* rating */ ATTRIB(MachineGun, bot_pickupbasevalue, float, 7000);
newmine.takedamage = this.takedamage;
newmine.damageforcescale = this.damageforcescale;
- SetResourceAmount(newmine, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH));
+ SetResourceAmount(newmine, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
newmine.event_damage = this.event_damage;
newmine.spawnshieldtime = this.spawnshieldtime;
newmine.damagedbycontents = true;
void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
float is_from_enemy = (inflictor.realowner != this.realowner);
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_from_enemy ? 1 : -1)))
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode_think);
}
mine.takedamage = DAMAGE_YES;
mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale);
- SetResourceAmount(mine, RESOURCE_HEALTH, WEP_CVAR(minelayer, health));
+ SetResourceAmount(mine, RES_HEALTH, WEP_CVAR(minelayer, health));
mine.event_damage = W_MineLayer_Damage;
mine.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, mine);
// but don't fire a new shot at the same time!
if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events
PHYS_INPUT_BUTTON_ATCK2(actor) = true;
- if((skill > 6.5) && (selfdamage > GetResourceAmount(actor, RESOURCE_HEALTH)))
+ if((skill > 6.5) && (selfdamage > GetResourceAmount(actor, RES_HEALTH)))
PHYS_INPUT_BUTTON_ATCK2(actor) = false;
//if(PHYS_INPUT_BUTTON_ATCK2(actor) == true)
// dprint(ftos(desirabledamage),"\n");
CLASS(MineLayer, Weapon)
/* spawnfunc */ ATTRIB(MineLayer, m_canonical_spawnfunc, string, "weapon_minelayer");
-/* ammotype */ ATTRIB(MineLayer, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(MineLayer, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(MineLayer, impulse, int, 4);
/* flags */ ATTRIB(MineLayer, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(MineLayer, bot_pickupbasevalue, float, 7000);
void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
settouch(gren, W_Mortar_Grenade_Touch1);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RESOURCE_HEALTH, WEP_CVAR_PRI(mortar, health));
+ SetResourceAmount(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;
- SetResourceAmount(gren, RESOURCE_HEALTH, WEP_CVAR_SEC(mortar, health));
+ SetResourceAmount(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;
CLASS(Mortar, Weapon)
/* spawnfunc */ ATTRIB(Mortar, m_canonical_spawnfunc, string, "weapon_mortar");
-/* ammotype */ ATTRIB(Mortar, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(Mortar, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(Mortar, impulse, int, 4);
/* flags */ ATTRIB(Mortar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Mortar, bot_pickupbasevalue, float, 7000);
CLASS(PortoLaunch, Weapon)
/* spawnfunc */ ATTRIB(PortoLaunch, m_canonical_spawnfunc, string, "weapon_porto");
-/* ammotype */ ATTRIB(PortoLaunch, ammo_type, int, RESOURCE_NONE);
+/* ammotype */ ATTRIB(PortoLaunch, ammo_type, int, RES_NONE);
/* impulse */ ATTRIB(PortoLaunch, impulse, int, 0);
/* flags */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON | WEP_FLAG_NODUAL);
/* rating */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0);
CLASS(Rifle, Weapon)
/* spawnfunc */ ATTRIB(Rifle, m_canonical_spawnfunc, string, "weapon_rifle");
-/* ammotype */ ATTRIB(Rifle, ammo_type, int, RESOURCE_BULLETS);
+/* ammotype */ ATTRIB(Rifle, ammo_type, int, RES_BULLETS);
/* impulse */ ATTRIB(Rifle, impulse, int, 7);
/* flags */ ATTRIB(Rifle, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_PENETRATEWALLS);
/* rating */ ATTRIB(Rifle, bot_pickupbasevalue, float, 7000);
void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_projectiles_damage says to halt
if(this.realowner == attacker)
- TakeResource(this, RESOURCE_HEALTH, (damage * 0.25));
+ TakeResource(this, RES_HEALTH, (damage * 0.25));
else
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_Seeker_Missile_Explode_think);
}
missile.scale = 2;
missile.takedamage = DAMAGE_YES;
missile.weaponentity_fld = weaponentity;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR(seeker, missile_health));
+ SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(seeker, missile_health));
missile.damageforcescale = WEP_CVAR(seeker, missile_damageforcescale);
missile.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, missile);
void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
- TakeResource(this, RESOURCE_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
W_Seeker_Tag_Explode(this);
}
missile.takedamage = DAMAGE_YES;
missile.event_damage = W_Seeker_Tag_Damage;
- SetResourceAmount(missile, RESOURCE_HEALTH, WEP_CVAR(seeker, tag_health));
+ SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
missile.damageforcescale = WEP_CVAR(seeker, tag_damageforcescale);
setorigin(missile, w_shotorg);
CLASS(Seeker, Weapon)
/* spawnfunc */ ATTRIB(Seeker, m_canonical_spawnfunc, string, "weapon_seeker");
-/* ammotype */ ATTRIB(Seeker, ammo_type, int, RESOURCE_ROCKETS);
+/* ammotype */ ATTRIB(Seeker, ammo_type, int, RES_ROCKETS);
/* impulse */ ATTRIB(Seeker, impulse, int, 8);
/* flags */ ATTRIB(Seeker, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
/* rating */ ATTRIB(Seeker, bot_pickupbasevalue, float, 5000);
CLASS(Shockwave, Weapon)
/* spawnfunc */ ATTRIB(Shockwave, m_canonical_spawnfunc, string, "weapon_shockwave");
-/* ammotype */ //ATTRIB(Shockwave, ammo_type, int, RESOURCE_NONE);
+/* ammotype */ //ATTRIB(Shockwave, ammo_type, int, RES_NONE);
/* impulse */ ATTRIB(Shockwave, impulse, int, 2);
/* flags */ ATTRIB(Shockwave, spawnflags, int, WEP_TYPE_HITSCAN | WEP_FLAG_CANCLIMB | WEP_TYPE_MELEE_SEC);
/* rating */ ATTRIB(Shockwave, bot_pickupbasevalue, float, 3000);
CLASS(Shotgun, Weapon)
/* spawnfunc */ ATTRIB(Shotgun, m_canonical_spawnfunc, string, "weapon_shotgun");
-/* ammotype */ ATTRIB(Shotgun, ammo_type, int, RESOURCE_SHELLS);
+/* ammotype */ ATTRIB(Shotgun, ammo_type, int, RES_SHELLS);
/* impulse */ ATTRIB(Shotgun, impulse, int, 2);
/* flags */ ATTRIB(Shotgun, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_TYPE_MELEE_SEC);
/* rating */ ATTRIB(Shotgun, bot_pickupbasevalue, float, 6000);
} else if(WEP_CVAR(vaporizer, reload_ammo) && actor.(weaponentity).clip_load < vaporizer_ammo) { // forced reload
thiswep.wr_reload(thiswep, actor, weaponentity);
}
- if((fire & 1) && (GetResourceAmount(actor, RESOURCE_CELLS) || !autocvar_g_rm) && !forbidWeaponUse(actor))
+ if((fire & 1) && (GetResourceAmount(actor, RES_CELLS) || !autocvar_g_rm) && !forbidWeaponUse(actor))
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
{
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
}
}
- if((fire & 2) || ((fire & 1) && !GetResourceAmount(actor, RESOURCE_CELLS) && autocvar_g_rm))
+ if((fire & 2) || ((fire & 1) && !GetResourceAmount(actor, RES_CELLS) && autocvar_g_rm))
{
if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
{
CLASS(Vaporizer, Weapon)
/* spawnfunc */ ATTRIB(Vaporizer, m_canonical_spawnfunc, string, "weapon_vaporizer");
-/* ammotype */ ATTRIB(Vaporizer, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(Vaporizer, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(Vaporizer, impulse, int, 7);
/* flags */ ATTRIB(Vaporizer, spawnflags, int, WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN | WEP_FLAG_NODUAL);
/* rating */ ATTRIB(Vaporizer, bot_pickupbasevalue, float, 10000);
CLASS(Vortex, Weapon)
/* spawnfunc */ ATTRIB(Vortex, m_canonical_spawnfunc, string, "weapon_vortex");
-/* ammotype */ ATTRIB(Vortex, ammo_type, int, RESOURCE_CELLS);
+/* ammotype */ ATTRIB(Vortex, ammo_type, int, RES_CELLS);
/* impulse */ ATTRIB(Vortex, impulse, int, 7);
/* flags */ ATTRIB(Vortex, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN);
/* rating */ ATTRIB(Vortex, bot_pickupbasevalue, float, 8000);
// Jetpack navigation
if(this.navigation_jetpack_goal)
if(this.goalcurrent==this.navigation_jetpack_goal)
- if(GetResourceAmount(this, RESOURCE_FUEL))
+ if(GetResourceAmount(this, RES_FUEL))
{
if(autocvar_bot_debug_goalstack)
{
return;
}
else if(!this.jumppadcount && !this.goalcurrent.wphardwired
- && GetResourceAmount(this, RESOURCE_HEALTH) + GetResourceAmount(this, RESOURCE_ARMOR) > ROCKETJUMP_DAMAGE())
+ && GetResourceAmount(this, RES_HEALTH) + GetResourceAmount(this, RES_ARMOR) > ROCKETJUMP_DAMAGE())
{
if(this.velocity.z < 0)
{
traceline(this.origin+this.view_ofs, ( this.enemy.absmin + this.enemy.absmax ) * 0.5,false,NULL);
if (trace_ent == this.enemy || trace_fraction == 1)
if (vdist(((this.enemy.absmin + this.enemy.absmax) * 0.5) - this.origin, <, 1000))
- if (GetResourceAmount(this, RESOURCE_HEALTH) > 30)
+ if (GetResourceAmount(this, RES_HEALTH) > 30)
{
// remain tracking him for a shot while (case he went after a small corner or pilar
this.havocbot_chooseenemy_finished = time + 0.5;
bool havocbot_goalrating_item_can_be_left_to_teammate(entity this, entity player, entity item)
{
- if (GetResourceAmount(item, RESOURCE_HEALTH) && GetResourceAmount(player, RESOURCE_HEALTH) <= GetResourceAmount(this, RESOURCE_HEALTH)) {return true;}
- if (GetResourceAmount(item, RESOURCE_ARMOR) && GetResourceAmount(player, RESOURCE_ARMOR) <= GetResourceAmount(this, RESOURCE_ARMOR)) {return true;}
+ if (GetResourceAmount(item, RES_HEALTH) && GetResourceAmount(player, RES_HEALTH) <= GetResourceAmount(this, RES_HEALTH)) {return true;}
+ if (GetResourceAmount(item, RES_ARMOR) && GetResourceAmount(player, RES_ARMOR) <= GetResourceAmount(this, RES_ARMOR)) {return true;}
if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;}
- if (GetResourceAmount(item, RESOURCE_SHELLS) && GetResourceAmount(player, RESOURCE_SHELLS) <= GetResourceAmount(this, RESOURCE_SHELLS)) {return true;}
- if (GetResourceAmount(item, RESOURCE_BULLETS) && GetResourceAmount(player, RESOURCE_BULLETS) <= GetResourceAmount(this, RESOURCE_BULLETS)) {return true;}
- if (GetResourceAmount(item, RESOURCE_ROCKETS) && GetResourceAmount(player, RESOURCE_ROCKETS) <= GetResourceAmount(this, RESOURCE_ROCKETS)) {return true;}
- if (GetResourceAmount(item, RESOURCE_CELLS) && GetResourceAmount(player, RESOURCE_CELLS) <= GetResourceAmount(this, RESOURCE_CELLS)) {return true;}
- if (GetResourceAmount(item, RESOURCE_PLASMA) && GetResourceAmount(player, RESOURCE_PLASMA) <= GetResourceAmount(this, RESOURCE_PLASMA)) {return true;}
+ if (GetResourceAmount(item, RES_SHELLS) && GetResourceAmount(player, RES_SHELLS) <= GetResourceAmount(this, RES_SHELLS)) {return true;}
+ if (GetResourceAmount(item, RES_BULLETS) && GetResourceAmount(player, RES_BULLETS) <= GetResourceAmount(this, RES_BULLETS)) {return true;}
+ if (GetResourceAmount(item, RES_ROCKETS) && GetResourceAmount(player, RES_ROCKETS) <= GetResourceAmount(this, RES_ROCKETS)) {return true;}
+ if (GetResourceAmount(item, RES_CELLS) && GetResourceAmount(player, RES_CELLS) <= GetResourceAmount(this, RES_CELLS)) {return true;}
+ if (GetResourceAmount(item, RES_PLASMA) && GetResourceAmount(player, RES_PLASMA) <= GetResourceAmount(this, RES_PLASMA)) {return true;}
if (item.itemdef.instanceOfPowerup) {return true;}
return false;
continue;
*/
- t = ((GetResourceAmount(this, RESOURCE_HEALTH) + GetResourceAmount(this, RESOURCE_ARMOR)) - (GetResourceAmount(it, RESOURCE_HEALTH) + GetResourceAmount(it, RESOURCE_ARMOR))) / 150;
+ t = ((GetResourceAmount(this, RES_HEALTH) + GetResourceAmount(this, RES_ARMOR)) - (GetResourceAmount(it, RES_HEALTH) + GetResourceAmount(it, RES_ARMOR))) / 150;
t = bound(0, 1 + t, 3);
if (skill > 3)
{
t += xydistance / autocvar_g_jetpack_maxspeed_side;
fuel = t * autocvar_g_jetpack_fuel * 0.8;
- LOG_DEBUG("jetpack ai: required fuel ", ftos(fuel), ", have ", ftos(GetResourceAmount(this, RESOURCE_FUEL)));
+ LOG_DEBUG("jetpack ai: required fuel ", ftos(fuel), ", have ", ftos(GetResourceAmount(this, RES_FUEL)));
// enough fuel ?
- if(GetResourceAmount(this, RESOURCE_FUEL) > fuel || (this.items & IT_UNLIMITED_WEAPON_AMMO))
+ if(GetResourceAmount(this, RES_FUEL) > fuel || (this.items & IT_UNLIMITED_WEAPON_AMMO))
{
// Estimate cost
// (as onground costs calculation is mostly based on distances, here we do the same establishing some relationship
switch(expr)
{
case "health":
- return GetResourceAmount(this, RESOURCE_HEALTH);
+ return GetResourceAmount(this, RES_HEALTH);
case "speed":
return vlen(this.velocity);
case "flagcarrier":
this.personal.origin = this.origin;
this.personal.v_angle = this.v_angle;
this.personal.velocity = this.velocity;
- SetResourceAmount(this.personal, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS));
- SetResourceAmount(this.personal, RESOURCE_BULLETS, GetResourceAmount(this, RESOURCE_BULLETS));
- SetResourceAmount(this.personal, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS));
- SetResourceAmount(this.personal, RESOURCE_PLASMA, GetResourceAmount(this, RESOURCE_PLASMA));
- SetResourceAmount(this.personal, RESOURCE_SHELLS, GetResourceAmount(this, RESOURCE_SHELLS));
- SetResourceAmount(this.personal, RESOURCE_FUEL, GetResourceAmount(this, RESOURCE_FUEL));
- SetResourceAmount(this.personal, RESOURCE_HEALTH, max(1, GetResourceAmount(this, RESOURCE_HEALTH)));
- SetResourceAmount(this.personal, RESOURCE_ARMOR, GetResourceAmount(this, RESOURCE_ARMOR));
+ SetResourceAmount(this.personal, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS));
+ SetResourceAmount(this.personal, RES_BULLETS, GetResourceAmount(this, RES_BULLETS));
+ SetResourceAmount(this.personal, RES_CELLS, GetResourceAmount(this, RES_CELLS));
+ SetResourceAmount(this.personal, RES_PLASMA, GetResourceAmount(this, RES_PLASMA));
+ SetResourceAmount(this.personal, RES_SHELLS, GetResourceAmount(this, RES_SHELLS));
+ SetResourceAmount(this.personal, RES_FUEL, GetResourceAmount(this, RES_FUEL));
+ SetResourceAmount(this.personal, RES_HEALTH, max(1, GetResourceAmount(this, RES_HEALTH)));
+ SetResourceAmount(this.personal, RES_ARMOR, GetResourceAmount(this, RES_ARMOR));
STAT(WEAPONS, this.personal) = STAT(WEAPONS, this);
this.personal.items = this.items;
this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
MUTATOR_CALLHOOK(AbortSpeedrun, this);
}
- SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this.personal, RESOURCE_ROCKETS));
- SetResourceAmount(this, RESOURCE_BULLETS, GetResourceAmount(this.personal, RESOURCE_BULLETS));
- SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this.personal, RESOURCE_CELLS));
- SetResourceAmount(this, RESOURCE_PLASMA, GetResourceAmount(this.personal, RESOURCE_PLASMA));
- SetResourceAmount(this, RESOURCE_SHELLS, GetResourceAmount(this.personal, RESOURCE_SHELLS));
- SetResourceAmount(this, RESOURCE_FUEL, GetResourceAmount(this.personal, RESOURCE_FUEL));
- SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(this.personal, RESOURCE_HEALTH));
- SetResourceAmount(this, RESOURCE_ARMOR, GetResourceAmount(this.personal, RESOURCE_ARMOR));
+ SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this.personal, RES_ROCKETS));
+ SetResourceAmount(this, RES_BULLETS, GetResourceAmount(this.personal, RES_BULLETS));
+ SetResourceAmount(this, RES_CELLS, GetResourceAmount(this.personal, RES_CELLS));
+ SetResourceAmount(this, RES_PLASMA, GetResourceAmount(this.personal, RES_PLASMA));
+ SetResourceAmount(this, RES_SHELLS, GetResourceAmount(this.personal, RES_SHELLS));
+ SetResourceAmount(this, RES_FUEL, GetResourceAmount(this.personal, RES_FUEL));
+ SetResourceAmount(this, RES_HEALTH, GetResourceAmount(this.personal, RES_HEALTH));
+ SetResourceAmount(this, RES_ARMOR, GetResourceAmount(this.personal, RES_ARMOR));
STAT(WEAPONS, this) = STAT(WEAPONS, this.personal);
this.items = this.personal.items;
this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
entity e = spawn();
e.model = strzone(argv(1));
e.mdl = "rocket_explode";
- SetResourceAmount(e, RESOURCE_HEALTH, 1000);
+ SetResourceAmount(e, RES_HEALTH, 1000);
setorigin(e, trace_endpos);
e.effects = EF_NOMODELFLAGS;
if(f == 1)
if (IS_PLAYER(this))
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) >= 1)
+ if(GetResourceAmount(this, RES_HEALTH) >= 1)
{
// despawn effect
Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
if(this.damagedbycontents)
IL_REMOVE(g_damagedbycontents, this);
this.damagedbycontents = false;
- SetResourceAmount(this, RESOURCE_HEALTH, FRAGS_SPECTATOR);
+ SetResourceAmount(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;
- SetResourceAmount(this, RESOURCE_ARMOR, autocvar_g_balance_armor_start); // was 666?!
+ SetResourceAmount(this, RES_ARMOR, autocvar_g_balance_armor_start); // was 666?!
this.pauserotarmor_finished = 0;
this.pauserothealth_finished = 0;
this.pauseregen_finished = 0;
this.effects = EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
if (warmup_stage) {
- SetResourceAmount(this, RESOURCE_SHELLS, warmup_start_ammo_shells);
- SetResourceAmount(this, RESOURCE_BULLETS, warmup_start_ammo_nails);
- SetResourceAmount(this, RESOURCE_ROCKETS, warmup_start_ammo_rockets);
- SetResourceAmount(this, RESOURCE_CELLS, warmup_start_ammo_cells);
- SetResourceAmount(this, RESOURCE_PLASMA, warmup_start_ammo_plasma);
- SetResourceAmount(this, RESOURCE_FUEL, warmup_start_ammo_fuel);
- SetResourceAmount(this, RESOURCE_HEALTH, warmup_start_health);
- SetResourceAmount(this, RESOURCE_ARMOR, warmup_start_armorvalue);
+ SetResourceAmount(this, RES_SHELLS, warmup_start_ammo_shells);
+ SetResourceAmount(this, RES_BULLETS, warmup_start_ammo_nails);
+ SetResourceAmount(this, RES_ROCKETS, warmup_start_ammo_rockets);
+ SetResourceAmount(this, RES_CELLS, warmup_start_ammo_cells);
+ SetResourceAmount(this, RES_PLASMA, warmup_start_ammo_plasma);
+ SetResourceAmount(this, RES_FUEL, warmup_start_ammo_fuel);
+ SetResourceAmount(this, RES_HEALTH, warmup_start_health);
+ SetResourceAmount(this, RES_ARMOR, warmup_start_armorvalue);
STAT(WEAPONS, this) = WARMUP_START_WEAPONS;
} else {
- SetResourceAmount(this, RESOURCE_SHELLS, start_ammo_shells);
- SetResourceAmount(this, RESOURCE_BULLETS, start_ammo_nails);
- SetResourceAmount(this, RESOURCE_ROCKETS, start_ammo_rockets);
- SetResourceAmount(this, RESOURCE_CELLS, start_ammo_cells);
- SetResourceAmount(this, RESOURCE_PLASMA, start_ammo_plasma);
- SetResourceAmount(this, RESOURCE_FUEL, start_ammo_fuel);
- SetResourceAmount(this, RESOURCE_HEALTH, start_health);
- SetResourceAmount(this, RESOURCE_ARMOR, start_armorvalue);
+ SetResourceAmount(this, RES_SHELLS, start_ammo_shells);
+ SetResourceAmount(this, RES_BULLETS, start_ammo_nails);
+ SetResourceAmount(this, RES_ROCKETS, start_ammo_rockets);
+ SetResourceAmount(this, RES_CELLS, start_ammo_cells);
+ SetResourceAmount(this, RES_PLASMA, start_ammo_plasma);
+ SetResourceAmount(this, RES_FUEL, start_ammo_fuel);
+ SetResourceAmount(this, RES_HEALTH, start_health);
+ SetResourceAmount(this, RES_ARMOR, start_armorvalue);
STAT(WEAPONS, this) = start_weapons;
if (MUTATOR_CALLHOOK(ForbidRandomStartWeapons, this) == false)
{
float mina, maxa, limith, limita;
maxa = autocvar_g_balance_armor_rotstable;
mina = autocvar_g_balance_armor_regenstable;
- limith = GetResourceLimit(this, RESOURCE_HEALTH);
- limita = GetResourceLimit(this, RESOURCE_ARMOR);
+ limith = GetResourceLimit(this, RES_HEALTH);
+ limita = GetResourceLimit(this, RES_ARMOR);
regen_health_rotstable = regen_health_rotstable * max_mod;
regen_health_stable = regen_health_stable * max_mod;
limith = limith * limit_mod;
limita = limita * limit_mod;
- SetResourceAmount(this, RESOURCE_ARMOR, CalcRotRegen(GetResourceAmount(this, RESOURCE_ARMOR), mina, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear,
+ SetResourceAmount(this, RES_ARMOR, CalcRotRegen(GetResourceAmount(this, RES_ARMOR), mina, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear,
regen_mod * frametime * (time > this.pauseregen_finished), maxa, autocvar_g_balance_armor_rot, autocvar_g_balance_armor_rotlinear,
rot_mod * frametime * (time > this.pauserotarmor_finished), limita));
- SetResourceAmount(this, RESOURCE_HEALTH, CalcRotRegen(GetResourceAmount(this, RESOURCE_HEALTH), regen_health_stable, regen_health, regen_health_linear,
+ SetResourceAmount(this, RES_HEALTH, CalcRotRegen(GetResourceAmount(this, RES_HEALTH), regen_health_stable, regen_health, regen_health_linear,
regen_mod * frametime * (time > this.pauseregen_finished), regen_health_rotstable, regen_health_rot, regen_health_rotlinear,
rot_mod * frametime * (time > this.pauserothealth_finished), limith));
}
// if player rotted to death... die!
// check this outside above checks, as player may still be able to rot to death
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 1)
+ if(GetResourceAmount(this, RES_HEALTH) < 1)
{
if(this.vehicle)
vehicles_exit(this.vehicle, VHEF_RELEASE);
maxf = autocvar_g_balance_fuel_rotstable;
minf = autocvar_g_balance_fuel_regenstable;
- limitf = GetResourceLimit(this, RESOURCE_FUEL);
+ limitf = GetResourceLimit(this, RES_FUEL);
- SetResourceAmount(this, RESOURCE_FUEL, CalcRotRegen(GetResourceAmount(this, RESOURCE_FUEL), minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear,
+ SetResourceAmount(this, RES_FUEL, CalcRotRegen(GetResourceAmount(this, RES_FUEL), minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear,
frametime * (time > this.pauseregen_finished) * ((this.items & ITEM_JetpackRegen.m_itemid) != 0),
maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > this.pauserotfuel_finished), limitf));
}
MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
PS(this) = PS(spectatee);
this.armortype = spectatee.armortype;
- SetResourceAmount(this, RESOURCE_ARMOR, GetResourceAmount(spectatee, RESOURCE_ARMOR));
- SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(spectatee, RESOURCE_CELLS));
- SetResourceAmount(this, RESOURCE_PLASMA, GetResourceAmount(spectatee, RESOURCE_PLASMA));
- SetResourceAmount(this, RESOURCE_SHELLS, GetResourceAmount(spectatee, RESOURCE_SHELLS));
- SetResourceAmount(this, RESOURCE_BULLETS, GetResourceAmount(spectatee, RESOURCE_BULLETS));
- SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(spectatee, RESOURCE_ROCKETS));
- SetResourceAmount(this, RESOURCE_FUEL, GetResourceAmount(spectatee, RESOURCE_FUEL));
+ SetResourceAmount(this, RES_ARMOR, GetResourceAmount(spectatee, RES_ARMOR));
+ SetResourceAmount(this, RES_CELLS, GetResourceAmount(spectatee, RES_CELLS));
+ SetResourceAmount(this, RES_PLASMA, GetResourceAmount(spectatee, RES_PLASMA));
+ SetResourceAmount(this, RES_SHELLS, GetResourceAmount(spectatee, RES_SHELLS));
+ SetResourceAmount(this, RES_BULLETS, GetResourceAmount(spectatee, RES_BULLETS));
+ SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(spectatee, RES_ROCKETS));
+ SetResourceAmount(this, RES_FUEL, GetResourceAmount(spectatee, RES_FUEL));
this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
- SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(spectatee, RESOURCE_HEALTH));
+ SetResourceAmount(this, RES_HEALTH, GetResourceAmount(spectatee, RES_HEALTH));
CS(this).impulse = 0;
this.items = spectatee.items;
STAT(LAST_PICKUP, this) = STAT(LAST_PICKUP, spectatee);
}
this.items_added = 0;
- if ((this.items & ITEM_Jetpack.m_itemid) && ((this.items & ITEM_JetpackRegen.m_itemid) || GetResourceAmount(this, RESOURCE_FUEL) >= 0.01))
+ if ((this.items & ITEM_Jetpack.m_itemid) && ((this.items & ITEM_JetpackRegen.m_itemid) || GetResourceAmount(this, RES_FUEL) >= 0.01))
this.items_added |= IT_FUEL;
this.items |= this.items_added;
if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
{
STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + frametime * this.revive_speed, 1);
- SetResourceAmount(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
+ SetResourceAmount(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);
- SetResourceAmount(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+ SetResourceAmount(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
- if (GetResourceAmount(this, RESOURCE_HEALTH) < 1)
+ if (GetResourceAmount(this, RES_HEALTH) < 1)
{
if (this.vehicle)
vehicles_exit(this.vehicle, VHEF_RELEASE);
}
if (this.waypointsprite_attachedforcarrier) {
- float hp = healtharmor_maxdamage(GetResourceAmount(this, RESOURCE_HEALTH), GetResourceAmount(this, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x;
+ float hp = healtharmor_maxdamage(GetResourceAmount(this, RES_HEALTH), GetResourceAmount(this, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x;
WaypointSprite_UpdateHealth(this.waypointsprite_attachedforcarrier, hp);
}
if(IS_SPEC(caller) || IS_OBSERVER(caller))
return; // no point warning about this, command does nothing
- if(GetResourceAmount(caller, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(caller, RES_HEALTH) <= 0)
{
sprint(caller, "Can't die - you are already dead!\n");
return;
if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
- Damage(mon, NULL, NULL, GetResourceAmount(mon, RESOURCE_HEALTH) + mon.max_health + 200, DEATH_KILL.m_id, DMG_NOWEP, mon.origin, '0 0 0');
+ Damage(mon, NULL, NULL, GetResourceAmount(mon, RES_HEALTH) + mon.max_health + 200, DEATH_KILL.m_id, DMG_NOWEP, mon.origin, '0 0 0');
print_to(caller, strcat("Your pet '", mon.monster_name, "' has been brutally mutilated"));
return;
}
{
if (!(this.spawnflags & 1))
{
- SetResourceAmount(actor, RESOURCE_ARMOR, start_armorvalue);
+ SetResourceAmount(actor, RES_ARMOR, start_armorvalue);
actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
}
if (!(this.spawnflags & 2))
{
- SetResourceAmount(actor, RESOURCE_HEALTH, start_health);
+ SetResourceAmount(actor, RES_HEALTH, start_health);
actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
}
if (!(this.spawnflags & 4))
{
- SetResourceAmount(actor, RESOURCE_SHELLS, start_ammo_shells);
- SetResourceAmount(actor, RESOURCE_BULLETS, start_ammo_nails);
- SetResourceAmount(actor, RESOURCE_ROCKETS, start_ammo_rockets);
- SetResourceAmount(actor, RESOURCE_CELLS, start_ammo_cells);
- SetResourceAmount(actor, RESOURCE_PLASMA, start_ammo_plasma);
- SetResourceAmount(actor, RESOURCE_FUEL, start_ammo_fuel);
+ SetResourceAmount(actor, RES_SHELLS, start_ammo_shells);
+ SetResourceAmount(actor, RES_BULLETS, start_ammo_nails);
+ SetResourceAmount(actor, RES_ROCKETS, start_ammo_rockets);
+ SetResourceAmount(actor, RES_CELLS, start_ammo_cells);
+ SetResourceAmount(actor, RES_PLASMA, start_ammo_plasma);
+ SetResourceAmount(actor, RES_FUEL, start_ammo_fuel);
STAT(WEAPONS, actor) = start_weapons;
if (this.spawnflags & 32)
IL_EACH(g_items, it.targetname == this.target,
{
if (it.classname == "weapon_devastator") {
- SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "devastator");
}
else if (it.classname == "weapon_vortex") {
- SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "vortex");
}
else if (it.classname == "weapon_electro") {
- SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "electro");
}
else if (it.classname == "weapon_hagar") {
- SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "hagar");
}
else if (it.classname == "weapon_crylink") {
- SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "crylink");
}
else if (it.classname == "weapon_mortar") {
- SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
+ SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "mortar");
}
else if (it.classname == "item_armor_mega")
- SetResourceAmount(this, RESOURCE_ARMOR, 100);
+ SetResourceAmount(this, RES_ARMOR, 100);
else if (it.classname == "item_health_mega")
- SetResourceAmount(this, RESOURCE_HEALTH, 200);
+ SetResourceAmount(this, RES_HEALTH, 200);
//remove(it); // removing ents in init functions causes havoc, workaround:
setthink(it, SUB_Remove);
it.nextthink = time;
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, GetResourceAmount(attacker, RESOURCE_HEALTH), GetResourceAmount(attacker, RESOURCE_ARMOR), (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, RES_HEALTH), GetResourceAmount(attacker, RES_ARMOR), (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping));
return true;
}
CHOICE_TYPEFRAGGED,
attacker.netname,
kill_count_to_target,
- GetResourceAmount(attacker, RESOURCE_HEALTH),
- GetResourceAmount(attacker, RESOURCE_ARMOR),
+ GetResourceAmount(attacker, RES_HEALTH),
+ GetResourceAmount(attacker, RES_ARMOR),
(IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
);
}
CHOICE_FRAGGED,
attacker.netname,
kill_count_to_target,
- GetResourceAmount(attacker, RESOURCE_HEALTH),
- GetResourceAmount(attacker, RESOURCE_ARMOR),
+ GetResourceAmount(attacker, RES_HEALTH),
+ GetResourceAmount(attacker, RES_ARMOR),
(IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
);
}
STAT(FROZEN, targ) = frozen_type;
STAT(REVIVE_PROGRESS, targ) = ((frozen_type == FROZEN_TEMP_DYING) ? 1 : 0);
- SetResourceAmount(targ, RESOURCE_HEALTH, ((frozen_type == FROZEN_TEMP_DYING) ? targ_maxhealth : 1));
+ SetResourceAmount(targ, RES_HEALTH, ((frozen_type == FROZEN_TEMP_DYING) ? targ_maxhealth : 1));
targ.revive_speed = revivespeed;
if(targ.bot_attack)
IL_REMOVE(g_bot_targets, targ);
return;
if (reset_health && STAT(FROZEN, targ) != FROZEN_TEMP_DYING)
- SetResourceAmount(targ, RESOURCE_HEALTH, ((IS_PLAYER(targ)) ? start_health : targ.max_health));
+ SetResourceAmount(targ, RES_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...
- SetResourceAmount(targ, RESOURCE_ARMOR, 0);
+ SetResourceAmount(targ, RES_ARMOR, 0);
targ.spawnshieldtime = 0;
- SetResourceAmount(targ, RESOURCE_HEALTH, 0.9); // this is < 1
+ SetResourceAmount(targ, RES_HEALTH, 0.9); // this is < 1
targ.flags -= targ.flags & FL_GODMODE;
damage = 100000;
}
if(autocvar_g_mirrordamage_virtual)
{
- vector v = healtharmor_applydamage(GetResourceAmount(attacker, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, mirrordamage);
+ vector v = healtharmor_applydamage(GetResourceAmount(attacker, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, mirrordamage);
attacker.dmg_take += v.x;
attacker.dmg_save += v.y;
attacker.dmg_inflictor = inflictor;
if(autocvar_g_friendlyfire_virtual)
{
- vector v = healtharmor_applydamage(GetResourceAmount(targ, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ vector v = healtharmor_applydamage(GetResourceAmount(targ, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
targ.dmg_take += v.x;
targ.dmg_save += v.y;
targ.dmg_inflictor = inflictor;
if(autocvar_g_frozen_revive_falldamage > 0 && deathtype == DEATH_FALL.m_id && damage >= autocvar_g_frozen_revive_falldamage)
{
Unfreeze(targ, false);
- SetResourceAmount(targ, RESOURCE_HEALTH, autocvar_g_frozen_revive_falldamage_health);
+ SetResourceAmount(targ, RES_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);
float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype, .entity weaponentity, entity directhitentity);
// Calls .event_heal on the target so that they can handle healing themselves
-// a limit of RESOURCE_LIMIT_NONE should be handled by the entity as its max health (if applicable)
+// a limit of RES_LIMIT_NONE should be handled by the entity as its max health (if applicable)
bool Heal(entity targ, entity inflictor, float amount, float limit);
.float fire_damagepersec;
void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if(GetResourceAmount(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
return; // g_balance_projectiledamage says to halt
- TakeResource(this, RESOURCE_HEALTH, damage);
+ TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= 0)
{
if(attacker != this.realowner)
{
missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION;
- SetResourceAmount(missile, RESOURCE_HEALTH, autocvar_g_balance_grapplehook_health);
+ SetResourceAmount(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
- SetResourceAmount(e, RESOURCE_HEALTH, -2342);
+ SetResourceAmount(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)
{
int totalvotes = 0;
FOREACH_CLIENT(IS_REAL_CLIENT(it), {
// hide scoreboard again
- if(GetResourceAmount(it, RESOURCE_HEALTH) != 2342)
+ if(GetResourceAmount(it, RES_HEALTH) != 2342)
{
- SetResourceAmount(it, RESOURCE_HEALTH, 2342);
+ SetResourceAmount(it, RES_HEALTH, 2342);
CS(it).impulse = 0;
msg_entity = it;
string ammoitems = "batteries";
switch (wep.ammo_type)
{
- case RESOURCE_SHELLS: ammoitems = ITEM_Shells.m_name; break;
- case RESOURCE_BULLETS: ammoitems = ITEM_Bullets.m_name; break;
- case RESOURCE_ROCKETS: ammoitems = ITEM_Rockets.m_name; break;
- case RESOURCE_CELLS: ammoitems = ITEM_Cells.m_name; break;
- case RESOURCE_PLASMA: ammoitems = ITEM_Plasma.m_name; break;
- case RESOURCE_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break;
+ case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break;
+ case RES_BULLETS: ammoitems = ITEM_Bullets.m_name; break;
+ case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name; break;
+ case RES_CELLS: ammoitems = ITEM_Cells.m_name; break;
+ case RES_PLASMA: ammoitems = ITEM_Plasma.m_name; break;
+ case RES_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break;
}
return ammoitems;
}
case "%": replacement = "%"; break;
case "\\":replacement = "\\"; break;
case "n": replacement = "\n"; break;
- case "a": replacement = ftos(floor(GetResourceAmount(this, RESOURCE_ARMOR))); break;
- case "h": replacement = ftos(floor(GetResourceAmount(this, RESOURCE_HEALTH))); break;
+ case "a": replacement = ftos(floor(GetResourceAmount(this, RES_ARMOR))); break;
+ case "h": replacement = ftos(floor(GetResourceAmount(this, RES_HEALTH))); break;
case "l": replacement = NearestLocation(this.origin); break;
case "y": replacement = NearestLocation(cursor); break;
case "d": replacement = NearestLocation(this.death_origin); break;
start_ammo_plasma = cvar("g_start_ammo_plasma");
start_ammo_fuel = cvar("g_start_ammo_fuel");
random_start_weapons_count = cvar("g_random_start_weapons_count");
- SetResourceAmount(random_start_ammo, RESOURCE_SHELLS, cvar(
+ SetResourceAmount(random_start_ammo, RES_SHELLS, cvar(
"g_random_start_shells"));
- SetResourceAmount(random_start_ammo, RESOURCE_BULLETS, cvar(
+ SetResourceAmount(random_start_ammo, RES_BULLETS, cvar(
"g_random_start_bullets"));
- SetResourceAmount(random_start_ammo, RESOURCE_ROCKETS,
+ SetResourceAmount(random_start_ammo, RES_ROCKETS,
cvar("g_random_start_rockets"));
- SetResourceAmount(random_start_ammo, RESOURCE_CELLS, cvar(
+ SetResourceAmount(random_start_ammo, RES_CELLS, cvar(
"g_random_start_cells"));
- SetResourceAmount(random_start_ammo, RESOURCE_PLASMA, cvar(
+ SetResourceAmount(random_start_ammo, RES_PLASMA, cvar(
"g_random_start_plasma"));
}
start_ammo_cells = max(0, start_ammo_cells);
start_ammo_plasma = max(0, start_ammo_plasma);
start_ammo_fuel = max(0, start_ammo_fuel);
- SetResourceAmount(random_start_ammo, RESOURCE_SHELLS, max(0,
- GetResourceAmount(random_start_ammo, RESOURCE_SHELLS)));
- SetResourceAmount(random_start_ammo, RESOURCE_BULLETS, max(0,
- GetResourceAmount(random_start_ammo, RESOURCE_BULLETS)));
- SetResourceAmount(random_start_ammo, RESOURCE_ROCKETS, max(0,
- GetResourceAmount(random_start_ammo, RESOURCE_ROCKETS)));
- SetResourceAmount(random_start_ammo, RESOURCE_CELLS, max(0,
- GetResourceAmount(random_start_ammo, RESOURCE_CELLS)));
- SetResourceAmount(random_start_ammo, RESOURCE_PLASMA, max(0,
- GetResourceAmount(random_start_ammo, RESOURCE_PLASMA)));
+ SetResourceAmount(random_start_ammo, RES_SHELLS, max(0,
+ GetResourceAmount(random_start_ammo, RES_SHELLS)));
+ SetResourceAmount(random_start_ammo, RES_BULLETS, max(0,
+ GetResourceAmount(random_start_ammo, RES_BULLETS)));
+ SetResourceAmount(random_start_ammo, RES_ROCKETS, max(0,
+ GetResourceAmount(random_start_ammo, RES_ROCKETS)));
+ SetResourceAmount(random_start_ammo, RES_CELLS, max(0,
+ GetResourceAmount(random_start_ammo, RES_CELLS)));
+ SetResourceAmount(random_start_ammo, RES_PLASMA, max(0,
+ GetResourceAmount(random_start_ammo, RES_PLASMA)));
warmup_start_ammo_shells = max(0, warmup_start_ammo_shells);
warmup_start_ammo_nails = max(0, warmup_start_ammo_nails);
/**/
MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);
-/** Called when the amount of resource of an entity changes. See RESOURCE_*
+/** Called when the amount of resource of an entity changes. See RES_*
constants for resource types. Return true to forbid the change. */
#define EV_SetResourceAmount(i, o) \
/** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(SetResourceAmount, EV_SetResourceAmount);
-/** Called after the amount of resource of an entity has changed. See RESOURCE_*
+/** Called after the amount of resource of an entity has changed. See RES_*
constants for resource types. Amount wasted is the amount of resource that is
above resource limit so it was not given. */
#define EV_ResourceAmountChanged(i, o) \
MUTATOR_HOOKABLE(ResourceAmountChanged, EV_ResourceAmountChanged);
/** Called when there was an attempt to set entity resources higher than their
-limit. See RESOURCE_* constants for resource types. Amount wasted is the amount
+limit. See RES_* constants for resource types. Amount wasted is the amount
of resource that is above resource limit so it was not given. */
#define EV_ResourceWasted(i, o) \
/** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(ResourceWasted, EV_ResourceWasted);
-/** Called when entity is being given some resource. See RESOURCE_* constants
+/** Called when entity is being given some resource. See RES_* constants
for resource types. Return true to forbid giving. */
#define EV_GiveResource(i, o) \
/** receiver */ i(entity, MUTATOR_ARGV_0_entity) \
MUTATOR_HOOKABLE(GiveResource, EV_GiveResource);
/** Called when entity is being given some resource with specified limit. See
-RESOURCE_* constants for resource types. Return true to forbid giving. */
+RES_* constants for resource types. Return true to forbid giving. */
#define EV_GiveResourceWithLimit(i, o) \
/** receiver */ i(entity, MUTATOR_ARGV_0_entity) \
/** resource type */ i(int, MUTATOR_ARGV_1_int) \
/**/
MUTATOR_HOOKABLE(GiveResourceWithLimit, EV_GiveResourceWithLimit);
-/** Called when some resource is being taken from an entity. See RESOURCE_* constants
+/** Called when some resource is being taken from an entity. See RES_* constants
for resource types. Return true to forbid giving. */
#define EV_TakeResource(i, o) \
/** receiver */ i(entity, MUTATOR_ARGV_0_entity) \
MUTATOR_HOOKABLE(TakeResource, EV_TakeResource);
/** Called when some resource is being taken from an entity, with a limit. See
-RESOURCE_* constants for resource types. Return true to forbid giving. */
+RES_* constants for resource types. Return true to forbid giving. */
#define EV_TakeResourceWithLimit(i, o) \
/** receiver */ i(entity, MUTATOR_ARGV_0_entity) \
/** resource type */ i(int, MUTATOR_ARGV_1_int) \
clone.dphitcontentsmask = this.dphitcontentsmask;
clone.death_time = this.death_time;
clone.pain_finished = this.pain_finished;
- SetResourceAmount(clone, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH));
- SetResourceAmount(clone, RESOURCE_ARMOR, GetResourceAmount(this, RESOURCE_ARMOR));
+ SetResourceAmount(clone, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
+ SetResourceAmount(clone, RES_ARMOR, GetResourceAmount(this, RES_ARMOR));
clone.armortype = this.armortype;
clone.model = this.model;
clone.modelindex = this.modelindex;
vector v;
Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
- v = healtharmor_applydamage(GetResourceAmount(this, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ v = healtharmor_applydamage(GetResourceAmount(this, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
take = v.x;
save = v.y;
if (take > 100)
Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, this, attacker);
- TakeResource(this, RESOURCE_ARMOR, save);
- TakeResource(this, RESOURCE_HEALTH, take);
+ TakeResource(this, RES_ARMOR, save);
+ TakeResource(this, RES_HEALTH, take);
// pause regeneration for 5 seconds
this.pauseregen_finished = max(this.pauseregen_finished, time + autocvar_g_balance_pause_health_regen);
this.dmg_take = this.dmg_take + take;//max(take - 10, 0);
this.dmg_inflictor = inflictor;
- if (GetResourceAmount(this, RESOURCE_HEALTH) <= -autocvar_sv_gibhealth && this.alpha >= 0)
+ if (GetResourceAmount(this, RES_HEALTH) <= -autocvar_sv_gibhealth && this.alpha >= 0)
{
// don't use any animations as a gib
this.frame = 0;
vector v;
float excess;
- dh = max(GetResourceAmount(this, RESOURCE_HEALTH), 0);
- da = max(GetResourceAmount(this, RESOURCE_ARMOR), 0);
+ dh = max(GetResourceAmount(this, RES_HEALTH), 0);
+ da = max(GetResourceAmount(this, RES_ARMOR), 0);
if(!DEATH_ISSPECIAL(deathtype))
{
else
Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
- v = healtharmor_applydamage(GetResourceAmount(this, RESOURCE_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ v = healtharmor_applydamage(GetResourceAmount(this, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
take = v.x;
save = v.y;
}
MUTATOR_CALLHOOK(PlayerDamage_SplitHealthArmor, inflictor, attacker, this, force, take, save, deathtype, damage);
- take = bound(0, M_ARGV(4, float), GetResourceAmount(this, RESOURCE_HEALTH));
- save = bound(0, M_ARGV(5, float), GetResourceAmount(this, RESOURCE_ARMOR));
+ take = bound(0, M_ARGV(4, float), GetResourceAmount(this, RES_HEALTH));
+ save = bound(0, M_ARGV(5, float), GetResourceAmount(this, RES_ARMOR));
excess = max(0, damage - take - save);
if(sound_allowed(MSG_BROADCAST, attacker))
{
if (!(this.flags & FL_GODMODE))
{
- TakeResource(this, RESOURCE_ARMOR, save);
- TakeResource(this, RESOURCE_HEALTH, take);
+ TakeResource(this, RES_ARMOR, save);
+ TakeResource(this, RES_HEALTH, take);
// pause regeneration for 5 seconds
if(take)
this.pauseregen_finished = max(this.pauseregen_finished, time + autocvar_g_balance_pause_health_regen);
animdecide_setaction(this, ANIMACTION_PAIN2, true);
}
}
- float myhp = GetResourceAmount(this, RESOURCE_HEALTH);
+ float myhp = GetResourceAmount(this, RES_HEALTH);
if(myhp > 1)
if(myhp < 25 || !(DEATH_WEAPONOF(deathtype).spawnflags & WEP_FLAG_CANCLIMB) || take > 20 || attacker != this)
if(sound_allowed(MSG_BROADCAST, attacker))
// throw off bot aim temporarily
float shake;
- if(IS_BOT_CLIENT(this) && GetResourceAmount(this, RESOURCE_HEALTH) >= 1)
+ if(IS_BOT_CLIENT(this) && GetResourceAmount(this, RES_HEALTH) >= 1)
{
shake = damage * 5 / (bound(0,skill,100) + 1);
this.v_angle_x = this.v_angle.x + (random() * 2 - 1) * shake;
valid_damage_for_weaponstats = true;
}
- dh = dh - max(GetResourceAmount(this, RESOURCE_HEALTH), 0);
- da = da - max(GetResourceAmount(this, RESOURCE_ARMOR), 0);
+ dh = dh - max(GetResourceAmount(this, RES_HEALTH), 0);
+ da = da - max(GetResourceAmount(this, RES_ARMOR), 0);
if(valid_damage_for_weaponstats)
{
WeaponStats_LogDamage(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot, dh + da);
MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
- if (GetResourceAmount(this, RESOURCE_HEALTH) < 1)
+ if (GetResourceAmount(this, RES_HEALTH) < 1)
{
float defer_ClientKill_Now_TeamChange;
defer_ClientKill_Now_TeamChange = false;
// player could have been miraculously resuscitated ;)
// e.g. players in freezetag get frozen, they don't really die
- if(GetResourceAmount(this, RESOURCE_HEALTH) >= 1 || !(IS_PLAYER(this) || this.classname == "body"))
+ if(GetResourceAmount(this, RES_HEALTH) >= 1 || !(IS_PLAYER(this) || this.classname == "body"))
return;
if (!this.respawn_time) // can be set in the mutator hook PlayerDies
bool PlayerHeal(entity targ, entity inflictor, float amount, float limit)
{
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= limit)
+ if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= limit)
return false;
- GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, limit);
+ GiveResourceWithLimit(targ, RES_HEALTH, amount, limit);
return true;
}
// 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);
- SetResourceAmount(teleporter, RESOURCE_HEALTH, autocvar_g_balance_portal_health);
- SetResourceAmount(teleporter.enemy, RESOURCE_HEALTH, autocvar_g_balance_portal_health);
+ SetResourceAmount(teleporter, RES_HEALTH, autocvar_g_balance_portal_health);
+ SetResourceAmount(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
return 1;
}
if(attacker != this.aiment)
if(IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(this.aiment))
return;
- TakeResource(this, RESOURCE_HEALTH, damage);
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResourceAmount(this, RES_HEALTH) < 0)
Portal_Remove(this, 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);
- SetResourceAmount(portal, RESOURCE_HEALTH, autocvar_g_balance_portal_health);
+ SetResourceAmount(portal, RES_HEALTH, autocvar_g_balance_portal_health);
setmodel(portal, MDL_PORTAL);
portal.savemodelindex = portal.modelindex;
setcefc(portal, Portal_Customize);
#include "autocvars.qh"
#include "miscfunctions.qh"
-float GetResourceLimit(entity e, int resource_type)
+float GetResourceLimit(entity e, int res_type)
{
if(!IS_PLAYER(e))
- return RESOURCE_LIMIT_NONE; // no limits on non-players
+ return RES_LIMIT_NONE; // no limits on non-players
float limit;
- switch (resource_type)
+ switch (res_type)
{
- case RESOURCE_HEALTH:
+ case RES_HEALTH:
{
limit = autocvar_g_balance_health_limit;
break;
}
- case RESOURCE_ARMOR:
+ case RES_ARMOR:
{
limit = autocvar_g_balance_armor_limit;
break;
}
- case RESOURCE_SHELLS:
+ case RES_SHELLS:
{
limit = g_pickup_shells_max;
break;
}
- case RESOURCE_BULLETS:
+ case RES_BULLETS:
{
limit = g_pickup_nails_max;
break;
}
- case RESOURCE_ROCKETS:
+ case RES_ROCKETS:
{
limit = g_pickup_rockets_max;
break;
}
- case RESOURCE_CELLS:
+ case RES_CELLS:
{
limit = g_pickup_cells_max;
break;
}
- case RESOURCE_PLASMA:
+ case RES_PLASMA:
{
limit = g_pickup_plasma_max;
break;
}
- case RESOURCE_FUEL:
+ case RES_FUEL:
{
limit = autocvar_g_balance_fuel_limit;
break;
return 0;
}
}
- MUTATOR_CALLHOOK(GetResourceLimit, e, resource_type, limit);
+ MUTATOR_CALLHOOK(GetResourceLimit, e, res_type, limit);
limit = M_ARGV(2, float);
- if (limit > RESOURCE_AMOUNT_HARD_LIMIT)
+ if (limit > RES_AMOUNT_HARD_LIMIT)
{
- limit = RESOURCE_AMOUNT_HARD_LIMIT;
+ limit = RES_AMOUNT_HARD_LIMIT;
}
return limit;
}
-float GetResourceAmount(entity e, int resource_type)
+float GetResourceAmount(entity e, int res_type)
{
- .float resource_field = GetResourceField(resource_type);
- return e.(resource_field);
+ return e.(GetResourceField(res_type));
}
-void SetResourceAmount(entity e, int resource_type, float amount)
+void SetResourceAmount(entity e, int res_type, float amount)
{
- bool forbid = MUTATOR_CALLHOOK(SetResourceAmount, e, resource_type, amount);
+ bool forbid = MUTATOR_CALLHOOK(SetResourceAmount, e, res_type, amount);
if (forbid)
{
return;
}
- resource_type = M_ARGV(1, int);
+ res_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
- float max_amount = GetResourceLimit(e, resource_type); // TODO: should allow overriding these limits if cheats are enabled!
+ float max_amount = GetResourceLimit(e, res_type); // TODO: should allow overriding these limits if cheats are enabled!
float amount_wasted = 0;
- if (amount > max_amount && max_amount != RESOURCE_LIMIT_NONE)
+ if (amount > max_amount && max_amount != RES_LIMIT_NONE)
{
amount_wasted = amount - max_amount;
amount = max_amount;
}
- .float resource_field = GetResourceField(resource_type);
- if (e.(resource_field) != amount)
+ .float res_field = GetResourceField(res_type);
+ if (e.(res_field) != amount)
{
- e.(resource_field) = amount;
- MUTATOR_CALLHOOK(ResourceAmountChanged, e, resource_type, amount);
+ e.(res_field) = amount;
+ MUTATOR_CALLHOOK(ResourceAmountChanged, e, res_type, amount);
}
if (amount_wasted == 0)
{
return;
}
- MUTATOR_CALLHOOK(ResourceWasted, e, resource_type, amount_wasted);
+ MUTATOR_CALLHOOK(ResourceWasted, e, res_type, amount_wasted);
}
-void GiveResource(entity receiver, int resource_type, float amount)
+void GiveResource(entity receiver, int res_type, float amount)
{
if (amount <= 0)
{
return;
}
- bool forbid = MUTATOR_CALLHOOK(GiveResource, receiver, resource_type,
- amount);
+ bool forbid = MUTATOR_CALLHOOK(GiveResource, receiver, res_type, amount);
if (forbid)
{
return;
}
- resource_type = M_ARGV(1, int);
+ res_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
if (amount <= 0)
{
return;
}
- SetResourceAmount(receiver, resource_type,
- GetResourceAmount(receiver, resource_type) + amount);
- switch (resource_type)
+ SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) + amount);
+ switch (res_type)
{
- case RESOURCE_HEALTH:
+ case RES_HEALTH:
{
receiver.pauserothealth_finished =
max(receiver.pauserothealth_finished, time +
autocvar_g_balance_pause_health_rot);
return;
}
- case RESOURCE_ARMOR:
+ case RES_ARMOR:
{
receiver.pauserotarmor_finished =
max(receiver.pauserotarmor_finished, time +
autocvar_g_balance_pause_armor_rot);
return;
}
- case RESOURCE_FUEL:
+ case RES_FUEL:
{
receiver.pauserotfuel_finished = max(receiver.pauserotfuel_finished,
time + autocvar_g_balance_pause_fuel_rot);
}
}
-void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit)
+void GiveResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
if (amount <= 0)
{
return;
}
- bool forbid = MUTATOR_CALLHOOK(GiveResourceWithLimit, receiver,
- resource_type, amount, limit);
+ bool forbid = MUTATOR_CALLHOOK(GiveResourceWithLimit, receiver, res_type, amount, limit);
if (forbid)
{
return;
}
- resource_type = M_ARGV(1, int);
+ res_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
limit = M_ARGV(3, float);
if (amount <= 0)
{
return;
}
- float current_amount = GetResourceAmount(receiver, resource_type);
- if (current_amount + amount > limit && limit != RESOURCE_LIMIT_NONE)
+ float current_amount = GetResourceAmount(receiver, res_type);
+ if (current_amount + amount > limit && limit != RES_LIMIT_NONE)
{
amount = limit - current_amount;
}
- GiveResource(receiver, resource_type, amount);
+ GiveResource(receiver, res_type, amount);
}
-void TakeResource(entity receiver, int resource_type, float amount)
+void TakeResource(entity receiver, int res_type, float amount)
{
if (amount <= 0)
{
return;
}
- bool forbid = MUTATOR_CALLHOOK(TakeResource, receiver, resource_type,
- amount);
+ bool forbid = MUTATOR_CALLHOOK(TakeResource, receiver, res_type, amount);
if (forbid)
{
return;
}
- resource_type = M_ARGV(1, int);
+ res_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
if (amount <= 0)
{
return;
}
- SetResourceAmount(receiver, resource_type,
- GetResourceAmount(receiver, resource_type) - amount);
+ SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) - amount);
}
-void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit)
+void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
if (amount <= 0)
{
return;
}
- bool forbid = MUTATOR_CALLHOOK(TakeResourceWithLimit, receiver,
- resource_type, amount, limit);
+ bool forbid = MUTATOR_CALLHOOK(TakeResourceWithLimit, receiver, res_type, amount, limit);
if (forbid)
{
return;
}
- resource_type = M_ARGV(1, int);
+ res_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
limit = M_ARGV(3, float);
if (amount <= 0)
{
return;
}
- float current_amount = GetResourceAmount(receiver, resource_type);
+ float current_amount = GetResourceAmount(receiver, res_type);
if (current_amount - amount < -limit)
{
amount = -limit + current_amount;
}
- TakeResource(receiver, resource_type, amount);
+ TakeResource(receiver, res_type, amount);
}
-void GiveOrTakeResource(entity receiver, int resource_type, float amount)
+void GiveOrTakeResource(entity receiver, int res_type, float amount)
{
if(amount < 0)
{
- TakeResource(receiver, resource_type, amount * -1);
+ TakeResource(receiver, res_type, amount * -1);
}
else
{
- GiveResource(receiver, resource_type, amount);
+ GiveResource(receiver, res_type, amount);
}
}
-void GiveOrTakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit)
+void GiveOrTakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
if(amount < 0)
{
- TakeResourceWithLimit(receiver, resource_type, amount * -1, limit);
+ TakeResourceWithLimit(receiver, res_type, amount * -1, limit);
}
else
{
- GiveResourceWithLimit(receiver, resource_type, amount, limit);
+ GiveResourceWithLimit(receiver, res_type, amount, limit);
}
}
-int GetResourceType(.float resource_field)
+int GetResourceType(.float res_field)
{
- switch (resource_field)
+ switch (res_field)
{
- case health: { return RESOURCE_HEALTH; }
- case armorvalue: { return RESOURCE_ARMOR; }
- case ammo_shells: { return RESOURCE_SHELLS; }
- case ammo_nails: { return RESOURCE_BULLETS; }
- case ammo_rockets: { return RESOURCE_ROCKETS; }
- case ammo_cells: { return RESOURCE_CELLS; }
- case ammo_plasma: { return RESOURCE_PLASMA; }
- case ammo_fuel: { return RESOURCE_FUEL; }
+ case health: { return RES_HEALTH; }
+ case armorvalue: { return RES_ARMOR; }
+ case ammo_shells: { return RES_SHELLS; }
+ case ammo_nails: { return RES_BULLETS; }
+ case ammo_rockets: { return RES_ROCKETS; }
+ case ammo_cells: { return RES_CELLS; }
+ case ammo_plasma: { return RES_PLASMA; }
+ case ammo_fuel: { return RES_FUEL; }
}
error("GetResourceType: Invalid field.");
return 0;
}
-.float GetResourceField(int resource_type)
+.float GetResourceField(int res_type)
{
- switch (resource_type)
+ switch (res_type)
{
- case RESOURCE_HEALTH: { return health; }
- case RESOURCE_ARMOR: { return armorvalue; }
- case RESOURCE_SHELLS: { return ammo_shells; }
- case RESOURCE_BULLETS: { return ammo_nails; }
- case RESOURCE_ROCKETS: { return ammo_rockets; }
- case RESOURCE_CELLS: { return ammo_cells; }
- case RESOURCE_PLASMA: { return ammo_plasma; }
- case RESOURCE_FUEL: { return ammo_fuel; }
+ case RES_HEALTH: { return health; }
+ case RES_ARMOR: { return armorvalue; }
+ case RES_SHELLS: { return ammo_shells; }
+ case RES_BULLETS: { return ammo_nails; }
+ case RES_ROCKETS: { return ammo_rockets; }
+ case RES_CELLS: { return ammo_cells; }
+ case RES_PLASMA: { return ammo_plasma; }
+ case RES_FUEL: { return ammo_fuel; }
}
error("GetResourceField: Invalid resource type.");
return health;
/// \brief Returns the maximum amount of the given resource.
/// \param[in] e Entity to check.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \return Maximum amount of the given resource.
-float GetResourceLimit(entity e, int resource_type);
+float GetResourceLimit(entity e, int res_type);
/// \brief Returns the current amount of resource the given entity has.
/// \param[in] e Entity to check.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \return Current amount of resource the given entity has.
-float GetResourceAmount(entity e, int resource_type);
+float GetResourceAmount(entity e, int res_type);
/// \brief Sets the current amount of resource the given entity will have.
/// \param[in,out] e Entity to adjust.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to set.
/// \return No return.
-void SetResourceAmount(entity e, int resource_type, float amount);
+void SetResourceAmount(entity e, int res_type, float amount);
/// \brief Gives an entity some resource.
/// \param[in,out] receiver Entity to give resource to.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to give.
/// \return No return.
-void GiveResource(entity receiver, int resource_type, float amount);
+void GiveResource(entity receiver, int res_type, float amount);
/// \brief Gives an entity some resource but not more than a limit.
/// \param[in,out] receiver Entity to give resource to.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to give.
/// \param[in] limit Limit of resources to give.
/// \return No return.
-void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit);
+void GiveResourceWithLimit(entity receiver, int res_type, float amount, float limit);
/// \brief Takes an entity some resource.
/// \param[in,out] receiver Entity to take resource from.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to take.
/// \return No return.
-void TakeResource(entity receiver, int resource_type, float amount);
+void TakeResource(entity receiver, int res_type, float amount);
/// \brief Takes an entity some resource but not less than a limit.
/// \param[in,out] receiver Entity to take resource from.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to take.
/// \param[in] limit Limit of resources to take.
/// \return No return.
-void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit);
+void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
/// \brief Gives to or takes from an entity resource.
/// \param[in,out] receiver Entity to give or take resource.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to give or take.
/// \return No return.
-void GiveOrTakeResource(entity receiver, int resource_type, float amount);
+void GiveOrTakeResource(entity receiver, int res_type, float amount);
/// \brief Gives to or takes from an entity resource but not more/less than a limit.
/// \param[in,out] receiver Entity to give or take resource.
-/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \param[in] res_type Type of the resource (a RES_* constant).
/// \param[in] amount Amount of resource to give or take.
/// \param[in] limit Limit of resources to give or take.
/// \return No return.
-void GiveOrTakeResourceWithLimit(entity receiver, int resource_type, float amount,
- float limit);
+void GiveOrTakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
// ===================== Legacy and/or internal API ===========================
/// \brief Converts an entity field to resource type.
-/// \param[in] resource_field Entity field to convert.
-/// \return Resource type (a RESOURCE_* constant).
-int GetResourceType(.float resource_field);
+/// \param[in] res_field Entity field to convert.
+/// \return Resource type (a RES_* constant).
+int GetResourceType(.float res_field);
-/// \brief Converts resource type (a RESOURCE_* constant) to entity field.
-/// \param[in] resource_type Type of the resource.
+/// \brief Converts resource type (a RES_* constant) to entity field.
+/// \param[in] res_type Type of the resource.
/// \return Entity field for that resource.
-.float GetResourceField(int resource_type);
+.float GetResourceField(int res_type);
void test_weapons_hurt(entity this)
{
- EXPECT_NE(100, GetResourceAmount(this, RESOURCE_HEALTH));
+ EXPECT_NE(100, GetResourceAmount(this, RES_HEALTH));
delete(this.enemy);
delete(this);
}
this.superweapons_finished = autocvar_g_balance_superweapons_time;
// if we don't already have ammo, give us some ammo
- if ((wpn.ammo_type != RESOURCE_NONE) && !GetResourceAmount(this, wpn.ammo_type))
+ if ((wpn.ammo_type != RES_NONE) && !GetResourceAmount(this, wpn.ammo_type))
{
switch (wpn.ammo_type)
{
- case RESOURCE_SHELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break;
- case RESOURCE_BULLETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break;
- case RESOURCE_ROCKETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break;
- case RESOURCE_CELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break;
- case RESOURCE_PLASMA: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break;
- case RESOURCE_FUEL: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break;
+ case RES_SHELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break;
+ case RES_BULLETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break;
+ case RES_ROCKETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break;
+ case RES_CELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break;
+ case RES_PLASMA: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break;
+ case RES_FUEL: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break;
}
}
wep.pickup_anyway = true; // these are ALWAYS pickable
//wa = W_AmmoItemCode(wpn);
- if(ammotype == RESOURCE_NONE)
+ if(ammotype == RES_NONE)
{
return 0;
}
entity this = actor.(weaponentity);
if (frametime) this.weapon_frametime = frametime;
- if (!this || GetResourceAmount(actor, RESOURCE_HEALTH) < 1) return; // Dead player can't use weapons and injure impulse commands
+ if (!this || GetResourceAmount(actor, RES_HEALTH) < 1) return; // Dead player can't use weapons and injure impulse commands
int button_atck = PHYS_INPUT_BUTTON_ATCK(actor);
int button_atck2 = PHYS_INPUT_BUTTON_ATCK2(actor);
w_ent.clip_load -= ammo_use;
w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load;
}
- else if (wep.ammo_type != RESOURCE_NONE)
+ else if (wep.ammo_type != RES_NONE)
{
float ammo = GetResourceAmount(actor, wep.ammo_type);
if (ammo < ammo_use)
w_ent.clip_load = w_ent.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
// if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load
- if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_type == RESOURCE_NONE)
+ if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_type == RES_NONE)
{
w_ent.clip_load = w_ent.reload_ammo_amount;
}
if (this.clip_load >= this.reload_ammo_amount) return;
// no ammo, so nothing to load
- if (e.ammo_type != RESOURCE_NONE)
+ if (e.ammo_type != RES_NONE)
{
if (!GetResourceAmount(actor, e.ammo_type) && this.reload_ammo_min)
{