]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/random_items/sv_random_items.qh
Merge branch 'master' into martin-t/dmgtext
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / random_items / sv_random_items.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the random items mutator.
5 /// \author Lyberta
6 /// \copyright GNU GPLv2 or any later version.
7
8 bool autocvar_g_random_items; ///< Whether to enable random items.
9 bool autocvar_g_random_loot; ///< Whether to enable random loot.
10
11 enum
12 {
13         RANDOM_ITEM_TYPE_HEALTH = BIT(0),
14         RANDOM_ITEM_TYPE_ARMOR = BIT(1),
15         RANDOM_ITEM_TYPE_RESOURCE = BIT(2),
16         RANDOM_ITEM_TYPE_WEAPON = BIT(3),
17         RANDOM_ITEM_TYPE_POWERUP = BIT(4),
18         RANDOM_ITEM_TYPE_ALL = BITS(5)
19 };
20
21 /// \brief Returns a random classname of the item.
22 /// \param[in] prefix Prefix of the cvars that hold probabilities.
23 /// \return Random classname of the item.
24 /// \note This function will automatically detect gamemode and use cvars from
25 /// that gamemode.
26 string RandomItems_GetRandomItemClassName(string prefix);
27
28 /// \brief Returns a random classname of the vanilla item.
29 /// \param[in] prefix Prefix of the cvars that hold probabilities.
30 /// \param[in] types Bitmask of the types. See RANDOM_ITEM_TYPE constants.
31 /// \return Random classname of the vanilla item.
32 /// \note This includes mutator items that don't change gameplay a lot such as
33 /// jetpack and new toys.
34 string RandomItems_GetRandomVanillaItemClassName(string prefix, int types);
35
36 /// \brief Called when random item classname is requested.
37 #define EV_RandomItems_GetRandomItemClassName(i, o) \
38         /** prefix */    i(string, MUTATOR_ARGV_0_string) \
39         /** classname */ o(string, MUTATOR_ARGV_1_string) \
40     /**/
41 MUTATOR_HOOKABLE(RandomItems_GetRandomItemClassName,
42         EV_RandomItems_GetRandomItemClassName);
43
44 REGISTER_MUTATOR(random_items, (autocvar_g_random_items ||
45         autocvar_g_random_loot));