Frictional Games Forum (read-only)

Full Version: [SOLVED] Fainting into a new map [Need scripting help]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys!

I'm not really that experienced in the scripting from scratch part of custom story making, so I was hoping someone here would know how to solve my problem. In my custom story, the player is supposed to walk to a scripting area where he will start to faint, the screen will go black and then he should wake up in a new map which features the same room but now in a much darker environment.
Hope you know how to help me out! :-)

EDIT:
I have already tried this:
void OnStart ()
{
AddEntityCollideCallback("Player", "Trigger_1", "Faint", true, 1);
}

void Faint(string &in asParent, string &in as Child, int alState)
{
FadePlayerRollTo(50, 220, 220); //Rolls your head to the side
SetPlayerCrouching(true); //Makes the falling down more realistic
FadeOut(5.0f); //This means it will take 5 seconds to fade to black
ChangeMap("00_Awakened", "PlayerStartArea_1", "", "",); //Changes the map
}

but the ChangeMap line creates scripterrors which keeps me from loading the custom story.
Thanks in advance,
Alex
If the script crashes, I can only assume it isn't finding the map. I do think you need to include the .map extension in the script. Also make sure the name is correct.

However as for your situation, you'll want to use some timers here. If you run the ChangeMap script immediately after the FadeOut script, it won't have time to fade out the screen, so it will just cut right away.

Also if you want the player's view to roll to the side, I think the speeds you have chosen for FadePlayerRollTo are very high. I think they might even be high enough so that the player won't notice the roll, but just the new angle of the camera. I suggest using speeds around 10-15.

As for the timers, instead of running ChangeMap right after FadeOut, try doing:

PHP Code:
AddTimer("fadeout"5.5f"TimerChangeMap"); 

And then below your the collision block:

PHP Code:
void TimerChangeMap(string &in asTimer)
{
    
ChangeMap("00_Awakened.map""PlayerStartArea_1""""",); //Changes the map


This will do so that the map change won't happen until 5.5 seconds after the fade out starts.
(01-07-2015, 11:10 AM)Mudbill Wrote: [ -> ]If the script crashes, I can only assume it isn't finding the map. I do think you need to include the .map extension in the script. Also make sure the name is correct.

However as for your situation, you'll want to use some timers here. If you run the ChangeMap script immediately after the FadeOut script, it won't have time to fade out the screen, so it will just cut right away.

Also if you want the player's view to roll to the side, I think the speeds you have chosen for FadePlayerRollTo are very high. I think they might even be high enough so that the player won't notice the roll, but just the new angle of the camera. I suggest using speeds around 10-15.

As for the timers, instead of running ChangeMap right after FadeOut, try doing:

PHP Code:
AddTimer("fadeout"5.5f"TimerChangeMap"); 

And then below your the collision block:

PHP Code:
void TimerChangeMap(string &in asTimer)
{
    
ChangeMap("00_Awakened.map""PlayerStartArea_1""""",); //Changes the map


This will do so that the map change won't happen until 5.5 seconds after the fade out starts.

I've used the scripts you've supplied but the changemap line still creates an error. It might be because of the map location as you say but I can't seem to figure out what it wants for it to work. My map is located at custom-stories/"customstoryname"/maps/mapname.map
and in the script i write "mapname.map" and afterwards "maps/mapname.map" but none of them works :/
What does the error say?
(01-07-2015, 11:36 AM)Mudbill Wrote: [ -> ]What does the error say?

"FATAL ERROR: Could not load script file 'custom_stories/NewProject/maps/NewProject2.hps'! main (76, 67): ERR : Expected expression value"

my line 76 is the ChangeMap line and the second number (in this case 67) changes every time i try to open my custom story, so that one isn't consistent.
Ah, I see. There's an extra comma at the end of the last string parameter in ChangeMap. Remove it.

PHP Code:
ChangeMap("00_Awakened.map""PlayerStartArea_1""""",); //Changes the map 
PHP Code:
ChangeMap("00_Awakened.map""PlayerStartArea_1"""""); //Changes the map 
Ahh thanks a lot, it works now! What a simple problem :p
Oh, and if you want to avoid the loading screen, you can put the second map in the same file and then teleport the player. But I think it's too late for that now Wink