Xonotic
cl_resources.qc File Reference

Source file that contains implementation of the resource system. More...

+ Include dependency graph for cl_resources.qc:

Go to the source code of this file.

Functions

float GetResource (entity e, Resource res_type)
 Returns the current amount of resource the given entity has. More...
 
void SetResource (entity e, Resource res_type, float amount)
 Sets the current amount of resource the given entity will have. More...
 
bool SetResourceExplicit (entity e, Resource res_type, float amount)
 Sets the resource amount of an entity without calling any hooks. More...
 
void TakeResource (entity receiver, Resource res_type, float amount)
 Takes an entity some resource. More...
 
void TakeResourceWithLimit (entity receiver, Resource res_type, float amount, float limit)
 Takes an entity some resource but not less than a limit. More...
 

Detailed Description

Source file that contains implementation of the resource system.

Definition in file cl_resources.qc.

Function Documentation

◆ 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.

Referenced by _StartItem(), ammo_pickupevalfunc(), assault_decreaser_sprite_visible(), assault_objective_decrease_use(), assault_wall_think(), basketball_touch(), bot_cmd_eval(), CheatImpulse(), ClientCommand_kill(), CommonCommand_editmob(), CopyBody(), cpicon_draw(), cpicon_send(), ctf_CheckFlagReturn(), ctf_FlagcarrierWaypoints(), ctf_Handle_Drop(), Damage(), destructible_heal(), dompointtouch(), door_damage(), door_reset(), door_trigger_touch(), Draw_ShowNames(), Draw_ShowNames_All(), football_touch(), formatmessage(), frag_centermessage_override(), freezetag_count_alive_players(), freezetag_LastPlayerForTeam(), generator_draw(), generator_send(), GENERIC_COMMAND(), GiveRandomWeapons(), GiveResourceValue(), GrapplingHook_Damage(), havocbot_goalrating_ctf_enemyflag(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_ft_freeplayers(), havocbot_goalrating_item_can_be_left_to_teammate(), havocbot_movetogoal(), healtharmor_pickupevalfunc(), instagib_ammocheck(), instagib_countdown(), Invasion_CheckWinner(), Item_GiveAmmoTo(), LinkDoors(), MapVote_Tick(), Monster_Attack_Leap_Check(), Monster_Damage(), Monster_Dead_Damage(), Monster_Frozen_Think(), Monster_Heal(), Monster_Move_Target(), Monster_Spawn_Setup(), Monster_Think(), Monster_ValidTarget(), MUTATOR_HOOKFUNCTION(), navigation_routerating(), 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(), PlayerPostThink(), PlayerPreThink(), Portal_Damage(), powerups_DropItem_Think(), PutObserverInServer(), readplayerstartcvars(), RotRegen(), spawnfunc(), SpectateCopy(), TakeResource(), TakeResourceWithLimit(), target_objective_spawn_evalfunc(), test_weapons_hurt(), turret_draw(), vehicles_damage(), vehicles_heal(), vehicles_painframe(), vehicles_projectile_damage(), vehicles_regen(), vehicles_regen_resource(), W_DecreaseAmmo(), W_Reload(), W_ReloadedAndReady(), W_ThrowNewWeapon(), W_WeaponFrame(), and weapon_defaultspawnfunc().

11 {
12  return e.(GetResourceField(res_type));
13 }
+ Here is the caller graph for this function:

◆ SetResource()

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

Sets the current amount of resource the given entity will have.

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.

Referenced by CheatImpulse(), Damage(), Freeze(), GENERIC_COMMAND(), MUTATOR_HOOKFUNCTION(), NIX_GiveCurrentWeapon(), PutPlayerInServer(), readplayerstartcvars(), REGISTER_MUTATOR(), RotRegen(), TakeResource(), target_init_use(), Unfreeze(), vehicles_regen_resource(), W_DecreaseAmmo(), W_ReloadedAndReady(), W_ThrowNewWeapon(), and weapon_defaultspawnfunc().

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.
Definition: cl_resources.qc:15
+ Here is the caller graph for this function:

◆ 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.

Referenced by assault_objective_decrease_use(), assault_objective_reset(), assault_objective_use(), CheatCommand(), CopyBody(), ctf_FlagDamage(), ctf_FlagSetup(), ctf_FlagThink(), ctf_Handle_Drop(), ctf_Handle_Pickup(), ctf_RespawnFlag(), Damage(), door_damage(), door_go_down(), Draw_ShowNames_All(), FireGrapplingHook(), FixIntermissionClient(), ft_RemovePlayer(), GiveResourceValue(), LinkDoors(), MapVote_Tick(), Monster_Dead_Fade(), Monster_Frozen_Think(), Monster_Reset(), Monster_Spawn_Setup(), MUTATOR_HOOKFUNCTION(), NET_HANDLE(), ons_ControlPoint_Icon_BuildThink(), ons_ControlPoint_Icon_Spawn(), ons_GeneratorReset(), ons_GeneratorSetup(), PlayerPreThink(), Portal_Spawn(), Portal_TeleportPlayer(), powerups_DropItem(), PutObserverInServer(), SetResource(), spawnfunc(), SpectateCopy(), turret_construct(), and vehicles_projectile().

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 }
+ Here is the caller graph for this function:

◆ 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.

Referenced by assault_objective_decrease_use(), ctf_FlagDamage(), ctf_FlagThink(), door_damage(), GrapplingHook_Damage(), Monster_Damage(), Monster_Dead_Damage(), MUTATOR_HOOKFUNCTION(), ons_ControlPoint_Icon_Damage(), ons_GeneratorDamage(), PlayerCorpseDamage(), PlayerDamage(), PM_jetpack(), Portal_Damage(), powerups_DropItem_Think(), TakeResourceWithLimit(), vehicles_damage(), and vehicles_projectile_damage().

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.
Definition: cl_resources.qc:26
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
+ Here is the caller graph for this function:

◆ 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.

Referenced by Item_GiveAmmoTo().

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.
Definition: cl_resources.qc:31
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
+ Here is the caller graph for this function: