Frictional Games Forum (read-only)
How do I use void ChangeMap? [SOLVED] - 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: How do I use void ChangeMap? [SOLVED] (/thread-17552.html)



How do I use void ChangeMap? [SOLVED] - Melvin - 08-07-2012

void ChangeMap(string &in asParent, string &in asChild, int alState) <- if I remember correctly?


I want to use it as a trigger when a player collides with an Area, is this possible?


RE: How do I use void ChangeMap? - Adny - 08-07-2012

That is very possible! Use an entity collide callback with the name of the area, then inside the function, use the change map command. If done properly, it should look something like this:

void OnStart()
{
AddEntityCollideCallback("Player", "NAME_OF_AREA", "FUNC", 1, true);
}

void FUNC(string &in asParent, string &in asChild, int alState)
{
ChangeMap("NAME_OF_MAP.map", "NAME_OF_PLAYER_START_AREA", "", "");
}

Hope that helped.


RE: How do I use void ChangeMap? - Melvin - 08-07-2012

(08-07-2012, 03:05 AM)andyrockin123 Wrote: That is very possible! Use an entity collide callback with the name of the area, then inside the function, use the change map command. If done properly, it should look something like this:

void OnStart()
{
AddEntityCollideCallback("Player", "NAME_OF_AREA", "FUNC", 1, true);
}

void FUNC(string &in asParent, string &in asChild, int alState)
{
ChangeMap("NAME_OF_MAP.map", "NAME_OF_PLAYER_START_AREA", "", "");
}

Hope that helped.
So now I've got this

void OnStart()
{
AddEntityCollideCallback("Player", "PlayerSleep", "OnStart", 1, true);
}

void OnStart(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}


I've started understanding this scripting bussiness today so I'm still a little noobie, sorry for that.

But I'm not sure what function I should use? I know the OnStart or OnEnter are functions, but I don't know which one I'm supposed to pick!

This is the scenario

Two maps, Floor_2_Day (starts here) and Floor_2_Night. The player walks to his room and goes to his bed, the next map loads, and its night.


RE: How do I use void ChangeMap? - Kazakarumariou - 08-07-2012

void OnStart()
{
AddEntityCollideCallback("Player", "PlayerSleep", "LOLOLFUNCNUMBERONE", 1, true);
}

void LOLOLFUNCNUMBERONE(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}




Whatever you use in the bolded area AddEntityCollideCallback("Player", "PlayerSleep", "LOLOLFUNCNUMBERONE", 1, true);


is used here in the bolded area
void LOLOLFUNCNUMBERONE(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}


RE: How do I use void ChangeMap? - Melvin - 08-07-2012

(08-07-2012, 03:27 AM)Harthex Wrote: void OnStart()
{
AddEntityCollideCallback("Player", "PlayerSleep", "LOLOLFUNCNUMBERONE", 1, true);
}

void LOLOLFUNCNUMBERONE(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}




Whatever you use in the bolded area AddEntityCollideCallback("Player", "PlayerSleep", "LOLOLFUNCNUMBERONE", 1, true);


is used here in the bolded area
void LOLOLFUNCNUMBERONE(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}
Hey man, thanks for the reply.

I'm still having an FATAL ERROR though. It says


Could not load script file blablalba maps/Floor_2_Day.hps'!
ExecuteString (1, 1) : ERR : No matching signatures to 'OnLeave()'
main (6, 1) : ERR : No matching signatures to 'AddEntityCollideCallback(string@&, string@&, string@&, const uint, const bool)'


My guess is that its the script where the problem is at, I can't seem to fix it.

////////////////////////////
// Run when first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "PlayerSleep", "FunctionOne", 1, true);
}

void FunctionOne(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}

void StartMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("Beforethestorm.ogg", true, 0.4, 8, 1, true);
}


The other one is a musicfile.
pls fix 'em bro(s)


RE: How do I use void ChangeMap? - Adny - 08-07-2012

Sorry, the callback I wrote was off the top of my head so I mixed up the Boolean and Int spots Tongue
Here's a fix:


////////////////////////////
// Run when first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "PlayerSleep", "FunctionOne", true, 1);
}

void FunctionOne(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}

void StartMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("Beforethestorm.ogg", true, 0.4, 8, 1, true);
}


RE: How do I use void ChangeMap? - Melvin - 08-07-2012

(08-07-2012, 03:41 AM)andyrockin123 Wrote: Sorry, the callback I wrote was off the top of my head so I mixed up the Boolean and Int spots Tongue
Here's a fix:


////////////////////////////
// Run when first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "Music", "StartMusic", true, 1);
AddEntityCollideCallback("Player", "PlayerSleep", "FunctionOne", true, 1);
}

void FunctionOne(string &in asParent, string &in asChild, int alState)
{
ChangeMap("Floor_2_Night.map", "SpawnAfterTeleport", "", "");
}

void StartMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("Beforethestorm.ogg", true, 0.4, 8, 1, true);
}
Omg it worked! You are getting a spot in the credits, FOR SURE! Now I'm going to make an awesome custom story, I'm so full of ideas! thanks dude!!! Just one thing for the looks, how do I script it so that it looks like I woke up lying on the ground?