Left 4 Dead 2 Guide

VSLib Developer Guide - Random Item Spawning

Sharing is temporarily disabled

Left 4 Dead 2 Guide

This guide describes how to use the Random Item Spawning feature in VSLib. 

The feature gives you the ability to randomly spawn items at set spawnpoints at any time in your mutation or mod.

Class reference: https://l4d2scripters.github.io/vslib/docs/db/d2b/class_v_s_lib_1_1_random_item_spawner.html

Usage

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

Arguments:

spawnArray: An array of vectors or VSLib entity objects 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 array 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 } ]

Tagged

Community Tags

  • VSLib

Guide Credits

You may like

  • Mod
    Anti-Trolls System
    N/A

    This mod made to prevent those team killers(aka Trolls) from killing all teammates and abuse vote system >>This mod is using vscripts. so it can not be used together with any other mods of mine or Vscripts driven mods. Such as Admin Syst...

    7,343
  • Mod
    Augmented Bots
    N/A

    This mod makes bots pretty stronger than vanilla bots Can not use together with other vscripts mods such as Rectus' Custom weapons, Admin System or any other mods of mine Mod Features - Cs weapons are unlocked - Bots have 150 shield po...

    26,017
  • Mod
    Insanity Worlds
    N/A

    This is a vscripts driven mod Note that this mod doesn't work on any Custom Maps or Official Servers This mod is not mutation. it can runs on every game mode _____________________________________________________________________________...

    13,994
  • Mod
    Guns+ and SI+
    N/A

    it's a vscripts mod. so, can't be used together with mods that alternate gameplay directly(such as Admin System) but works fine with Weapon Script mods since i didn't use weapon script files Works only on Local Host and Singleplay. Does...

    29,265
  • Mod
    Brutal Apocalypse
    N/A

    THIS MOD IS USING A VSLIBs scripts. So it might be collided some Vslibs/Vscripts mods THIS MOD DOES NOT WORK ON CUSTOM CAMPAIGNS. ⋙WARNING!!!!⋘ This mod makes the game much more difficult. if you're easy to upset or play serious, you mig...

    22,118

Feedback