X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ft_items.qh;h=bd46599aa39ed1ae750ebdca4dcc2f57c802a5a7;hb=e51ce3d45d2852ca793118fc73da9c25f789101f;hp=bdc63a7ccda5e2e5fcb8f97aa30102132141679f;hpb=45ccf5629b069c240a72cdabae5bf1605733f29e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index bdc63a7cc..bd46599aa 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -1,25 +1,5 @@ #pragma once -#ifdef SVQC -#include -#endif - -/// \brief Unconditional maximum amount of resources the player can have. -const int RESOURCE_AMOUNT_HARD_LIMIT = 999; - -/// \brief Describes the available resource types. -enum -{ - RESOURCE_HEALTH, ///< Health. - RESOURCE_ARMOR, ///< Armor. - RESOURCE_SHELLS, ///< Shells (used by shotgun). - RESOURCE_BULLETS, ///< Bullets (used by machinegun and rifle) - RESOURCE_ROCKETS, ///< Rockets (used by mortar, hagar, devastator, etc). - RESOURCE_CELLS, ///< Cells (used by electro, crylink, vortex, etc) - RESOURCE_PLASMA, ///< Plasma (unused). - RESOURCE_FUEL ///< Fuel (used by jetpack). -}; - const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel // item networking @@ -46,6 +26,8 @@ const int ISF_SIZE = BIT(7); #ifdef SVQC void StartItem(entity this, entity a); +.int item_group; +.int item_group_count; #endif #ifdef CSQC @@ -64,31 +46,22 @@ string autocvar_cl_simpleitems_postfix = "_simple"; .vector colormod; void ItemDraw(entity this); -void ItemDrawSimple(entity this); #endif #ifdef SVQC -spawnfunc(item_strength); -spawnfunc(item_invincible); -spawnfunc(item_armor_small); -spawnfunc(item_shells); -spawnfunc(item_bullets); -spawnfunc(item_rockets); float autocvar_sv_simple_items; bool ItemSend(entity this, entity to, int sf); - bool have_pickup_item(entity this); const float ITEM_RESPAWN_TICKS = 10; -#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS)) - // range: 10 .. respawntime + respawntimejitter - .float max_armorvalue; .float pickup_anyway; +.float item_respawncounter; + void Item_Show (entity e, float mode); void Item_Respawn (entity this); @@ -100,52 +73,16 @@ void Item_ScheduleRespawn(entity e); void Item_ScheduleInitialRespawn(entity e); -/// \brief Converts resource entity property to resource type. -/// \param[in] resource_property Resource entity property to convert. -/// \return Resource type (a RESOURCE_* constant). -int GetResourceType(.float resource_property); - -/// \brief Converts resource type (a RESOURCE_* constant) to entity property. -/// \param[in] resource_type Type of the resource. -/// \return Entity proprty for that resource. -.float GetResourceProperty(int resource_type); - -/// \brief Returns the maximum amount of the given resource. -/// \param[in] e Entity to check. -/// \param[in] resource_type Type of the resource (a RESOURCE_* constant). -/// \return Maximum amount of the given resource. -float GetResourceLimit(entity e, int resource_type); - -/// \brief Gives player a resource such as health, armor or ammo. -/// \param[in,out] receiver Entity to give resource to. -/// \param[in] resource_type Type of the resource (a RESOURCE_* constant). -/// \param[in] amount Amount of resource to give. -/// \return No return. -void GiveResource(entity receiver, int resource_type, float amount); - -/// \brief Gives player a resource such as health, armor or ammo. -/// \param[in,out] e Entity to give resource to. -/// \param[in] resource_property Entity property of the resource. -/// \param[in] amount Amount of resource to give. -/// \return No return. -void GiveResourceViaProperty(entity receiver, .float resource_property, - float amount); - -/// \brief Give several random weapons and ammo to the player. -/// \param[in,out] player Player to give weapons to. +/// \brief Give several random weapons and ammo to the entity. +/// \param[in,out] receiver Entity to give weapons to. /// \param[in] num_weapons Number of weapons to give. /// \param[in] weapon_names Names of weapons to give separated by spaces. -/// \param[in] shells Amount of shells to give with shell-based weapon. -/// \param[in] bullets Amount of bullets to give with bullet-based weapon. -/// \param[in] rockets Amount of rockets to give with rocket-based weapon. -/// \param[in] cells Amount of cells to give with cell-based weapon. -/// \param[in] cells Amount of plasma to give with plasma-based weapon. +/// \param[in] ammo Entity containing the ammo amount for each possible weapon. /// \return No return. -void GivePlayerRandomWeapons(entity player, int num_weapons, - string weapon_names, float shells, float bullets, float rockets, - float cells, float plasma); +void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, + entity ammo_entity); -float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax); +float Item_GiveAmmoTo(entity item, entity player, int resource_type, float ammomax); float Item_GiveTo(entity item, entity player); @@ -187,9 +124,9 @@ void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime); -#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = e.weapons +#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = STAT(WEAPONS, e) #define PREGIVE(e,f) float save_##f; save_##f = (e).f -#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) +#define POSTGIVE_WEAPON(e,b,snd_incr,snd_decr) GiveSound((e), !!(save_weapons & WepSet_FromWeapon(b)), !!(STAT(WEAPONS, e) & WepSet_FromWeapon(b)), 0, snd_incr, snd_decr) #define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr) #define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr) #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)