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


Thread Rating:
  • 4 Vote(s) - 3.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting n00b in need of help.
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#1
Scripting n00b in need of help.

So I've done some action scripting (Flash), but not C++.
I see some stuff thats done the same way, but for the most part, I'm just confused.

So what I tried to make, was that when you walk in an area, a zombie spawns and walks into a door and then disappears.

I've gotten to the part that it spawns (I just place it down, but I'm not sure how to spawn it), and that it walks to the desired node I made.
The grunt automatically disappears as it should, so thats good Big Grin

void OnStart()
{  
   GiveItemFromFile("lantern", "lantern.ent");

   for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");    
}

void OnEnter()
{
AddEntityCollideCallback("Player", "scaretrigger", "scareactivate", true, 1);
AddEnemyPatrolNode("scaremonster", "scaremonsterpath1", 0, "");
}

void OnLeave()
{

}

I started out with the basic starting code, or however it was called Tongue
I'm going to delete the code of the tinderboxes and lantern later on when I'm going to do some actual play-testing.
I understand the code of the starting items a bit, except "int i=0;i<10;i++". What do the ";" mean in C++?

"scaretrigger" = the area I made in which it triggers. I've used the Area tool with the Script option...
"scareactivate" = the boolean that is created? If someone would explain this to me, I'd be gratefull.
"scaremonster" = the grunt, who is activated in the map editor.
"scaremonsterpath1" = the node where scaremonster walks to.

What I need now, is a way to trigger the monster to spawn and walk to "scaremonsterpath1".

I've searched through the forum, but I didnt get a real proper explaination of how it actually works. This might also be because I'm a real newbie to C++ though.

I've got the script functions from the wikipedia.
From what I've seen and done up to now, I understand that "string& asXXXX" is basically the name of an object/function?

Thanks in advance.
(This post was last modified: 11-13-2010, 01:02 AM by Akumasama.)
11-13-2010, 12:59 AM
Find
Cellrage Offline
Junior Member

Posts: 4
Threads: 0
Joined: Oct 2010
Reputation: 0
#2
RE: Scripting n00b in need of help.

First, you should move your CollideCallback into the OnStart function.

Then, make a new function, (Not inside the OnStart, OnEnter, or OnLeave), which should look like:

void scareactivate(string &in asParent, string &in asChild, int alState)
{
}

Then you put whatever it is you want to be activated inside those brackets.

Your finished code should look something like this:
void OnStart()
{  
   GiveItemFromFile("lantern", "lantern.ent");

   for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");

AddEntityCollideCallback("Player", "scaretrigger", "scareactivate", true, 1);
}

void scareactivate(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("scaremonster", true);
AddEnemyPatrolNode("scaremonster", "scaremonsterpath1", 0, "");
}

Don't forget to set the monster to inactive in the level editor.
11-13-2010, 01:37 AM
Find
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#3
RE: Scripting n00b in need of help.

Quote:void scareactivate(string &in asParent, string &in asChild, int alState)

I'm not sure how this part works... Care to explain?

And now that I read it like this, when you start with void, bool, float or int, you create a new fuction. Correct?
11-13-2010, 01:54 AM
Find
Gamemakingdude Offline
Senior Member

Posts: 470
Threads: 82
Joined: Nov 2010
Reputation: 9
#4
RE: Scripting n00b in need of help.

(11-13-2010, 01:54 AM)Akumasama Wrote:
Quote:void scareactivate(string &in asParent, string &in asChild, int alState)

I'm not sure how this part works... Care to explain?

And now that I read it like this, when you start with void, bool, float or int, you create a new fuction. Correct?

Nope. void creates an new function.

bool, float, int, string are variable types.

you put what you want for the proc under that proc.

Rep if like me or im helpful or you love my stories!
Stephanos house
11-13-2010, 02:33 AM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#5
RE: Scripting n00b in need of help.

Ok, lets start simply. void creates a new function.

Anything in OnStart is a function that will either need to be detailed in its own void, or finalized right there in OnStart.

OnEnter are things that happen every time you enter an area.

OnLeave is every time you leave.

http://wiki.frictionalgames.com/hpl2/amn..._functions
Should help a bit, but you just need to think of XML as being a ladder. You place the top of the ladder, then you need to fill in the missing rungs right down to the bottom. This can be hard to learn, but its easy once you know how its done.

Also, the community will assist you if you need a particular script written, as long as it isnt too complicated.

Also, the actual games scripts can make an excellent point of reference
Best of luck
11-13-2010, 03:02 AM
Find
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#6
RE: Scripting n00b in need of help.

I had that link you posted in my bookmarks, it's also where I got the script functions from which I used in my first post. Smile

Also, thanks for the explanation guys!

But I still don't really understand this part:
void scareactivate(string &in asParent, string &in asChild, int alState)

I'm not sure what they mean with the "string &in asXXXX" part...
11-13-2010, 01:56 PM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#7
RE: Scripting n00b in need of help.

(11-13-2010, 01:56 PM)Akumasama Wrote: I had that link you posted in my bookmarks, it's also where I got the script functions from which I used in my first post. Smile

Also, thanks for the explanation guys!

But I still don't really understand this part:
void scareactivate(string &in asParent, string &in asChild, int alState)

I'm not sure what they mean with the "string &in asXXXX" part...

Its a syntax - You do not touch it. You put functions BELOW it, and the syntax makes them possible.
11-13-2010, 02:52 PM
Find
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#8
RE: Scripting n00b in need of help.

Mmmm...
Why may you not change the "scareactivate" syntax, but you may change the "AddEntityCollideCallback"?

How would I know what strings I have to place in the "scaretrigger" or similar functions?

Sorry if I sound dumb, but its my first script, really. Tongue
11-13-2010, 03:08 PM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#9
RE: Scripting n00b in need of help.

We all start from somewere. I was just fortunate to know XML already Smile
The function is the name of the function itself - As in, you say AddEntityCollideCallback, then what you want it to affect and what you want it to do.

But scareactivate is the name of a result.

As in, Say you make a script zone. We're calling it Origin.
AddEntityCollideCallback("Player", "Origin", "scareactivate", true, 1); in OnStart {}
Means that when the Player Enters Origin, The scareactivate function will activate. You can rename scareactivate to anything, its irrelevant.

Then, you made
void scareactivate(string &in asParent, string &in asChild, int alState)
{
In here, you put the functions you want to activate when the player walks into Origin.
This can be health loss, sanity loss, gaining an item, end of the game, anything.
}

Hope this helps
(This post was last modified: 11-13-2010, 03:16 PM by Chilton.)
11-13-2010, 03:15 PM
Find
Akumasama Offline
Member

Posts: 122
Threads: 2
Joined: Nov 2010
Reputation: 0
#10
RE: Scripting n00b in need of help.

So the function that you create with one of the functions in the list, has a standard syntax?
(string &in asParent, string &in asChild, int alState)

If so, then I think I'm beginning to understand how this scripting works alot better.

Also, you don't particularly need the onEnter, onStart and onLeave.
You only put those in when you want something to happen at start, enter area or leave area.
11-13-2010, 03:30 PM
Find




Users browsing this thread: 2 Guest(s)