]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/items.qh
d8703370c2e570c501f51260aa21db7f231531f1
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items.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 /// \brief Returns the item definition corresponding to the given class name.
8 /// \param[in] class_name Class name to search for.
9 /// \return Item definition corresponding to the given class name or NULL is not
10 /// found.
11 entity Item_FindDefinition(string class_name);
12
13 /// \brief Checks whether the items with the specified class name are allowed to
14 /// spawn.
15 /// \param[in] class_name Item class name to check.
16 /// \return True items with the specified class name are allowed to spawn, false
17 /// otherwise.
18 bool Item_IsAllowed(string class_name);
19
20 /// \brief Checks whether the items with the specified definition are allowed to
21 /// spawn.
22 /// \param[in] definition Item definition to check.
23 /// \return True items with the specified definition are allowed to spawn, false
24 /// otherwise.
25 bool Item_IsDefinitionAllowed(entity definition);
26
27 /// \brief Creates a new item.
28 /// \param[in] class_name Class name of the item.
29 /// \param[in] position Position of the item.
30 /// \param[in] no_align True if item should be placed directly at specified
31 /// position, false to let it drop to the ground.
32 /// \return Item on success, NULL otherwise.
33 entity Item_Create(string class_name, vector position, bool no_align);
34
35 /// \brief Initializes the item according to class name.
36 /// \param[in,out] item Item to initialize.
37 /// \param[in] class_name Class name to use.
38 /// \return No return.
39 /// \nore This function is useful if you want to set some item properties before
40 /// initialization.
41 void Item_Initialize(entity item, string class_name);
42
43 /// \brief Creates a loot item.
44 /// \param[in] class_name Class name of the item.
45 /// \param[in] position Position of the item.
46 /// \param[in] velocity of the item.
47 /// \param[in] time_to_live Amount of time after which the item will disappear.
48 /// \return Item on success, NULL otherwise.
49 entity Item_CreateLoot(string class_name, vector position, vector vel,
50         float time_to_live);
51
52 /// \brief Initializes the loot item.
53 /// \param[in] class_name Class name of the item.
54 /// \param[in] position Position of the item.
55 /// \param[in] velocity of the item.
56 /// \param[in] time_to_live Amount of time after which the item will disappear.
57 /// \return True on success, false otherwise.
58 /// \nore This function is useful if you want to set some item properties before
59 /// initialization.
60 bool Item_InitializeLoot(entity item, string class_name, vector position,
61         vector vel, float time_to_live);
62
63 /// \brief Returns whether the item is loot.
64 /// \param[in] item Item to check.
65 /// \return True if the item is loot, false otherwise.
66 bool Item_IsLoot(entity item);
67
68 /// \brief Sets the item loot status.
69 /// \param[in,out] item Item to adjust.
70 /// \param[in] loot Whether item is loot.
71 /// \return No return.
72 void Item_SetLoot(entity item, bool loot);
73
74 /// \brief Returns whether item should keep its position or be dropped to the
75 /// ground.
76 /// \param[in] item Item to check.
77 /// \return True if item should keep its position or false if it should be
78 /// dropped to the ground.
79 bool Item_ShouldKeepPosition(entity item);
80
81 /// \brief Returns whether the item is expiring (i.e. its strength, shield and
82 /// superweapon timers expire while it is on the ground).
83 /// \param[in] item Item to check.
84 /// \return True if the item is expiring, false otherwise.
85 bool Item_IsExpiring(entity item);
86
87 /// \brief Sets the item expiring status (i.e. whether its strength, shield
88 /// and superweapon timers expire while it is on the ground).
89 /// \param[in,out] item Item to adjust.
90 /// \param[in] expiring Whether item is expiring.
91 /// \return No return.
92 void Item_SetExpiring(entity item, bool expiring);