Re: Alchemy questions + discussion
Posted: Sat Mar 26, 2016 9:52 am
potions.lua
SpoilerShow
Code: Select all
-- This file has been generated by Dungeon Editor 2.1.17
-- TODO: place your custom item definitions here
defineObject{
name = "flask",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Flask (empty)",
gfxIndex = 143,
weight = 0.1,
stackable = true,
},
{
class = "UsableItem",
--emptyItem = "water_flask",
sound = "consume_potion",
onUseItem = function(self, champion)
if party.elevation > 0 then return false end
local dx,dy = getForward(party.facing)
if party.map:getAutomapTile(party.x,party.y) == 2 or party.map:getAutomapTile(party.x+dx,party.y+dy) == 2 then
for slot = 1,ItemSlot.MaxSlots do
local item = champion:getItem(slot)
if item then
if item.go == self.go then
local w = spawn("water_flask")
w.item:setStackSize(self.go.item:getStackSize())
--self.go:destroyDelayed()
champion:removeItemFromSlot(slot)
champion:insertItem(slot, w.item)
playSound("party_move_wade")
return false
elseif item.go.containeritem then
for s = 1,item.go.containeritem:getCapacity() do
local i = item.go.containeritem:getItem(s)
if i and i.go == self.go then
local w = spawn("water_flask")
w.item:setStackSize(self.go.item:getStackSize())
--self.go:destroyDelayed()
item.go.containeritem:removeItemFromSlot(s)
item.go.containeritem:insertItem(s, w.item)
playSound("party_move_wade")
return false
end
end
end
end
end
end
return false
end,
},
},
}
defineObject{
name = "potion_healing",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Healing Potion",
gfxIndex = 146,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
local mult = iff(champion:hasTrait("fast_metabolism"), 2, 1)
champion:regainHealth(75*mult)
champion:removeCondition("head_wound")
champion:removeCondition("chest_wound")
champion:removeCondition("leg_wound")
champion:removeCondition("feet_wound")
champion:removeCondition("right_hand_wound")
champion:removeCondition("left_hand_wound")
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_greater_healing",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/big_potion.fbx",
},
{
class = "Item",
uiName = "Greater Healing Potion",
gfxIndex = 409,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:regainHealth(150)
champion:removeCondition("head_wound")
champion:removeCondition("chest_wound")
champion:removeCondition("leg_wound")
champion:removeCondition("feet_wound")
champion:removeCondition("right_hand_wound")
champion:removeCondition("left_hand_wound")
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_energy",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Energy Potion",
gfxIndex = 145,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:regainEnergy(75)
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_greater_energy",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/big_potion.fbx",
},
{
class = "Item",
uiName = "Greater Energy Potion",
gfxIndex = 410,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:regainEnergy(150)
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_poison",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Poignant Potion",
gfxIndex = 147,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:setCondition("poison")
end,
},
},
}
defineObject{
name = "potion_shield",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Shield Potion",
gfxIndex = 151,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:setCondition("protective_shield")
end,
},
},
}
defineObject{
name = "potion_cure_poison",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Antivenom",
gfxIndex = 149,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:removeCondition("poison")
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_cure_disease",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Antidote",
gfxIndex = 148,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
canBeUsedByDeadChampion = true,
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
-- can't be used by dead champion but can be used to cure petrification
if not champion:isAlive() and not champion:hasCondition("petrified") then
return false
end
champion:removeCondition("diseased")
champion:removeCondition("paralyzed")
champion:removeCondition("petrified")
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_rage",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Rage Potion",
gfxIndex = 152,
weight = 0.3,
stackable = true,
traits = { "potion" },
description = "This potion has a sulphurous stench.",
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:setConditionValue("rage", champion:getConditionValue("rage") + 20)
end,
},
},
}
defineObject{
name = "potion_speed",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Speed Potion",
gfxIndex = 153,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:setCondition("haste")
end,
},
},
}
defineObject{
name = "potion_bear_form",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Potion of Bear Form",
gfxIndex = 154,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "polymorph_bear",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:setCondition("bear_form", 1)
end,
},
},
}
defineObject{
name = "potion_oblivion",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Potion of Oblivion",
gfxIndex = 155,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "level_up",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
for _,skill in ipairs(skills.script.defOrdered) do
local level = champion:getSkillLevel(skill.name) or 0
if level>0 then
champion:trainSkill(skill.name, -level)
--champion:setSkillPoints(champion:getSkillPoints() + level)
end
end
hudPrint(champion:getName().." forgot all learned skills.")
end,
},
},
}
defineObject{
name = "potion_resurrection",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Potion of Resurrection",
gfxIndex = 150,
weight = 0.3,
stackable = true,
gameEffect = "Restores dead character to full health and energy.",
description = "This potion has a foul stench.",
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "none",
canBeUsedByDeadChampion = true,
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
-- can't be used on alive champion
if champion:isAlive() then return false end
playSound("heal_party")
champion:setBaseStat("health", champion:getCurrentStat("max_health"))
champion:setBaseStat("energy", champion:getCurrentStat("max_energy"))
champion:playHealingIndicator()
end,
},
},
}
defineObject{
name = "potion_strength",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask_large.fbx",
},
{
class = "Item",
uiName = "Potion of Strength",
gfxIndex = 414,
weight = 0.5,
stackable = true,
gameEffect = "Permanently increases strength by 1.",
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "level_up",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:upgradeBaseStat("strength", 1)
end,
},
{
class = "Particle",
particleSystem = "potion_of_strength",
},
},
}
defineObject{
name = "potion_dexterity",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask_large.fbx",
},
{
class = "Item",
uiName = "Potion of Dexterity",
gfxIndex = 413,
weight = 0.5,
stackable = true,
gameEffect = "Permanently increases dexterity by 1.",
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "level_up",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:upgradeBaseStat("dexterity", 1)
end,
},
{
class = "Particle",
particleSystem = "potion_of_dexterity",
},
},
}
defineObject{
name = "potion_vitality",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask_large.fbx",
},
{
class = "Item",
uiName = "Potion of Vitality",
gfxIndex = 411,
weight = 0.5,
stackable = true,
gameEffect = "Permanently increases vitality by 1.",
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "level_up",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:upgradeBaseStat("vitality", 1)
end,
},
{
class = "Particle",
particleSystem = "potion_of_vitality",
},
},
}
defineObject{
name = "potion_willpower",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask_large.fbx",
},
{
class = "Item",
uiName = "Potion of Willpower",
gfxIndex = 412,
weight = 0.5,
stackable = true,
gameEffect = "Permanently increases willpower by 1.",
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "level_up",
onUseItem = function(self, champion)
champions.script.addFlask(self.go, champion)
champion:upgradeBaseStat("willpower", 1)
end,
},
{
class = "Particle",
particleSystem = "potion_of_willpower",
},
},
}