I'm not even going to try anything clever or complicated (at least not yet anyway), I'd rather just begin with the simple basics.
1: WHAT GOES WHERE
1 = Current active Left Hand
2 = Current active Right Hand
3 = Head
4 = Chest
5 = Legs
6 = Feet
7 = Cloak
8 = Necklace
9 = Gloves
10 = Bracers
11 = Current inactive Left Hand
12 = Current inactive Right Hand
13 - 32 = Backpack

While it is possible to do this outside of a function, I found the editor isn't always happy if I do, and gives some interesting error messages, especially the first time I load it. So, I've used a function triggered by a timer to avoid this problem.
First, place a timer and set the timerInterval to 0.01 seconds and make sure the timer and disableSelf boxes are both checked.
Now place a script_entity and add the following script:
Code: Select all
function startItems()
local i = 1
repeat
if party.party:getChampion(1):getEnabled() then
party.party:getChampion(1):removeItemFromSlot(i)
end
if party.party:getChampion(2):getEnabled() then
party.party:getChampion(2):removeItemFromSlot(i)
end
if party.party:getChampion(3):getEnabled() then
party.party:getChampion(3):removeItemFromSlot(i)
end
if party.party:getChampion(4):getEnabled() then
party.party:getChampion(4):removeItemFromSlot(i)
end
i = i + 1
until i == 33
if party.party:getChampion(1):getEnabled() then
party.party:getChampion(1):insertItem(1,spawn("compass").item)
party.party:getChampion(1):insertItem(2,spawn("dagger").item)
party.party:getChampion(1):insertItem(4,spawn("peasant_tunic").item)
party.party:getChampion(1):insertItem(5,spawn("peasant_breeches").item)
party.party:getChampion(1):insertItem(6,spawn("sandals").item)
end
if party.party:getChampion(2):getEnabled() then
party.party:getChampion(2):insertItem(1,spawn("torch").item)
party.party:getChampion(2):insertItem(4,spawn("peasant_tunic").item)
party.party:getChampion(2):insertItem(5,spawn("peasant_breeches").item)
party.party:getChampion(2):insertItem(6,spawn("sandals").item)
end
if party.party:getChampion(3):getEnabled() then
party.party:getChampion(3):insertItem(2,spawn("rock").item)
party.party:getChampion(3):insertItem(4,spawn("peasant_tunic").item)
party.party:getChampion(3):insertItem(5,spawn("peasant_breeches").item)
party.party:getChampion(3):insertItem(6,spawn("sandals").item)
end
if party.party:getChampion(4):getEnabled() then
party.party:getChampion(4):insertItem(4,spawn("peasant_tunic").item)
party.party:getChampion(4):insertItem(5,spawn("peasant_breeches").item)
party.party:getChampion(4):insertItem(6,spawn("sandals").item)
end
end
Trying to insert an item into a slot that isn't empty will result in the item being spawned on the floor, which is why I added the little loop to remove all existing items first, otherwise you'll end up with a heap of gear on the floor if you refresh / restart the dungeon in the editor:

You will also end up with items on the floor if you try to insert an item into the wrong slot, such as trying to place a pair of boots on a champion's head!
3: A BIT MORE COMPLICATED
Now that I've managed to get the basic principle working, I wanted to see if I could find a fairly simple and easy way to make the items more tailor-made to each champion.
Like everything else in life, it's easy when you know how, I just had to try and figure out what works and what doesn't first.
So, without further ado, here's the new script that I managed to get working:
Code: Select all
function startItems()
local i
local i = 1
repeat
if party.party:getChampion(1):getEnabled() then
party.party:getChampion(1):removeItemFromSlot(i)
end
if party.party:getChampion(2):getEnabled() then
party.party:getChampion(2):removeItemFromSlot(i)
end
if party.party:getChampion(3):getEnabled() then
party.party:getChampion(3):removeItemFromSlot(i)
end
if party.party:getChampion(4):getEnabled() then
party.party:getChampion(4):removeItemFromSlot(i)
end
i = i + 1
until i > 32
local i = 1
repeat
if party.party:getChampion(i):getEnabled() then
-- CHECK FOR SOME BASIC CHAMPION STATS --
local champ_ord = party.party:getChampion(i):getOrdinal()
local champ_race = party.party:getChampion(i):getRace()
local champ_class = party.party:getChampion(i):getClass()
-- MAKE THE MAIN HAND THE ONE CLOSEST TO THE CENTRE --
if champ_ord == 1 or champ_ord == 3 then
mainhand_slot = 2
offhand_slot = 1
else
mainhand_slot = 1
offhand_slot = 2
end
-- SOME SIMPLE CLOTHING --
party.party:getChampion(i):insertItem(4,spawn("peasant_tunic").item)
party.party:getChampion(i):insertItem(5,spawn("peasant_breeches").item)
party.party:getChampion(i):insertItem(6,spawn("sandals").item)
-- SOME EXTRA FOOD FOR MINOTAURS --
if champ_race == "minotaur" then
party.party:getChampion(i):insertItem(13,spawn("mole_jerky").item)
end
-- ALCHEMIST ITEMS --
if champ_class == "alchemist" then
local alchemist_mainhand = spawn("dart")
alchemist_mainhand.item:setStackSize(5)
party.party:getChampion(i):insertItem(mainhand_slot,alchemist_mainhand.item)
end
-- BARBARIAN ITEMS --
if champ_class == "barbarian" then
party.party:getChampion(i):insertItem(mainhand_slot,spawn("bone_club").item)
end
-- BATTLE MAGE ITEMS --
if champ_class == "battle_mage" then
local battle_mage_offhand = spawn("rock")
battle_mage_offhand.item:setStackSize(2)
party.party:getChampion(i):insertItem(offhand_slot,battle_mage_offhand.item)
end
-- FARMER ITEMS --
if champ_class == "farmer" then
party.party:getChampion(i):insertItem(mainhand_slot,spawn("shovel").item)
end
-- FIGHTER ITEMS --
if champ_class == "fighter" then
party.party:getChampion(i):insertItem(mainhand_slot,spawn("dagger").item)
end
-- KNIGHT ITEMS --
if champ_class == "knight" then
party.party:getChampion(i):insertItem(mainhand_slot,spawn("dagger").item)
end
-- ROGUE ITEMS --
if champ_class == "rogue" then
local rogue_mainhand = spawn("dart")
rogue_mainhand.item:setStackSize(5)
party.party:getChampion(i):insertItem(mainhand_slot,rogue_mainhand.item)
end
-- WIZARD ITEMS --
if champ_class == "wizard" then
local wizard_offhand = spawn("rock")
wizard_offhand.item:setStackSize(2)
party.party:getChampion(i):insertItem(offhand_slot,wizard_offhand.item)
end
end
i = i + 1
until i > 4
end
1: I put everything in a repeat, so I wouldn't end up with a separate block of script for each champion (DRY!).
2: The script now gathers some basic information about the champions (classes and races) that we can use to decide what kind of items we want to give them.
3: The mainhand slot will always be the one closest to the middle, based on the champions' initial starting positions within the party.