Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_resources.qh File Reference

Header file that describes the resource system. More...

Include dependency graph for sv_resources.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int GetAmmoConsumption (entity wpn)
 Returns ammo consumed per shot by the primary/default fire mode.
float GetResource (entity e, Resource res_type)
 Returns the current amount of resource the given entity has.
float GetResourceLimit (entity e, Resource res_type)
 Returns the maximum amount of the given resource.
void GiveResource (entity receiver, Resource res_type, float amount)
 Gives an entity some resource.
void GiveResourceWithLimit (entity receiver, Resource res_type, float amount, float limit)
 Gives an entity some resource but not more than a limit.
void SetResource (entity e, Resource res_type, float amount)
 Sets the current amount of resource the given entity will have but limited to the max amount allowed for the resource type.
bool SetResourceExplicit (entity e, Resource res_type, float amount)
 Sets the resource amount of an entity without calling any hooks.
void TakeResource (entity receiver, Resource res_type, float amount)
 Takes an entity some resource.
void TakeResourceWithLimit (entity receiver, Resource res_type, float amount, float limit)
 Takes an entity some resource but not less than a limit.

Variables

int autocvar_g_balance_armor_limit
float autocvar_g_balance_armor_regen
float autocvar_g_balance_armor_regenlinear
int autocvar_g_balance_armor_regenstable
float autocvar_g_balance_armor_rot
float autocvar_g_balance_armor_rotlinear
int autocvar_g_balance_armor_rotstable
float autocvar_g_balance_fuel_limit
float autocvar_g_balance_fuel_regen
float autocvar_g_balance_fuel_regenlinear
int autocvar_g_balance_fuel_regenstable
float autocvar_g_balance_fuel_rot
float autocvar_g_balance_fuel_rotlinear
int autocvar_g_balance_fuel_rotstable
float autocvar_g_balance_health_limit
float autocvar_g_balance_health_regen
float autocvar_g_balance_health_regenlinear
float autocvar_g_balance_health_regenstable
float autocvar_g_balance_health_rot
float autocvar_g_balance_health_rotlinear
float autocvar_g_balance_health_rotstable
float autocvar_g_balance_pause_armor_rot
float autocvar_g_balance_pause_fuel_regen
float autocvar_g_balance_pause_fuel_rot
float autocvar_g_balance_pause_health_regen
float autocvar_g_balance_pause_health_rot

Detailed Description

Header file that describes the resource system.

Author
Lyberta

Definition in file sv_resources.qh.

Function Documentation

◆ GetAmmoConsumption()

int GetAmmoConsumption ( entity wpn)

Returns ammo consumed per shot by the primary/default fire mode.

Parameters
[in]wpnWeapon entity
Returns
value is undefined if wpn entity isn't a weapon.

Definition at line 231 of file sv_resources.qc.

232{
233 if (wpn.ammo_type == RES_NONE) return 0;
234 switch (wpn)
235 {
236 case WEP_ARC: return WEP_CVAR(WEP_ARC, beam_ammo);
237 case WEP_DEVASTATOR: return WEP_CVAR(WEP_DEVASTATOR, ammo);
238 case WEP_MACHINEGUN: return WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
239 case WEP_MINE_LAYER: return WEP_CVAR(WEP_MINE_LAYER, ammo);
240 case WEP_SEEKER: return WEP_CVAR(WEP_SEEKER, tag_ammo);
241 default: return WEP_CVAR_PRI(wpn, ammo);
242 }
243}
float ammo
Definition sv_turrets.qh:43
#define WEP_CVAR_PRI(wep, name)
Definition all.qh:322
#define WEP_CVAR(wep, name)
Definition all.qh:321

References ammo, entity(), WEP_CVAR, and WEP_CVAR_PRI.

Referenced by weapon_defaultspawnfunc().

◆ GetResource()

float GetResource ( entity e,
Resource res_type )

Returns the current amount of resource the given entity has.

Parameters
[in]eEntity to check.
[in]res_typeType of the resource (a RES_* constant).
Returns
Current amount of resource the given entity has.

Definition at line 10 of file cl_resources.qc.

11{
12 return e.(GetResourceField(res_type));
13}

References entity().

Referenced by ammo_bullets_init(), ammo_cells_init(), ammo_fuel_init(), ammo_pickupevalfunc(), ammo_rockets_init(), ammo_shells_init(), ammo_vaporizercells_init(), assault_decreaser_sprite_visible(), assault_objective_decrease_use(), assault_wall_think(), basketball_touch(), bot_cmd_eval(), bumblebee_pilot_frame(), button_damage(), button_reset(), button_return(), CA_PreventStalemate(), CheatImpulse(), ClientCommand_kill(), CommonCommand_editmob(), CopyBody(), cpicon_damage(), cpicon_draw(), cpicon_send(), ctf_CheckFlagReturn(), ctf_FlagcarrierWaypoints(), ctf_Handle_Drop(), Damage(), DebugText3d::DebugText3d_draw2d(), destructible_heal(), door_damage(), door_init_shared(), door_trigger_touch(), Draw_ShowNames(), Draw_ShowNames_All(), Draw_WaypointSprite(), Ent_WaypointSprite(), ENTCS_PROP_RESOURCE(), ewheel_draw(), football_touch(), formatmessage(), frag_centermessage_override(), freezetag_count_alive_players(), freezetag_LastPlayerForTeam(), func_breakable_behave_restore(), func_breakable_colormod(), func_breakable_damage(), func_breakable_setup(), generator_draw(), generator_send(), GiveRandomWeapons(), GiveResource(), GiveResourceValue(), GiveResourceWithLimit(), GrapplingHook_Damage(), havocbot_chooseenemy(), havocbot_goalrating_ctf_enemyflag(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_ft_freeplayers(), havocbot_goalrating_item_can_be_left_to_teammate(), havocbot_movetogoal(), healtharmor_pickupevalfunc(), hk_is_valid_target(), if(), instagib_ammocheck(), instagib_countdown(), Invasion_CheckWinner(), item_armorbig_init(), item_armormedium_init(), item_armormega_init(), item_armorsmall_init(), Item_GiveAmmoTo(), item_healthbig_init(), item_healthmedium_init(), item_healthmega_init(), item_healthsmall_init(), LinkDoors(), lms_RemovePlayer(), load_unit_settings(), M_Golem_Attack_Lightning_Damage(), M_Mage_Attack_Spike_Think(), M_Mage_Defend_Heal(), M_Mage_Defend_Heal_Check(), M_Spider_Attack_Web_Explode(), M_Zombie_Attack(), M_Zombie_Attack_Leap_Touch(), M_Zombie_Defend_Block_End(), MapVote_Tick(), Monster_Attack_Leap_Check(), Monster_Damage(), Monster_Dead_Damage(), Monster_Enemy_Check(), Monster_Heal(), Monster_Spawn_Setup(), Monster_Think(), Monster_ValidTarget(), multi_eventdamage(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nade_ammo_touch(), nade_damage(), nade_darkness_think(), nade_heal_touch(), nade_ice_think(), nade_touch(), NET_HANDLE(), NET_HANDLE(), NET_HANDLE(), Obituary(), ons_ControlPoint_Icon_BuildThink(), ons_ControlPoint_Icon_Damage(), ons_ControlPoint_Icon_Heal(), ons_ControlPoint_Icon_Spawn(), ons_ControlPoint_Icon_Think(), ons_ControlPoint_UpdateSprite(), ons_GeneratorDamage(), ons_GeneratorHeal(), ons_GeneratorReset(), ons_GeneratorSetup(), Onslaught_count_generators(), plat_center_touch(), plat_outside_touch(), player_regen(), PlayerCorpseDamage(), PlayerDamage(), PlayerHeal(), PlayerHealth(), Portal_Damage(), powerup_jetpack_init(), powerups_DropItem_Think(), PutObserverInServer(), raptor_flare_damage(), readplayerstartcvars(), RotRegen(), spawnfunc(), spawnfunc(), spawnfunc(), SpectateCopy(), StartItem(), TakeResource(), TakeResourceWithLimit(), target_objective_decrease_activate(), target_objective_spawn_evalfunc(), tdeath(), test_weapons_hurt(), toss_nade(), turret_damage(), turret_draw(), turret_draw2d(), turret_heal(), turret_initialize(), turret_projectile_damage(), turret_send(), turret_validate_target(), vehicles_damage(), vehicles_heal(), vehicles_painframe(), vehicles_projectile_damage(), vehicles_regen(), vehicles_regen_resource(), W_Arc_Beam_Think(), W_Arc_Bolt_Damage(), W_DecreaseAmmo(), W_Devastator_Damage(), W_Devastator_DoRemoteExplode(), W_Devastator_Explode(), W_Electro_Orb_Damage(), W_Electro_Orb_Stick(), W_Fireball_Damage(), W_Fireball_Explode(), W_Hagar_Attack2_Load(), W_Hagar_Damage(), W_Hook_Damage(), W_MineLayer_Damage(), W_MineLayer_Stick(), W_Mortar_Grenade_Damage(), W_OverkillRocketPropelledChainsaw_Damage(), W_Reload(), W_ReloadedAndReady(), W_Seeker_Missile_Damage(), W_Seeker_Tag_Damage(), W_Seeker_Vollycontroller_Think(), W_ThrowNewWeapon(), W_WeaponFrame(), walker_draw(), walker_rocket_damage(), WaypointSprite_AttachCarrier(), WaypointSprite_SendEntity(), WaypointSprite_UpdateHealth(), and weapon_defaultspawnfunc().

◆ GetResourceLimit()

float GetResourceLimit ( entity e,
Resource res_type )

Returns the maximum amount of the given resource.

Parameters
[in]eEntity to check.
[in]res_typeType of the resource (a RES_* constant).
Returns
Maximum amount of the given resource.

Definition at line 12 of file sv_resources.qc.

13{
14 if(!IS_PLAYER(e))
15 return RES_LIMIT_NONE; // no limits on non-players
16
17 float limit;
18 // TODO: registry handles
19 switch (res_type)
20 {
21 case RES_HEALTH:
22 {
24 break;
25 }
26 case RES_ARMOR:
27 {
29 break;
30 }
31 case RES_SHELLS:
32 {
34 break;
35 }
36 case RES_BULLETS:
37 {
39 break;
40 }
41 case RES_ROCKETS:
42 {
44 break;
45 }
46 case RES_CELLS:
47 {
49 break;
50 }
51 case RES_FUEL:
52 {
54 break;
55 }
56 default:
57 {
58 error("GetResourceLimit: Invalid resource type.");
59 return 0;
60 }
61 }
62 MUTATOR_CALLHOOK(GetResourceLimit, e, res_type, limit);
63 limit = M_ARGV(9, float);
64 if (limit > RES_AMOUNT_HARD_LIMIT)
65 {
67 }
68 return limit;
69}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
int autocvar_g_pickup_rockets_max
Definition ammo.qh:116
int autocvar_g_pickup_shells_max
Definition ammo.qh:44
int autocvar_g_pickup_cells_max
Definition ammo.qh:152
int autocvar_g_pickup_nails_max
Definition ammo.qh:80
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_PLAYER(s)
Definition player.qh:243
RES_ARMOR
Definition ent_cs.qc:130
#define error
Definition pre.qh:6
const int RES_LIMIT_NONE
Definition resources.qh:60
const int RES_AMOUNT_HARD_LIMIT
Unconditional maximum amount of resources the entity can have.
Definition resources.qh:59
float GetResourceLimit(entity e, Resource res_type)
Returns the maximum amount of the given resource.
float autocvar_g_balance_fuel_limit
int autocvar_g_balance_armor_limit
float autocvar_g_balance_health_limit

References autocvar_g_balance_armor_limit, autocvar_g_balance_fuel_limit, autocvar_g_balance_health_limit, autocvar_g_pickup_cells_max, autocvar_g_pickup_nails_max, autocvar_g_pickup_rockets_max, autocvar_g_pickup_shells_max, entity(), error, GetResourceLimit(), IS_PLAYER, M_ARGV, MUTATOR_CALLHOOK, RES_AMOUNT_HARD_LIMIT, RES_ARMOR, and RES_LIMIT_NONE.

Referenced by ammo_pickupevalfunc(), GetResourceLimit(), MUTATOR_HOOKABLE(), RotRegen(), and SetResource().

◆ GiveResource()

void GiveResource ( entity receiver,
Resource res_type,
float amount )

Gives an entity some resource.

Parameters
[in,out]receiverEntity to give resource to.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to give.
Returns
No return.

Definition at line 115 of file sv_resources.qc.

116{
117 if (amount <= 0)
118 {
119 return;
120 }
121 bool forbid = MUTATOR_CALLHOOK(GiveResource, receiver, res_type, amount);
122 if (forbid)
123 {
124 return;
125 }
126 res_type = M_ARGV(8, entity);
127 amount = M_ARGV(9, float);
128 if (amount <= 0)
129 {
130 return;
131 }
132 SetResource(receiver, res_type, GetResource(receiver, res_type) + amount);
133 // TODO: registry handles
134 switch (res_type)
135 {
136 case RES_HEALTH:
137 {
138 receiver.pauserothealth_finished =
139 max(receiver.pauserothealth_finished, time +
141 return;
142 }
143 case RES_ARMOR:
144 {
145 receiver.pauserotarmor_finished =
146 max(receiver.pauserotarmor_finished, time +
148 return;
149 }
150 case RES_FUEL:
151 {
152 receiver.pauserotfuel_finished = max(receiver.pauserotfuel_finished,
154 return;
155 }
156 }
157}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float time
float max(float f,...)
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
void GiveResource(entity receiver, Resource res_type, float amount)
Gives an entity some resource.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
float autocvar_g_balance_pause_armor_rot
float autocvar_g_balance_pause_health_rot
float autocvar_g_balance_pause_fuel_rot

References autocvar_g_balance_pause_armor_rot, autocvar_g_balance_pause_fuel_rot, autocvar_g_balance_pause_health_rot, entity(), GetResource(), GiveResource(), M_ARGV, max(), MUTATOR_CALLHOOK, RES_ARMOR, SetResource(), and time.

Referenced by GiveRandomWeapons(), GiveResource(), GiveResourceWithLimit(), Monster_Miniboss_Setup(), MUTATOR_HOOKABLE(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), NIX_GiveCurrentWeapon(), ons_ControlPoint_Icon_BuildThink(), and W_ThrowNewWeapon().

◆ GiveResourceWithLimit()

void GiveResourceWithLimit ( entity receiver,
Resource res_type,
float amount,
float limit )

Gives an entity some resource but not more than a limit.

Parameters
[in,out]receiverEntity to give resource to.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to give.
[in]limitLimit of resources to give.
Returns
No return.

Definition at line 159 of file sv_resources.qc.

160{
161 if (amount <= 0)
162 {
163 return;
164 }
165 bool forbid = MUTATOR_CALLHOOK(GiveResourceWithLimit, receiver, res_type, amount, limit);
166 if (forbid)
167 {
168 return;
169 }
170 res_type = M_ARGV(8, entity);
171 amount = M_ARGV(9, float);
172 limit = M_ARGV(10, float);
173 if (amount <= 0)
174 {
175 return;
176 }
177 float current_amount = GetResource(receiver, res_type);
178 if (current_amount + amount > limit && limit != RES_LIMIT_NONE)
179 {
180 amount = limit - current_amount;
181 }
182 GiveResource(receiver, res_type, amount);
183}
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.

References entity(), GetResource(), GiveResource(), GiveResourceWithLimit(), M_ARGV, MUTATOR_CALLHOOK, and RES_LIMIT_NONE.

Referenced by bumblebee_pilot_frame(), destructible_heal(), GiveResourceWithLimit(), Item_GiveAmmoTo(), M_Mage_Defend_Heal(), Monster_Heal(), MUTATOR_HOOKABLE(), nade_heal_touch(), ons_ControlPoint_Icon_Heal(), ons_ControlPoint_Icon_Think(), ons_GeneratorHeal(), PlayerHeal(), turret_heal(), vehicles_heal(), and W_Arc_Beam_Think().

◆ SetResource()

void SetResource ( entity e,
Resource res_type,
float amount )

Sets the current amount of resource the given entity will have but limited to the max amount allowed for the resource type.

Parameters
[in,out]eEntity to adjust.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to set.
Returns
No return.

Sets the current amount of resource the given entity will have but limited to the max amount allowed for the resource type.

Parameters
[in,out]eEntity to adjust.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to set.
Returns
No return.

Definition at line 26 of file cl_resources.qc.

27{
28 SetResourceExplicit(e, res_type, amount);
29}
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.

References entity(), GetResourceLimit(), M_ARGV, MUTATOR_CALLHOOK, RES_LIMIT_NONE, SetResource(), and SetResourceExplicit().

Referenced by DebugText3d::DebugText3d(), CheatImpulse(), freezetag_Freeze(), freezetag_Unfreeze(), GiveResource(), GiveWarmupResources(), MUTATOR_HOOKABLE(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nade_damage(), nade_spawn_SetSpawnHealth(), NIX_GiveCurrentWeapon(), PutPlayerInServer(), readplayerstartcvars(), REGISTER_MUTATOR(), RotRegen(), SetResource(), TakeResource(), target_init_use(), toss_nade(), vehicles_regen_resource(), W_Arc_Beam_Think(), W_DecreaseAmmo(), W_ReloadedAndReady(), W_ThrowNewWeapon(), and weapon_defaultspawnfunc().

◆ SetResourceExplicit()

bool SetResourceExplicit ( entity e,
Resource res_type,
float amount )

Sets the resource amount of an entity without calling any hooks.

Parameters
[in,out]eEntity to adjust.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to set.
Returns
Boolean for whether the ammo amount was changed

Definition at line 15 of file cl_resources.qc.

16{
17 .float res_field = GetResourceField(res_type);
18 if (e.(res_field) != amount)
19 {
20 e.(res_field) = amount;
21 return true;
22 }
23 return false;
24}
float GetResourceField(Resource res_type)
Converts resource type (a RES_* constant) to entity field.
Definition resources.qc:11

References entity(), and GetResourceField().

Referenced by ammo_bullets_init(), ammo_cells_init(), ammo_fuel_init(), ammo_rockets_init(), ammo_shells_init(), ammo_vaporizercells_init(), assault_objective_decrease_use(), assault_objective_reset(), assault_objective_use(), button_fire(), button_reset(), CheatCommand(), CopyBody(), ctf_FlagDamage(), ctf_FlagSetup(), ctf_FlagThink(), ctf_Handle_Drop(), ctf_Handle_Pickup(), ctf_RespawnFlag(), Damage(), door_damage(), door_go_down(), door_rotating_go_down(), Draw_ShowNames_All(), Draw_WaypointSprite(), electro_orb_setup(), Ent_WaypointSprite(), fd_secret_done(), fd_secret_use(), FireGrapplingHook(), FixIntermissionClient(), ft_RemovePlayer(), func_breakable_behave_destroyed(), func_breakable_behave_restore(), func_breakable_setup(), GiveResourceValue(), item_armorbig_init(), item_armormedium_init(), item_armormega_init(), item_armorsmall_init(), item_healthbig_init(), item_healthmedium_init(), item_healthmega_init(), item_healthsmall_init(), LinkDoors(), load_unit_settings(), M_Golem_Attack_Lightning(), M_Mage_Defend_Shield(), M_Spider_Attack_Web(), M_Zombie_Defend_Block(), M_Zombie_Defend_Block_End(), MapVote_Tick(), Monster_Dead_Fade(), Monster_Reset(), Monster_Spawn_Setup(), multi_reset(), multi_wait(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), NET_HANDLE(), NET_HANDLE(), NET_HANDLE(), ons_ControlPoint_Icon_BuildThink(), ons_ControlPoint_Icon_Spawn(), ons_GeneratorReset(), ons_GeneratorSetup(), orb_setup(), Portal_Spawn(), Portal_TeleportPlayer(), powerup_jetpack_init(), powerups_DropItem(), PutObserverInServer(), secret_reset(), SetResource(), spawnfunc(), spawnfunc(), SpectateCopy(), turret_construct(), turret_die(), turret_initialize(), turret_projectile(), turret_respawn(), vehicles_projectile(), W_Arc_Attack_Bolt(), W_Devastator_Attack(), W_Electro_Attack_Orb(), W_Electro_Orb_Stick(), W_Fireball_Attack1(), W_Hagar_Attack(), W_Hagar_Attack2(), W_Hagar_Attack2_Load_Release(), W_Hook_Attack2(), W_Hook_Damage(), W_MineLayer_Attack(), W_MineLayer_Stick(), W_Mortar_Attack(), W_Mortar_Attack2(), W_OverkillRocketPropelledChainsaw_Attack(), W_Seeker_Fire_Missile(), W_Seeker_Fire_Tag(), walker_fire_rocket(), and WaypointSprite_UpdateHealth().

◆ TakeResource()

void TakeResource ( entity receiver,
Resource res_type,
float amount )

Takes an entity some resource.

Parameters
[in,out]receiverEntity to take resource from.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to take.
Returns
No return.

Definition at line 31 of file cl_resources.qc.

32{
33 if (amount == 0)
34 {
35 return;
36 }
37 SetResource(receiver, res_type, GetResource(receiver, res_type) - amount);
38}
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.

References entity(), GetResource(), M_ARGV, MUTATOR_CALLHOOK, SetResource(), and TakeResource().

Referenced by assault_objective_decrease_use(), button_damage(), ctf_FlagDamage(), ctf_FlagThink(), door_damage(), func_breakable_damage(), GrapplingHook_Damage(), M_Golem_Attack_Lightning_Damage(), Monster_Damage(), Monster_Dead_Damage(), multi_eventdamage(), MUTATOR_HOOKABLE(), MUTATOR_HOOKFUNCTION(), ons_ControlPoint_Icon_Damage(), ons_ControlPoint_Icon_Think(), ons_GeneratorDamage(), PlayerCorpseDamage(), PlayerDamage(), PM_jetpack(), Portal_Damage(), raptor_flare_damage(), TakeResource(), TakeResourceWithLimit(), turret_damage(), turret_projectile_damage(), vehicles_damage(), vehicles_projectile_damage(), W_Arc_Bolt_Damage(), W_Devastator_Damage(), W_Electro_Orb_Damage(), W_Fireball_Damage(), W_Hagar_Damage(), W_MineLayer_Damage(), W_Mortar_Grenade_Damage(), W_OverkillRocketPropelledChainsaw_Damage(), W_Seeker_Missile_Damage(), W_Seeker_Tag_Damage(), and walker_rocket_damage().

◆ TakeResourceWithLimit()

void TakeResourceWithLimit ( entity receiver,
Resource res_type,
float amount,
float limit )

Takes an entity some resource but not less than a limit.

Parameters
[in,out]receiverEntity to take resource from.
[in]res_typeType of the resource (a RES_* constant).
[in]amountAmount of resource to take.
[in]limitLimit of resources to take.
Returns
No return.

Definition at line 40 of file cl_resources.qc.

41{
42 if (amount == 0)
43 {
44 return;
45 }
46 float current_amount = GetResource(receiver, res_type);
47 if (current_amount - amount < limit)
48 {
49 amount = limit + current_amount;
50 }
51 TakeResource(receiver, res_type, amount);
52}
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.

References entity(), GetResource(), M_ARGV, MUTATOR_CALLHOOK, TakeResource(), and TakeResourceWithLimit().

Referenced by Item_GiveAmmoTo(), MUTATOR_HOOKABLE(), and TakeResourceWithLimit().

Variable Documentation

◆ autocvar_g_balance_armor_limit

int autocvar_g_balance_armor_limit

Definition at line 12 of file sv_resources.qh.

Referenced by GetResourceLimit().

◆ autocvar_g_balance_armor_regen

float autocvar_g_balance_armor_regen

Definition at line 14 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_armor_regenlinear

float autocvar_g_balance_armor_regenlinear

Definition at line 15 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_armor_regenstable

int autocvar_g_balance_armor_regenstable

Definition at line 16 of file sv_resources.qh.

Referenced by M_Mage_Defend_Heal(), M_Mage_Defend_Heal_Check(), and player_regen().

◆ autocvar_g_balance_armor_rot

float autocvar_g_balance_armor_rot

Definition at line 17 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_armor_rotlinear

float autocvar_g_balance_armor_rotlinear

Definition at line 18 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_armor_rotstable

int autocvar_g_balance_armor_rotstable

Definition at line 19 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_limit

float autocvar_g_balance_fuel_limit

Definition at line 13 of file sv_resources.qh.

Referenced by GetResourceLimit().

◆ autocvar_g_balance_fuel_regen

float autocvar_g_balance_fuel_regen

Definition at line 20 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_regenlinear

float autocvar_g_balance_fuel_regenlinear

Definition at line 21 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_regenstable

int autocvar_g_balance_fuel_regenstable

Definition at line 22 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_rot

float autocvar_g_balance_fuel_rot

Definition at line 23 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_rotlinear

float autocvar_g_balance_fuel_rotlinear

Definition at line 24 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_fuel_rotstable

int autocvar_g_balance_fuel_rotstable

Definition at line 25 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_health_limit

float autocvar_g_balance_health_limit

Definition at line 11 of file sv_resources.qh.

Referenced by GetResourceLimit().

◆ autocvar_g_balance_health_regen

float autocvar_g_balance_health_regen

Definition at line 26 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_health_regenlinear

float autocvar_g_balance_health_regenlinear

Definition at line 27 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_health_regenstable

float autocvar_g_balance_health_regenstable

◆ autocvar_g_balance_health_rot

float autocvar_g_balance_health_rot

Definition at line 29 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_health_rotlinear

float autocvar_g_balance_health_rotlinear

Definition at line 30 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_health_rotstable

float autocvar_g_balance_health_rotstable

Definition at line 31 of file sv_resources.qh.

Referenced by player_regen().

◆ autocvar_g_balance_pause_armor_rot

float autocvar_g_balance_pause_armor_rot

Definition at line 32 of file sv_resources.qh.

Referenced by GiveItems(), GiveResource(), target_init_use(), and W_Arc_Beam_Think().

◆ autocvar_g_balance_pause_fuel_regen

float autocvar_g_balance_pause_fuel_regen

Definition at line 33 of file sv_resources.qh.

Referenced by GiveItems(), and PM_jetpack().

◆ autocvar_g_balance_pause_fuel_rot

float autocvar_g_balance_pause_fuel_rot

Definition at line 34 of file sv_resources.qh.

Referenced by GiveItems(), and GiveResource().

◆ autocvar_g_balance_pause_health_regen

float autocvar_g_balance_pause_health_regen

◆ autocvar_g_balance_pause_health_rot

float autocvar_g_balance_pause_health_rot

Definition at line 36 of file sv_resources.qh.

Referenced by GiveItems(), GiveResource(), and target_init_use().