return limit;
}
+float GetResourceAmount(entity e, int resource_type)
+{
+ .float resource_field = GetResourceField(resource_type);
+ return e.(resource_field);
+}
+
void GiveResource(entity receiver, int resource_type, float amount)
{
if (amount == 0)
}
resource_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
- .float resource_property = GetResourceProperty(resource_type);
+ .float resource_field = GetResourceField(resource_type);
float max_amount = GetResourceLimit(receiver, resource_type);
- receiver.(resource_property) = bound(receiver.(resource_property),
- receiver.(resource_property) + amount, max_amount);
+ receiver.(resource_field) = bound(receiver.(resource_field),
+ receiver.(resource_field) + amount, max_amount);
switch (resource_type)
{
case RESOURCE_HEALTH:
}
}
-int GetResourceType(.float resource_property)
+int GetResourceType(.float resource_field)
{
- switch (resource_property)
+ switch (resource_field)
{
case health: { return RESOURCE_HEALTH; }
case armorvalue: { return RESOURCE_ARMOR; }
case ammo_plasma: { return RESOURCE_PLASMA; }
case ammo_fuel: { return RESOURCE_FUEL; }
}
- error("GetResourceType: Invalid property.");
+ error("GetResourceType: Invalid field.");
return 0;
}
-.float GetResourceProperty(int resource_type)
+.float GetResourceField(int resource_type)
{
switch (resource_type)
{
case RESOURCE_PLASMA: { return ammo_plasma; }
case RESOURCE_FUEL: { return ammo_fuel; }
}
- error("GetResourceProperty: Invalid resource type.");
+ error("GetResourceField: Invalid resource type.");
return health;
}
/// \return Maximum amount of the given resource.
float GetResourceLimit(entity e, int resource_type);
-/// \brief Gives player a resource such as health, armor or ammo.
+/// \brief Returns the current amount of resource the given entity has.
+/// \param[in] e Entity to check.
+/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
+/// \return Current amount of resource the given entity has.
+float GetResourceAmount(entity e, int resource_type);
+
+/// \brief Gives an entity some resource.
/// \param[in,out] receiver Entity to give resource to.
/// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
/// \param[in] amount Amount of resource to give.
// ===================== Legacy and/or internal API ===========================
-/// \brief Converts resource entity property to resource type.
-/// \param[in] resource_property Resource entity property to convert.
+/// \brief Converts an entity field to resource type.
+/// \param[in] resource_field Entity field to convert.
/// \return Resource type (a RESOURCE_* constant).
-int GetResourceType(.float resource_property);
+int GetResourceType(.float resource_field);
-/// \brief Converts resource type (a RESOURCE_* constant) to entity property.
+/// \brief Converts resource type (a RESOURCE_* constant) to entity field.
/// \param[in] resource_type Type of the resource.
-/// \return Entity proprty for that resource.
-.float GetResourceProperty(int resource_type);
+/// \return Entity field for that resource.
+.float GetResourceField(int resource_type);