Left 4 Dead 2

Left 4 Dead 2

Not enough ratings
EMS: VSLib Random Item Spawning
By Rectus
This guide described how to use the Random Item Spawning feature in VSLib.

The script gives you the ability to randomly spawn items at set spawnpoints at any time in your mutation. It's a similar to the weapon spawning in Killing Floor, or the Battlefield 3 Scavenger mode.

Note: This script is intended to be used when authoring mutations.
 
Rate  
Favorite
Favorited
Unfavorite
Usage
Download: VSLib GitHub[github.com]

VSLib Documentation[zombiescanfly.com]

To use the script, include it into any script with:
IncludeScript("VSLib");

To intitialize a spawner create a spawner object:
VSLib.RandomItemSpawner(spawnArray, itemArray = null, flags = 0)

Arguments:

spawnArray: An array of vectors or VSLib entities for the location spawn points.

itemArray: An array of spawnable items (see Spawn Lists for more information).

itemList: Use a custom item list of the same format as the one below.
flags:
RANDOM_USEPARTICLES: Spawns a fireworks particle effect where an item spawns.
RANDOM_ALLOWMULTIPLEITEMS: Can spawn multiple items on the same spawnpoint during a single call of SpawnRandomItems().


Example:
mySpawner <- VSLib.RandomItemSpawner(mySpawnArray, myItemArray, (RANDOM_USEPARTICLES | RANDOM_ALLOWMULTIPLEITEMS));


Items are spawned with: SpawnRandomItems(amount)
Where amount is the number of items spawned. The function returns an arrray with the entity objects of the items spawned.

Example:
spawnedItemArray = mySpawner.SpawnRandomItems(5);
Spawn Lists
This list determines what items can spawn, and the probability of each weapon spawning. If no list is specified, the default one below is used.

The item probability is relative to the other items, the actual spawning probability is the items probability divided by the probabilities of all items added together.

Melee weapons and upgrades get converted to other entities when they spawn. They are untrackable, and will not be returned by the spawning function.

ent: Classname of the item. The spawn list currently supports the entities specified below.
prob: This is the probability for the item to spawn.
ammo: The ammo reserves primary weapons spawn with. Weapons spawn with double the value set. Set to null on other items.
melee_type: Works the same way as on a weapon_melee_spawn. Set to null if not a melee weapon.

myItemArray <- [//[] //Entity: Probability: Ammo: Melee type: {ent = "weapon_rifle" prob = 10, ammo = 50, melee_type = null }, {ent = "weapon_shotgun_spas" prob = 10, ammo = 10, melee_type = null }, {ent = "weapon_sniper_military" prob = 10, ammo = 15, melee_type = null }, {ent = "weapon_rifle_ak47" prob = 10, ammo = 40, melee_type = null }, {ent = "weapon_autoshotgun" prob = 10, ammo = 10, melee_type = null }, {ent = "weapon_rifle_desert" prob = 10, ammo = 60, melee_type = null }, {ent = "weapon_hunting_rifle" prob = 15, ammo = 15, melee_type = null }, {ent = "weapon_rifle_m60" prob = 2, ammo = 50, melee_type = null }, {ent = "weapon_grenade_launcher" prob = 2, ammo = 50, melee_type = null }, {ent = "weapon_smg_silenced" prob = 20, ammo = 50, melee_type = null }, {ent = "weapon_smg" prob = 20, ammo = 50, melee_type = null }, {ent = "weapon_shotgun_chrome" prob = 20, ammo = 10, melee_type = null }, {ent = "weapon_pumpshotgun" prob = 20, ammo = 10, melee_type = null }, {ent = "weapon_pistol_magnum" prob = 5, ammo = null, melee_type = null }, {ent = "weapon_pistol" prob = 10, ammo = null, melee_type = null }, {ent = "weapon_adrenaline" prob = 10, ammo = null, melee_type = null }, {ent = "weapon_pain_pills" prob = 20, ammo = null, melee_type = null }, {ent = "weapon_vomitjar" prob = 3, ammo = null, melee_type = null }, {ent = "weapon_molotov" prob = 10, ammo = null, melee_type = null }, {ent = "weapon_pipe_bomb" prob = 10, ammo = null, melee_type = null }, {ent = "weapon_first_aid_kit" prob = 1, ammo = null, melee_type = null }, // Note: These items don't retain their entities when spawned, and cannot be tracked. {ent = "weapon_melee_spawn" prob = 10, ammo = null, melee_type = "any" }, {ent = "upgrade_spawn" prob = 3, ammo = null, melee_type = null }, // Laser sight only {ent = "weapon_upgradepack_explosive" prob = 5, ammo = null, melee_type = null }, {ent = "weapon_upgradepack_incendiary" prob = 7, ammo = null, melee_type = null }, //[] ]
< >
2 Comments
YAZEED Dec 4, 2016 @ 9:14am 
.
Stewie Oct 30, 2013 @ 9:28am 
i almost instantly left when i saw download.

nty T-T