So: Easy Item Placement Randomizer
I just coded this for my dungeon and thought it could be useful to others. Simply placed in a script entity in your dungeon, this script spreads out randomly a list of items to a list of alcoves when the dungeon is initialized. (Works with monsters & containers too).
I tried to code the script so that it's very easy to put in lists of items and destinations for those with lesser scripting skills. In the example below, the armor of valor set is spread between 5 alcoves, and a lucky ogre gets one too!
The commented line prints what went where, for debug purposes.
Code: Select all
function distributeItems()
local targetIndex = 0
local itemsTable = {
"boots_valor",
"cuirass_valor",
"gauntlets_valor",
"greaves_valor",
"helmet_valor",
"shield_valor",
}
local alcovesTable = {
temple_alcove_1,
temple_alcove_2,
temple_alcove_3,
temple_alcove_4,
temple_alcove_5,
ogre_1,
}
for i, v in ipairs(itemsTable) do
targetIndex = math.random(# alcovesTable)
alcovesTable[targetIndex]:addItem(spawn(v))
--print(v," went to ",alcovesTable[targetIndex].id)
table.remove(alcovesTable,targetIndex)
end
end
distributeItems()
