Page 1 of 2

Reusing Flasks

Posted: Tue Nov 27, 2012 7:47 pm
by LordGarth
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

Re: Reusing Flasks

Posted: Tue Nov 27, 2012 9:06 pm
by Phitt
Uhm...in my game flasks don't disappear when I drink a potion.

Re: Reusing Flasks

Posted: Tue Nov 27, 2012 9:10 pm
by LordGarth
Maybe it is custom potions. I will check on that.

LG

Re: Reusing Flasks

Posted: Tue Nov 27, 2012 9:23 pm
by Komag
I assumed you were talking about custom potions, and how to recreate the same function as the original game potions

Re: Reusing Flasks

Posted: Tue Nov 27, 2012 9:27 pm
by HaunterV
must be, cause my flasks dont up and vanish either.... although if someone can make one of these little guys;
Image
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.

Re: Reusing Flasks

Posted: Tue Nov 27, 2012 9:34 pm
by LordGarth
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

Re: Reusing Flasks

Posted: Wed Nov 28, 2012 1:13 am
by Xanathar
Ignore the below :)
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 :D).

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 8-) )

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
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 :shock: . Tomorrow I'll check how it can be done sigh. Sadly containers do not have a removeItem method :(

@HaunterV: thanks, I lost 2 hours with my brain stuck on "what game had that *#!@##! imp" ? :lol: Now I remember! The golden deodorant :lol:

Re: Reusing Flasks

Posted: Wed Nov 28, 2012 6:33 pm
by Ancylus
Giving your custom potions the parameter emptyItem = "flask" should do the trick.

Re: Reusing Flasks

Posted: Thu Nov 29, 2012 3:19 am
by Komag
Are you serious, it's that simple?! :lol:

Re: Reusing Flasks

Posted: Thu Nov 29, 2012 3:33 pm
by LordGarth
Yep I tried it and it works.

Thx alot :D

LG