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