IL_EACH(g_radaricons, it.teamradar_icon, {
if ( hud_panel_radar_mouse )
- if ( GetResourceAmount(it, RES_HEALTH) >= 0 )
+ if ( GetResource(it, RES_HEALTH) >= 0 )
if ( it.team == myteam + 1 || ISGAMETYPE(RACE) || !teamplay )
{
vector coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(it.origin));
vector Rotate(vector v, float a);
-#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResourceAmount((s), RES_HEALTH) <= 0))
+#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((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 res_type)
+float GetResource(entity e, int res_type)
{
return e.(GetResourceField(res_type));
}
-void SetResourceAmount(entity e, int res_type, float amount)
+void SetResource(entity e, int res_type, float amount)
{
e.(GetResourceField(res_type)) = amount;
}
{
return;
}
- SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) - amount);
+ SetResource(receiver, res_type, GetResource(receiver, res_type) - amount);
}
void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
return;
}
- float current_amount = GetResourceAmount(receiver, res_type);
+ float current_amount = GetResource(receiver, res_type);
if (current_amount - amount < limit)
{
amount = limit + current_amount;
/// \param[in] e Entity to check.
/// \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 res_type);
+float GetResource(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] 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 res_type, float amount);
+void SetResource(entity e, int res_type, float amount);
/// \brief Takes an entity some resource.
/// \param[in,out] receiver Entity to take resource from.
this.healthvalue / autocvar_hud_panel_healtharmor_maxhealth, false, 1, '1 0 0', a,
DRAWFLAG_NORMAL);
}
- if (GetResourceAmount(this, RES_ARMOR) > 0)
+ if (GetResource(this, RES_ARMOR) > 0)
{
HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize.x, sz, "nametag_statusbar",
- GetResourceAmount(this, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor, false, 0, '0 1 0', a,
+ GetResource(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, RES_ARMOR, GetResourceAmount(entcs, RES_ARMOR));
+ SetResource(it, RES_ARMOR, GetResource(entcs, RES_ARMOR));
it.sameteam = true;
}
else
{
it.healthvalue = 0;
- SetResourceAmount(it, RES_ARMOR, 0);
+ SetResource(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, RES_HEALTH, align);
+ SetResource(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, RES_HEALTH);
+ float align = GetResource(this, RES_HEALTH);
string msg;
vector msg_pos;
#ifdef SVQC
#define ENTCS_PROP_RESOURCE(id, ispublic, checkprop, setprop, decfactor, svsend, clreceive) \
bool id##_check(entity ent, entity player) { \
- return (floor(GetResourceAmount(ent, checkprop) / decfactor) != floor(GetResourceAmount(player, checkprop) / decfactor)); \
+ return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \
} \
- void id##_set(entity ent, entity player) { SetResourceAmount(ent, checkprop, GetResourceAmount(player, checkprop)); } \
+ void id##_set(entity ent, entity player) { SetResource(ent, checkprop, GetResource(player, checkprop)); } \
void id##_send(int chan, entity ent) { LAMBDA(svsend); } \
REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \
this.m_public = ispublic; \
// FIXME: use a better scale?
#define DEC_FACTOR 10
ENTCS_PROP_RESOURCE(HEALTH, false, RES_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
- { WriteByte(chan, bound(0, GetResourceAmount(ent, RES_HEALTH) / DEC_FACTOR, 255)); },
+ { WriteByte(chan, bound(0, GetResource(ent, RES_HEALTH) / DEC_FACTOR, 255)); },
{ ent.healthvalue = 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); })
+ { WriteByte(chan, bound(0, GetResource(ent, RES_ARMOR) / DEC_FACTOR, 255)); },
+ { SetResource(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, RES_HEALTH, 100);
+ SetResource(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, RES_HEALTH);
+ float hlth = GetResource(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, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
+ SetResource(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
}
// decrease the health of targeted objectives
else
return; // already activated! cannot activate again!
- float hlth = GetResourceAmount(this.enemy, RES_HEALTH);
+ float hlth = GetResource(this.enemy, RES_HEALTH);
if (hlth < ASSAULT_VALUE_INACTIVE)
{
if (hlth - this.dmg > 0.5)
{
GameRules_scoring_add_team(actor, SCORE, hlth);
GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
- SetResourceAmount(this.enemy, RES_HEALTH, -1);
+ SetResource(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, RES_HEALTH) >= ASSAULT_VALUE_INACTIVE)
+ if(GetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(spr, GetResource(it, RES_HEALTH));
it.sprite = spr;
}
else
void assault_wall_think(entity this)
{
- if(GetResourceAmount(this.enemy, RES_HEALTH) < 0)
+ if(GetResource(this.enemy, RES_HEALTH) < 0)
{
this.model = "";
this.solid = SOLID_NOT;
this.dmg = 101;
this.use = assault_objective_decrease_use;
- SetResourceAmount(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
+ SetResource(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE);
this.max_health = ASSAULT_VALUE_INACTIVE;
this.enemy = NULL;
bool destructible_heal(entity targ, entity inflictor, float amount, float limit)
{
float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
- float hlth = GetResourceAmount(targ, RES_HEALTH);
+ float hlth = GetResource(targ, RES_HEALTH);
if (hlth <= 0 || hlth >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.sprite)
{
- WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RES_HEALTH));
+ WaypointSprite_UpdateHealth(targ.sprite, GetResource(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, RES_HEALTH);
+ float hlth = GetResource(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, RES_HEALTH));
- float damage_save = bound(0, M_ARGV(5, float), GetResourceAmount(frag_target, RES_ARMOR));
+ float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResource(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, RES_HEALTH), GetResourceAmount(player, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResource(player, RES_HEALTH), GetResource(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, RES_HEALTH, flag.max_flag_health);
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(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, RES_HEALTH, flag.max_flag_health); break; // reset health/return timelimit
+ case PICKUP_DROPPED: SetResource(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, RES_HEALTH)); }
+ if(flag.wps_flagdropped) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(flag, RES_HEALTH)); }
- if((GetResourceAmount(flag, RES_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time))
+ if((GetResource(flag, RES_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time))
{
switch(returntype)
{
this.ctf_flagdamaged_byworld = true;
else
{
- SetResourceAmount(this, RES_HEALTH, 0);
+ SetResource(this, RES_HEALTH, 0);
ctf_CheckFlagReturn(this, RETURN_NEEDKILL);
}
return;
{
if((vdist(this.origin - this.ctf_spawnorigin, <=, autocvar_g_ctf_flag_return_dropped)) || (autocvar_g_ctf_flag_return_dropped == -1))
{
- SetResourceAmount(this, RES_HEALTH, 0);
+ SetResource(this, RES_HEALTH, 0);
ctf_CheckFlagReturn(this, RETURN_DROPPED);
return;
}
{
if(this.speedrunning && ctf_captimerecord && (time >= this.ctf_pickuptime + ctf_captimerecord))
{
- SetResourceAmount(this, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH, flag.max_flag_health);
+ SetResource(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, RES_HEALTH, flag.max_flag_health);
+ SetResource(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, RES_HEALTH) + GetResourceAmount(head, RES_ARMOR)) / 100, 2) - 1;
+ float f = bound(0, (GetResource(head, RES_HEALTH) + GetResource(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, RES_HEALTH), GetResourceAmount(player, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(player.wps_flagcarrier, healtharmor_maxdamage(GetResource(player, RES_HEALTH), GetResource(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, RES_HEALTH), GetResourceAmount(frag_target, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x
+ if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > healtharmor_maxdamage(GetResource(frag_target, RES_HEALTH), GetResource(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, RES_HEALTH) < 1)
+ if(GetResource(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, RES_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
+ if (GetResource(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, RES_HEALTH) >= 1)
+ if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1)
{
if (!last_pl)
last_pl = it;
navigation_routerating(this, it, ratingscale, 2000);
}
else if (best_dist2
- && GetResourceAmount(it, RES_HEALTH) < GetResourceAmount(this, RES_HEALTH) + 30
+ && GetResource(it, RES_HEALTH) < GetResource(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, RES_HEALTH, 0); // neccessary to correctly count alive players
+ SetResource(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, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+ SetResource(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, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
+ SetResource(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, RES_HEALTH), GetResourceAmount(frag_attacker, RES_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
+ GetResource(frag_attacker, RES_HEALTH), GetResource(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, RES_HEALTH) > 0,
+ IL_EACH(g_monsters, GetResource(it, RES_HEALTH) > 0,
{
if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
++supermonster_count;
}
if (!IS_PLAYER(toucher))
return;
- if(GetResourceAmount(toucher, RES_HEALTH) < 1)
+ if(GetResource(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, RES_HEALTH) < 1)
+ if(GetResource(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, RES_HEALTH) / this.max_health;
+ if(!this.iscaptured) this.alpha = GetResource(this, RES_HEALTH) / this.max_health;
if(this.iscaptured)
{
this.origin = ReadVector();
setorigin(this, this.origin);
- SetResourceAmount(this, RES_HEALTH, ReadByte());
+ SetResource(this, RES_HEALTH, ReadByte());
this.max_health = ReadByte();
this.count = ReadByte();
this.team = ReadByte();
this.iscaptured = ReadByte();
if(!this.count)
- this.count = (GetResourceAmount(this, RES_HEALTH) - this.max_health) * frametime;
+ this.count = (GetResource(this, RES_HEALTH) - this.max_health) * frametime;
cpicon_changeteam(this);
cpicon_construct(this, isnew);
_tmp = ReadByte();
- if(_tmp != GetResourceAmount(this, RES_HEALTH))
+ if(_tmp != GetResource(this, RES_HEALTH))
cpicon_damage(this, _tmp);
- SetResourceAmount(this, RES_HEALTH, _tmp);
+ SetResource(this, RES_HEALTH, _tmp);
}
}
if(time < this.move_time)
return;
- if(GetResourceAmount(this, RES_HEALTH) > 0)
+ if(GetResource(this, RES_HEALTH) > 0)
{
// damaged fx (less probable the more damaged is the generator)
- if(random() < 0.9 - GetResourceAmount(this, RES_HEALTH) / this.max_health)
+ if(random() < 0.9 - GetResource(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, RES_HEALTH, ReadByte());
+ SetResource(this, RES_HEALTH, ReadByte());
this.max_health = ReadByte();
this.count = ReadByte();
this.team = ReadByte();
_tmp = ReadByte();
- if(_tmp != GetResourceAmount(this, RES_HEALTH))
+ if(_tmp != GetResource(this, RES_HEALTH))
generator_damage(this, _tmp);
- SetResourceAmount(this, RES_HEALTH, _tmp);
+ SetResource(this, RES_HEALTH, _tmp);
}
}
entity gen = NULL;
if(ons_roundlost)
{
- IL_EACH(g_onsgenerators, GetResourceAmount(it, RES_HEALTH) <= 0,
+ IL_EACH(g_onsgenerators, GetResource(it, RES_HEALTH) <= 0,
{
gen = it;
break;
{
WriteVector(MSG_ENTITY, this.origin);
- WriteByte(MSG_ENTITY, GetResourceAmount(this, RES_HEALTH));
+ WriteByte(MSG_ENTITY, GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResource(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
{
WriteVector(MSG_ENTITY, this.origin);
- WriteByte(MSG_ENTITY, GetResourceAmount(this, RES_HEALTH));
+ WriteByte(MSG_ENTITY, GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResource(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
TakeResource(this, RES_HEALTH, damage);
if(this.owner.iscaptured)
- WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResource(this, RES_HEALTH));
else
- WaypointSprite_UpdateBuildFinished(this.owner.sprite, time + (this.max_health - GetResourceAmount(this, RES_HEALTH)) / (this.count / ONS_CP_THINKRATE));
+ WaypointSprite_UpdateBuildFinished(this.owner.sprite, time + (this.max_health - GetResource(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, RES_HEALTH) < 0)
+ if (GetResource(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, RES_HEALTH);
+ float hlth = GetResource(targ, RES_HEALTH);
float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
if (hlth <= 0 || hlth >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
- hlth = GetResourceAmount(targ, RES_HEALTH);
+ hlth = GetResource(targ, RES_HEALTH);
if(targ.owner.iscaptured)
WaypointSprite_UpdateHealth(targ.owner.sprite, hlth);
else
GiveResourceWithLimit(this, RES_HEALTH, (_friendly_count - _enemy_count), this.max_health);
this.SendFlags |= CPSF_STATUS;
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH) < this.max_health)
+ if(GetResource(this, RES_HEALTH) < this.max_health)
{
GiveResourceWithLimit(this, RES_HEALTH, this.count, this.max_health);
- WaypointSprite_UpdateHealth(this.owner.sprite, GetResourceAmount(this, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResource(this, RES_HEALTH));
}
}
}
// damaged fx
- if(random() < 0.6 - GetResourceAmount(this, RES_HEALTH) / this.max_health)
+ if(random() < 0.6 - GetResource(this, RES_HEALTH) / this.max_health)
{
Send_Effect(EFFECT_ELECTRIC_SPARKS, this.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
this.SendFlags |= CPSF_STATUS;
- if (GetResourceAmount(this, RES_HEALTH) >= this.max_health)
+ if (GetResource(this, RES_HEALTH) >= this.max_health)
{
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.owner.sprite, GetResource(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, RES_HEALTH) / this.max_health)
+ if(random() < 0.9 - GetResource(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, RES_HEALTH, autocvar_g_onslaught_cp_buildhealth);
+ SetResource(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, RES_HEALTH)) * ONS_CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
+ e.count = (e.max_health - GetResource(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, RES_HEALTH)) / (e.count / ONS_CP_THINKRATE));
+ WaypointSprite_UpdateBuildFinished(cp.sprite, time + (e.max_health - GetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(e.sprite, GetResource(e.goalentity, RES_HEALTH));
}
}
if(e.lastshielded)
}
}
TakeResource(this, RES_HEALTH, damage);
- float hlth = GetResourceAmount(this, RES_HEALTH);
+ float hlth = GetResource(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 != RES_LIMIT_NONE) ? limit : targ.max_health);
- float hlth = GetResourceAmount(targ, RES_HEALTH);
+ float hlth = GetResource(targ, RES_HEALTH);
if (hlth <= 0 || hlth >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
- hlth = GetResourceAmount(targ, RES_HEALTH);
+ hlth = GetResource(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, RES_HEALTH, autocvar_g_onslaught_gen_health);
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(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, RES_HEALTH, autocvar_g_onslaught_gen_health);
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(gen.sprite, GetResource(gen, RES_HEALTH));
InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
}
for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext)
{
++total_generators;
- if (GetResourceAmount(e, RES_HEALTH) < 1)
+ if (GetResource(e, RES_HEALTH) < 1)
{
continue;
}
{
entity source_point = ons_Nearest_ControlPoint(player, player.origin, autocvar_g_onslaught_teleport_radius);
- if ( !source_point && GetResourceAmount(player, RES_HEALTH) > 0 )
+ if ( !source_point && GetResource(player, RES_HEALTH) > 0 )
{
sprint(player, "\nYou need to be next to a control point\n");
return true;
return true;
}
- if ( GetResourceAmount(player, RES_HEALTH) <= 0 )
+ if ( GetResource(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, RES_HEALTH) >= wp_owner.goalentity.max_health) { wp_flag |= 2; }
+ if(SAME_TEAM(e, wp_owner) && GetResource(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, RES_HEALTH) >= wp_owner.max_health) { wp_flag |= 2; }
- if(GetResourceAmount(wp_owner, RES_HEALTH) <= 0) { wp_flag |= 2; }
+ if(wp_owner.isshielded && GetResource(wp_owner, RES_HEALTH) >= wp_owner.max_health) { wp_flag |= 2; }
+ if(GetResource(wp_owner, RES_HEALTH) <= 0) { wp_flag |= 2; }
}
}
PROPERTY(int, g_pickup_nails);
void ammo_bullets_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RES_BULLETS))
- SetResourceAmount(item, RES_BULLETS, g_pickup_nails);
+ if(!GetResource(item, RES_BULLETS))
+ SetResource(item, RES_BULLETS, g_pickup_nails);
}
#endif
PROPERTY(int, g_pickup_cells);
void ammo_cells_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RES_CELLS))
- SetResourceAmount(item, RES_CELLS, g_pickup_cells);
+ if(!GetResource(item, RES_CELLS))
+ SetResource(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, RES_PLASMA))
- SetResourceAmount(item, RES_PLASMA, g_pickup_plasma);
+ if(!GetResource(item, RES_PLASMA))
+ SetResource(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, RES_ROCKETS))
- SetResourceAmount(item, RES_ROCKETS, g_pickup_rockets);
+ if(!GetResource(item, RES_ROCKETS))
+ SetResource(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, RES_SHELLS))
- SetResourceAmount(item, RES_SHELLS, g_pickup_shells);
+ if(!GetResource(item, RES_SHELLS))
+ SetResource(item, RES_SHELLS, g_pickup_shells);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armorsmall_max;
- if(!GetResourceAmount(item, RES_ARMOR))
- SetResourceAmount(item, RES_ARMOR, g_pickup_armorsmall);
+ if(!GetResource(item, RES_ARMOR))
+ SetResource(item, RES_ARMOR, g_pickup_armorsmall);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armormedium_max;
- if(!GetResourceAmount(item, RES_ARMOR))
- SetResourceAmount(item, RES_ARMOR, g_pickup_armormedium);
+ if(!GetResource(item, RES_ARMOR))
+ SetResource(item, RES_ARMOR, g_pickup_armormedium);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armorbig_max;
- if(!GetResourceAmount(item, RES_ARMOR))
- SetResourceAmount(item, RES_ARMOR, g_pickup_armorbig);
+ if(!GetResource(item, RES_ARMOR))
+ SetResource(item, RES_ARMOR, g_pickup_armorbig);
}
#endif
{
if(!item.max_armorvalue)
item.max_armorvalue = g_pickup_armormega_max;
- if(!GetResourceAmount(item, RES_ARMOR))
- SetResourceAmount(item, RES_ARMOR, g_pickup_armormega);
+ if(!GetResource(item, RES_ARMOR))
+ SetResource(item, RES_ARMOR, g_pickup_armormega);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthsmall_max;
- if(!GetResourceAmount(item, RES_HEALTH))
- SetResourceAmount(item, RES_HEALTH, g_pickup_healthsmall);
+ if(!GetResource(item, RES_HEALTH))
+ SetResource(item, RES_HEALTH, g_pickup_healthsmall);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthmedium_max;
- if(!GetResourceAmount(item, RES_HEALTH))
- SetResourceAmount(item, RES_HEALTH, g_pickup_healthmedium);
+ if(!GetResource(item, RES_HEALTH))
+ SetResource(item, RES_HEALTH, g_pickup_healthmedium);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthbig_max;
- if(!GetResourceAmount(item, RES_HEALTH))
- SetResourceAmount(item, RES_HEALTH, g_pickup_healthbig);
+ if(!GetResource(item, RES_HEALTH))
+ SetResource(item, RES_HEALTH, g_pickup_healthbig);
}
#endif
{
if(!item.max_health)
item.max_health = g_pickup_healthmega_max;
- if(!GetResourceAmount(item, RES_HEALTH))
- SetResourceAmount(item, RES_HEALTH, g_pickup_healthmega);
+ if(!GetResource(item, RES_HEALTH))
+ SetResource(item, RES_HEALTH, g_pickup_healthmega);
}
#endif
PROPERTY(int, g_pickup_fuel_jetpack);
void powerup_jetpack_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RES_FUEL))
- SetResourceAmount(item, RES_FUEL, g_pickup_fuel_jetpack);
+ if(!GetResource(item, RES_FUEL))
+ SetResource(item, RES_FUEL, g_pickup_fuel_jetpack);
}
#endif
PROPERTY(int, g_pickup_fuel);
void ammo_fuel_init(Pickup this, entity item)
{
- if(!GetResourceAmount(item, RES_FUEL))
- SetResourceAmount(item, RES_FUEL, g_pickup_fuel);
+ if(!GetResource(item, RES_FUEL))
+ SetResource(item, RES_FUEL, g_pickup_fuel);
}
#endif
REGISTER_ITEM(JetpackFuel, Ammo) {
float h;
if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE))
return;
- h = GetResourceAmount(this, RES_HEALTH) / this.max_health;
+ h = GetResource(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, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH, this.max_health);
+ SetResource(this, RES_HEALTH, this.max_health);
if(this.sprite)
{
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
}
if(!(this.spawnflags & BREAKABLE_NODAMAGE))
{
if(this.sprite)
{
WaypointSprite_Ping(this.sprite);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
}
func_breakable_colormod(this);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
{
debrisforce = force;
spawnfunc(func_breakable)
{
float n, i;
- if(!GetResourceAmount(this, RES_HEALTH))
- SetResourceAmount(this, RES_HEALTH, 100);
- this.max_health = GetResourceAmount(this, RES_HEALTH);
+ if(!GetResource(this, RES_HEALTH))
+ SetResource(this, RES_HEALTH, 100);
+ this.max_health = GetResource(this, RES_HEALTH);
// yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
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, RES_HEALTH))
+ if (GetResource(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, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH))
+ if (GetResource(this, RES_HEALTH))
this.takedamage = DAMAGE_YES; // can be shot again
}
return;
if (this.spawnflags & BUTTON_DONTACCUMULATEDMG)
{
- if (GetResourceAmount(this, RES_HEALTH) <= damage)
+ if (GetResource(this, RES_HEALTH) <= damage)
{
this.enemy = attacker;
button_fire(this);
else
{
TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(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, RES_HEALTH))
+ if (GetResource(this, RES_HEALTH))
{
- this.max_health = GetResourceAmount(this, RES_HEALTH);
+ this.max_health = GetResource(this, RES_HEALTH);
this.event_damage = button_damage;
this.takedamage = DAMAGE_YES;
}
if (this.max_health)
{
this.takedamage = DAMAGE_YES;
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(this, RES_HEALTH, this.max_health);
}
this.state = STATE_DOWN;
return;
}
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
{
- SetResourceAmount(this.owner, RES_HEALTH, this.owner.max_health);
+ SetResource(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, RES_HEALTH) < 1)
+ if (GetResource(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, RES_HEALTH))
+ if (GetResource(this, RES_HEALTH))
return;
IFTARGETED
return;
cmaxs = this.absmax;
for(t = this; ; t = t.enemy)
{
- if(GetResourceAmount(t, RES_HEALTH) && !GetResourceAmount(this, RES_HEALTH))
- SetResourceAmount(this, RES_HEALTH, GetResourceAmount(t, RES_HEALTH));
+ if(GetResource(t, RES_HEALTH) && !GetResource(this, RES_HEALTH))
+ SetResource(this, RES_HEALTH, GetResource(t, RES_HEALTH));
if((t.targetname != "") && (this.targetname == ""))
this.targetname = t.targetname;
if((t.message != "") && (this.message == ""))
// distribute health, targetname, message
for(t = this; t; t = t.enemy)
{
- SetResourceAmount(t, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
+ SetResource(t, RES_HEALTH, GetResource(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, RES_HEALTH))
+ if (GetResource(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, RES_HEALTH);
+ this.max_health = GetResource(this, RES_HEALTH);
// unlock sound
if(this.noise == "")
this.state = STATE_BOTTOM;
- if (GetResourceAmount(this, RES_HEALTH))
+ if (GetResource(this, RES_HEALTH))
{
//this.canteamdamage = true; // TODO
this.takedamage = DAMAGE_YES;
if (this.max_health)
{
this.takedamage = DAMAGE_YES;
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(this, RES_HEALTH, this.max_health);
}
this.state = STATE_DOWN;
float temp;
string message_save;
- SetResourceAmount(this, RES_HEALTH, 10000);
+ SetResource(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, RES_HEALTH, 10000);
+ SetResource(this, RES_HEALTH, 10000);
this.takedamage = DAMAGE_YES;
//this.th_pain = fd_secret_use;
}
{
if (this.spawnflags & DOOR_SECRET_YES_SHOOT)
{
- SetResourceAmount(this, RES_HEALTH, 10000);
+ SetResource(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, RES_HEALTH, 10000);
+ SetResource(this, RES_HEALTH, 10000);
this.takedamage = DAMAGE_YES;
this.event_damage = fd_secret_damage;
}
if (!toucher.iscreature)
return;
- if (GetResourceAmount(toucher, RES_HEALTH) <= 0)
+ if (GetResource(toucher, RES_HEALTH) <= 0)
return;
#elif defined(CSQC)
if (!IS_PLAYER(toucher))
if (!toucher.iscreature)
return;
- if (GetResourceAmount(toucher, RES_HEALTH) <= 0)
+ if (GetResource(toucher, RES_HEALTH) <= 0)
return;
#elif defined(CSQC)
if (!IS_PLAYER(toucher))
{
TDEATHLOOP(player.origin)
{
- if (IS_PLAYER(player) && GetResourceAmount(player, RES_HEALTH) >= 1)
+ if (IS_PLAYER(player) && GetResource(player, RES_HEALTH) >= 1)
{
if (!(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team))
{
if(IS_PLAYER(head))
- if(GetResourceAmount(head, RES_HEALTH) >= 1)
+ if(GetResource(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, RES_HEALTH), this.max_health);
+ bool healed = Heal(toucher, this, GetResource(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, RES_HEALTH))
- SetResourceAmount(this, RES_HEALTH, 10); // TODO: use a special field for this, it doesn't have actual health!
+ if(!GetResource(this, RES_HEALTH))
+ SetResource(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, RES_HEALTH, this.max_health);
+ SetResource(this, RES_HEALTH, this.max_health);
this.takedamage = DAMAGE_YES;
this.solid = SOLID_BBOX;
}
if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != attacker.team))
return;
TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
{
this.enemy = attacker;
this.goalentity = inflictor;
settouch(this, multi_touch);
if (this.max_health)
{
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH))
+ if (GetResource(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, RES_HEALTH);
+ this.max_health = GetResource(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, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
{
this.owner.in_swamp = 0;
delete(this);
{
if(targ == NULL)
return false;
- if(GetResourceAmount(targ, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH) < targ.max_health);
+ return (IS_MONSTER(targ) && GetResource(targ, RES_HEALTH) < targ.max_health);
if(targ.items & ITEM_Shield.m_itemid)
return false;
switch(this.skin)
{
- case 0: return (GetResourceAmount(targ, RES_HEALTH) < autocvar_g_balance_health_regenstable);
+ case 0: return (GetResource(targ, RES_HEALTH) < autocvar_g_balance_health_regenstable);
case 1:
{
- 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)
+ return ((GetResource(targ, RES_CELLS) && GetResource(targ, RES_CELLS) < g_pickup_cells_max)
+ || (GetResource(targ, RES_PLASMA) && GetResource(targ, RES_PLASMA) < g_pickup_plasma_max)
+ || (GetResource(targ, RES_ROCKETS) && GetResource(targ, RES_ROCKETS) < g_pickup_rockets_max)
+ || (GetResource(targ, RES_BULLETS) && GetResource(targ, RES_BULLETS) < g_pickup_nails_max)
+ || (GetResource(targ, RES_SHELLS) && GetResource(targ, RES_SHELLS) < g_pickup_shells_max)
);
}
- case 2: return (GetResourceAmount(targ, RES_ARMOR) < autocvar_g_balance_armor_regenstable);
- case 3: return (GetResourceAmount(targ, RES_HEALTH) > 0);
+ case 2: return (GetResource(targ, RES_ARMOR) < autocvar_g_balance_armor_regenstable);
+ case 3: return (GetResource(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, RES_HEALTH) <= 0) || GetResourceAmount(this.owner, RES_HEALTH) <= 0) {
+ if (time > this.ltime || (this.enemy && GetResource(this.enemy, RES_HEALTH) <= 0) || GetResource(this.owner, RES_HEALTH) <= 0) {
this.projectiledeathtype |= HITTYPE_SPLASH;
M_Mage_Attack_Spike_Explode(this, NULL);
}
}
case 1:
{
- 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);
+ if(GetResource(this, RES_CELLS)) GiveResourceWithLimit(it, RES_CELLS, 1, g_pickup_cells_max);
+ if(GetResource(this, RES_PLASMA)) GiveResourceWithLimit(it, RES_PLASMA, 1, g_pickup_plasma_max);
+ if(GetResource(this, RES_ROCKETS)) GiveResourceWithLimit(it, RES_ROCKETS, 1, g_pickup_rockets_max);
+ if(GetResource(this, RES_SHELLS)) GiveResourceWithLimit(it, RES_SHELLS, 2, g_pickup_shells_max);
+ if(GetResource(this, RES_BULLETS)) GiveResourceWithLimit(it, RES_BULLETS, 5, g_pickup_nails_max);
// TODO: fuel?
fx = EFFECT_AMMO_REGEN;
break;
}
case 2:
- if(GetResourceAmount(it, RES_ARMOR) < autocvar_g_balance_armor_regenstable)
+ if(GetResource(it, RES_ARMOR) < autocvar_g_balance_armor_regenstable)
{
GiveResourceWithLimit(it, RES_ARMOR, autocvar_g_monster_mage_heal_allies, autocvar_g_balance_armor_regenstable);
fx = EFFECT_ARMOR_REPAIR;
Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(it.sprite, GetResource(it, RES_HEALTH));
}
});
void M_Mage_Defend_Shield_Remove(entity this)
{
this.effects &= ~(EF_ADDITIVE | EF_BLUE);
- SetResourceAmount(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResource(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, RES_ARMOR, autocvar_g_monster_mage_shield_blockpercent);
+ SetResource(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, RES_HEALTH) < (autocvar_g_monster_mage_heal_minhealth) || need_help)
+ if(GetResource(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, RES_ARMOR))
+ if(time >= actor.mage_shield_time && GetResource(actor, RES_ARMOR))
M_Mage_Defend_Shield_Remove(actor);
if(actor.enemy)
- if(GetResourceAmount(actor, RES_HEALTH) < actor.max_health)
+ if(GetResource(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, RES_HEALTH)) SetResourceAmount(actor, RES_HEALTH, autocvar_g_monster_mage_health);
+ if(!GetResource(this, RES_HEALTH)) SetResource(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, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
settouch(gren, M_Shambler_Attack_Lightning_Touch);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RES_HEALTH, 50);
+ SetResource(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, RES_HEALTH)) SetResourceAmount(actor, RES_HEALTH, autocvar_g_monster_shambler_health);
+ if(!GetResource(this, RES_HEALTH)) SetResource(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, RES_HEALTH) > 0 && it.monsterid != MON_SPIDER.monsterid,
+ FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && GetResource(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, RES_HEALTH, 500);
+ SetResource(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, RES_HEALTH)) SetResourceAmount(actor, RES_HEALTH, autocvar_g_monster_spider_health);
+ if(!GetResource(this, RES_HEALTH)) SetResource(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, RES_HEALTH)) SetResourceAmount(actor, RES_HEALTH, autocvar_g_monster_wyvern_health);
+ if(!GetResource(this, RES_HEALTH)) SetResource(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, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
return;
vector angles_face;
void M_Zombie_Defend_Block_End(entity this)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
setanim(this, this.anim_blockend, false, true, true);
- SetResourceAmount(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResource(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
}
bool M_Zombie_Defend_Block(entity this)
{
- SetResourceAmount(this, RES_ARMOR, 0.9);
+ SetResource(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, RES_HEALTH) < 75 && GetResourceAmount(actor.enemy, RES_HEALTH) > 10)
+ if(random() < 0.3 && GetResource(actor, RES_HEALTH) < 75 && GetResource(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, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
+ SetResource(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, RES_HEALTH)) SetResourceAmount(actor, RES_HEALTH, autocvar_g_monster_zombie_health);
+ if(!GetResource(actor, RES_HEALTH)) SetResource(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, RES_HEALTH) <= 0 || GetResourceAmount(this, RES_HEALTH) <= 0))
+ || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || GetResource(targ, RES_HEALTH) <= 0 || GetResource(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, RES_HEALTH) <= 0 || IS_DEAD(this))
+ if(GetResource(this, RES_HEALTH) <= 0 || IS_DEAD(this))
return false; // called when dead?
if(time < this.attack_finished_single[0])
return false; // still attacking
this.takedamage = DAMAGE_NO;
setorigin(this, this.pos1);
this.angles = this.pos2;
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH) < 1)
+ || (IS_DEAD(this.enemy) || GetResource(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, RES_HEALTH, this.max_health);
+ SetResource(this, RES_HEALTH, this.max_health);
this.velocity = '0 0 0';
this.enemy = NULL;
this.goalentity = NULL;
Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
- if(GetResourceAmount(this, RES_HEALTH) <= -50) // 100 health until gone?
+ if(GetResource(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, RES_ARMOR) / 100, deathtype, damage);
+ vector v = healtharmor_applydamage(100, GetResource(this, RES_ARMOR) / 100, deathtype, damage);
float take = v.x;
//float save = v.y;
}
if(this.sprite)
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
this.dmg_time = time;
Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, this, attacker);
}
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id));
+ Monster_Dead(this, attacker, (GetResource(this, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id));
WaypointSprite_Kill(this.sprite);
MUTATOR_CALLHOOK(MonsterDies, this, attacker, deathtype);
- if(GetResourceAmount(this, RES_HEALTH) <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
+ if(GetResource(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 != RES_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
+ if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.sprite)
- WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RES_HEALTH));
+ WaypointSprite_UpdateHealth(targ.sprite, GetResource(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, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(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, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+ SetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
- if(GetResourceAmount(this, RES_HEALTH) < 1)
+ if(GetResource(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, RES_HEALTH) + this.max_health, DEATH_KILL.m_id, DMG_NOWEP, this.origin, this.origin);
+ Damage(this, this, this, GetResource(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, 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(!GetResource(this, RES_HEALTH)) { SetResource(this, RES_HEALTH, 100); }
+ if(!GetResource(this, RES_ARMOR)) { SetResource(this, RES_ARMOR, bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9)); }
if(!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, RES_HEALTH, GetResourceAmount(this, RES_HEALTH) * MONSTER_SKILLMOD(this));
+ SetResource(this, RES_HEALTH, GetResource(this, RES_HEALTH) * MONSTER_SKILLMOD(this));
if(!this.skin)
this.skin = rint(random() * 4);
}
- this.max_health = GetResourceAmount(this, RES_HEALTH);
+ this.max_health = GetResource(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, RES_HEALTH));
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
}
}
entity player = M_ARGV(0, entity);
if(IS_PLAYER(player))
- if(GetResourceAmount(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
+ if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
{
PHYS_INPUT_BUTTON_CROUCH(player) = true;
{
entity player = M_ARGV(0, entity);
- if(GetResourceAmount(player, RES_HEALTH) <= autocvar_g_bloodloss)
+ if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss)
return true;
}
{
continue;
}
- float hp = GetResourceAmount(it, RES_HEALTH);
+ float hp = GetResource(it, RES_HEALTH);
if(hp >= autocvar_g_balance_health_regenstable)
{
continue;
}
Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
- SetResourceAmount(it, RES_HEALTH, bound(0, hp + autocvar_g_buffs_medic_heal_amount, autocvar_g_balance_health_regenstable));
+ SetResource(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, RES_HEALTH) - frag_damage) <= 0)
+ if((GetResource(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, RES_HEALTH) - autocvar_g_buffs_medic_survive_health);
+ frag_damage = max(5, GetResource(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, RES_HEALTH));
+ GetResource(frag_target, RES_HEALTH));
GiveResourceWithLimit(frag_attacker, RES_HEALTH, amount, g_pickup_healthsmall_max);
- if (GetResourceAmount(frag_target, RES_ARMOR))
+ if (GetResource(frag_target, RES_ARMOR))
{
amount = bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal,
- GetResourceAmount(frag_target, RES_ARMOR));
+ GetResource(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, RES_HEALTH) + GetResourceAmount(player, RES_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, GetResource(player, RES_HEALTH) + GetResource(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, RES_CELLS))
- SetResourceAmount(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
+ if(!GetResource(item, RES_CELLS))
+ SetResource(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, RES_CELLS) > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+ else if (GetResource(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, RES_HEALTH);
+ float hp = GetResource(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, RES_ARMOR);
+ float armor = GetResource(frag_target, RES_ARMOR);
if(armor)
{
armor -= 1;
- SetResourceAmount(frag_target, RES_ARMOR, armor);
+ SetResource(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, RES_HEALTH) > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
+ if(frag_damage <= 0 && GetResource(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, RES_ARMOR);
+ float armor = GetResource(frag_attacker, RES_ARMOR);
if(armor > 0)
{
armor -= 1;
- SetResourceAmount(frag_attacker, RES_ARMOR, armor);
+ SetResource(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, RES_CELLS, autocvar_g_instagib_ammo_drop);
+ SetResource(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
return false;
}
if(item.flags & FL_POWERUP)
return false;
- float cells = GetResourceAmount(item, RES_CELLS);
+ float cells = GetResource(item, RES_CELLS);
if(cells > autocvar_g_instagib_ammo_drop && item.classname != "item_vaporizer_cells")
- SetResourceAmount(item, RES_CELLS, autocvar_g_instagib_ammo_drop);
+ SetResource(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, RES_CELLS))
+ if(GetResource(item, RES_CELLS))
{
// play some cool sounds ;)
- float hp = GetResourceAmount(toucher, RES_HEALTH);
+ float hp = GetResource(toucher, RES_HEALTH);
if (IS_CLIENT(toucher))
{
if(hp <= 5)
}
if(hp < 100)
- SetResourceAmount(toucher, RES_HEALTH, 100);
+ SetResource(toucher, RES_HEALTH, 100);
return MUT_ITEMTOUCH_CONTINUE;
}
{
entity proj = M_ARGV(1, entity);
- if(GetResourceAmount(proj, RES_HEALTH))
+ if(GetResource(proj, RES_HEALTH))
{
// disable health which in effect disables damage calculations
- SetResourceAmount(proj, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH) > 0 && current_freeze_time > 0,
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResource(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, RES_HEALTH);
+ float hp = GetResource(toucher, RES_HEALTH);
if (hp < maxhealth)
{
if (this.nade_show_particles)
if(autocvar_g_nades_pickup)
if(time >= this.spawnshieldtime)
- if(!toucher.nade && GetResourceAmount(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
+ if(!toucher.nade && GetResource(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, RES_HEALTH) == this.max_health)
+ if(GetResource(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, RES_HEALTH);
+ float hp = GetResource(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, RES_HEALTH, hp);
+ SetResource(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, RES_HEALTH, autocvar_g_nades_nade_health);
- _nade.max_health = GetResourceAmount(_nade, RES_HEALTH);
+ SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
+ _nade.max_health = GetResource(_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, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
+ SetResource(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, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
+ SetResource(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, RES_HEALTH, 255);
+ SetResource(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, 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);
+ SetResource(it, RES_SHELLS, start_ammo_shells);
+ SetResource(it, RES_BULLETS, start_ammo_nails);
+ SetResource(it, RES_ROCKETS, start_ammo_rockets);
+ SetResource(it, RES_CELLS, start_ammo_cells);
+ SetResource(it, RES_PLASMA, start_ammo_plasma);
+ SetResource(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, 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);
+ SetResource(this, RES_SHELLS, 0);
+ SetResource(this, RES_BULLETS, 0);
+ SetResource(this, RES_ROCKETS, 0);
+ SetResource(this, RES_CELLS, 0);
+ SetResource(this, RES_PLASMA, 0);
+ SetResource(this, RES_FUEL, 0);
if(this.items & IT_UNLIMITED_WEAPON_AMMO)
{
switch (wpn.ammo_type)
{
- 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;
+ case RES_SHELLS: SetResource(this, RES_SHELLS, autocvar_g_pickup_shells_max); break;
+ case RES_BULLETS: SetResource(this, RES_BULLETS, autocvar_g_pickup_nails_max); break;
+ case RES_ROCKETS: SetResource(this, RES_ROCKETS, autocvar_g_pickup_rockets_max); break;
+ case RES_CELLS: SetResource(this, RES_CELLS, autocvar_g_pickup_cells_max); break;
+ case RES_PLASMA: SetResource(this, RES_PLASMA, autocvar_g_pickup_plasma_max); break;
+ case RES_FUEL: SetResource(this, RES_FUEL, autocvar_g_pickup_fuel_max); break;
}
}
else
{
switch (wpn.ammo_type)
{
- 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;
+ case RES_SHELLS: SetResource(this, RES_SHELLS, autocvar_g_balance_nix_ammo_shells); break;
+ case RES_BULLETS: SetResource(this, RES_BULLETS, autocvar_g_balance_nix_ammo_nails); break;
+ case RES_ROCKETS: SetResource(this, RES_ROCKETS, autocvar_g_balance_nix_ammo_rockets); break;
+ case RES_CELLS: SetResource(this, RES_CELLS, autocvar_g_balance_nix_ammo_cells); break;
+ case RES_PLASMA: SetResource(this, RES_PLASMA, autocvar_g_balance_nix_ammo_plasma); break;
+ case RES_FUEL: SetResource(this, RES_FUEL, autocvar_g_balance_nix_ammo_fuel); break;
}
}
METHOD(OverkillHeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okhmg, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okhmg, ammo);
if (autocvar_g_balance_okhmg_reload_ammo)
{
ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_HMG.m_id]) >= WEP_CVAR_PRI(okhmg, ammo);
METHOD(OverkillHeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(okhmg, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(okhmg, ammo);
if (autocvar_g_balance_okhmg_reload_ammo)
{
ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_HMG.m_id]) >= WEP_CVAR_SEC(okhmg, ammo);
METHOD(OverkillMachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float ammo_amount;
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okmachinegun, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okmachinegun, ammo);
if (WEP_CVAR(okmachinegun, reload_ammo))
{
ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_MACHINEGUN.m_id]) >= WEP_CVAR_PRI(okmachinegun, ammo);
METHOD(OverkillNex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(oknex, ammo);
ammo_amount += (autocvar_g_balance_oknex_reload_ammo && actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(oknex, ammo));
return ammo_amount;
}
if (WEP_CVAR(oknex, secondary))
{
// don't allow charging if we don't have enough ammo
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(oknex, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(oknex, ammo);
return ammo_amount;
}
void W_OverkillRocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(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, RES_HEALTH, WEP_CVAR_PRI(okrpc, health));
+ SetResource(missile, RES_HEALTH, WEP_CVAR_PRI(okrpc, health));
missile.event_damage = W_OverkillRocketPropelledChainsaw_Damage;
missile.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, missile);
METHOD(OverkillRocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okrpc, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okrpc, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(okrpc, ammo);
return ammo_amount;
}
METHOD(OverkillRocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(okrpc, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(okrpc, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(okrpc, ammo);
return ammo_amount;
}
METHOD(OverkillShotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(okshotgun, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[WEP_OVERKILL_SHOTGUN.m_id]) >= WEP_CVAR_PRI(okshotgun, ammo);
return ammo_amount;
}
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, RES_HEALTH) < autocvar_g_balance_health_regenstable) continue;
+ if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && GetResource(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(!IS_DEAD(frag_target))
{
GiveResource(frag_attacker, RES_HEALTH,
- bound(0, damage_take, GetResourceAmount(frag_target, RES_HEALTH)));
+ bound(0, damage_take, GetResource(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, RES_HEALTH) > 0)
+ if(GetResource(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, RES_HEALTH, min(GetResourceAmount(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
+ SetResource(targ, RES_HEALTH, min(GetResource(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
if(dmgent == thehook.owner)
TakeResource(dmgent, RES_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
{
if (this.max_health)
{
- WriteByte(MSG_ENTITY, (GetResourceAmount(this, RES_HEALTH) / this.max_health) * 191.0);
+ WriteByte(MSG_ENTITY, (GetResource(this, RES_HEALTH) / this.max_health) * 191.0);
}
else
{
int t = ReadByte();
if (t < 192)
{
- SetResourceAmount(this, RES_HEALTH, t / 191.0);
+ SetResource(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, RES_HEALTH), 1);
+ this.build_starthealth = bound(0, GetResource(this, RES_HEALTH), 1);
else
this.build_starthealth = 0;
this.build_finished = servertime + t / 32;
}
else
{
- SetResourceAmount(this, RES_HEALTH, -1);
+ SetResource(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, RES_HEALTH);
+ float health_val = GetResource(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, RES_HEALTH, this.build_starthealth);
+ SetResource(this, RES_HEALTH, this.build_starthealth);
else if (time < this.build_finished)
- SetResourceAmount(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
+ SetResource(this, RES_HEALTH, (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth);
else
- SetResourceAmount(this, RES_HEALTH, 1);
+ SetResource(this, RES_HEALTH, 1);
}
else
- SetResourceAmount(this, RES_HEALTH, -1);
+ SetResource(this, RES_HEALTH, -1);
}
o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
}
draw_beginBoldFont();
- if (GetResourceAmount(this, RES_HEALTH) >= 0)
+ if (GetResource(this, RES_HEALTH) >= 0)
{
float align = 0, marg;
if (this.build_finished)
drawhealthbar(
o,
0,
- GetResourceAmount(this, RES_HEALTH),
+ GetResource(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, RES_HEALTH) / step)) || e.pain_finished)
+ if ((floor(f / step) != floor(GetResource(e, RES_HEALTH) / step)) || e.pain_finished)
{
- SetResourceAmount(e, RES_HEALTH, f);
+ SetResource(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, RES_HEALTH))
+ if (GetResource(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, RES_HEALTH), GetResourceAmount(carrier, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
+ WaypointSprite_UpdateHealth(e, healtharmor_maxdamage(GetResource(carrier, RES_HEALTH), GetResource(carrier, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x);
}
return e;
}
{
continue;
}
- if (GetResourceAmount(receiver,
+ if (GetResource(receiver,
RandomSelection_chosen_ent.ammo_type) != 0)
{
continue;
}
GiveResource(receiver, RandomSelection_chosen_ent.ammo_type,
- GetResourceAmount(ammo_entity,
+ GetResource(ammo_entity,
RandomSelection_chosen_ent.ammo_type));
}
}
float Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
{
- float amount = GetResourceAmount(item, res_type);
+ float amount = GetResource(item, res_type);
if (amount == 0)
{
return false;
}
- float player_amount = GetResourceAmount(player, res_type);
+ float player_amount = GetResource(player, res_type);
if (item.spawnshieldtime)
{
if ((player_amount >= ammomax) && (item.pickup_anyway <= 0))
if(item.itemdef.instanceOfWeaponPickup)
{
entity ammo = NULL;
- 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(GetResource(item, RES_SHELLS)) { need_shells = true; ammo = ITEM_Shells; }
+ else if(GetResource(item, RES_BULLETS)) { need_nails = true; ammo = ITEM_Bullets; }
+ else if(GetResource(item, RES_ROCKETS)) { need_rockets = true; ammo = ITEM_Rockets; }
+ else if(GetResource(item, RES_CELLS)) { need_cells = true; ammo = ITEM_Cells; }
+ else if(GetResource(item, RES_PLASMA)) { need_plasma = true; ammo = ITEM_Plasma; }
+ else if(GetResource(item, RES_FUEL)) { need_fuel = true; ammo = ITEM_JetpackFuel; }
if(!ammo)
return 0;
float noammorating = 0.5;
- 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_shells) && GetResource(item, RES_SHELLS) && (GetResource(player, RES_SHELLS) < g_pickup_shells_max))
+ c = GetResource(item, RES_SHELLS) / max(noammorating, GetResource(player, RES_SHELLS));
- 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_nails) && GetResource(item, RES_BULLETS) && (GetResource(player, RES_BULLETS) < g_pickup_nails_max))
+ c = GetResource(item, RES_BULLETS) / max(noammorating, GetResource(player, RES_BULLETS));
- 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_rockets) && GetResource(item, RES_ROCKETS) && (GetResource(player, RES_ROCKETS) < g_pickup_rockets_max))
+ c = GetResource(item, RES_ROCKETS) / max(noammorating, GetResource(player, RES_ROCKETS));
- 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_cells) && GetResource(item, RES_CELLS) && (GetResource(player, RES_CELLS) < g_pickup_cells_max))
+ c = GetResource(item, RES_CELLS) / max(noammorating, GetResource(player, RES_CELLS));
- 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_plasma) && GetResource(item, RES_PLASMA) && (GetResource(player, RES_PLASMA) < g_pickup_plasma_max))
+ c = GetResource(item, RES_PLASMA) / max(noammorating, GetResource(player, RES_PLASMA));
- 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));
+ if ((need_fuel) && GetResource(item, RES_FUEL) && (GetResource(player, RES_FUEL) < g_pickup_fuel_max))
+ c = GetResource(item, RES_FUEL) / max(noammorating, GetResource(player, RES_FUEL));
rating *= min(c, 2);
if(wpn)
float c = 0;
float rating = item.bot_pickupbasevalue;
- float itemarmor = GetResourceAmount(item, RES_ARMOR);
- float itemhealth = GetResourceAmount(item, RES_HEALTH);
+ float itemarmor = GetResource(item, RES_ARMOR);
+ float itemhealth = GetResource(item, RES_HEALTH);
if(item.item_group)
{
itemhealth *= min(4, item.item_group_count);
}
- 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 (itemarmor && (GetResource(player, RES_ARMOR) < item.max_armorvalue))
+ c = itemarmor / max(1, GetResource(player, RES_ARMOR) * 2/3 + GetResource(player, RES_HEALTH) * 1/3);
- if (itemhealth && (GetResourceAmount(player, RES_HEALTH) < item.max_health))
- c = itemhealth / max(1, GetResourceAmount(player, RES_HEALTH));
+ if (itemhealth && (GetResource(player, RES_HEALTH) < item.max_health))
+ c = itemhealth / max(1, GetResource(player, RES_HEALTH));
rating *= min(2, c);
return rating;
if(def.instanceOfPowerup)
this.ItemStatus |= ITS_ANIMATE1;
- if(GetResourceAmount(this, RES_ARMOR) || GetResourceAmount(this, RES_HEALTH))
+ if(GetResource(this, RES_ARMOR) || GetResource(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, 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");
+ if(GetResource(this, RES_SHELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_SHELLS)), "shells");
+ if(GetResource(this, RES_BULLETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_BULLETS)), "nails");
+ if(GetResource(this, RES_ROCKETS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_ROCKETS)), "rockets");
+ if(GetResource(this, RES_CELLS) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_CELLS)), "cells");
+ if(GetResource(this, RES_PLASMA) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_PLASMA)), "plasma");
+ if(GetResource(this, RES_FUEL) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_FUEL)), "fuel");
+ if(GetResource(this, RES_HEALTH) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(this, RES_HEALTH)), "health");
+ if(GetResource(this, RES_ARMOR) != 0) this.netname = sprintf("%s %s%d %s", this.netname, valueprefix, max(0, GetResource(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));
}
}
bool GiveResourceValue(entity e, int res_type, int op, int val)
{
- int v0 = GetResourceAmount(e, res_type);
+ int v0 = GetResource(e, res_type);
switch (op)
{
// 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;
+ case OP_SET: SetResource(e, res_type, val); break;
+ case OP_MIN: SetResource(e, res_type, max(v0, val)); break;
+ case OP_MAX: SetResource(e, res_type, min(v0, val)); break;
+ case OP_PLUS: SetResource(e, res_type, v0 + val); break;
+ case OP_MINUS: SetResource(e, res_type, v0 - val); break;
}
- int v1 = GetResourceAmount(e, res_type);
+ int v1 = GetResource(e, res_type);
return v0 != v1;
}
#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = STAT(WEAPONS, e)
#define PREGIVE(e,f) float save_##f; save_##f = (e).f
-#define PREGIVE_RESOURCE(e,f) float save_##f = GetResourceAmount((e), (f))
+#define PREGIVE_RESOURCE(e,f) float save_##f = GetResource((e), (f))
#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_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_RESOURCE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, GetResource((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,GetResource((e),(f)),rotfield,rottime,regenfield,regentime);GiveSound((e),save_##f,GetResource((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, RES_HEALTH) < 127)
+ if (GetResource(this, RES_HEALTH) < 127)
{
dt = random();
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
- if(GetResourceAmount(this, RES_HEALTH) < 85)
+ if(GetResource(this, RES_HEALTH) < 85)
if(dt < 0.01)
pointparticles(EFFECT_SMOKE_LARGE, (this.origin + (randomvec() * 80)), '0 0 0', 1);
- if(GetResourceAmount(this, RES_HEALTH) < 32)
+ if(GetResource(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, RES_HEALTH) / 255,
+ GetResource(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, RES_HEALTH, 255);
+ SetResource(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, RES_HEALTH);
+ float myhp = GetResource(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, RES_HEALTH, _tmp);
+ SetResource(this, RES_HEALTH, _tmp);
}
return true;
}
this.event_heal = func_null;
this.takedamage = DAMAGE_NO;
- SetResourceAmount(this, RES_HEALTH, 0);
+ SetResource(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);
if (this.turret_flags & TUR_FLAG_MOVE)
this.velocity = this.velocity + vforce;
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(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 != RES_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
+ if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
this.avelocity = '0 0 0';
this.tur_head.avelocity = this.avelocity;
this.tur_head.angles = this.idle_aim;
- SetResourceAmount(this, RES_HEALTH, this.max_health);
+ SetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
WriteByte(MSG_ENTITY, 0);
else
- WriteByte(MSG_ENTITY, ceil((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 255));
+ WriteByte(MSG_ENTITY, ceil((GetResource(this, RES_HEALTH) / this.max_health) * 255));
}
return true;
ent.tur_head.angles = '0 0 0';
}
- SetResourceAmount(ent, RES_HEALTH, cvar(strcat(sbase,"_health")) * ent.turret_scale_health);
+ SetResource(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;
this.velocity += vforce;
TakeResource(this, RES_HEALTH, damage);
//this.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, this.owner, turret_projectile_explode);
}
PROJECTILE_MAKETRIGGER(proj);
if(_health)
{
- SetResourceAmount(proj, RES_HEALTH, _health);
+ SetResource(proj, RES_HEALTH, _health);
proj.takedamage = DAMAGE_YES;
proj.event_damage = turret_projectile_damage;
}
return -5;
// Cant touch this
- if (GetResourceAmount(e_target, RES_HEALTH) <= 0)
+ if (GetResource(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, RES_HEALTH)) { SetResourceAmount(this, RES_HEALTH, 1000); }
+ if(!GetResource(this, RES_HEALTH)) { SetResource(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, RES_HEALTH);
+ this.max_health = GetResource(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, RES_HEALTH) < 127)
+ if(GetResource(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, RES_HEALTH) < 0))
+ if ((targ.takedamage == DAMAGE_NO) || (GetResource(targ, RES_HEALTH) < 0))
return false;
// player
TakeResource(this, RES_HEALTH, damage);
this.velocity = this.velocity + vforce;
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(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, RES_HEALTH, 25);
+ SetResource(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, RES_HEALTH) < 127)
+ if(GetResource(this, RES_HEALTH) < 127)
if(random() < 0.15)
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
TakeResource(this, RES_HEALTH, damage);
this.velocity += force;
- if(GetResourceAmount(this, RES_HEALTH) < 1)
+ if(GetResource(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, RES_HEALTH, _health);
+ SetResource(proj, RES_HEALTH, _health);
}
else
proj.flags |= FL_NOTARGET;
if(timer + rpause < time)
{
if(_healthscale)
- regen = regen * (GetResourceAmount(this, RES_HEALTH) / this.max_health);
+ regen = regen * (GetResource(this, RES_HEALTH) / this.max_health);
this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max);
void vehicles_regen_resource(entity this, float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, int resource)
{
- float resource_amount = GetResourceAmount(this, resource);
+ float resource_amount = GetResource(this, resource);
if(resource_amount < field_max)
if(timer + rpause < time)
if(_healthscale)
regen = regen * (resource_amount / this.max_health);
- SetResourceAmount(this, resource, min(resource_amount + regen * delta_time, field_max));
+ SetResource(this, resource, min(resource_amount + regen * delta_time, field_max));
if(this.owner)
- this.owner.(regen_field) = (GetResourceAmount(this, resource) / field_max) * 100;
+ this.owner.(regen_field) = (GetResource(this, resource) / field_max) * 100;
}
}
void vehicles_painframe(entity this)
{
- int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResourceAmount(this, RES_HEALTH) / this.max_health) * 100));
+ int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResource(this, RES_HEALTH) / this.max_health) * 100));
if(myhealth <= 50)
if(this.pain_frame < time)
else
this.velocity += force;
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
{
if(this.owner)
{
bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
{
float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= true_limit)
+ if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= true_limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
if(targ.owner)
- targ.owner.vehicle_health = (GetResourceAmount(targ, RES_HEALTH) / targ.max_health) * 100;
+ targ.owner.vehicle_health = (GetResource(targ, RES_HEALTH) / targ.max_health) * 100;
return true;
}
ply.vehicle_##fld = (vehi.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
#define VEHICLE_UPDATE_PLAYER_RESOURCE(ply,vehi,fld,vhname,res) \
- ply.vehicle_##fld = (GetResourceAmount(vehi, res) / autocvar_g_vehicle_##vhname##_##fld) * 100
+ ply.vehicle_##fld = (GetResource(vehi, res) / autocvar_g_vehicle_##vhname##_##fld) * 100
.float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly
if(IS_VEHICLE(trace_ent))
{
- if(autocvar_g_vehicle_bumblebee_healgun_sps && GetResourceAmount(trace_ent, RES_HEALTH) <= trace_ent.max_health)
+ if(autocvar_g_vehicle_bumblebee_healgun_sps && GetResource(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, RES_ARMOR) <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
+ if(GetResource(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);
}
}
Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(instance.origin, 16), '0 0 0', 1);
- SetResourceAmount(instance, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
- instance.max_health = GetResourceAmount(instance, RES_HEALTH);
+ SetResource(instance, RES_HEALTH, autocvar_g_vehicle_bumblebee_health);
+ instance.max_health = GetResource(instance, RES_HEALTH);
instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
}
{
#ifdef SVQC
set_movetype(instance, MOVETYPE_BOUNCE);
- instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_racer_health) * 100;
+ instance.owner.vehicle_health = (GetResource(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, RES_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResource(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, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_racer_health);
+ SetResource(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
- instance.max_health = GetResourceAmount(instance, RES_HEALTH);
+ instance.max_health = GetResource(instance, RES_HEALTH);
#endif
#ifdef CSQC
instance.owner.PlayerPhysplug = raptor_takeoff;
set_movetype(instance, MOVETYPE_BOUNCEMISSILE);
instance.solid = SOLID_SLIDEBOX;
- instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
+ instance.owner.vehicle_health = (GetResource(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, RES_HEALTH, 0);
+ SetResource(instance, RES_HEALTH, 0);
instance.event_damage = func_null;
instance.solid = SOLID_CORPSE;
instance.takedamage = DAMAGE_NO;
}
instance.frame = 0;
- SetResourceAmount(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_raptor_health);
+ SetResource(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
- instance.max_health = GetResourceAmount(instance, RES_HEALTH);
+ instance.max_health = GetResource(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, RES_HEALTH, 20);
+ SetResource(_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, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
delete(this);
}
STAT(VEHICLESTAT_W2MODE, instance) = SBRM_GUIDE;
set_movetype(instance, MOVETYPE_WALK);
CSQCVehicleSetup(instance.owner, 0);
- instance.owner.vehicle_health = (GetResourceAmount(instance, RES_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100;
+ instance.owner.vehicle_health = (GetResource(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, RES_HEALTH, 0);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
+ SetResource(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, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
+ SetResource(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
- instance.max_health = GetResourceAmount(instance, RES_HEALTH);
+ instance.max_health = GetResource(instance, RES_HEALTH);
instance.pushable = true; // spiderbot can use jumppads
}
void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1))
TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
missile.bot_dodgerating = WEP_CVAR(arc, bolt_damage);
missile.takedamage = DAMAGE_YES;
- SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(arc, bolt_health));
+ SetResource(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;
if(rootammo)
{
- coefficient = min(coefficient, GetResourceAmount(own, thiswep.ammo_type) / rootammo);
- SetResourceAmount(own, thiswep.ammo_type, max(0, GetResourceAmount(own, thiswep.ammo_type) - (rootammo * frametime)));
+ coefficient = min(coefficient, GetResource(own, thiswep.ammo_type) / rootammo);
+ SetResource(own, thiswep.ammo_type, max(0, GetResource(own, thiswep.ammo_type) - (rootammo * frametime)));
}
}
float heat_speed = burst ? WEP_CVAR(arc, burst_heat) : WEP_CVAR(arc, beam_heat);
Heal(trace_ent, own, (roothealth * coefficient), hplimit);
if(IS_PLAYER(trace_ent) && rootarmor)
{
- if(GetResourceAmount(trace_ent, RES_ARMOR) <= WEP_CVAR(arc, beam_healing_amax))
+ if(GetResource(trace_ent, RES_ARMOR) <= WEP_CVAR(arc, beam_healing_amax))
{
GiveResourceWithLimit(trace_ent, RES_ARMOR, (rootarmor * coefficient), WEP_CVAR(arc, beam_healing_amax));
trace_ent.pauserotarmor_finished = max(
}
METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- return ((!WEP_CVAR(arc, beam_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0));
+ return ((!WEP_CVAR(arc, beam_ammo)) || (GetResource(actor, thiswep.ammo_type) > 0));
}
METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
if(WEP_CVAR(arc, bolt))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(arc, bolt_ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(arc, bolt_ammo);
ammo_amount += actor.(weaponentity).(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
return ammo_amount;
}
else
return WEP_CVAR(arc, overheat_max) > 0 &&
- ((!WEP_CVAR(arc, burst_ammo)) || (GetResourceAmount(actor, thiswep.ammo_type) > 0));
+ ((!WEP_CVAR(arc, burst_ammo)) || (GetResource(actor, thiswep.ammo_type) > 0));
}
METHOD(Arc, wr_killmessage, Notification(entity thiswep))
{
if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
return true;
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(crylink, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(crylink, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
return ammo_amount;
}
if(actor.(weaponentity).crylink_lastgroup && actor.(weaponentity).crylink_waitrelease)
return true;
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(crylink, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(crylink, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
return ammo_amount;
}
.entity weaponentity = this.weaponentity_fld;
if(this.realowner.(weaponentity).m_weapon == thiswep)
{
- if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
+ if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
{
this.realowner.cnt = thiswep.m_id;
Weapon thiswep = WEP_DEVASTATOR;
if(this.realowner.(weaponentity).m_weapon == thiswep)
{
- if(GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
+ if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
{
this.realowner.cnt = thiswep.m_id;
void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think);
}
missile.takedamage = DAMAGE_YES;
missile.damageforcescale = WEP_CVAR(devastator, damageforcescale);
- SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(devastator, health));
+ SetResource(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, RES_HEALTH)))
+ if((skill > 6.5) && (selfdamage > GetResource(actor, RES_HEALTH)))
PHYS_INPUT_BUTTON_ATCK2(actor) = false;
//if(PHYS_INPUT_BUTTON_ATCK2(actor) == true)
// dprint(ftos(desirabledamage),"\n");
ammo_amount = false;
if(WEP_CVAR(devastator, reload_ammo))
{
- if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
+ if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
}
- else if(GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
+ else if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
return !ammo_amount;
}
#if 0
if(actor.rl_release == 0)
{
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo));
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo));
return true;
}
else
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, GetResourceAmount(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
return ammo_amount;
}
#else
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(devastator, ammo);
return ammo_amount;
#endif
newproj.takedamage = this.takedamage;
newproj.damageforcescale = this.damageforcescale;
- SetResourceAmount(newproj, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
+ SetResource(newproj, RES_HEALTH, GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
// note: combos are usually triggered by W_Electro_TriggerCombo, not damage
return; // g_projectiles_damage says to halt
TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH, WEP_CVAR_SEC(electro, health));
+ SetResource(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
proj.event_damage = W_Electro_Orb_Damage;
proj.flags = FL_PROJECTILE;
IL_PUSH(g_projectiles, proj);
}
METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo);
return ammo_amount;
}
float ammo_amount;
if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
}
else
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo);
}
return ammo_amount;
this.takedamage = DAMAGE_NO;
// 1. dist damage
- d = (GetResourceAmount(this.realowner, RES_HEALTH) + GetResourceAmount(this.realowner, RES_ARMOR));
+ d = (GetResource(this.realowner, RES_HEALTH) + GetResource(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, RES_HEALTH) + GetResourceAmount(this.realowner, RES_ARMOR) >= d)
+ if(GetResource(this.realowner, RES_HEALTH) + GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH, WEP_CVAR_PRI(fireball, health));
+ SetResource(proj, RES_HEALTH, WEP_CVAR_PRI(fireball, health));
proj.team = actor.team;
proj.event_damage = W_Fireball_Damage;
proj.takedamage = DAMAGE_YES;
void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
float is_linkexplode = ( ((inflictor.owner != NULL) ? (inflictor.owner == this.owner) : true)
TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, getthink(this));
}
missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
missile.takedamage = DAMAGE_YES;
- SetResourceAmount(missile, RES_HEALTH, WEP_CVAR_PRI(hagar, health));
+ SetResource(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, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
+ SetResource(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, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
+ SetResource(missile, RES_HEALTH, WEP_CVAR_SEC(hagar, health));
missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
missile.event_damage = W_Hagar_Damage;
missile.damagedbycontents = true;
else if(autocvar_g_balance_hagar_reload_ammo)
enough_ammo = actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
else
- enough_ammo = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo);
+ enough_ammo = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo);
bool stopped = loaded || !enough_ammo;
}
METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hagar, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hagar, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
return ammo_amount;
}
METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hagar, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
return ammo_amount;
}
}
METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(hlac, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
return ammo_amount;
}
METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(hlac, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
return ammo_amount;
}
void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
+ SetResource(this, RES_HEALTH, GetResource(this, RES_HEALTH));
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
}
settouch(gren, W_Hook_Touch2);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RES_HEALTH, WEP_CVAR_SEC(hook, health));
+ SetResource(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, RES_FUEL) >= (time - actor.(weaponentity).hook_time_fueldecrease) * hooked_fuel )
+ if( GetResource(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, RES_FUEL, 0);
+ SetResource(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, RES_FUEL) > 0;
+ return GetResource(actor, RES_FUEL) > 0;
- return GetResourceAmount(actor, RES_FUEL) >= WEP_CVAR_PRI(hook, ammo);
+ return GetResource(actor, RES_FUEL) >= WEP_CVAR_PRI(hook, ammo);
}
METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor, .entity weaponentity))
{
{
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, sustained_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, sustained_ammo);
else
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
{
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, burst_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, burst_ammo);
else
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
newmine.takedamage = this.takedamage;
newmine.damageforcescale = this.damageforcescale;
- SetResourceAmount(newmine, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
+ SetResource(newmine, RES_HEALTH, GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
float is_from_enemy = (inflictor.realowner != this.realowner);
TakeResource(this, RES_HEALTH, damage);
this.angles = vectoangles(this.velocity);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode_think);
}
mine.takedamage = DAMAGE_YES;
mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale);
- SetResourceAmount(mine, RES_HEALTH, WEP_CVAR(minelayer, health));
+ SetResource(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, RES_HEALTH)))
+ if((skill > 6.5) && (selfdamage > GetResource(actor, RES_HEALTH)))
PHYS_INPUT_BUTTON_ATCK2(actor) = false;
//if(PHYS_INPUT_BUTTON_ATCK2(actor) == true)
// dprint(ftos(desirabledamage),"\n");
if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
{
// not if we're holding the minelayer without enough ammo, but can detonate existing mines
- if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) {
+ if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResource(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) {
thiswep.wr_reload(thiswep, actor, weaponentity);
}
}
// actually do // don't switch while placing a mine
//if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
//{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);
return ammo_amount;
//}
void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
}
settouch(gren, W_Mortar_Grenade_Touch1);
gren.takedamage = DAMAGE_YES;
- SetResourceAmount(gren, RES_HEALTH, WEP_CVAR_PRI(mortar, health));
+ SetResource(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, RES_HEALTH, WEP_CVAR_SEC(mortar, health));
+ SetResource(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;
}
METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(mortar, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(mortar, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
return ammo_amount;
}
METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(mortar, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(mortar, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
return ammo_amount;
}
}
METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(rifle, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(rifle, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
return ammo_amount;
}
METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(rifle, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(rifle, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
return ammo_amount;
}
void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
else
TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH, WEP_CVAR(seeker, missile_health));
+ SetResource(missile, RES_HEALTH, WEP_CVAR(seeker, missile_health));
missile.damageforcescale = WEP_CVAR(seeker, missile_damageforcescale);
missile.damagedbycontents = true;
IL_PUSH(g_damagedbycontents, missile);
Weapon thiswep = WEP_SEEKER;
.entity weaponentity = this.weaponentity_fld;
- if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != thiswep))
+ if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != thiswep))
{
delete(this);
return;
void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
W_Seeker_Tag_Explode(this);
}
missile.takedamage = DAMAGE_YES;
missile.event_damage = W_Seeker_Tag_Damage;
- SetResourceAmount(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
+ SetResource(missile, RES_HEALTH, WEP_CVAR(seeker, tag_health));
missile.damageforcescale = WEP_CVAR(seeker, tag_damageforcescale);
setorigin(missile, w_shotorg);
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, missile_ammo);
}
else
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
return ammo_amount;
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
else
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(seeker, flac_ammo);
}
return ammo_amount;
}
if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
if(WEP_CVAR(shotgun, secondary) == 1)
- if(((fire & 1) && GetResourceAmount(actor, thiswep.ammo_type) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
+ if(((fire & 1) && GetResource(actor, thiswep.ammo_type) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire)))
{
// attempt forcing playback of the anim by switching to another anim (that we never play) here...
}
METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
case 1: return true; // melee does not use ammo
case 2: // secondary triple shot
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
{
- if(GetResourceAmount(actor, thiswep.ammo_type) > 0)
+ if(GetResource(actor, thiswep.ammo_type) > 0)
PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false);
else
PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
} 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, RES_CELLS) || !autocvar_g_rm) && !forbidWeaponUse(actor))
+ if((fire & 1) && (GetResource(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, RES_CELLS) && autocvar_g_rm))
+ if((fire & 2) || ((fire & 1) && !GetResource(actor, RES_CELLS) && autocvar_g_rm))
{
if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
{
METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
float vaporizer_ammo = ((autocvar_g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= vaporizer_ammo;
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= vaporizer_ammo;
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= vaporizer_ammo;
return ammo_amount;
}
{
if(!WEP_CVAR_SEC(vaporizer, ammo))
return true;
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vaporizer, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vaporizer, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
return ammo_amount;
}
}
else
{
- dt = min(dt, (GetResourceAmount(actor, thiswep.ammo_type) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
+ dt = min(dt, (GetResource(actor, thiswep.ammo_type) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
dt = max(0, dt);
if(dt > 0)
{
- SetResourceAmount(actor, thiswep.ammo_type, max(WEP_CVAR_SEC(vortex, ammo), GetResourceAmount(actor, thiswep.ammo_type) - WEP_CVAR_SEC(vortex, ammo) * dt));
+ SetResource(actor, thiswep.ammo_type, max(WEP_CVAR_SEC(vortex, ammo), GetResource(actor, thiswep.ammo_type) - WEP_CVAR_SEC(vortex, ammo) * dt));
}
}
}
}
METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(vortex, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(vortex, ammo);
ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
return ammo_amount;
}
if(WEP_CVAR(vortex, secondary))
{
// don't allow charging if we don't have enough ammo
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vortex, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(vortex, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
return ammo_amount;
}
// Jetpack navigation
if(this.navigation_jetpack_goal)
if(this.goalcurrent==this.navigation_jetpack_goal)
- if(GetResourceAmount(this, RES_FUEL))
+ if(GetResource(this, RES_FUEL))
{
if(autocvar_bot_debug_goalstack)
{
return;
}
else if(!this.jumppadcount && !this.goalcurrent.wphardwired
- && GetResourceAmount(this, RES_HEALTH) + GetResourceAmount(this, RES_ARMOR) > ROCKETJUMP_DAMAGE())
+ && GetResource(this, RES_HEALTH) + GetResource(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, RES_HEALTH) > 30)
+ if (GetResource(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, 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 (GetResource(item, RES_HEALTH) && GetResource(player, RES_HEALTH) <= GetResource(this, RES_HEALTH)) {return true;}
+ if (GetResource(item, RES_ARMOR) && GetResource(player, RES_ARMOR) <= GetResource(this, RES_ARMOR)) {return true;}
if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {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 (GetResource(item, RES_SHELLS) && GetResource(player, RES_SHELLS) <= GetResource(this, RES_SHELLS)) {return true;}
+ if (GetResource(item, RES_BULLETS) && GetResource(player, RES_BULLETS) <= GetResource(this, RES_BULLETS)) {return true;}
+ if (GetResource(item, RES_ROCKETS) && GetResource(player, RES_ROCKETS) <= GetResource(this, RES_ROCKETS)) {return true;}
+ if (GetResource(item, RES_CELLS) && GetResource(player, RES_CELLS) <= GetResource(this, RES_CELLS)) {return true;}
+ if (GetResource(item, RES_PLASMA) && GetResource(player, RES_PLASMA) <= GetResource(this, RES_PLASMA)) {return true;}
if (item.itemdef.instanceOfPowerup) {return true;}
return false;
continue;
*/
- t = ((GetResourceAmount(this, RES_HEALTH) + GetResourceAmount(this, RES_ARMOR)) - (GetResourceAmount(it, RES_HEALTH) + GetResourceAmount(it, RES_ARMOR))) / 150;
+ t = ((GetResource(this, RES_HEALTH) + GetResource(this, RES_ARMOR)) - (GetResource(it, RES_HEALTH) + GetResource(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, RES_FUEL)));
+ LOG_DEBUG("jetpack ai: required fuel ", ftos(fuel), ", have ", ftos(GetResource(this, RES_FUEL)));
// enough fuel ?
- if(GetResourceAmount(this, RES_FUEL) > fuel || (this.items & IT_UNLIMITED_WEAPON_AMMO))
+ if(GetResource(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, RES_HEALTH);
+ return GetResource(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, 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));
+ SetResource(this.personal, RES_ROCKETS, GetResource(this, RES_ROCKETS));
+ SetResource(this.personal, RES_BULLETS, GetResource(this, RES_BULLETS));
+ SetResource(this.personal, RES_CELLS, GetResource(this, RES_CELLS));
+ SetResource(this.personal, RES_PLASMA, GetResource(this, RES_PLASMA));
+ SetResource(this.personal, RES_SHELLS, GetResource(this, RES_SHELLS));
+ SetResource(this.personal, RES_FUEL, GetResource(this, RES_FUEL));
+ SetResource(this.personal, RES_HEALTH, max(1, GetResource(this, RES_HEALTH)));
+ SetResource(this.personal, RES_ARMOR, GetResource(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, 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));
+ SetResource(this, RES_ROCKETS, GetResource(this.personal, RES_ROCKETS));
+ SetResource(this, RES_BULLETS, GetResource(this.personal, RES_BULLETS));
+ SetResource(this, RES_CELLS, GetResource(this.personal, RES_CELLS));
+ SetResource(this, RES_PLASMA, GetResource(this.personal, RES_PLASMA));
+ SetResource(this, RES_SHELLS, GetResource(this.personal, RES_SHELLS));
+ SetResource(this, RES_FUEL, GetResource(this.personal, RES_FUEL));
+ SetResource(this, RES_HEALTH, GetResource(this.personal, RES_HEALTH));
+ SetResource(this, RES_ARMOR, GetResource(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, RES_HEALTH, 1000);
+ SetResource(e, RES_HEALTH, 1000);
setorigin(e, trace_endpos);
e.effects = EF_NOMODELFLAGS;
if(f == 1)
if (IS_PLAYER(this))
{
- if(GetResourceAmount(this, RES_HEALTH) >= 1)
+ if(GetResource(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, RES_HEALTH, FRAGS_SPECTATOR);
+ SetResource(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, RES_ARMOR, autocvar_g_balance_armor_start); // was 666?!
+ SetResource(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, 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);
+ SetResource(this, RES_SHELLS, warmup_start_ammo_shells);
+ SetResource(this, RES_BULLETS, warmup_start_ammo_nails);
+ SetResource(this, RES_ROCKETS, warmup_start_ammo_rockets);
+ SetResource(this, RES_CELLS, warmup_start_ammo_cells);
+ SetResource(this, RES_PLASMA, warmup_start_ammo_plasma);
+ SetResource(this, RES_FUEL, warmup_start_ammo_fuel);
+ SetResource(this, RES_HEALTH, warmup_start_health);
+ SetResource(this, RES_ARMOR, warmup_start_armorvalue);
STAT(WEAPONS, this) = WARMUP_START_WEAPONS;
} else {
- 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);
+ SetResource(this, RES_SHELLS, start_ammo_shells);
+ SetResource(this, RES_BULLETS, start_ammo_nails);
+ SetResource(this, RES_ROCKETS, start_ammo_rockets);
+ SetResource(this, RES_CELLS, start_ammo_cells);
+ SetResource(this, RES_PLASMA, start_ammo_plasma);
+ SetResource(this, RES_FUEL, start_ammo_fuel);
+ SetResource(this, RES_HEALTH, start_health);
+ SetResource(this, RES_ARMOR, start_armorvalue);
STAT(WEAPONS, this) = start_weapons;
if (MUTATOR_CALLHOOK(ForbidRandomStartWeapons, this) == false)
{
limith = limith * limit_mod;
limita = limita * limit_mod;
- SetResourceAmount(this, RES_ARMOR, CalcRotRegen(GetResourceAmount(this, RES_ARMOR), mina, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear,
+ SetResource(this, RES_ARMOR, CalcRotRegen(GetResource(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, RES_HEALTH, CalcRotRegen(GetResourceAmount(this, RES_HEALTH), regen_health_stable, regen_health, regen_health_linear,
+ SetResource(this, RES_HEALTH, CalcRotRegen(GetResource(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, RES_HEALTH) < 1)
+ if(GetResource(this, RES_HEALTH) < 1)
{
if(this.vehicle)
vehicles_exit(this.vehicle, VHEF_RELEASE);
minf = autocvar_g_balance_fuel_regenstable;
limitf = GetResourceLimit(this, RES_FUEL);
- SetResourceAmount(this, RES_FUEL, CalcRotRegen(GetResourceAmount(this, RES_FUEL), minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear,
+ SetResource(this, RES_FUEL, CalcRotRegen(GetResource(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, 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));
+ SetResource(this, RES_ARMOR, GetResource(spectatee, RES_ARMOR));
+ SetResource(this, RES_CELLS, GetResource(spectatee, RES_CELLS));
+ SetResource(this, RES_PLASMA, GetResource(spectatee, RES_PLASMA));
+ SetResource(this, RES_SHELLS, GetResource(spectatee, RES_SHELLS));
+ SetResource(this, RES_BULLETS, GetResource(spectatee, RES_BULLETS));
+ SetResource(this, RES_ROCKETS, GetResource(spectatee, RES_ROCKETS));
+ SetResource(this, RES_FUEL, GetResource(spectatee, RES_FUEL));
this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
- SetResourceAmount(this, RES_HEALTH, GetResourceAmount(spectatee, RES_HEALTH));
+ SetResource(this, RES_HEALTH, GetResource(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, RES_FUEL) >= 0.01))
+ if ((this.items & ITEM_Jetpack.m_itemid) && ((this.items & ITEM_JetpackRegen.m_itemid) || GetResource(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, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
+ SetResource(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, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
+ SetResource(this, RES_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
- if (GetResourceAmount(this, RES_HEALTH) < 1)
+ if (GetResource(this, RES_HEALTH) < 1)
{
if (this.vehicle)
vehicles_exit(this.vehicle, VHEF_RELEASE);
}
if (this.waypointsprite_attachedforcarrier) {
- float hp = healtharmor_maxdamage(GetResourceAmount(this, RES_HEALTH), GetResourceAmount(this, RES_ARMOR), autocvar_g_balance_armor_blockpercent, DEATH_WEAPON.m_id).x;
+ float hp = healtharmor_maxdamage(GetResource(this, RES_HEALTH), GetResource(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, RES_HEALTH) <= 0)
+ if(GetResource(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, RES_HEALTH) + mon.max_health + 200, DEATH_KILL.m_id, DMG_NOWEP, mon.origin, '0 0 0');
+ Damage(mon, NULL, NULL, GetResource(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, RES_ARMOR, start_armorvalue);
+ SetResource(actor, RES_ARMOR, start_armorvalue);
actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
}
if (!(this.spawnflags & 2))
{
- SetResourceAmount(actor, RES_HEALTH, start_health);
+ SetResource(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, 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);
+ SetResource(actor, RES_SHELLS, start_ammo_shells);
+ SetResource(actor, RES_BULLETS, start_ammo_nails);
+ SetResource(actor, RES_ROCKETS, start_ammo_rockets);
+ SetResource(actor, RES_CELLS, start_ammo_cells);
+ SetResource(actor, RES_PLASMA, start_ammo_plasma);
+ SetResource(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, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
+ SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "devastator");
}
else if (it.classname == "weapon_vortex") {
- SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
+ SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "vortex");
}
else if (it.classname == "weapon_electro") {
- SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
+ SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "electro");
}
else if (it.classname == "weapon_hagar") {
- SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
+ SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "hagar");
}
else if (it.classname == "weapon_crylink") {
- SetResourceAmount(this, RES_CELLS, GetResourceAmount(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
+ SetResource(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "crylink");
}
else if (it.classname == "weapon_mortar") {
- SetResourceAmount(this, RES_ROCKETS, GetResourceAmount(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
+ SetResource(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
this.netname = cons(this.netname, "mortar");
}
else if (it.classname == "item_armor_mega")
- SetResourceAmount(this, RES_ARMOR, 100);
+ SetResource(this, RES_ARMOR, 100);
else if (it.classname == "item_health_mega")
- SetResourceAmount(this, RES_HEALTH, 200);
+ SetResource(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, RES_HEALTH), GetResourceAmount(attacker, RES_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, GetResource(attacker, RES_HEALTH), GetResource(attacker, RES_ARMOR), (IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping));
return true;
}
CHOICE_TYPEFRAGGED,
attacker.netname,
kill_count_to_target,
- GetResourceAmount(attacker, RES_HEALTH),
- GetResourceAmount(attacker, RES_ARMOR),
+ GetResource(attacker, RES_HEALTH),
+ GetResource(attacker, RES_ARMOR),
(IS_BOT_CLIENT(attacker) ? -1 : CS(attacker).ping)
);
}
CHOICE_FRAGGED,
attacker.netname,
kill_count_to_target,
- GetResourceAmount(attacker, RES_HEALTH),
- GetResourceAmount(attacker, RES_ARMOR),
+ GetResource(attacker, RES_HEALTH),
+ GetResource(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, RES_HEALTH, ((frozen_type == FROZEN_TEMP_DYING) ? targ_maxhealth : 1));
+ SetResource(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, RES_HEALTH, ((IS_PLAYER(targ)) ? start_health : targ.max_health));
+ SetResource(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, RES_ARMOR, 0);
+ SetResource(targ, RES_ARMOR, 0);
targ.spawnshieldtime = 0;
- SetResourceAmount(targ, RES_HEALTH, 0.9); // this is < 1
+ SetResource(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, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, mirrordamage);
+ vector v = healtharmor_applydamage(GetResource(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, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ vector v = healtharmor_applydamage(GetResource(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, RES_HEALTH, autocvar_g_frozen_revive_falldamage_health);
+ SetResource(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);
void GrapplingHook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(GetResourceAmount(this, RES_HEALTH) <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
TakeResource(this, RES_HEALTH, damage);
- if (GetResourceAmount(this, RES_HEALTH) <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
{
if(attacker != this.realowner)
{
missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION;
- SetResourceAmount(missile, RES_HEALTH, autocvar_g_balance_grapplehook_health);
+ SetResource(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, RES_HEALTH, -2342);
+ SetResource(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, RES_HEALTH) != 2342)
+ if(GetResource(it, RES_HEALTH) != 2342)
{
- SetResourceAmount(it, RES_HEALTH, 2342);
+ SetResource(it, RES_HEALTH, 2342);
CS(it).impulse = 0;
msg_entity = it;
case "%": replacement = "%"; break;
case "\\":replacement = "\\"; break;
case "n": replacement = "\n"; break;
- case "a": replacement = ftos(floor(GetResourceAmount(this, RES_ARMOR))); break;
- case "h": replacement = ftos(floor(GetResourceAmount(this, RES_HEALTH))); break;
+ case "a": replacement = ftos(floor(GetResource(this, RES_ARMOR))); break;
+ case "h": replacement = ftos(floor(GetResource(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, RES_SHELLS, cvar(
+ SetResource(random_start_ammo, RES_SHELLS, cvar(
"g_random_start_shells"));
- SetResourceAmount(random_start_ammo, RES_BULLETS, cvar(
+ SetResource(random_start_ammo, RES_BULLETS, cvar(
"g_random_start_bullets"));
- SetResourceAmount(random_start_ammo, RES_ROCKETS,
+ SetResource(random_start_ammo, RES_ROCKETS,
cvar("g_random_start_rockets"));
- SetResourceAmount(random_start_ammo, RES_CELLS, cvar(
+ SetResource(random_start_ammo, RES_CELLS, cvar(
"g_random_start_cells"));
- SetResourceAmount(random_start_ammo, RES_PLASMA, cvar(
+ SetResource(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, 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)));
+ SetResource(random_start_ammo, RES_SHELLS, max(0,
+ GetResource(random_start_ammo, RES_SHELLS)));
+ SetResource(random_start_ammo, RES_BULLETS, max(0,
+ GetResource(random_start_ammo, RES_BULLETS)));
+ SetResource(random_start_ammo, RES_ROCKETS, max(0,
+ GetResource(random_start_ammo, RES_ROCKETS)));
+ SetResource(random_start_ammo, RES_CELLS, max(0,
+ GetResource(random_start_ammo, RES_CELLS)));
+ SetResource(random_start_ammo, RES_PLASMA, max(0,
+ GetResource(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);
/** 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) \
+#define EV_SetResource(i, o) \
/** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \
/** resource type */ i(int, MUTATOR_ARGV_1_int) \
/**/ o(int, MUTATOR_ARGV_1_int) \
/** amount */ i(float, MUTATOR_ARGV_2_float) \
/**/ o(float, MUTATOR_ARGV_2_float) \
/**/
-MUTATOR_HOOKABLE(SetResourceAmount, EV_SetResourceAmount);
+MUTATOR_HOOKABLE(SetResource, EV_SetResource);
/** 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
clone.dphitcontentsmask = this.dphitcontentsmask;
clone.death_time = this.death_time;
clone.pain_finished = this.pain_finished;
- SetResourceAmount(clone, RES_HEALTH, GetResourceAmount(this, RES_HEALTH));
- SetResourceAmount(clone, RES_ARMOR, GetResourceAmount(this, RES_ARMOR));
+ SetResource(clone, RES_HEALTH, GetResource(this, RES_HEALTH));
+ SetResource(clone, RES_ARMOR, GetResource(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, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ v = healtharmor_applydamage(GetResource(this, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
take = v.x;
save = v.y;
this.dmg_take = this.dmg_take + take;//max(take - 10, 0);
this.dmg_inflictor = inflictor;
- if (GetResourceAmount(this, RES_HEALTH) <= -autocvar_sv_gibhealth && this.alpha >= 0)
+ if (GetResource(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, RES_HEALTH), 0);
- da = max(GetResourceAmount(this, RES_ARMOR), 0);
+ dh = max(GetResource(this, RES_HEALTH), 0);
+ da = max(GetResource(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, RES_ARMOR), autocvar_g_balance_armor_blockpercent, deathtype, damage);
+ v = healtharmor_applydamage(GetResource(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, RES_HEALTH));
- save = bound(0, M_ARGV(5, float), GetResourceAmount(this, RES_ARMOR));
+ take = bound(0, M_ARGV(4, float), GetResource(this, RES_HEALTH));
+ save = bound(0, M_ARGV(5, float), GetResource(this, RES_ARMOR));
excess = max(0, damage - take - save);
if(sound_allowed(MSG_BROADCAST, attacker))
animdecide_setaction(this, ANIMACTION_PAIN2, true);
}
}
- float myhp = GetResourceAmount(this, RES_HEALTH);
+ float myhp = GetResource(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, RES_HEALTH) >= 1)
+ if(IS_BOT_CLIENT(this) && GetResource(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, RES_HEALTH), 0);
- da = da - max(GetResourceAmount(this, RES_ARMOR), 0);
+ dh = dh - max(GetResource(this, RES_HEALTH), 0);
+ da = da - max(GetResource(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, RES_HEALTH) < 1)
+ if (GetResource(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, RES_HEALTH) >= 1 || !(IS_PLAYER(this) || this.classname == "body"))
+ if(GetResource(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, RES_HEALTH) <= 0 || GetResourceAmount(targ, RES_HEALTH) >= limit)
+ if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, limit);
// 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, RES_HEALTH, autocvar_g_balance_portal_health);
- SetResourceAmount(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
+ SetResource(teleporter, RES_HEALTH, autocvar_g_balance_portal_health);
+ SetResource(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
return 1;
}
if(IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(this.aiment))
return;
TakeResource(this, RES_HEALTH, damage);
- if(GetResourceAmount(this, RES_HEALTH) < 0)
+ if(GetResource(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, RES_HEALTH, autocvar_g_balance_portal_health);
+ SetResource(portal, RES_HEALTH, autocvar_g_balance_portal_health);
setmodel(portal, MDL_PORTAL);
portal.savemodelindex = portal.modelindex;
setcefc(portal, Portal_Customize);
return limit;
}
-float GetResourceAmount(entity e, int res_type)
+float GetResource(entity e, int res_type)
{
return e.(GetResourceField(res_type));
}
-void SetResourceAmount(entity e, int res_type, float amount)
+void SetResource(entity e, int res_type, float amount)
{
- bool forbid = MUTATOR_CALLHOOK(SetResourceAmount, e, res_type, amount);
+ bool forbid = MUTATOR_CALLHOOK(SetResource, e, res_type, amount);
if (forbid)
{
return;
{
return;
}
- SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) + amount);
+ SetResource(receiver, res_type, GetResource(receiver, res_type) + amount);
switch (res_type)
{
case RES_HEALTH:
{
return;
}
- float current_amount = GetResourceAmount(receiver, res_type);
+ float current_amount = GetResource(receiver, res_type);
if (current_amount + amount > limit && limit != RES_LIMIT_NONE)
{
amount = limit - current_amount;
{
return;
}
- SetResourceAmount(receiver, res_type, GetResourceAmount(receiver, res_type) - amount);
+ SetResource(receiver, res_type, GetResource(receiver, res_type) - amount);
}
void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
{
return;
}
- float current_amount = GetResourceAmount(receiver, res_type);
+ float current_amount = GetResource(receiver, res_type);
if (current_amount - amount < -limit)
{
amount = -limit + current_amount;
/// \param[in] e Entity to check.
/// \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 res_type);
+float GetResource(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] 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 res_type, float amount);
+void SetResource(entity e, int res_type, float amount);
/// \brief Gives an entity some resource.
/// \param[in,out] receiver Entity to give resource to.
void test_weapons_hurt(entity this)
{
- EXPECT_NE(100, GetResourceAmount(this, RES_HEALTH));
+ EXPECT_NE(100, GetResource(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 != RES_NONE) && !GetResourceAmount(this, wpn.ammo_type))
+ if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type))
{
switch (wpn.ammo_type)
{
- 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;
+ case RES_SHELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break;
+ case RES_BULLETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break;
+ case RES_ROCKETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break;
+ case RES_CELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break;
+ case RES_PLASMA: SetResource(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break;
+ case RES_FUEL: SetResource(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break;
}
}
GiveResource(own, ammotype, own.(weaponentity).(weapon_load[i]));
own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading
}
- SetResourceAmount(wep, ammotype, 0);
+ SetResource(wep, ammotype, 0);
}
else if(doreduce)
{
own.(weaponentity).(weapon_load[i]) = -1; // schedule the weapon for reloading
}
- float ownderammo = GetResourceAmount(own, ammotype);
- float thisammo = min(ownderammo, GetResourceAmount(wep, ammotype));
- SetResourceAmount(wep, ammotype, thisammo);
- SetResourceAmount(own, ammotype, ownderammo - thisammo);
+ float ownderammo = GetResource(own, ammotype);
+ float thisammo = min(ownderammo, GetResource(wep, ammotype));
+ SetResource(wep, ammotype, thisammo);
+ SetResource(own, ammotype, ownderammo - thisammo);
return thisammo;
}
entity this = actor.(weaponentity);
if (frametime) this.weapon_frametime = frametime;
- if (!this || GetResourceAmount(actor, RES_HEALTH) < 1) return; // Dead player can't use weapons and injure impulse commands
+ if (!this || GetResource(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);
}
else if (wep.ammo_type != RES_NONE)
{
- float ammo = GetResourceAmount(actor, wep.ammo_type);
+ float ammo = GetResource(actor, wep.ammo_type);
if (ammo < ammo_use)
{
backtrace(sprintf(
ammo
));
}
- SetResourceAmount(actor, wep.ammo_type, ammo - ammo_use);
+ SetResource(actor, wep.ammo_type, ammo - ammo_use);
}
}
else
{
// make sure we don't add more ammo than we have
- float ammo = GetResourceAmount(actor, wpn.ammo_type);
+ float ammo = GetResource(actor, wpn.ammo_type);
float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, ammo);
w_ent.clip_load += load;
- SetResourceAmount(actor, wpn.ammo_type, ammo - load);
+ SetResource(actor, wpn.ammo_type, ammo - load);
}
w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load;
// no ammo, so nothing to load
if (e.ammo_type != RES_NONE)
{
- if (!GetResourceAmount(actor, e.ammo_type) && this.reload_ammo_min)
+ if (!GetResource(actor, e.ammo_type) && this.reload_ammo_min)
{
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{