Reusing Flasks

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Reusing Flasks

Post 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
Dungeon Master and DOOM will live forever.
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: Reusing Flasks

Post by Phitt »

Uhm...in my game flasks don't disappear when I drink a potion.
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Reusing Flasks

Post by LordGarth »

Maybe it is custom potions. I will check on that.

LG
Dungeon Master and DOOM will live forever.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Reusing Flasks

Post by Komag »

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
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Reusing Flasks

Post 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.
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
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Reusing Flasks

Post 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
Dungeon Master and DOOM will live forever.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Reusing Flasks

Post 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:
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
Ancylus
Posts: 50
Joined: Thu Oct 11, 2012 5:54 pm

Re: Reusing Flasks

Post by Ancylus »

Giving your custom potions the parameter emptyItem = "flask" should do the trick.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Reusing Flasks

Post by Komag »

Are you serious, it's that simple?! :lol:
Finished Dungeons - complete mods to play
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Reusing Flasks

Post by LordGarth »

Yep I tried it and it works.

Thx alot :D

LG
Dungeon Master and DOOM will live forever.
Post Reply