]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/resources/sv_resources.qh
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / resources / sv_resources.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the resource system.
5 /// \author Lyberta
6 /// \copyright GNU GPLv2 or any later version.
7
8 #include <common/resources/resources.qh>
9
10 // TODO: split resources into their own files, registry based
11 float autocvar_g_balance_health_limit;
12 int autocvar_g_balance_armor_limit;
13 float autocvar_g_balance_fuel_limit;
14 float autocvar_g_balance_armor_regen;
15 float autocvar_g_balance_armor_regenlinear;
16 int autocvar_g_balance_armor_regenstable;
17 float autocvar_g_balance_armor_rot;
18 float autocvar_g_balance_armor_rotlinear;
19 int autocvar_g_balance_armor_rotstable;
20 float autocvar_g_balance_fuel_regen;
21 float autocvar_g_balance_fuel_regenlinear;
22 int autocvar_g_balance_fuel_regenstable;
23 float autocvar_g_balance_fuel_rot;
24 float autocvar_g_balance_fuel_rotlinear;
25 int autocvar_g_balance_fuel_rotstable;
26 float autocvar_g_balance_health_regen;
27 float autocvar_g_balance_health_regenlinear;
28 float autocvar_g_balance_health_regenstable;
29 float autocvar_g_balance_health_rot;
30 float autocvar_g_balance_health_rotlinear;
31 float autocvar_g_balance_health_rotstable;
32 float autocvar_g_balance_pause_armor_rot;
33 float autocvar_g_balance_pause_fuel_regen;
34 float autocvar_g_balance_pause_fuel_rot;
35 float autocvar_g_balance_pause_health_regen;
36 float autocvar_g_balance_pause_health_rot;
37
38 // ============================ Public API ====================================
39
40 /// \brief Returns the maximum amount of the given resource.
41 /// \param[in] e Entity to check.
42 /// \param[in] res_type Type of the resource (a RES_* constant).
43 /// \return Maximum amount of the given resource.
44 float GetResourceLimit(entity e, Resource res_type);
45
46 /// \brief Returns the current amount of resource the given entity has.
47 /// \param[in] e Entity to check.
48 /// \param[in] res_type Type of the resource (a RES_* constant).
49 /// \return Current amount of resource the given entity has.
50 float GetResource(entity e, Resource res_type);
51
52 /// \brief Sets the resource amount of an entity without calling any hooks.
53 /// \param[in,out] e Entity to adjust.
54 /// \param[in] res_type Type of the resource (a RES_* constant).
55 /// \param[in] amount Amount of resource to set.
56 /// \return Boolean for whether the ammo amount was changed
57 bool SetResourceExplicit(entity e, Resource res_type, float amount);
58
59 /// \brief Sets the current amount of resource the given entity will have
60 /// but limited to the max amount allowed for the resource type.
61 /// \param[in,out] e Entity to adjust.
62 /// \param[in] res_type Type of the resource (a RES_* constant).
63 /// \param[in] amount Amount of resource to set.
64 /// \return No return.
65 void SetResource(entity e, Resource res_type, float amount);
66
67 /// \brief Gives an entity some resource.
68 /// \param[in,out] receiver Entity to give resource to.
69 /// \param[in] res_type Type of the resource (a RES_* constant).
70 /// \param[in] amount Amount of resource to give.
71 /// \return No return.
72 void GiveResource(entity receiver, Resource res_type, float amount);
73
74 /// \brief Gives an entity some resource but not more than a limit.
75 /// \param[in,out] receiver Entity to give resource to.
76 /// \param[in] res_type Type of the resource (a RES_* constant).
77 /// \param[in] amount Amount of resource to give.
78 /// \param[in] limit Limit of resources to give.
79 /// \return No return.
80 void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit);
81
82 /// \brief Takes an entity some resource.
83 /// \param[in,out] receiver Entity to take resource from.
84 /// \param[in] res_type Type of the resource (a RES_* constant).
85 /// \param[in] amount Amount of resource to take.
86 /// \return No return.
87 void TakeResource(entity receiver, Resource res_type, float amount);
88
89 /// \brief Takes an entity some resource but not less than a limit.
90 /// \param[in,out] receiver Entity to take resource from.
91 /// \param[in] res_type Type of the resource (a RES_* constant).
92 /// \param[in] amount Amount of resource to take.
93 /// \param[in] limit Limit of resources to take.
94 /// \return No return.
95 void TakeResourceWithLimit(entity receiver, Resource res_type, float amount, float limit);