29 ratings
EMS: Random Item Spawning Script
By Rectus
This is a slightly simpler version of the random item spawning script I made for Gun Hunt. It is only usable with the Extended Mutation System in the Left 4 Dead 2 Beta.

The script gives you the ability to randomly spawn items at preset spawnpoints at any time you choose. It's a similar to the weapon spawning in Killing Floor, or the Battlefield 3 Scavenger mode. It is made to work in an EMS mutation script, but can with some modification work with map level scripts as well.


NOTE!
The up to date version of the script is avalable in VSLib[github.com].
 
Rate  
Favorite
Favorited
Unfavorite
Usage
Download: VSLib github
https://github.com/L4D2Scripters/vslib

Pastebin links (old version without class):
Script[pastebin.com]
Entity Group[pastebin.com]

The spawner uses an array of vectors or VSLib entities for spawn points.

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)

There are two optional argumets:

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 }, //[] ]
< >
19 Comments
Rectus  [author] Jul 29 @ 12:35am 
I'm not sure, I haven't tried it. This is a library meant to be accessed from inside another script though, so you wouldn't really have any gain from loading it from a console commnad.
girly Jul 28 @ 5:45pm 
does script_execute work for this? I don't want the IncludeScript
Nastya May 22 @ 12:45pm 
Left 4 Dead 2 Beta как удалить с аккаунта стим?
AmazingJ Feb 22 @ 4:32am 
wo:GiveHug:w
Fina Nov 23, 2017 @ 3:50pm 
wow
Rectus  [author] Apr 30, 2017 @ 12:27am 
Check out the dates on the guide. People were using the beta when there was actual stuff to beta test.
PootisPootsPoot Apr 29, 2017 @ 8:32pm 
why would you make a guide for a beta that no one plays?
Nazo The Negative™ Mar 17, 2017 @ 3:33pm 
basically i use all the mods on the l4d2 beta work out too well
绝地小聋瞎 Apr 29, 2016 @ 11:11pm 
...
HOLOS VENTA Mar 6, 2016 @ 11:17am 
trust me
it does work i trid it