]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/items/spawning.qh
Wrap all status and bitflag checks with parentesis to avoid possible obscure bugs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items / spawning.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the functions related to game items.
5 /// \copyright GNU GPLv2 or any later version.
6
7 bool startitem_failed;
8
9 /// \brief lifetime < 0 means permanent (not loot), lifetime > 0 overrides the default
10 .float lifetime;
11 /// \brief Holds whether item is loot.
12 .bool m_isloot;
13 /// \brief Holds whether strength, shield or superweapon timers expire while this item is on the ground.
14 .bool m_isexpiring;
15
16 /// \brief Checks whether the items with the specified definition are allowed to
17 /// spawn.
18 /// \param[in] definition Item definition to check.
19 /// \return True items with the specified definition are allowed to spawn, false
20 /// otherwise.
21 bool Item_IsDefinitionAllowed(entity definition);
22
23 /// \brief An optimised and generic way to initialise items (loot or permanent)
24 /// \param[in] item The item entity to initialise
25 /// \return True on success, false otherwise.
26 /// \nore required field: itemdef (faster, preferred) OR classname
27 /// optional fields: origin, velocity, lifetime, noalign
28 /// lifetime < 0 means permanent (not loot), lifetime > 0 overrides the default
29 /// permanent items only: noalign means the item is suspended (won't drop to floor)
30 bool Item_Initialise(entity item);
31
32 /// \brief Returns whether the item is loot.
33 /// \param[in] item Item to check.
34 /// \return True if the item is loot, false otherwise.
35 #define ITEM_IS_LOOT(item) (item.m_isloot || item.classname == "droppedweapon")
36
37 /// \brief Sets the item loot status.
38 /// \param[in,out] item Item to adjust.
39 /// \param[in] loot Whether item is loot.
40 /// \return No return.
41 #define ITEM_SET_LOOT(item, loot) (item.m_isloot = loot)
42
43 /// \brief Returns whether item should keep its position or be dropped to the
44 /// ground.
45 /// \param[in] item Item to check.
46 /// \return True if item should keep its position or false if it should be
47 /// dropped to the ground.
48 #define ITEM_SHOULD_KEEP_POSITION(item) (item.noalign || (item.spawnflags & 1))
49
50 /// \brief Returns whether the item is expiring (i.e. its strength, shield and
51 /// superweapon timers expire while it is on the ground).
52 /// \param[in] item Item to check.
53 /// \return True if the item is expiring, false otherwise.
54 #define ITEM_IS_EXPIRING(item) (item.m_isexpiring)
55
56 /// \brief Sets the item expiring status (i.e. whether its strength, shield
57 /// and superweapon timers expire while it is on the ground).
58 /// \param[in,out] item Item to adjust.
59 /// \param[in] expiring Whether item is expiring.
60 /// \return No return.
61 #define ITEM_SET_EXPIRING(item, expiring) (item.m_isexpiring = expiring)