4 #include <server/defs.qh>
7 /// \brief Unconditional maximum amount of resources the player can have.
8 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
10 /// \brief Describes the available resource types.
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).
23 const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
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);
48 void StartItem(entity this, entity a);
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";
66 void ItemDraw(entity this);
67 void ItemDrawSimple(entity this);
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);
78 float autocvar_sv_simple_items;
79 bool ItemSend(entity this, entity to, int sf);
82 bool have_pickup_item(entity this);
84 const float ITEM_RESPAWN_TICKS = 10;
86 #define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))
87 // range: 10 .. respawntime + respawntimejitter
89 .float max_armorvalue;
92 void Item_Show (entity e, float mode);
94 void Item_Respawn (entity this);
96 void Item_RespawnCountdown(entity this);
97 void Item_ScheduleRespawnIn(entity e, float t);
99 void Item_ScheduleRespawn(entity e);
101 void Item_ScheduleInitialRespawn(entity e);
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);
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);
113 /// \brief Gives player a resource such as health, armor or ammo.
114 /// \param[in,out] player Player to give resource to.
115 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
116 /// \param[in] amount Amount of resource to give.
117 /// \return No return.
118 void GivePlayerResource(entity player, int resource_type, float amount);
120 /// \brief Gives player a resource such as health, armor or ammo.
121 /// \param[in,out] player Player to give resource to.
122 /// \param[in] resource_property Entity property of the resource.
123 /// \param[in] amount Amount of resource to give.
124 /// \return No return.
125 void GivePlayerResourceViaProperty(entity player, .float resource_property,
128 /// \brief Gives health to the player.
129 /// \param[in,out] player Player to give health to.
130 /// \param[in] amount Amount of health to give.
131 /// \return No return.
132 void GivePlayerHealth(entity player, float amount);
134 /// \brief Gives armor to the player.
135 /// \param[in,out] player Player to give armor to.
136 /// \param[in] amount Amount of armor to give.
137 /// \return No return.
138 void GivePlayerArmor(entity player, float amount);
140 /// \brief Gives fuel to the player.
141 /// \param[in,out] player Player to give fuel to.
142 /// \param[in] amount Amount of fuel to give.
143 /// \return No return.
144 void GivePlayerFuel(entity player, float amount);
146 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax);
148 float Item_GiveTo(entity item, entity player);
150 void Item_Touch(entity this, entity toucher);
152 void Item_Reset(entity this);
154 void Item_FindTeam(entity this);
155 // Savage: used for item garbage-collection
157 bool ItemSend(entity this, entity to, int sf);
158 void ItemUpdate(entity this);
160 void UpdateItemAfterTeleport(entity this);
162 // pickup evaluation functions
163 // these functions decide how desirable an item is to the bots
165 float generic_pickupevalfunc(entity player, entity item);// {return item.bot_pickupbasevalue;} // WEAPONTODO
167 float weapon_pickupevalfunc(entity player, entity item);
168 float ammo_pickupevalfunc(entity player, entity item);
169 float healtharmor_pickupevalfunc(entity player, entity item);
173 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter);
175 void setItemGroup(entity this);
176 void setItemGroupCount();
178 float GiveWeapon(entity e, float wpn, float op, float val);
180 float GiveBit(entity e, .float fld, float bit, float op, float val);
182 float GiveValue(entity e, .float fld, float op, float val);
184 void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_decr);
186 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime);
188 #define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = e.weapons
189 #define PREGIVE(e,f) float save_##f; save_##f = (e).f
190 #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)
191 #define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr)
192 #define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
193 #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)
195 float GiveItems(entity e, float beginarg, float endarg);