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
Help on entity activation
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#6
RE: Help on entity activation

Okay, let's start from the top. This'll be a long explanation so I'm going to use spoilers.

Step One
Spoiler below!


Say you have 3 notes that you want the player to have in their possession before they can progress.

These notes are called

"note1"
"note2"
and "note3"

So, in order for your character to progress, you need to set up a script box nearby that runs a check function to see whether or not the character has those notes in their possession.

Let's start with adding the collide callback.

PHP Code: (Select All)
void OnStart()

{
AddEntityCollideCallback(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates);

// "string& asParentName" is the player, "string& asChildName" is the script box, "string& asFunction" is the function that's called, "bool abDeleteOnCollide" is whether or not this callback is deleted once the player has gone through the script box, "int alStates" is whether the script is called when the player enters (1), leaves (-1), or both (0).

//So this script will be set up to look like this.

AddEntityCollideCallback("Player""CheckScriptBox""CheckIfHasNotes"false1);





Step Two

Spoiler below!

So, going off of some stuff that Romulator suggested and reminded me of, lets give each note a local variable, (or a global variable if your script is being used across multiple maps.)

For each of your notes, you need to set up an interact callback. So lets go do that.

PHP Code: (Select All)
void onStart()
{
SetEntityPlayerInteractCallback(stringasNamestringasCallbackbool abRemoveOnInteraction);

// "string& asName" is the name of the entity, so this would be "note1", "note2", or "note3", "string& asCallback" is the function called and you'll need a separate function for each note you pickup, "bool abRemoveOnInteraction" is whether or not the callback is removed once the entity is interacted with.

//So the script will look like this:

SetEntityPlayerInteractCallback("note1""GiveNote1Var"true);
}


//Then outside of OnStart we give "note1" its variable to be referenced later. This looks like this:

void GiveNote1Var(string &in asEntity)
{
SetLocalVarInt("note1var"1); // "note1var" is a name that's given in order to reference the variable later when we call it in the if statement. "1" is the variable we give.


You need three of them, one for each note.


Step Three
Spoiler below!

Now we need to set up the function that the CollideCallback calls for, which is the check, it looks for the if statement.

PHP Code: (Select All)
void CheckIfHasNotes(string &in asParentstring &in asChildint alState
{
if (
GetLocalVarInt("note1var") == && GetLocalVarInt("note2var") == && GetLocalVarInt("note3var") == 1)
{
//Whatever you want done here.
}



And that's it. I hope this can clear some stuff up for you and that it works for you. If you still have problems and are getting error messages, then post your script and hpl log. Smile

07-13-2014, 05:26 AM
Find


Messages In This Thread
Help on entity activation - by TShapeShifter - 07-12-2014, 10:26 PM
RE: Help on entity activation - by TShapeShifter - 07-12-2014, 10:54 PM
RE: Help on entity activation - by Romulator - 07-13-2014, 01:56 AM
RE: Help on entity activation - by TShapeShifter - 07-13-2014, 03:07 AM
RE: Help on entity activation - by MsHannerBananer - 07-13-2014, 05:26 AM
RE: Help on entity activation - by Mudbill - 07-13-2014, 07:38 AM
RE: Help on entity activation - by Romulator - 07-13-2014, 08:42 AM
RE: Help on entity activation - by TShapeShifter - 07-13-2014, 10:03 PM
RE: Help on entity activation - by Mudbill - 07-13-2014, 10:15 PM
RE: Help on entity activation - by TShapeShifter - 07-13-2014, 10:45 PM
RE: Help on entity activation - by Mudbill - 07-14-2014, 12:12 AM



Users browsing this thread: 2 Guest(s)