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
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#1
Just need some help scripting, im a beginner

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.
05-26-2011, 04:02 AM
Find
triadtimes Offline
Senior Member

Posts: 508
Threads: 16
Joined: Jan 2011
Reputation: 21
#2
RE: Just need some help scripting, im a beginner

The way I did it awhile back was this:

In the OnStart I had this:
AddEntityCollideCallback("Player", "Area1", "FunctionName", false, 1);

And the actual function looked like this:
void FunctionName(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("Item1") == true)
    {
        //DO STUFF HERE
    }
}

What would happen is the function would trigger every time the Player walks past but a certain action wouldn't be taken until the Player has Item1. (Depending on the action you may also need to put a variable in to stop it from happening more than once.)

(This post was last modified: 05-26-2011, 05:02 PM by triadtimes.)
05-26-2011, 04:56 AM
Find
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




Users browsing this thread: 1 Guest(s)