Page 1 of 1

Alchemy Hook?

Posted: Mon Nov 10, 2014 3:57 am
by strangely
Is there any way to have the system call a function when a character creates a potion?

Re: Alchemy Hook?

Posted: Mon Nov 10, 2014 11:15 pm
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.

Re: Alchemy Hook?

Posted: Tue Nov 11, 2014 6:24 am
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...

Re: Alchemy Hook?

Posted: Tue Nov 11, 2014 6:55 am
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.

Re: Alchemy Hook?

Posted: Thu Nov 13, 2014 2:46 am
by strangely
Now that's lateral thinking!

Thanks, I'll give that a go.