This is pretty easy to do, actually. Here is an implementation of it. I trust that you can add any visual effects you want on your own.
Put this in your init.lua before any defineCondition() calls:
Code: Select all
CONDITION_LIST = {"dead","cursed","diseased","paralyzed","petrified","poison",
"slow","bear_form","haste","invisibility","level_up","rage","water_breathing",
"fire_shield","frost_shield","poison_shield","protective_shield","shock_shield",
"chest_wound","feet_wound","head_wound","left_hand_wound","leg_wound","right_hand_wound"}
-- Automatically adds custom conditions to the list
local orig_defineCondition = defineCondition
defineCondition = function(desc)
orig_defineCondition(desc)
table.insert(CONDITION_LIST,desc.name)
end
and define these objects (the dm_wall_altarvi redefinition, of course, must come *after* all your defineCondition() calls have been made)
Code: Select all
defineObject{
name = "dummy_monster",
placement = "floor",
components = {
{
class = "Model",
model = "assets/models/monsters/snail.fbx", -- simplest existing valid monster model (would be easy to make a new one though)
storeSourceData = true,
enabled = false,
},
{
class = "Animation",
animations = {idle = "assets/animations/monsters/snail/snail_idle.fbx"},
currentLevelOnly = true,
enabled = false,
},
{
class = "Monster",
meshName = "snail_mesh",
hitSound = "snail_hit",
dieSound = "snail_die",
hitEffect = "hit_goo",
health = 100,
capsuleHeight = 0,
capsuleRadius = 0,
collisionRadius = 0,
exp = 0,
},
}
}
defineObject{
name = "champion_remains",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/remains_of_toorum.fbx",
},
{
class = "Item",
uiName = "Remains",
gfxIndex = 212,
weight = 5.0,
},
{
class = "Particle",
particleSystem = "glitter_toorum",
},
{
class = "Counter",
name = "ordinal",
},
},
}
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onDie = function(self, champion)
local championCount = 0
for i=1,4 do
if party.party:getChampion(i):getEnabled() and party.party:getChampion(i):isAlive() then championCount = championCount+1 end
end
if championCount ~= 0 then -- champion that just "died" counts as dead
champion:setEnabled(false)
-- Spawning a dummy monster is the only way to move items from the inventory to the map
local dummy = self.go:spawn("dummy_monster")
for slot,itm in champion:carriedItems() do
champion:removeItemFromSlot(slot)
dummy.monster:addItem(itm)
end
dummy.monster:dropAllItems()
dummy:destroy()
local remains = self.go:spawn("champion_remains")
remains.item:setUiName(string.format("Remains of %s",champion:getName()))
remains.ordinal:setValue(champion:getOrdinal())
playSound("champion_die")
return false -- Important! There is no good scripting-side way to remove the "dead" condition without healing the entire party.
else
return true
end
end,
},
},
}
local conditions = CONDITION_LIST
defineObject{
name = "dm_wall_altarvi",
baseObject = "dm_wall_altarvi",
components = {
{
class = "Surface",
offset = vec(0, 0.904, 0.3),
size = vec(1.3, 0.65),
onInsertItem = function(self, item)
if item.go.name == "champion_remains" then
local champ = party.party:getChampionByOrdinal(item.go.ordinal:getValue())
champ:setEnabled(true)
for _,condition in ipairs(conditions) do
champ:removeCondition(condition)
end
champ:regainHealth(math.huge)
champ:regainEnergy(math.huge)
champ:playHealingIndicator()
champ:showAttackResult("Resurrected","HitSplash")
playSound("heal_party")
item.go:destroy()
end
end,
},
},
}
Do not use surfaces or sockets to add items to the map. Items cannot be removed from surfaces or sockets except by destroying the items or having the player click on them (destroying the surface/socket just taints the item and makes it impossible to pick up ever again without causing a crash).