(05-26-2011, 04:02 AM)willochill Wrote: okay, so im like a complete noob at scripting, like i'm stumped with a lot of stuff. I have an area in my map. In this area, when the player walks by, I want a grunt to be alerted, but ONLY if the player has a certain item in the inventory. How would I script this? (let's call the area Area1 and the item Item1). thx, im just stumped here.
void OnStart()
{
AddEntityCollideCallback("Player", "Area1", "Func01", false, 1);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
if (HasItem("Item1") == true)
{
SetEnemyActive("MonsterName", true);
RemoveEntityCollideCallback("Player", "Area1");
return;
}
}
MonsterName is meant to be replaced with the name of the monster that's spawned.
I have to set the bool abOnDelete for the AddEntityCollideCallback because if the player doesn't have the object and when they walk through, it would stop the function from working because it's deleted and also nothing would happen.
So when the player does have the item, it sets the monster active and then prevents the player from accidently colliding with Area1 after the script was used.