Reusing Flasks
Reusing Flasks
Hello all,
Dont know if someone has posted this already but if you want to be able to reuse flasks like in the original DM then here is the code that will spawn one in front of the party on the floor.
It will work even if you are facing a wall. It spawns an empty flask in the same square as the party and you wont have to find a new flask everytime you want to make a new healing pot.
Just add this code
if party.facing == 0 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 1 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 2 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 3 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
where I have inserted it below.
defineObject{
name = "potion_healinghi",
class = "Item",
uiName = "High Healing Potion",
model = "assets/models/items/flask_full.fbx",
gfxIndex = 146,
consumable = true,
potion = true,
weight = 0.6,
onUseItem = function(self, champion)
playSound("consume_potion")
champion:modifyStat("health", 125)
if party.facing == 0 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 1 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 2 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 3 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
return true
end,
}
Thx,
LG
Dont know if someone has posted this already but if you want to be able to reuse flasks like in the original DM then here is the code that will spawn one in front of the party on the floor.
It will work even if you are facing a wall. It spawns an empty flask in the same square as the party and you wont have to find a new flask everytime you want to make a new healing pot.
Just add this code
if party.facing == 0 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 1 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 2 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 3 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
where I have inserted it below.
defineObject{
name = "potion_healinghi",
class = "Item",
uiName = "High Healing Potion",
model = "assets/models/items/flask_full.fbx",
gfxIndex = 146,
consumable = true,
potion = true,
weight = 0.6,
onUseItem = function(self, champion)
playSound("consume_potion")
champion:modifyStat("health", 125)
if party.facing == 0 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 1 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 2 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
if party.facing == 3 then
spawn("flask", party.level, party.x, party.y, party.facing)
end
return true
end,
}
Thx,
LG
Dungeon Master and DOOM will live forever.
Re: Reusing Flasks
Uhm...in my game flasks don't disappear when I drink a potion.
Re: Reusing Flasks
Maybe it is custom potions. I will check on that.
LG
LG
Dungeon Master and DOOM will live forever.
Re: Reusing Flasks
I assumed you were talking about custom potions, and how to recreate the same function as the original game potions
Finished Dungeons - complete mods to play
Re: Reusing Flasks
must be, cause my flasks dont up and vanish either.... although if someone can make one of these little guys;

and have them be super small, like to the size of fitting in them grates on the bottom of some wall sections. Then we can have our explanation as to where custom potion flasks go to.

and have them be super small, like to the size of fitting in them grates on the bottom of some wall sections. Then we can have our explanation as to where custom potion flasks go to.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
Re: Reusing Flasks
It is custom potions. I have used the regular healing potion and the empty flask is returned to the same inventory slot. With my new custom healing potions, the flask just dissappears after drinking the pot.
There must be a hard coded script that gets inventory slot and upon use of a list of potions. It spawns a flask in the inventory slot.
LG
There must be a hard coded script that gets inventory slot and upon use of a list of potions. It spawns a flask in the inventory slot.
LG
Dungeon Master and DOOM will live forever.
Re: Reusing Flasks
Ignore the below
@HaunterV: thanks, I lost 2 hours with my brain stuck on "what game had that *#!@##! imp" ?
Now I remember! The golden deodorant 
SpoilerShow
I used this problem as a test case for the new version of GrimQ I did just now (and it worked, it was a good test case
).
Don't worry if you don't get the query part, setup the grimq library in your dungeon (a matter of copy and paste as detailed in the pdf) and you can use this for the custom flasks (if you want of course
)
This replaces the item with an empty flask right there in the champion inventory. in the right slot 
EDIT: This has a problem with items in sacks/crates even if in theory it handles them
. Tomorrow I'll check how it can be done sigh. Sadly containers do not have a removeItem method 
Don't worry if you don't get the query part, setup the grimq library in your dungeon (a matter of copy and paste as detailed in the pdf) and you can use this for the custom flasks (if you want of course
Code: Select all
onUseItem = function(item, champion)
local obj = grimq.fromChampionInventoryEx(champion, true):where(grimq.has("item", item)):first()
obj:replace(spawn("flask"))
return false
end
EDIT: This has a problem with items in sacks/crates even if in theory it handles them
@HaunterV: thanks, I lost 2 hours with my brain stuck on "what game had that *#!@##! imp" ?
Last edited by Xanathar on Wed Nov 28, 2012 6:34 pm, edited 1 time in total.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563
My preciousss: http://www.moonsharp.org
Re: Reusing Flasks
Giving your custom potions the parameter emptyItem = "flask" should do the trick.
Re: Reusing Flasks
Yep I tried it and it works.
Thx alot
LG
Thx alot
LG
Dungeon Master and DOOM will live forever.
