X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fitems.qh;h=7b0d760df6e61afe908d4aaaf17b3263d1f022ca;hp=35cc00232bfd329eab32beeb5907f6707852f7aa;hb=4eab3f0253a063bdbd4e1ff64c4b2b08077c44c4;hpb=ace43a0b9fc339c80df65741952b07dd2bc5f52f diff --git a/qcsrc/common/items.qh b/qcsrc/common/items.qh index 35cc00232b..7b0d760df6 100644 --- a/qcsrc/common/items.qh +++ b/qcsrc/common/items.qh @@ -1,153 +1,138 @@ -const float BOT_PICKUP_RATING_LOW = 2500; -const float BOT_PICKUP_RATING_MID = 5000; -const float BOT_PICKUP_RATING_HIGH = 10000; - -const float WEP_TYPE_OTHER = 0x00; // not for damaging people -const float WEP_TYPE_SPLASH = 0x01; // splash damage -const float WEP_TYPE_HITSCAN = 0x02; // hitscan -const float WEP_TYPEMASK = 0x0F; -const float WEP_FLAG_CANCLIMB = 0x10; // can be used for movement -const float WEP_FLAG_NORMAL = 0x20; // in "most weapons" set -const float WEP_FLAG_HIDDEN = 0x40; // hides from menu -const float WEP_FLAG_RELOADABLE = 0x80; // can has reload -const float WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer -const float WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag) - -const float IT_UNLIMITED_WEAPON_AMMO = 1; -// when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup. -const float IT_UNLIMITED_SUPERWEAPONS = 2; -// when this bit is set, superweapons don't expire. Checkpoints can give this powerup. -const float IT_CTF_SHIELDED = 4; // set for the flag shield -const float IT_USING_JETPACK = 8; // confirmation that button is pressed -const float IT_JETPACK = 16; // actual item -const float IT_FUEL_REGEN = 32; // fuel regeneration trigger -WANT_CONST float IT_SHELLS = 256; -WANT_CONST float IT_NAILS = 512; -WANT_CONST float IT_ROCKETS = 1024; -WANT_CONST float IT_CELLS = 2048; -const float IT_SUPERWEAPON = 4096; -const float IT_FUEL = 128; -const float IT_STRENGTH = 8192; -const float IT_INVINCIBLE = 16384; -const float IT_HEALTH = 32768; -// union: - // for items: - WANT_CONST float IT_KEY1 = 131072; - WANT_CONST float IT_KEY2 = 262144; - // for players: - const float IT_RED_FLAG_TAKEN = 32768; - const float IT_RED_FLAG_LOST = 65536; - const float IT_RED_FLAG_CARRYING = 98304; - const float IT_BLUE_FLAG_TAKEN = 131072; - const float IT_BLUE_FLAG_LOST = 262144; - const float IT_BLUE_FLAG_CARRYING = 393216; -// end -const float IT_5HP = 524288; -const float IT_25HP = 1048576; -const float IT_ARMOR_SHARD = 2097152; -const float IT_ARMOR = 4194304; - -const float IT_AMMO = 3968; // IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_FUEL; -const float IT_PICKUPMASK = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately -const float IT_UNLIMITED_AMMO = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO; - -const float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel - -// variables: -string weaponorder_byid; - -// functions: -entity get_weaponinfo(float id); -string W_FixWeaponOrder(string order, float complete); -string W_NameWeaponOrder(string order); -string W_NumberWeaponOrder(string order); - -// ammo types -.float ammo_shells; -.float ammo_nails; -.float ammo_rockets; -.float ammo_cells; -.float ammo_fuel; -.float ammo_batteries; // dummy - -// Weapon sets -typedef vector WepSet; -WepSet WepSet_FromWeapon(float a); +#pragma once + +const int AMMO_COUNT = 4; // amount of ammo types to show in the ammo panel + +// item networking +const int ISF_LOCATION = BIT(1); +const int ISF_MODEL = BIT(2); +const int ISF_STATUS = BIT(3); + const int ITS_STAYWEP = BIT(0); + const int ITS_ANIMATE1 = BIT(1); + const int ITS_ANIMATE2 = BIT(2); + const int ITS_AVAILABLE = BIT(3); + const int ITS_ALLOWFB = BIT(4); + const int ITS_ALLOWSI = BIT(5); + const int ITS_GLOW = BIT(6); +const int ISF_COLORMAP = BIT(4); +const int ISF_DROP = BIT(5); +const int ISF_ANGLES = BIT(6); +const int ISF_SIZE = BIT(7); + +.int ItemStatus; + +.float onground_time; +.float fade_start; +.float fade_end; + #ifdef SVQC -void WepSet_AddStat(); -void WriteWepSet(float dest, WepSet w); +void StartItem(entity this, entity a); +.int item_group; +.int item_group_count; #endif + #ifdef CSQC -WepSet WepSet_GetFromStat(); -WepSet ReadWepSet(); -#endif -// Weapon name macros -#define WEP_FIRST 1 -#define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much. -float WEP_COUNT; -float WEP_LAST; -WepSet WEPSET_ALL; -WepSet WEPSET_SUPERWEAPONS; - -// entity properties of weaponinfo: -.float weapon; // WEP_... -.WepSet weapons; // WEPSET_... -.string netname; // short name -.string message; // human readable name -.float items; // IT_... -.float(float) weapon_func; // w_... -.string mdl; // modelname without g_, v_, w_ -.string model; // full name of g_ model -.float spawnflags; // WEPSPAWNFLAG_... combined -.float impulse; // weapon impulse -.float bot_pickupbasevalue; // bot weapon priority -.string model2; // wpn- sprite name -..float ammo_field; // main ammo field - -// dynamic weapon adding -float w_null(float dummy); -void register_weapon(float id, WepSet bit, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname); -void register_weapons_done(); - -#define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \ - float id; \ - WepSet bit; \ - float func(float); \ - void RegisterWeapons_##id() \ - { \ - WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \ - bit = WepSet_FromWeapon(id); \ - WEPSET_ALL |= bit; \ - if((weapontype) & WEP_FLAG_SUPERWEAPON) \ - WEPSET_SUPERWEAPONS |= bit; \ - ++WEP_COUNT; \ - register_weapon(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \ - } \ - ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id) -#ifdef MENUQC -#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \ - REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) -#else -#define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \ - REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) +bool autocvar_cl_items_nofade; +float autocvar_cl_animate_items = 1; +float autocvar_cl_ghost_items = 0.45; +vector autocvar_cl_ghost_items_color = '-1 -1 -1'; +vector autocvar_cl_weapon_stay_color = '2 0.5 0.5'; +float autocvar_cl_weapon_stay_alpha = 0.75; +float autocvar_cl_simple_items = 0; +string autocvar_cl_simpleitems_postfix = "_simple"; +.float spawntime; +.float gravity; +.vector colormod; + +void ItemDraw(entity this); + #endif +#ifdef SVQC + +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; + +.float max_armorvalue; +.float pickup_anyway; + +.float item_respawncounter; + +void Item_Show (entity e, int mode); + +void Item_Respawn (entity this); + +void Item_RespawnCountdown(entity this); +void Item_ScheduleRespawnIn(entity e, float t); + +void Item_ScheduleRespawn(entity e); + +void Item_ScheduleInitialRespawn(entity e); -#include "../server/w_all.qc" +/// \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] ammo Entity containing the ammo amount for each possible weapon. +/// \return No return. +void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, entity ammo_entity); -#undef REGISTER_WEAPON -ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done); +bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax); +bool Item_GiveTo(entity item, entity player); -string W_FixWeaponOrder(string order, float complete); -string W_NumberWeaponOrder(string order); -string W_NameWeaponOrder(string order); -string W_FixWeaponOrder_BuildImpulseList(string o); -string W_FixWeaponOrder_AllowIncomplete(string order); -string W_FixWeaponOrder_ForceComplete(string order); +void Item_Touch(entity this, entity toucher); -void W_RandomWeapons(entity e, float n); +void Item_Reset(entity this); -string W_Name(float weaponid); +void Item_FindTeam(entity this); +// Savage: used for item garbage-collection -float W_AmmoItemCode(float wpn); +bool ItemSend(entity this, entity to, int sf); +void ItemUpdate(entity this); + +void UpdateItemAfterTeleport(entity this); + +// pickup evaluation functions +// these functions decide how desirable an item is to the bots + +float generic_pickupevalfunc(entity player, entity item);// {return item.bot_pickupbasevalue;} // WEAPONTODO + +float weapon_pickupevalfunc(entity player, entity item); +float ammo_pickupevalfunc(entity player, entity item); +float healtharmor_pickupevalfunc(entity player, entity item); + +.bool is_item; +.entity itemdef; +void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter); + +void setItemGroup(entity this); +void setItemGroupCount(); + +float GiveWeapon(entity e, float wpn, float op, float val); + +float GiveBit(entity e, .float fld, float bit, float op, float val); + +float GiveValue(entity e, .float fld, float op, float val); + +void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_decr); + +void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime); + +spawnfunc(target_items); + +#define PREGIVE_WEAPONS(e) WepSet save_weapons; save_weapons = STAT(WEAPONS, e) +#define PREGIVE(e,f) float save_##f; save_##f = (e).f +#define PREGIVE_RESOURCE(e,f) float save_##f = GetResource((e), (f)) +#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_RESOURCE(e,f,t,snd_incr,snd_decr) GiveSound((e), save_##f, GetResource((e), (f)), t, snd_incr, snd_decr) +#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) +#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) + +float GiveItems(entity e, float beginarg, float endarg); +#endif