Xonotic
items.qh
Go to the documentation of this file.
1 #pragma once
2 
4 #include <common/sounds/sound.qh>
5 
13 #define autocvar_g_weapon_stay cvar("g_weapon_stay")
14 
15 void StartItem(entity this, entity a);
18 
20 bool ItemSend(entity this, entity to, int sf);
21 
22 bool have_pickup_item(entity this);
23 
24 const float ITEM_RESPAWN_TICKS = 10;
25 
26 // string overrides entity
30 
33 .int count;
34 
36 .float respawntime;
39 
41 
42 .float noalign; // if set to 1, the item or spawnpoint won't be dropped to the floor
43 
44 .float superweapons_finished; // NOTE: this field is used only by map entities, it does not directly apply the superweapons stat
45 
46 // delay before this item can be picked up
48 
49 void Item_Show (entity e, int mode);
50 
51 void Item_Respawn (entity this);
52 
53 void Item_RespawnCountdown(entity this);
54 void Item_ScheduleRespawnIn(entity e, float t);
55 
57 
59 
66 void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, entity ammo_entity);
67 
68 bool Item_GiveAmmoTo(entity item, entity player, Resource res_type, float ammomax);
69 
70 bool Item_GiveTo(entity item, entity player);
71 
72 void Item_Touch(entity this, entity toucher);
73 
74 void Item_Reset(entity this);
75 
76 void Item_FindTeam(entity this);
77 // Savage: used for item garbage-collection
78 
79 bool ItemSend(entity this, entity to, int sf);
80 void ItemUpdate(entity this);
81 
83 
84 // pickup evaluation functions
85 // these functions decide how desirable an item is to the bots
86 
87 float generic_pickupevalfunc(entity player, entity item);// {return item.bot_pickupbasevalue;} // WEAPONTODO
88 
89 float weapon_pickupevalfunc(entity player, entity item);
90 float ammo_pickupevalfunc(entity player, entity item);
91 float healtharmor_pickupevalfunc(entity player, entity item);
92 
93 .bool is_item;
94 .entity itemdef;
95 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter);
96 
97 void setItemGroup(entity this);
98 void setItemGroupCount();
99 
100 float GiveWeapon(entity e, float wpn, float op, float val);
101 
102 float GiveBit(entity e, .float fld, float bit, float op, float val);
103 
104 float GiveValue(entity e, .float fld, float op, float val);
105 
106 void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_decr);
107 
108 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime);
109 
110 spawnfunc(target_items);
111 
112 #define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = STAT(WEAPONS, e)
113 #define PREGIVE(e,f) float save_##f; save_##f = (e).f
114 #define PREGIVE_STATUSEFFECT(e,f) bool save_##f = StatusEffects_active(f, (e))
115 #define PREGIVE_RESOURCE(e,f) float save_##f = GetResource((e), (f))
116 #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)
117 #define POSTGIVE_BIT(e,f,b,snd_incr,snd_decr) GiveSound((e), save_##f & (b), (e).f & (b), 0, snd_incr, snd_decr)
118 #define POSTGIVE_STATUSEFFECT(e,f,snd_incr,snd_decr) GiveSound((e), save_##f, StatusEffects_active(f, (e)), 0, snd_incr, snd_decr)
119 #define POSTGIVE_RESOURCE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, GetResource((e), (f)), t, snd_incr, snd_decr)
120 #define POSTGIVE_RES_ROT(e,f,t,rotfield,rottime,regenfield,regentime,snd_incr,snd_decr) GiveRot((e),save_##f,GetResource((e),(f)),rotfield,rottime,regenfield,regentime);GiveSound((e),save_##f,GetResource((e),(f)),t,snd_incr,snd_decr)
121 #define POSTGIVE_VALUE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, (e).f, t, snd_incr, snd_decr)
122 #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)
123 
124 float GiveItems(entity e, float beginarg, float endarg);
125 
127 STATIC_INIT(g_items) { g_items = IL_NEW(); }
128 
129 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
130 #define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id))
void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_decr)
Definition: items.qc:1431
float autocvar_g_balance_superweapons_time
Definition: items.qh:6
float autocvar_sv_simple_items
Definition: items.qh:19
float autocvar_g_items_mindist
Definition: items.qh:8
float respawntimejitter
Definition: items.qh:37
float respawntime
Definition: items.qh:36
float item_respawncounter
Definition: items.qh:40
entity item_model_ent
Definition: items.qh:29
bool Item_GiveTo(entity item, entity player)
Definition: items.qc:479
void UpdateItemAfterTeleport(entity this)
Definition: items.qc:92
bool is_item
Definition: items.qh:93
float GiveItems(entity e, float beginarg, float endarg)
Definition: items.qc:1504
bool ItemSend(entity this, entity to, int sf)
Definition: items.qc:31
#define IL_NEW()
void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, entity ammo_entity)
Give several random weapons and ammo to the entity.
Definition: items.qc:406
entity() spawn
void Item_FindTeam(entity this)
Definition: items.qc:749
void GiveRot(entity e, float v0, float v1,.float rotfield, float rottime,.float regenfield, float regentime)
Definition: items.qc:1447
void Item_ScheduleInitialRespawn(entity e)
Definition: items.qc:371
bool autocvar_g_fullbrightitems
Definition: items.qh:7
float GiveValue(entity e,.float fld, float op, float val)
entity to
Definition: self.qh:96
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
float respawntimestart
Definition: items.qh:38
float noalign
Definition: items.qh:42
float item_spawnshieldtime
Definition: items.qh:47
int count
Definition: items.qh:33
void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
Definition: items.qc:925
int item_group
Definition: items.qh:16
void StartItem(entity this, entity a)
int item_group_count
Definition: items.qh:17
void Item_ScheduleRespawn(entity e)
Definition: items.qc:351
void Item_Show(entity e, int mode)
Definition: items.qc:120
void Item_Reset(entity this)
Definition: items.qc:728
void Item_Touch(entity this, entity toucher)
Definition: items.qc:631
void Item_ScheduleRespawnIn(entity e, float t)
Definition: items.qc:286
STATIC_INIT(g_items)
Definition: items.qh:127
float scheduledrespawntime
Definition: items.qh:35
const float ITEM_RESPAWN_TICKS
Definition: items.qh:24
IntrusiveList g_items
Definition: items.qh:126
float autocvar_g_items_maxdist
Definition: items.qh:9
entity itemdef
Definition: items.qh:94
float generic_pickupevalfunc(entity player, entity item)
Definition: items.qc:797
float pickup_anyway
Definition: items.qh:32
float max_armorvalue
Definition: items.qh:31
Definition: sound.qh:119
float autocvar_g_items_dropped_lifetime
Definition: items.qh:10
spawnfunc(target_items)
Definition: items.qc:1242
bool autocvar_g_nodepthtestitems
Definition: items.qh:12
void ItemUpdate(entity this)
Definition: items.qc:86
float GiveWeapon(entity e, float wpn, float op, float val)
Definition: items.qc:1364
void setItemGroup(entity this)
Definition: items.qc:1171
float superweapons_finished
Definition: items.qh:44
void Item_Respawn(entity this)
Definition: items.qc:198
void Item_RespawnCountdown(entity this)
Definition: items.qc:218
bool have_pickup_item(entity this)
Definition: items.qc:98
float healtharmor_pickupevalfunc(entity player, entity item)
Definition: items.qc:889
void setItemGroupCount()
Definition: items.qc:1205
float ammo_pickupevalfunc(entity player, entity item)
Definition: items.qc:821
bool Item_GiveAmmoTo(entity item, entity player, Resource res_type, float ammomax)
Definition: items.qc:451
int autocvar_g_pickup_items
Definition: items.qh:11
float GiveBit(entity e,.float fld, float bit, float op, float val)
entity item_pickupsound_ent
Definition: items.qh:28
string item_pickupsound
Definition: items.qh:27
float weapon_pickupevalfunc(entity player, entity item)
Definition: items.qc:799