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 =
"";
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.",
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)
272 new_item.classname =
strzone(new_classname);
273 new_item.lifetime = -1;
275 new_item.ok_item =
true;
280 return wasfreed(new_item) ?
NULL : new_item;
289 if (class_name ==
"")
299 item.classname = class_name;
300 item.origin = position;
301 item.velocity = spread;
360 if (new_item ==
NULL)
377 vector loot_position = victim.origin +
'0 0 32';
380 for (
int item_index = 0; item_index < num_loot_items; ++item_index)
#define MUTATOR_CALLHOOK(id,...)
#define MUTATOR_IS_ENABLED(this)
#define MUTATOR_HOOKFUNCTION(...)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
@ ITEM_FLAG_NORMAL
Item is usable during normal gameplay.
float CVAR_TYPEFLAG_EXISTS
bool Item_Initialise(entity item)
An optimised and generic way to initialise items (loot or permanent)
bool Item_IsDefinitionAllowed(entity definition)
Checks whether the items with the specified definition are allowed to spawn.
#define ITEM_IS_LOOT(item)
Returns whether the item is loot.
#define FOREACH(list, cond, body)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
ERASEABLE void RandomSelection_Init()
float RandomSelection_chosen_float
string RandomSelection_chosen_string
#define RandomSelection_AddFloat(f, weight, priority)
#define RandomSelection_AddString(s, weight, priority)
void Item_ScheduleRespawn(entity e)
void Item_CopyFields(entity this, entity to)
float autocvar_g_random_loot_time
Amount of time the loot will stay.
string RandomItems_GetItemReplacementClassNames(entity item)
Returns list of classnames to replace a map item with.
entity RandomItems_ReplaceMapItem(entity item)
Replaces a map item.
bool random_items_is_spawning
Probability of random s spawning as loot.
string RandomItems_GetRandomItemClassNameWithProperty(string prefix,.bool item_property)
Returns a random classname of the item with specific property.
float autocvar_g_random_loot_min
Classnames to replace s with.
string RandomItems_GetRandomItemClassName(string prefix)
Returns a random classname of the item.
float autocvar_g_random_loot_max
Maximum amount of loot items.
string RandomItems_GetRandomVanillaItemClassName(string prefix, int types)
Returns a random classname of the vanilla item.
void RandomItems_SpawnLootItem(vector position)
Spawns a random loot item.
float autocvar_g_random_loot_spread
How far can loot be thrown.
Header file that describes the random items mutator.
bool autocvar_g_random_items
Whether to enable random items.
bool autocvar_g_random_loot
Whether to enable random loot.
@ RANDOM_ITEM_TYPE_RESOURCE
@ RANDOM_ITEM_TYPE_HEALTH
@ RANDOM_ITEM_TYPE_WEAPON
@ RANDOM_ITEM_TYPE_POWERUP
const int WEP_FLAG_MUTATORBLOCKED