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
[SOLVED] Fainting into a new map [Need scripting help]
Aletho Offline
Junior Member

Posts: 14
Threads: 4
Joined: Jan 2015
Reputation: 0
#1
[SOLVED] Fainting into a new map [Need scripting help]

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
(This post was last modified: 01-07-2015, 02:44 PM by Aletho.)
01-07-2015, 10:05 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Fainting into a new map [Need scripting help]

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: (Select All)
AddTimer("fadeout"5.5f"TimerChangeMap"); 

And then below your the collision block:

PHP Code: (Select All)
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.

(This post was last modified: 01-07-2015, 11:11 AM by Mudbill.)
01-07-2015, 11:10 AM
Find
Aletho Offline
Junior Member

Posts: 14
Threads: 4
Joined: Jan 2015
Reputation: 0
#3
RE: Fainting into a new map [Need scripting help]

(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: (Select All)
AddTimer("fadeout"5.5f"TimerChangeMap"); 

And then below your the collision block:

PHP Code: (Select All)
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 :/
01-07-2015, 11:33 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Fainting into a new map [Need scripting help]

What does the error say?

01-07-2015, 11:36 AM
Find
Aletho Offline
Junior Member

Posts: 14
Threads: 4
Joined: Jan 2015
Reputation: 0
#5
RE: Fainting into a new map [Need scripting help]

(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.
01-07-2015, 11:41 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Fainting into a new map [Need scripting help]

Ah, I see. There's an extra comma at the end of the last string parameter in ChangeMap. Remove it.

PHP Code: (Select All)
ChangeMap("00_Awakened.map""PlayerStartArea_1""""",); //Changes the map 
PHP Code: (Select All)
ChangeMap("00_Awakened.map""PlayerStartArea_1"""""); //Changes the map 

(This post was last modified: 01-07-2015, 11:53 AM by Mudbill.)
01-07-2015, 11:52 AM
Find
Aletho Offline
Junior Member

Posts: 14
Threads: 4
Joined: Jan 2015
Reputation: 0
#7
RE: Fainting into a new map [Need scripting help]

Ahh thanks a lot, it works now! What a simple problem :p
01-07-2015, 11:59 AM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#8
RE: [SOLVED] Fainting into a new map [Need scripting help]

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

01-19-2015, 10:32 AM
Find




Users browsing this thread: 1 Guest(s)