]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Merge branch 'master' into martin-t/okc2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / resources.qh
1 #pragma once
2 /// \file
3 /// \brief Header file that describes the resource system.
4 /// \author Lyberta
5 /// \copyright GNU GPLv2 or any later version.
6
7 /// \brief Unconditional maximum amount of resources the entity can have.
8 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
9
10 /// \brief Describes the available resource types.
11 enum
12 {
13         RESOURCE_HEALTH = 1, ///< Health.
14         RESOURCE_ARMOR, ///< Armor.
15         RESOURCE_SHELLS, ///< Shells (used by shotgun).
16         RESOURCE_BULLETS, ///< Bullets (used by machinegun and rifle)
17         RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc).
18         RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc)
19         RESOURCE_PLASMA, ///< Plasma (unused).
20         RESOURCE_FUEL ///< Fuel (used by jetpack).
21 };
22
23 // ============================ Public API ====================================
24
25 /// \brief Returns the maximum amount of the given resource.
26 /// \param[in] e Entity to check.
27 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
28 /// \return Maximum amount of the given resource.
29 float GetResourceLimit(entity e, int resource_type);
30
31 /// \brief Returns the current amount of resource the given entity has.
32 /// \param[in] e Entity to check.
33 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
34 /// \return Current amount of resource the given entity has.
35 float GetResourceAmount(entity e, int resource_type);
36
37 /// \brief Sets the current amount of resource the given entity will have.
38 /// \param[in,out] e Entity to adjust.
39 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
40 /// \param[in] amount Amount of resource to set.
41 /// \return No return.
42 void SetResourceAmount(entity e, int resource_type, float amount);
43
44 /// \brief Gives an entity some resource.
45 /// \param[in,out] receiver Entity to give resource to.
46 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
47 /// \param[in] amount Amount of resource to give.
48 /// \return No return.
49 void GiveResource(entity receiver, int resource_type, float amount);
50
51 /// \brief Gives an entity some resource but not more than a limit.
52 /// \param[in,out] receiver Entity to give resource to.
53 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
54 /// \param[in] amount Amount of resource to give.
55 /// \param[in] limit Limit of resources to give.
56 /// \return No return.
57 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
58         float limit);
59
60 // ===================== Legacy and/or internal API ===========================
61
62 /// \brief Converts an entity field to resource type.
63 /// \param[in] resource_field Entity field to convert.
64 /// \return Resource type (a RESOURCE_* constant).
65 int GetResourceType(.float resource_field);
66
67 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
68 /// \param[in] resource_type Type of the resource.
69 /// \return Entity field for that resource.
70 .float GetResourceField(int resource_type);