toucher = M_ARGV(1, entity);
- // TODO: Proper way to handle expiring and not expiring loot.
- // Expiring loot will have strength "ticking" will it's dropped.
- // Not expiring will not tick.
- // OTOH, do we really need expiring loot?
- //if (this.classname == "droppedweapon")
- //{
- // this.strength_finished = max(0, this.strength_finished - time);
- // this.invincible_finished = max(0, this.invincible_finished - time);
- // this.superweapons_finished = max(0, this.superweapons_finished - time);
- //}
+ if (Item_IsExpiring(this))
+ {
+ this.strength_finished = max(0, this.strength_finished - time);
+ this.invincible_finished = max(0, this.invincible_finished - time);
+ this.superweapons_finished = max(0, this.superweapons_finished - time);
+ }
bool gave = ITEM_HANDLE(Pickup, this.itemdef, this, toucher);
if (!gave)
{
- //if (this.classname == "droppedweapon")
- //{
- // // undo what we did above
- // this.strength_finished += time;
- // this.invincible_finished += time;
- // this.superweapons_finished += time;
- //}
+ if (Item_IsExpiring(this))
+ {
+ // undo what we did above
+ this.strength_finished += time;
+ this.invincible_finished += time;
+ this.superweapons_finished += time;
+ }
return;
}
this.takedamage = DAMAGE_YES;
this.event_damage = Item_Damage;
- // TODO: Proper way to handle expiring and not expiring loot.
- // Expiring loot will have strength "ticking" will it's dropped.
- // Not expiring will not tick.
- // OTOH, do we really need expiring loot?
- if (this.strength_finished || this.invincible_finished || this.superweapons_finished)
+ if (Item_IsExpiring(this))
{
// if item is worthless after a timer, have it expire then
this.nextthink = max(this.strength_finished, this.invincible_finished, this.superweapons_finished);
#include <common/weapons/all.qh>
.bool m_isloot; ///< Holds whether item is loot.
+/// \brief Holds whether strength, shield or superweapon timers expire while
+/// this item is on the ground.
+.bool m_isexpiring;
entity Item_Create(string class_name, vector position)
{
item.m_isloot = loot;
}
+bool Item_IsExpiring(entity item)
+{
+ return item.m_isexpiring;
+}
+
+void Item_SetExpiring(entity item, bool expiring)
+{
+ item.m_isexpiring = expiring;
+}
+
// Compatibility spawn functions
// FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
#pragma once
+
/// \file
/// \brief Header file that describes the functions related to game items.
/// \copyright GNU GPLv2 or any later version.
/// \return No return.
void Item_SetLoot(entity item, bool loot);
+/// \brief Returns whether the item is expiring (i.e. its strength, shield and
+/// superweapon timers expire while it is on the ground).
+/// \param[in] item Item to check.
+/// \return True if the item is expiring, false otherwise.
+bool Item_IsExpiring(entity item);
+
+/// \brief Sets the item expiring status (i.e. whether its strength, shield
+/// and superweapon timers expire while it is on the ground).
+/// \param[in,out] item Item to adjust.
+/// \param[in] expiring Whether item is expiring.
+/// \return No return.
+void Item_SetExpiring(entity item, bool expiring);