Frictional Games Forum (read-only)
Making Puzzle Items Consumable - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Making Puzzle Items Consumable (/thread-9768.html)



Making Puzzle Items Consumable - Homicide13 - 08-15-2011

I want to make a puzzle item consumable, meaning that if it is clicked on in the inventory it immediately causes an effect (much like a can of oil or health potion, though the effect would be done through script). However I cannot find a callback that would trigger when the item double clicked (so that the player holds it out in front of him). My idea was that I would use script to remove the item when it was clicked in this manner, so that it would appear to have been drunk.


RE: Making Puzzle Items Consumable - MrBigzy - 08-15-2011

You might be able to use this: void SetEntityCallbackFunc(string& asName, string& asCallback)

Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc

Perhaps OnUse would work? Other than that you might have to tinker in the model editor.


RE: Making Puzzle Items Consumable - Homicide13 - 08-15-2011

nope, doesn't work. Sad I have no idea how to use the model editor at all, but either way I need it to be able to run code.


RE: Making Puzzle Items Consumable - Tanshaydar - 08-15-2011

Try it with a health potion and see if code works, model editor part is easier.


RE: Making Puzzle Items Consumable - Homicide13 - 08-15-2011

The problem with a health potion is that I don't want the number next to the icon in the menu. I got it to work so that the script runs as soon as the object is picked up, so that might have to do.


RE: Making Puzzle Items Consumable - DRedshot - 08-15-2011

maybe try looping GetEntityExists("namehere") if it doesn't exist, assume it has been consumed.
for example
Code:
void OnPickup(string &in asEntity , string &in asType)
{
if(asType=="OnPickup"){ // Player has picked up the potion
AddTimer("EntityExists" , 0.1f , "DoesEntityExist");
}
}

void DoesEntityExist(string &in asTimer)
{
if (GetEntityExists("")){
// player hasn't drank the potion
AddTimer "loop" , 0.1f , "DoesEntityExist");
}

else {
// player has drank it! - remove the timers and end the loop! do what you want to do here!
}
}