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!!!
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


Messages In This Thread
HELP!!! - by JPPSJ - 04-16-2012, 11:38 PM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:01 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:06 AM
RE: HELP!!! - by MrIcabod123 - 04-17-2012, 12:12 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:14 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:19 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:27 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:37 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:39 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:46 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:52 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:53 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 12:57 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 12:59 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:01 AM
RE: HELP!!! - by Xanthos - 04-17-2012, 01:00 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:02 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:08 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:11 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:13 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:14 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:18 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:28 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:27 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:33 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:39 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 01:45 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 01:46 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 02:02 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 02:05 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 02:15 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 02:23 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 03:00 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 03:54 AM
RE: HELP!!! - by Putmalk - 04-17-2012, 04:05 AM
RE: HELP!!! - by JPPSJ - 04-17-2012, 04:14 AM
RE: HELP!!! - by Putmalk - 04-18-2012, 02:16 AM
RE: HELP!!! - by jessehmusic - 04-18-2012, 12:23 PM



Users browsing this thread: 1 Guest(s)