]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items.qh
Merge branch 'master' into divVerent/4team_ctf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items.qh
1 const float BOT_PICKUP_RATING_LOW       = 2500;
2 const float BOT_PICKUP_RATING_MID       = 5000;
3 const float BOT_PICKUP_RATING_HIGH      = 10000;
4
5 const float WEP_TYPE_OTHER            =  0x00; // not for damaging people
6 const float WEP_TYPE_SPLASH           =  0x01; // splash damage
7 const float WEP_TYPE_HITSCAN          =  0x02; // hitscan
8 const float WEP_TYPEMASK            =  0x0F;
9 const float WEP_FLAG_CANCLIMB       =  0x10; // can be used for movement
10 const float WEP_FLAG_NORMAL         =  0x20; // in "most weapons" set
11 const float WEP_FLAG_HIDDEN         =  0x40; // hides from menu
12 const float WEP_FLAG_RELOADABLE     =  0x80; // can has reload
13 const float WEP_FLAG_SUPERWEAPON    = 0x100; // powerup timer
14 const float WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
15
16 const float     IT_UNLIMITED_WEAPON_AMMO     = 1;
17 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
18 const float     IT_UNLIMITED_SUPERWEAPONS    = 2;
19 // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
20 const float   IT_CTF_SHIELDED              = 4; // set for the flag shield
21 const float   IT_USING_JETPACK             = 8; // confirmation that button is pressed
22 const float   IT_JETPACK                   = 16; // actual item
23 const float   IT_FUEL_REGEN                = 32; // fuel regeneration trigger
24 WANT_CONST float   IT_SHELLS                    = 256;
25 WANT_CONST float   IT_NAILS                     = 512;
26 WANT_CONST float   IT_ROCKETS                   = 1024;
27 WANT_CONST float   IT_CELLS                     = 2048;
28 const float   IT_SUPERWEAPON               = 4096;
29 const float   IT_FUEL                      = 128;
30 const float   IT_STRENGTH                  = 8192;
31 const float   IT_INVINCIBLE                = 16384;
32 const float   IT_HEALTH                    = 32768;
33 // union:
34         // for items:
35         WANT_CONST float        IT_KEY1                                 = 131072;
36         WANT_CONST float        IT_KEY2                                 = 262144;
37         // for players:
38         const float     IT_RED_FLAG_TAKEN               = 32768;
39         const float     IT_RED_FLAG_LOST                = 65536;
40         const float     IT_RED_FLAG_CARRYING    = 98304;
41         const float     IT_BLUE_FLAG_TAKEN              = 131072;
42         const float     IT_BLUE_FLAG_LOST               = 262144;
43         const float     IT_BLUE_FLAG_CARRYING   = 393216;
44         const float     IT_YELLOW_FLAG_TAKEN    = 524288;
45         const float     IT_YELLOW_FLAG_LOST             = 1048576;
46         const float     IT_YELLOW_FLAG_CARRYING = 1572864;
47         const float     IT_PINK_FLAG_TAKEN              = 2097152;
48         const float     IT_PINK_FLAG_LOST               = 4194304;
49         const float     IT_PINK_FLAG_CARRYING   = 6291456;
50 // end
51 const float   IT_5HP                       = 524288;
52 const float   IT_25HP                      = 1048576;
53 const float   IT_ARMOR_SHARD               = 2097152;
54 const float   IT_ARMOR                     = 4194304;
55
56 const float   IT_AMMO                      = 3968; // IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_FUEL;
57 const float   IT_PICKUPMASK                = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
58 const float   IT_UNLIMITED_AMMO            = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
59
60 const float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
61
62 // variables:
63 string weaponorder_byid;
64
65 // functions:
66 entity get_weaponinfo(float id);
67 string W_FixWeaponOrder(string order, float complete);
68 string W_NameWeaponOrder(string order);
69 string W_NumberWeaponOrder(string order);
70
71 // ammo types
72 .float ammo_shells;
73 .float ammo_nails;
74 .float ammo_rockets;
75 .float ammo_cells;
76 .float ammo_fuel;
77 .float ammo_batteries; // dummy
78
79 // Weapon sets
80 typedef vector WepSet;
81 WepSet WepSet_FromWeapon(float a);
82 #ifdef SVQC
83 void WepSet_AddStat();
84 void WriteWepSet(float dest, WepSet w);
85 #endif
86 #ifdef CSQC
87 WepSet WepSet_GetFromStat();
88 WepSet ReadWepSet();
89 #endif
90
91 // Weapon name macros
92 #define WEP_FIRST 1
93 #define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much.
94 float WEP_COUNT;
95 float WEP_LAST;
96 WepSet WEPSET_ALL;
97 WepSet WEPSET_SUPERWEAPONS;
98
99 // entity properties of weaponinfo:
100 .float weapon; // WEP_...
101 .WepSet weapons; // WEPSET_...
102 .string netname; // short name
103 .string message; // human readable name
104 .float items; // IT_...
105 .float(float) weapon_func; // w_...
106 .string mdl; // modelname without g_, v_, w_
107 .string model; // full name of g_ model
108 .float spawnflags; // WEPSPAWNFLAG_... combined
109 .float impulse; // weapon impulse
110 .float bot_pickupbasevalue; // bot weapon priority
111 .string model2; // wpn- sprite name
112 ..float ammo_field; // main ammo field
113
114 // dynamic weapon adding
115 float w_null(float dummy);
116 void register_weapon(float id, WepSet bit, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
117 void register_weapons_done();
118
119 #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
120         float id; \
121         WepSet bit; \
122         float func(float); \
123         void RegisterWeapons_##id() \
124         { \
125                 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
126                 bit = WepSet_FromWeapon(id); \
127                 WEPSET_ALL |= bit; \
128                 if((weapontype) & WEP_FLAG_SUPERWEAPON) \
129                         WEPSET_SUPERWEAPONS |= bit; \
130                 ++WEP_COUNT; \
131                 register_weapon(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
132         } \
133         ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
134 #ifdef MENUQC
135 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
136         REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
137 #else
138 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
139         REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
140 #endif
141
142 #include "../server/w_all.qc"
143
144 #undef REGISTER_WEAPON
145 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done)
146
147
148 string W_FixWeaponOrder(string order, float complete);
149 string W_NumberWeaponOrder(string order);
150 string W_NameWeaponOrder(string order);
151 string W_FixWeaponOrder_BuildImpulseList(string o);
152 string W_FixWeaponOrder_AllowIncomplete(string order);
153 string W_FixWeaponOrder_ForceComplete(string order);
154
155 void W_RandomWeapons(entity e, float n);
156
157 string W_Name(float weaponid);
158
159 float W_AmmoItemCode(float wpn);