Currently allows defining of left and right hand weapons per class, including stack size for throwing items and ammo (both hands). Allows defining equipable items for all non-weapon slots per class. Allows defining one or more food items per race. Allows defining one or more items for the party. Party items must fit in the inventory of one single champion, and the first available champion is selected for this. The script currently doesn't check if there is enough inventory space for items.
Call the function startItems() to equip the party.
Don't hesitate to ask for additions and changes

Code: Select all
classWeapons = {}
classWeapons["alchemist"] = {
leftHand = "rock", leftStack = 3,
rightHand = "", rightStack = 0
}
classWeapons["barbarian"] = {
leftHand = "bone_club", leftStack = 0,
rightHand = "", rightStack = 0
}
classWeapons["battle_mage"] = {
leftHand = "rock", leftStack = 3,
rightHand = "", rightStack = 0
}
classWeapons["farmer"] = {
leftHand = "rock", leftStack = 3,
rightHand = "", rightStack = 0
}
classWeapons["fighter"] = {
leftHand = "branch", leftStack = 0,
rightHand = "", rightStack = 0
}
classWeapons["knight"] = {
leftHand = "branch", leftStack = 0,
rightHand = "", rightStack = 0
}
classWeapons["rogue"] = {
leftHand = "rock", leftStack = 3,
rightHand = "", rightStack = 0
}
classWeapons["wizard"] = {
leftHand = "rock", leftStack = 3,
rightHand = "", rightStack = 0
}
classArmor = {}
classArmor["alchemist"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["barbarian"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["battle_mage"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["farmer"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["fighter"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["knight"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["rogue"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
classArmor["wizard"] = {
head = "",
necklace = "",
cloak = "",
chest = "tattered_shirt",
gloves = "",
bracers = "",
legs = "torn_breeches",
feet = "sandals"
}
partyItems = {
"torch",
"compass",
"timepiece",
"rope",
"sack"
}
raceItems = {}
raceItems["human"] = {"rotten_pitroot_bread"}
raceItems["insectoid"] = {"baked_maggot"}
raceItems["lizardman"] = {"boiled_beetle"}
raceItems["minotaur"] = {"mole_jerky"}
raceItems["ratling"] = {"cheese"}
function startItems()
local a
for a = 1, 4 do
local champion = party.party:getChampion(a)
if champion:getEnabled() == true then
unequipChampion(champion)
addChampionItems(champion)
end
end
addPartyItems()
end
function unequipChampion(champion)
local b
for b=1,32,1 do
champion:removeItemFromSlot(b)
end
end
function addItem(champion,slot,itemName,stackSize)
if itemName ~= "" then
local item = spawn(itemName)
if stackSize > 0 then
item.item:setStackSize(stackSize)
end
champion:insertItem(slot,item.item)
end
end
function getFirstEmptySlot(champion)
local a
for a = 13, 32 do
if champion:getItem(a) == nil then
return a
end
end
return 0
end
function addChampionItems(champion)
local cWeapons = classWeapons[champion:getClass()]
local cArmor = classArmor[champion:getClass()]
local rItems = raceItems[champion:getRace()]
addItem(champion, 1, cWeapons.leftHand, cWeapons.leftStack)
addItem(champion, 2, cWeapons.rightHand, cWeapons.rightStack)
addItem(champion, 3, cArmor.head, 0)
addItem(champion, 4, cArmor.chest, 0)
addItem(champion, 5, cArmor.legs, 0)
addItem(champion, 6, cArmor.feet, 0)
addItem(champion, 7, cArmor.cloak, 0)
addItem(champion, 8, cArmor.necklace, 0)
addItem(champion, 9, cArmor.gloves, 0)
addItem(champion, 10, cArmor.bracers, 0)
local slot = getFirstEmptySlot(champion)
local a
for a, item in ipairs(rItems) do
addItem(champion, slot, item, 0)
slot = slot + 1
end
end
function addPartyItems()
local a
for a = 1, 4 do
local champion = party.party:getChampion(a)
if champion:getEnabled() then
local slot = getFirstEmptySlot(champion)
if slot > 0 then
for b, itemName in ipairs(partyItems) do
addItem(champion, slot, itemName, 0)
slot = slot + 1
end
break
end
end
end
end