Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Just need some help scripting, im a beginner
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#3
RE: Just need some help scripting, im a beginner

(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.

05-26-2011, 11:09 AM
Find


Messages In This Thread
RE: Just need some help scripting, im a beginner - by Kyle - 05-26-2011, 11:09 AM



Users browsing this thread: 2 Guest(s)