Frictional Games Forum (read-only)
Death with inventory item. - 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: Death with inventory item. (/thread-9926.html)



Death with inventory item. - Homicide13 - 08-22-2011

When a player dies, I want to remove an item from their inventory and re-place it back where it belongs in the level. However, resetting the prop just gives it to their inventory, and I can't figure out how to do what I want to do with it.
(and yes, I have the whole checkpoint/call a function script correct. I just don't know how to deal with this one reset)

Help would be much appreciated ^^


RE: Death with inventory item. - Tanshaydar - 08-22-2011

RemoveItem
CreateEntityAtArea

These two function will do it for you.


RE: Death with inventory item. - Kyle - 08-22-2011

Perhaps something like this?

Code:
void OnStart()
{
     if (GetPlayerHealth() <= 0)
     {
          RemoveItem("ItemName");
          SetEntityActive("ItemName");
     }
}

It might work if you try it like this.

Whoops, Tanshaydar is right. I shouldn't use SetEntityActive because the player can move the object with another entity. Tongue


RE: Death with inventory item. - Homicide13 - 08-22-2011

This works...except the new item doesn't have a CustomSubItemTypeName, so it doesn't display any information in the inventory :/ I can't find a command that will change this on an item.

Also, is there a way to check if an entity is in somebody's inventory? I assume there would be, but all I can find is bool GetEntityExists(string& asName);, which would just return true either way.


RE: Death with inventory item. - Kyle - 08-22-2011

(08-22-2011, 06:27 PM)Homicide13 Wrote: This works...except the new item doesn't have a CustomSubItemTypeName, so it doesn't display any information in the inventory :/ I can't find a command that will change this on an item.

Also, is there a way to check if an entity is in somebody's inventory? I assume there would be, but all I can find is bool GetEntityExists(string& asName);, which would just return true either way.

You just add a local variable that's attached to a SetEntityPlayerInteractCallback. Like so:

Code:
void OnStart()
{
     SetLocalVarInt("Var01", 0);
     SetEntityPlayerInteractCallback("ItemName", "Func01", false);
     if ((GetPlayerHealth() <= 0) && (GetLocalVarInt("Var01") == 1))
     {
          RemoveItem("ItemName");
          SetEntityActive("ItemName", true); //Or change this to make it work with CreateEntityAtArea.
     }
}
void Func01(string &in asEntity)
{
     SetLocalVarInt("Var01", 1);
}



RE: Death with inventory item. - Homicide13 - 08-22-2011

I tried SetEntityActive, it didn't work :/ I don't know why


RE: Death with inventory item. - Kyle - 08-22-2011

(08-22-2011, 08:17 PM)Homicide13 Wrote: I tried SetEntityActive, it didn't work :/ I don't know why

Of course it wouldn't work, that's what I said.


RE: Death with inventory item. - Homicide13 - 08-22-2011

er - then why did you suggest I use a local var? T_T EDIT: Oh right, to see if it's in the inventory. I normally think of stuff like that. >.<

haha I have this map completely finished except for this one bug D: