Frictional Games Forum (read-only)
[LVL ED] How do I make a ladder teleport you to next level? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [LVL ED] How do I make a ladder teleport you to next level? (/thread-12496.html)



How do I make a ladder teleport you to next level? - MissMarilynn - 01-09-2012

I have a ladder in the elevator shaft leading to the basement but I want to add an area at the bottom of the ladder where it will load the next map. How do I go about doing that?


RE: How do I make a ladder teleport you to next level? - Inurias - 01-09-2012

(I am assuming that you already created a working script file for the corresponding map. If this is not the case, google up the basics about scripting with hpl2, also, this link could help you a lot: http://wiki.frictionalgames.com/hpl2/start)



First you add a ScriptArea to your desired location, after that, you add a "AddEntityCollideCallback" call into your initializing function (most likely "OnStart" in your case), you do this by using:

Code:
void AddEntityCollideCallback(string& asParentName, string&  asChildName, string& asFunction, bool abDeleteOnCollide, int  alStates);

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave

asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both


Then, in your CallBack function you use:

Code:
void ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);

asMapName - the file to load
asStartPos - the name of the StartPos on the next map
asStartSound - the sound that is played when the change starts
asEndSound - the sound that is played when the new map is loaded


RE: How do I make a ladder teleport you to next level? - MissMarilynn - 01-09-2012

(01-09-2012, 07:45 PM)Inurias Wrote: (I am assuming that you already created a working script file for the corresponding map. If this is not the case, google up the basics about scripting with hpl2, also, this link could help you a lot: http://wiki.frictionalgames.com/hpl2/start)



First you add a ScriptArea to your desired location, after that, you add a "AddEntityCollideCallback" call into your initializing function (most likely "OnStart" in your case), you do this by using:

Code:
void AddEntityCollideCallback(string& asParentName, string&  asChildName, string& asFunction, bool abDeleteOnCollide, int  alStates);

Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave

asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both


Then, in your CallBack function you use:

Code:
void ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);

asMapName - the file to load
asStartPos - the name of the StartPos on the next map
asStartSound - the sound that is played when the change starts
asEndSound - the sound that is played when the new map is loaded
I do have a working script file, yes. Could you make an example of the script I would need to make? Thank you. Smile


RE: How do I make a ladder teleport you to next level? - Inurias - 01-09-2012

Okay, but you should make sure to read through the little script and make sure that you understand what's going on. I hope that you'll learn from it.

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "YourScriptArea", "YourCallBackFunction", true, 1);
}

void YourCallBackFunction(string &in asParent, string &in asChild, int alState)
{
    ChangeMap("YourMapName", "YourStartPosName", "YourStartSound", "YourEndSound");
}

- Inurias



RE: How do I make a ladder teleport you to next level? - MissMarilynn - 01-09-2012

(01-09-2012, 07:53 PM)Inurias Wrote: Okay, but you should make sure to read through the little script and make sure that you understand what's going on. I hope that you'll learn from it.

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "YourScriptArea", "YourCallBackFunction", true, 1);
}

void YourCallBackFunction(string &in asParent, string &in asChild, int alState)
{
    ChangeMap("YourMapName", "YourStartPosName", "YourStartSound", "YourEndSound");
}

- Inurias
*facepalm* I should've learned that by now haha. I'm terribly sick today so my brains not working at full XP Thank you so much.


RE: How do I make a ladder teleport you to next level? - Inurias - 01-09-2012

You're Welcome.