Not logged inOpenClonk Forum
Up Topic [QUESTION] Potion brewing

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Zapper
You could have an item, that opens a menu on ControlUse() with CreateMenu and then adds one menu entry with AddMenuEntry to the menu for every possible potion. Wenn the player chooses a potion from the menu, another function is called (the one that you set in AddMenuEntry) and then you can check whether he has all the ingredients.
When he has all the ingredients, you can start the brewing, remove the ingredients and after a short time (for example with ScheduleCall or AddEffect or even AddTimer) you can create a potion.

You can find out what an object is made of with GetComponent and you could list all potions by adding a callback "func IsPotion() { return true; }" to your potions and then use GetDefinition to list all the objects with that callback, for example:

func ControlUse()
{
CreateMenu(...);
var i = 0, obj;
while (obj = GetDefinition(i++))
{
    if (!obj->~IsPotion()) continue;
    AddMenuEntry("MakePotion", ..., obj);
}
}

func MakePotion(ID)
{
    // check if OK with GetComponents
    ...
    // remove components
    ...
    // start timer to create potion
   var effect = AddEffect("MakePOtion"....);
    effect.potion = ID;
}

func FxMakePotionTimer(target, effect, time)
{
    // effects...
    ...
    if (time > 36*3) // three seconds
    {
        CreateObject(effect.potion);
       return -1;
    }
}

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill