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!!!
JPPSJ Offline
Junior Member

Posts: 20
Threads: 2
Joined: Apr 2012
Reputation: 0
#1
HELP!!!

I need desparate help with scripting!!! Ive watched alot of videos and have done everything they have said and it does not work at all! Even the most simple things! please help!
(This post was last modified: 04-16-2012, 11:42 PM by JPPSJ.)
04-16-2012, 11:38 PM
Find Reply
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#2
RE: HELP!!!

Please calm down and explain your problem so we can help you.

04-17-2012, 12:01 AM
Find Reply
JPPSJ Offline
Junior Member

Posts: 20
Threads: 2
Joined: Apr 2012
Reputation: 0
#3
RE: HELP!!!

(04-17-2012, 12:01 AM)Putmalk Wrote: Please calm down and explain your problem so we can help you.
Sorry i was emphasizing my anger, ive tryed to do scripting on my custom map as in "Flying jesus" amd door slams ect. but NONE of my scripting attempts have worked. I even tryed to do the beginning script to give the player a lanturn and tat dident work either. im at a loss.

04-17-2012, 12:06 AM
Find Reply
MrIcabod123 Offline
Junior Member

Posts: 43
Threads: 7
Joined: Jan 2012
Reputation: 0
#4
RE: HELP!!!

(04-17-2012, 12:06 AM)JPPSJ Wrote:
(04-17-2012, 12:01 AM)Putmalk Wrote: Please calm down and explain your problem so we can help you.
Sorry i was emphasizing my anger, ive tryed to do scripting on my custom map as in "Flying jesus" amd door slams ect. but NONE of my scripting attempts have worked. I even tryed to do the beginning script to give the player a lanturn and tat dident work either. im at a loss.
Don't dive into the deep end without learning how to swim.
04-17-2012, 12:12 AM
Find Reply
JPPSJ Offline
Junior Member

Posts: 20
Threads: 2
Joined: Apr 2012
Reputation: 0
#5
RE: HELP!!!

(04-17-2012, 12:12 AM)MrIcabod123 Wrote:
(04-17-2012, 12:06 AM)JPPSJ Wrote:
(04-17-2012, 12:01 AM)Putmalk Wrote: Please calm down and explain your problem so we can help you.
Sorry i was emphasizing my anger, ive tryed to do scripting on my custom map as in "Flying jesus" amd door slams ect. but NONE of my scripting attempts have worked. I even tryed to do the beginning script to give the player a lanturn and tat dident work either. im at a loss.
Don't dive into the deep end without learning how to swim.
ok i understand that now, i even tyred the beginner tutorial on the wiki and it dident work, is there anyway you can help explain scripting to me? or refer me to sombody other than ELVEN because nomatter how ard i consetrate i cannot understand him.

04-17-2012, 12:14 AM
Find Reply
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#6
RE: HELP!!!

Okay, let me do this as clear as possible.

Do you know what a function is? Pretty much, any "scripting" we do on our maps are simply calling premade functions that do what we want them to do already.

We start out every file with three functions:

void OnStart()
{

}

void OnEnter()
{

}

void OnLeave()
{

}

That is how every script file should look.

Everything inside the brackets "{""}" in the OnStart() function will happen the FIRST AND ONLY FIRST TIME you enter a map. Everything inside OnEnter() will happen EVERY TIME you enter the map. Everything inside OnLeave() happens every time you leave the map.

This is the bare minimum for any map script file you want.

I am not going to continue to post until you reply to this comment.

(This post was last modified: 04-17-2012, 12:20 AM by Putmalk.)
04-17-2012, 12:19 AM
Find Reply
JPPSJ Offline
Junior Member

Posts: 20
Threads: 2
Joined: Apr 2012
Reputation: 0
#7
RE: HELP!!!

(04-17-2012, 12:19 AM)Putmalk Wrote: Okay, let me do this as clear as possible.

Do you know what a function is? Pretty much, any "scripting" we do on our maps are simply calling premade functions that do what we want them to do already.

We start out every file with three functions:

void OnStart()
{

}

void OnEnter()
{

}

void OnLeave()
{

}

That is how every script file should look.

Everything inside the brackets "{""}" in the OnStart() function will happen the FIRST AND ONLY FIRST TIME you enter a map. Everything inside OnEnter() will happen EVERY TIME you enter the map. Everything inside OnLeave() happens every time you leave the map.

This is the bare minimum for any map script file you want.

I am not going to continue to post until you reply to this comment.

im listining.

(04-17-2012, 12:27 AM)JPPSJ Wrote:
(04-17-2012, 12:19 AM)Putmalk Wrote: Okay, let me do this as clear as possible.

Do you know what a function is? Pretty much, any "scripting" we do on our maps are simply calling premade functions that do what we want them to do already.

We start out every file with three functions:

void OnStart()
{

}

void OnEnter()
{

}

void OnLeave()
{

}

That is how every script file should look.

Everything inside the brackets "{""}" in the OnStart() function will happen the FIRST AND ONLY FIRST TIME you enter a map. Everything inside OnEnter() will happen EVERY TIME you enter the map. Everything inside OnLeave() happens every time you leave the map.

This is the bare minimum for any map script file you want.

I am not going to continue to post until you reply to this comment.

im listining.
By the way thank you so much for helping me im at a huge loss.



(This post was last modified: 04-17-2012, 12:35 AM by JPPSJ.)
04-17-2012, 12:27 AM
Find Reply
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#8
RE: HELP!!!

I am not going to teach you how to do flying jesus's, as it's very annoying and not scary at all.

What I am going to do is teach you how to slam your doors the way you want them to.

Okay, so, we have our basic script file. You need to remember that every line of code (minus the function headers such as "OnStart()", etc, must end in ";" (that tells the computer to move on to the next line of code). I'm not going to explain loops and stuff, that can be covered at a different time in a different thread.

So, our scenario: We want the player to come close to the door, and when he does, the door slams shut in his face! Included is a loud bang and a sanity drain.

Here we have a list of functions: http://wiki.frictionalgames.com/hpl2/amn..._functions

I could make you go down that list, but I'd rather just pinpoint all the functions we need.

AddEntityCollideCallback(string parentname, string childname, string function, bool deleteoncollide, int alStates);


GiveSanityDamage(float amount, bool UseEffects);

PlaySoundAtEntity(string soundname, string soundfile, string entity, float fadetime, bool savesound);


SetSwingDoorClosed(string name, bool closed, bool effects);

Those are all the functions we need to complete our task. I know this looks weird. What do these functions do?

AddEntityCollideCallback: We call this when the player touches another entity (such as a script area), and when he does, we fire a function with a name that we specify.

GiveSanityDamage: We deal a specific amount of sanity damage (good values: 5-20) to the player and we can choose whether to show an effect or not.

PlaySoundAtEntity: We play a sound from the sound folder in the Amnesia directory. We can set several values here, such as how fast it fades and where the sound is played.

SetSwingDoorClosed: We swing the door closed as fast as we can.

This is only step one of the process. Next post will detail how to use these functions in your script.

04-17-2012, 12:37 AM
Find Reply
JPPSJ Offline
Junior Member

Posts: 20
Threads: 2
Joined: Apr 2012
Reputation: 0
#9
RE: HELP!!!

(04-17-2012, 12:37 AM)Putmalk Wrote: I am not going to teach you how to do flying jesus's, as it's very annoying and not scary at all.

What I am going to do is teach you how to slam your doors the way you want them to.

Okay, so, we have our basic script file. You need to remember that every line of code (minus the function headers such as "OnStart()", etc, must end in ";" (that tells the computer to move on to the next line of code). I'm not going to explain loops and stuff, that can be covered at a different time in a different thread.

So, our scenario: We want the player to come close to the door, and when he does, the door slams shut in his face! Included is a loud bang and a sanity drain.

Here we have a list of functions: http://wiki.frictionalgames.com/hpl2/amn..._functions

I could make you go down that list, but I'd rather just pinpoint all the functions we need.

AddEntityCollideCallback(string parentname, string childname, string function, bool deleteoncollide, int alStates);


GiveSanityDamage(float amount, bool UseEffects);

PlaySoundAtEntity(string soundname, string soundfile, string entity, float fadetime, bool savesound);


SetSwingDoorClosed(string name, bool closed, bool effects);

Those are all the functions we need to complete our task. I know this looks weird. What do these functions do?

AddEntityCollideCallback: We call this when the player touches another entity (such as a script area), and when he does, we fire a function with a name that we specify.

GiveSanityDamage: We deal a specific amount of sanity damage (good values: 5-20) to the player and we can choose whether to show an effect or not.

PlaySoundAtEntity: We play a sound from the sound folder in the Amnesia directory. We can set several values here, such as how fast it fades and where the sound is played.

SetSwingDoorClosed: We swing the door closed as fast as we can.

This is only step one of the process. Next post will detail how to use these functions in your script.
Ok, That makes sense...
04-17-2012, 12:39 AM
Find Reply
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#10
RE: HELP!!!

Okay, so, first, we have a mapping problem. In our map, we are going to have a door called "mansion_1", an area called "AreaSlamDoor", and that's pretty much it. Our player is always called "Player" when referred to by the script.

So, when we collide with AreaSlamDoor, mansion_1 will be shut closed!

How do we do this?

First, we add a callback in our OnStart function so that the game knows when the player will collide with the area.

void OnStart()
{
    //Hey! This is a comment. Any text following "//" will not affect your script at all!
    //Player is our parent, it collides with our child, AreaSlamDoor.
    //When it does, SlamDoor function is called, with a specific callback that you will find in the Engine Scripts webpage
    //That "true" means we are deleting the callback when the player enters the area, so it won't trigger twice by accident
    //That 0 pretty much means it will trigger when the player enters or leaves the area, it doesn't matter.
    AddEntityCollideCallback("Player", "AreaSlamDoor", "SlamDoor", true, 0);

}

void OnEnter()
{

}

void OnLeave()
{

}

//see that weird stuff in the parantheses? That's a function argument...you'll find this following every function that needs in the Engine scripts I linked above!
void SlamDoor(string &in asParent, string &in asChild, int alStates)
{
    //this function got called when player touches Area
    //The door "mansion_1" will be closed because the first boolean statement (true or false) is set to true
    //Effects will be shown because the second boolean argument is set to true as well
    SetSwingDoorLocked("mansion_1", true, true);
    //We deal 10 sanity damage to the player, and we will show effects on his screen because true is set for use effects!
    GiveSanityDamage(10, true);
    //the "doorslam" could be anything, this is just so that can easily identify the sound
    //we play the 15_slam_door sound effect, located in this sounds folder of Amnesia directory, because it sounds like a slam door!
    //Don't worry about the true or false in this function
    //0.4 seconds (notice the "f", it's there because this is a float (there's a decimal in the number) to fade out
    PlaySoundAtEntity("doorslam", "15_slam_door.snt", "mansion_1", 0.4f, false);
}

That should work for you. Don't copy and paste that code, write it out and study my comments, it is the only way you will learn syntax and how to code!

There are many advanced methods on how to script, but you are a beginner and this is how you need to learn.

(This post was last modified: 04-17-2012, 12:47 AM by Putmalk.)
04-17-2012, 12:46 AM
Find Reply




Users browsing this thread: 1 Guest(s)