2 /// \brief Header file that describes the resource system.
4 /// \copyright GNU GPLv2 or any later version.
8 /// \brief Unconditional maximum amount of resources the entity can have.
9 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
11 /// \brief Describes the available resource types.
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).
24 // ============================ Public API ====================================
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);
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);
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);
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);
52 /// \brief Gives an entity some resource but not more than a limit.
53 /// \param[in,out] receiver Entity to give resource to.
54 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
55 /// \param[in] amount Amount of resource to give.
56 /// \param[in] limit Limit of resources to give.
57 /// \return No return.
58 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
61 // ===================== Legacy and/or internal API ===========================
63 /// \brief Converts an entity field to resource type.
64 /// \param[in] resource_field Entity field to convert.
65 /// \return Resource type (a RESOURCE_* constant).
66 int GetResourceType(.float resource_field);
68 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
69 /// \param[in] resource_type Type of the resource.
70 /// \return Entity field for that resource.
71 .float GetResourceField(int resource_type);