Frictional Games Forum (read-only)
Help needed with "Intro script" - 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: Help needed with "Intro script" (/thread-9186.html)



Help needed with "Intro script" - HumiliatioN - 07-16-2011

Hello again so I'm working my next project but, how I can do this in script?

"Wake up normally style i know that then player moving slowly starting hallway then it falls down to the ground and get blackout or something then he teleports and...
then he wakes up again normally?

Help is appreciated thanks.

- Scripting noob -.-


RE: Help needed with "Intro script" - palistov - 07-17-2011

Use these functions to make the player seem dazed/injured etc:

Teleport the Player to a PlayerStart area:
TeleportPlayer(string areaname);

Tilted/lowered head:
FadePlayerRollTo(float X, float speed, float maxspeed);
MovePlayerHeadPos(float x, float y, float z, float speed, float slowdowndist);

Move/Look speed multipliers:
SetPlayerMoveSpeedMul(float multiplier);
SetPlayerRunSpeedMul(float multiplier);
SetPlayerLookSpeed(float multiplier);

Image effects:
FadeImageTrailTo(float amount, float speed);
FadeSepiaColorTo(float amount, float speed);


Amnesia's faint sequences in the beginning use the head position/tilt controllers. You can script blackouts with FadeOut(float time); and FadeIn(float time);

Use a good combination of these functions using a switch function, which lets you tightly control the sequence without having to use multiple functions (like FunctionOne doing the blackout while FunctionTwo does the sound effects)

Here's a good example of an event switch function:

Code:
void SwitchFuncScaryEvent(string &in timer) {
    switch(GetLocalVarInt("eventStep")) {
        case 1:
            //Player sees something scary happen!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 2:
            //Player reacts to said scary thing!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 3:
            //Another part of the event happens, even more scary stuff!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 4:
            //Player falls down and gasps!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 5:
            //Player blacks out!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
    }
    
    AddLocalVarInt("eventstep", 1);
}
You can control the time between each step in the function by editing the timer duration in the step before it. This is how FG did their events, and boy did they do it well. With some practice you can make really convincing and detailed events using one or perhaps two functions!


RE: Help needed with "Intro script" - HumiliatioN - 07-17-2011

(07-17-2011, 09:22 AM)palistov Wrote: Use these functions to make the player seem dazed/injured etc:

Teleport the Player to a PlayerStart area:
TeleportPlayer(string areaname);

Tilted/lowered head:
FadePlayerRollTo(float X, float speed, float maxspeed);
MovePlayerHeadPos(float x, float y, float z, float speed, float slowdowndist);

Move/Look speed multipliers:
SetPlayerMoveSpeedMul(float multiplier);
SetPlayerRunSpeedMul(float multiplier);
SetPlayerLookSpeed(float multiplier);

Image effects:
FadeImageTrailTo(float amount, float speed);
FadeSepiaColorTo(float amount, float speed);


Amnesia's faint sequences in the beginning use the head position/tilt controllers. You can script blackouts with FadeOut(float time); and FadeIn(float time);

Use a good combination of these functions using a switch function, which lets you tightly control the sequence without having to use multiple functions (like FunctionOne doing the blackout while FunctionTwo does the sound effects)

Here's a good example of an event switch function:

Code:
void SwitchFuncScaryEvent(string &in timer) {
    switch(GetLocalVarInt("eventStep")) {
        case 1:
            //Player sees something scary happen!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 2:
            //Player reacts to said scary thing!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 3:
            //Another part of the event happens, even more scary stuff!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 4:
            //Player falls down and gasps!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
        case 5:
            //Player blacks out!
            AddTimer("nextstep", 1, "SwitchFuncScaryEvent");
        break;
    }
    
    AddLocalVarInt("eventstep", 1);
}
You can control the time between each step in the function by editing the timer duration in the step before it. This is how FG did their events, and boy did they do it well. With some practice you can make really convincing and detailed events using one or perhaps two functions!


Okay begin was good but he teleports "Player doesn't fall down he automatic teleport and then he rotates he's head 90 degrees right then later he is normally state. and i can move... its stupid how i can make it more realistic I dont understand that Scaryevent advanced timer thing.




RE: Help needed with "Intro script" - palistov - 07-17-2011

I'm not sure if there was a question in your reply haha. OK well to stop the player from moving use SetPlayerActive(false);

Make sure you use SetPlayerActive(true); later so the player can move again Tongue

The switch function isn't too hard to understand once you get the hang of it. Think of it like a music playlist. The first song (case 1) plays first, then the timer calls the function again and this time it plays the second song (case 2), and it keeps going until there are no more songs (no more cases!).

You need to use those functions I posted above in a switch function to efficiently make a faint/wake up sequence. Just practice. Smile


RE: Help needed with "Intro script" - HumiliatioN - 07-17-2011

(07-17-2011, 07:38 PM)palistov Wrote: I'm not sure if there was a question in your reply haha. OK well to stop the player from moving use SetPlayerActive(false);

Make sure you use SetPlayerActive(true); later so the player can move again Tongue

The switch function isn't too hard to understand once you get the hang of it. Think of it like a music playlist. The first song (case 1) plays first, then the timer calls the function again and this time it plays the second song (case 2), and it keeps going until there are no more songs (no more cases!).

You need to use those functions I posted above in a switch function to efficiently make a faint/wake up sequence. Just practice. Smile

Oh now i have it thanks. But i have this script but why player is still 90 degrees.. all the time no stops after that teleport.

Whole script just in case:

void OnStart()

{
// AddEntityCollideBacks
AddEntityCollideCallback("Player", "Felldown", "Teleport1", true, 1);










FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);

SetPlayerCrouching(true); // Simulates being on the ground
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer){
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadeSepiaColorTo(0.5f, 0.5f);
FadeRadialBlurTo(0.7f, 0.5f);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
SetPlayerMoveSpeedMul(0.2);
PlayMusic("29_amb_end_daniel", false, 3, 3, 10, true);
}






void OnEnter()
{
}


// Functions
void Teleport1(string &in asParent, string &in asChild, int alState)
{
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(80.0f, 80.0f, 100.0f);
FadeOut(0.45f);
GiveSanityDamage(100, true);
AddTimer("tele", 3, "Teleport");
}

void Teleport(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_2");
AddTimer("trig1", 8.0f, "beginStory2");
}

void beginStory2(string &in asTimer){
FadeIn(3);
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
PlayMusic("16_amb", false, 3, 3, 10, true);
}








void OnLeave()
{
}

EDIT: Nothing I solved it ! Thanks for your help!