76 cvar_name = sprintf(
"g_%s_health_probability", prefix);
79 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
89 cvar_name = sprintf(
"g_%s_armor_probability", prefix);
92 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
102 cvar_name = sprintf(
"g_%s_resource_probability", prefix);
105 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
115 cvar_name = sprintf(
"g_%s_weapon_probability", prefix);
118 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
127 cvar_name = sprintf(
"g_%s_powerup_probability", prefix);
130 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
138 string class_name =
"";
144 prefix, instanceOfHealth);
150 prefix, instanceOfArmor);
156 prefix, instanceOfAmmo);
162 FOREACH(Weapons, it != WEP_Null &&
165 cvar_name = sprintf(
"g_%s_%s_probability", prefix,
166 it.m_canonical_spawnfunc);
167 if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS))
169 LOG_WARNF(
"Random items: cvar %s doesn't exist.",
182 prefix, instanceOfPowerup);
186 if (class_name !=
"")
202 string cvar_name = sprintf(
"g_random_items_replace_%s", item.classname);
205 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
218 string cvar_name = sprintf(
"g_%s_%s_probability", prefix,
219 it.m_canonical_spawnfunc);
222 LOG_WARNF(
"Random items: cvar %s doesn't exist.", cvar_name);
237 if (new_classnames ==
"")
241 string new_classname;
242 if (new_classnames ==
"random")
245 if (new_classname ==
"")
253 if (num_new_classnames == 1)
255 new_classname = new_classnames;
259 int classname_index =
floor(
random() * num_new_classnames);
260 new_classname =
argv(classname_index);
264 if (new_classname == item.classname)
275 if (new_item ==
NULL)
283 new_item.classname =
strzone(new_classname);
284 new_item.spawnfunc_checked =
true;
286 new_item.ok_item =
true;
289 if (wasfreed(new_item))
297 new_item.team = item.team;
308 if (class_name ==
"")
325 item.classname = class_name;
382 if (new_item ==
NULL)
399 vector loot_position = victim.origin +
'0 0 32';
402 for (
int item_index = 0; item_index < num_loot_items; ++item_index)
Item is usable during normal gameplay.
float autocvar_g_random_loot_time
Amount of time the loot will stay.
float autocvar_g_random_loot_max
Maximum amount of loot items.
string RandomSelection_chosen_string
bool Item_IsDefinitionAllowed(entity definition)
Checks whether the items with the specified definition are allowed to spawn.
string RandomItems_GetItemReplacementClassNames(entity item)
Returns list of classnames to replace a map item with.
void Item_Initialize(entity item, string class_name)
Initializes the item according to class name.
ERASEABLE void RandomSelection_Init()
bool Item_InitializeLoot(entity item, string class_name, vector position, vector vel, float time_to_live)
Initializes the loot item.
float CVAR_TYPEFLAG_EXISTS
bool autocvar_g_random_items
Whether to enable random items.
Header file that describes the random items mutator.
string RandomItems_GetRandomVanillaItemClassName(string prefix, int types)
Returns a random classname of the vanilla item.
#define RandomSelection_AddString(s, weight, priority)
float RandomSelection_chosen_float
float autocvar_g_random_loot_min
Classnames to replace s with.
#define MUTATOR_IS_ENABLED(this)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
string RandomItems_GetRandomItemClassName(string prefix)
Returns a random classname of the item.
string RandomItems_GetRandomItemClassNameWithProperty(string prefix,.bool item_property)
Returns a random classname of the item with specific property.
void RandomItems_SpawnLootItem(vector position)
Spawns a random loot item.
vector(float skel, float bonenum) _skel_get_boneabs_hidden
MUTATOR_HOOKFUNCTION(random_items, BuildMutatorsString)
#define RandomSelection_AddFloat(f, weight, priority)
bool autocvar_g_random_loot
Whether to enable random loot.
bool Item_ShouldKeepPosition(entity item)
Returns whether item should keep its position or be dropped to the ground.
entity Item_Create(string class_name, vector position, bool no_align)
Creates a new item.
#define MUTATOR_CALLHOOK(id,...)
bool Item_IsLoot(entity item)
Returns whether the item is loot.
const int WEP_FLAG_MUTATORBLOCKED
float autocvar_g_random_loot_spread
How far can loot be thrown.
entity RandomItems_ReplaceMapItem(entity item)
Replaces a map item.
bool random_items_is_spawning
Probability of random s spawning as loot.
#define FOREACH(list, cond, body)
void Item_ScheduleRespawn(entity e)
entity Item_CreateLoot(string class_name, vector position, vector vel, float time_to_live)
Creates a loot item.