Alchemy Hook?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
strangely
Posts: 25
Joined: Mon Oct 29, 2012 2:28 am
Location: Tucson, AZ

Alchemy Hook?

Post by strangely »

Is there any way to have the system call a function when a character creates a potion?
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Alchemy Hook?

Post by Prozail »

Havn't found a way to do this yet. There is no existing hook, and i have tried modifying the mortar, and had a look at tracking what items party receives. None triggers.
User avatar
strangely
Posts: 25
Joined: Mon Oct 29, 2012 2:28 am
Location: Tucson, AZ

Re: Alchemy Hook?

Post by strangely »

Hmm. I wonder if the following pseudo code would suffice:

Code: Select all

mortar.onUseItem()

   count all potions in all inventories and save the result in currentPotionCount
end

<all potions>.onUseItem()

   decrement currentPotionCount
end

<all potions>.onPickUpItem()

   count all potions in all inventories
   if count > currentPotionCount then

      -- potion created!

     initialPotionCount = count

   end
end
No, that won't work. What if the user picks up a potion from the floor?

Bugger. Guess I'll have to think about this some more...
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Alchemy Hook?

Post by minmay »

Try this: redefine all recipes to produce "dummy" potions that are copies of the regular potions but with different names. Check getMouseItem() every frame in the PartyComponent.onDrawGui hook. If it's one of the dummy potions, change it into the corresponding regular potion and run your alchemy hook.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
strangely
Posts: 25
Joined: Mon Oct 29, 2012 2:28 am
Location: Tucson, AZ

Re: Alchemy Hook?

Post by strangely »

Now that's lateral thinking!

Thanks, I'll give that a go.
Post Reply