Party script:
Code: Select all
cloneObject{
baseObject = "party",
name = "party",
onDie = function(champ)
--Checking, is there anyone else alive
local livingChampions = 0
for partyNum = 1,4 do
if party:getChampion(partyNum):isAlive() then
livingChampions = livingChampions + 1
end
end
if livingChampions > 0 then
--the items
for slot1 = 1,31 do
local old1 = champ:getItem(slot1)
if old1 then
local new1 = spawn(old1.name, party.level, party.x, party.y, party.facing)
--setting Fuel
if old1:getFuel() ~= 0 then
new1:setFuel(old1:getFuel())
end
--stackSize
if old1:getStackSize() > 0 then
new1:setStackSize(old1:getStackSize())
end
--Charges
if old1:getCharges() > 0 then
new1:setCharges(old1:getCharges())
end
--Note or Scroll
if old1:getScrollText() then
new1:setScrollText(old1:getScrollText())
end
if old1:getScrollImage() then
new1:setScrollImage(old1:getScrollImage())
end
--CONTAINER
for slot2 = 1,10 do
local old2 = old1:getItem(slot2)
if old2 then
local new2 = spawn(old2.name, party.level, party.x, party.y, party.facing)
--if container contains Torch
if old2:getFuel() ~= 0 then
new2:setFuel(old2:getFuel())
end
--stackSize
if old2:getStackSize() > 0 then
new2:setStackSize(old2:getStackSize())
end
--Charges
if old2:getCharges() > 0 then
new2:setCharges(old2:getCharges())
end
--Note or Scroll
if old2:getScrollText() then
new2:setScrollText(old2:getScrollText())
end
if old2:getScrollImage() then
new2:setScrollImage(old2:getScrollImage())
end
--Mortar (mortar is the only container that goes into container)
if old2.name == "mortar" then
for slot3 = 1,6 do
local old3 = old2:getItem(slot3)
if old3 then
local new3 = spawn(old3.name, party.level, party.x, party.y, party.facing)
--if mortar contains Torch
if old3:getFuel() ~= 0 then
new3:setFuel(old3:getFuel())
end
--stackSize
if old3:getStackSize() > 0 then
new3:setStackSize(old3:getStackSize())
end
--Charges
if old3:getCharges() > 0 then
new3:setCharges(old3:getCharges())
end
--Note or Scroll
if old3:getScrollText() then
new3:setScrollText(old3:getScrollText())
end
if old3:getScrollImage() then
new3:setScrollImage(old3:getScrollImage())
end
end
end
end
end
end
--Deleting the item
champ:removeItem(slot1)
end
end
--spawning right bones
local bones = spawn("champion_bones_"..champ:getOrdinal(),party.level,party.x,party.y,party.facing)
bones:setScrollText("The bones of "..champ:getName()..".")
--disable the champion
champ:setEnabled(false)
end
end
}
Code: Select all
cloneObject{
baseObject = "remains_of_toorum",
name = "champion_bones_1",
uiName = "Bones",
description = "",
scroll = true
}
cloneObject{
baseObject = "remains_of_toorum",
name = "champion_bones_2",
uiName = "Bones",
description = "",
scroll = true
}
cloneObject{
baseObject = "remains_of_toorum",
name = "champion_bones_3",
uiName = "Bones",
description = "",
scroll = true
}
cloneObject{
baseObject = "remains_of_toorum",
name = "champion_bones_4",
uiName = "Bones",
description = "",
scroll = true
}
Code: Select all
cloneObject{
baseObject = "altar",
name = "blessed_altar",
onInsertItem = function(altar, item)
if item.name == "champion_bones_1" then
item:destroy()
for num = 1,4 do
if party:getChampion(num):getOrdinal() == 1 then
playSound("generic_spell")
party:getChampion(num):playDamageSound()
party:getChampion(num):setEnabled(true)
party:getChampion(num):setStat("health", math.random(10,40))
setMouseItem(nil)
return false
end
end
elseif item.name == "champion_bones_2" then
item:destroy()
for num = 1,4 do
if party:getChampion(num):getOrdinal() == 2 then
playSound("generic_spell")
party:getChampion(num):playDamageSound()
party:getChampion(num):setEnabled(true)
party:getChampion(num):setStat("health", math.random(10,40))
setMouseItem(nil)
return false
end
end
elseif item.name == "champion_bones_3" then
item:destroy()
for num = 1,4 do
if party:getChampion(num):getOrdinal() == 3 then
playSound("generic_spell")
party:getChampion(num):playDamageSound()
party:getChampion(num):setEnabled(true)
party:getChampion(num):setStat("health", math.random(10,40))
setMouseItem(nil)
return false
end
end
elseif item.name == "champion_bones_4" then
item:destroy()
for num = 1,4 do
if party:getChampion(num):getOrdinal() == 4 then
playSound("generic_spell")
party:getChampion(num):playDamageSound()
party:getChampion(num):setEnabled(true)
party:getChampion(num):setStat("health", math.random(10,40))
setMouseItem(nil)
return false
end
end
end
return true
end
}
So, maybe someone can help me with that. Or make the script simpler and shorter?
(And sorry for my bad english)