]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/t_items.qh
bdc63a7ccda5e2e5fcb8f97aa30102132141679f
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qh
1 #pragma once
2
3 #ifdef SVQC
4 #include <server/defs.qh>
5 #endif
6
7 /// \brief Unconditional maximum amount of resources the player can have.
8 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
9
10 /// \brief Describes the available resource types.
11 enum
12 {
13         RESOURCE_HEALTH, ///< Health.
14         RESOURCE_ARMOR, ///< Armor.
15         RESOURCE_SHELLS, ///< Shells (used by shotgun).
16         RESOURCE_BULLETS, ///< Bullets (used by machinegun and rifle)
17         RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc).
18         RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc)
19         RESOURCE_PLASMA, ///< Plasma (unused).
20         RESOURCE_FUEL ///< Fuel (used by jetpack).
21 };
22
23 const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
24
25 // item networking
26 const int ISF_LOCATION                  = BIT(1);
27 const int ISF_MODEL                             = BIT(2);
28 const int ISF_STATUS                    = BIT(3);
29     const int ITS_STAYWEP                   = BIT(0);
30     const int ITS_ANIMATE1                  = BIT(1);
31     const int ITS_ANIMATE2                  = BIT(2);
32     const int ITS_AVAILABLE         = BIT(3);
33     const int ITS_ALLOWFB                   = BIT(4);
34     const int ITS_ALLOWSI                   = BIT(5);
35     const int ITS_GLOW                      = BIT(6);
36 const int ISF_COLORMAP                  = BIT(4);
37 const int ISF_DROP                              = BIT(5);
38 const int ISF_ANGLES                    = BIT(6);
39 const int ISF_SIZE                              = BIT(7);
40
41 .int ItemStatus;
42
43 .float onground_time;
44 .float fade_start;
45 .float fade_end;
46
47 #ifdef SVQC
48 void StartItem(entity this, entity a);
49 #endif
50
51 #ifdef CSQC
52
53 bool   autocvar_cl_items_nofade;
54 float  autocvar_cl_animate_items = 1;
55 float  autocvar_cl_ghost_items = 0.45;
56 vector autocvar_cl_ghost_items_color = '-1 -1 -1';
57 float  autocvar_cl_fullbright_items = 0;
58 vector autocvar_cl_weapon_stay_color = '2 0.5 0.5';
59 float  autocvar_cl_weapon_stay_alpha = 0.75;
60 float  autocvar_cl_simple_items = 0;
61 string autocvar_cl_simpleitems_postfix = "_simple";
62 .float  spawntime;
63 .float  gravity;
64 .vector colormod;
65
66 void ItemDraw(entity this);
67 void ItemDrawSimple(entity this);
68
69 #endif
70 #ifdef SVQC
71 spawnfunc(item_strength);
72 spawnfunc(item_invincible);
73 spawnfunc(item_armor_small);
74 spawnfunc(item_shells);
75 spawnfunc(item_bullets);
76 spawnfunc(item_rockets);
77
78 float autocvar_sv_simple_items;
79 bool ItemSend(entity this, entity to, int sf);
80
81
82 bool have_pickup_item(entity this);
83
84 const float ITEM_RESPAWN_TICKS = 10;
85
86 #define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))
87         // range: 10 .. respawntime + respawntimejitter
88
89 .float max_armorvalue;
90 .float pickup_anyway;
91
92 void Item_Show (entity e, float mode);
93
94 void Item_Respawn (entity this);
95
96 void Item_RespawnCountdown(entity this);
97 void Item_ScheduleRespawnIn(entity e, float t);
98
99 void Item_ScheduleRespawn(entity e);
100
101 void Item_ScheduleInitialRespawn(entity e);
102
103 /// \brief Converts resource entity property to resource type.
104 /// \param[in] resource_property Resource entity property to convert.
105 /// \return Resource type (a RESOURCE_* constant).
106 int GetResourceType(.float resource_property);
107
108 /// \brief Converts resource type (a RESOURCE_* constant) to entity property.
109 /// \param[in] resource_type Type of the resource.
110 /// \return Entity proprty for that resource.
111 .float GetResourceProperty(int resource_type);
112
113 /// \brief Returns the maximum amount of the given resource.
114 /// \param[in] e Entity to check.
115 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
116 /// \return Maximum amount of the given resource.
117 float GetResourceLimit(entity e, int resource_type);
118
119 /// \brief Gives player a resource such as health, armor or ammo.
120 /// \param[in,out] receiver Entity to give resource to.
121 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
122 /// \param[in] amount Amount of resource to give.
123 /// \return No return.
124 void GiveResource(entity receiver, int resource_type, float amount);
125
126 /// \brief Gives player a resource such as health, armor or ammo.
127 /// \param[in,out] e Entity to give resource to.
128 /// \param[in] resource_property Entity property of the resource.
129 /// \param[in] amount Amount of resource to give.
130 /// \return No return.
131 void GiveResourceViaProperty(entity receiver, .float resource_property,
132         float amount);
133
134 /// \brief Give several random weapons and ammo to the player.
135 /// \param[in,out] player Player to give weapons to.
136 /// \param[in] num_weapons Number of weapons to give.
137 /// \param[in] weapon_names Names of weapons to give separated by spaces.
138 /// \param[in] shells Amount of shells to give with shell-based weapon.
139 /// \param[in] bullets Amount of bullets to give with bullet-based weapon.
140 /// \param[in] rockets Amount of rockets to give with rocket-based weapon.
141 /// \param[in] cells Amount of cells to give with cell-based weapon.
142 /// \param[in] cells Amount of plasma to give with plasma-based weapon.
143 /// \return No return.
144 void GivePlayerRandomWeapons(entity player, int num_weapons,
145         string weapon_names, float shells, float bullets, float rockets,
146         float cells, float plasma);
147
148 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax);
149
150 float Item_GiveTo(entity item, entity player);
151
152 void Item_Touch(entity this, entity toucher);
153
154 void Item_Reset(entity this);
155
156 void Item_FindTeam(entity this);
157 // Savage: used for item garbage-collection
158
159 bool ItemSend(entity this, entity to, int sf);
160 void ItemUpdate(entity this);
161
162 void UpdateItemAfterTeleport(entity this);
163
164 // pickup evaluation functions
165 // these functions decide how desirable an item is to the bots
166
167 float generic_pickupevalfunc(entity player, entity item);// {return item.bot_pickupbasevalue;} // WEAPONTODO
168
169 float weapon_pickupevalfunc(entity player, entity item);
170 float ammo_pickupevalfunc(entity player, entity item);
171 float healtharmor_pickupevalfunc(entity player, entity item);
172
173 .float is_item;
174 .entity itemdef;
175 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter);
176
177 void setItemGroup(entity this);
178 void setItemGroupCount();
179
180 float GiveWeapon(entity e, float wpn, float op, float val);
181
182 float GiveBit(entity e, .float fld, float bit, float op, float val);
183
184 float GiveValue(entity e, .float fld, float op, float val);
185
186 void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_decr);
187
188 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime);
189
190 #define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = e.weapons
191 #define PREGIVE(e,f) float save_##f; save_##f = (e).f
192 #define POSTGIVE_WEAPON(e,b,snd_incr,snd_decr) GiveSound((e), !!(save_weapons & WepSet_FromWeapon(b)), !!(e.weapons & WepSet_FromWeapon(b)), 0, snd_incr, snd_decr)
193 #define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr)
194 #define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
195 #define POSTGIVE_VALUE_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e), save_##f, (e).f, rotfield, rottime, regenfield, regentime); GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
196
197 float GiveItems(entity e, float beginarg, float endarg);
198 #endif