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
Interacting with item then teleporting to another area script?
Artsy Offline
Member

Posts: 213
Threads: 10
Joined: Feb 2014
Reputation: 9
#1
Interacting with item then teleporting to another area script?

Hello there,
I'm working on a custom story and had this cool idea for something which requires script.
It's basically like this:
the player interacts with the lever, the screen fades black and then the player teleports to another area.
I've found script from the Cellar Archives from TDD, which is exactly what I want:

Quote: FadeOut(0.3);

AddTimer("scare", 0.3f, "TimerPlayerReact");
AddTimer("breath", 2.0f, "TimerPlayerReact");
AddTimer("breathl", 4.0f, "TimerPlayerReact");
AddTimer("breathl", 6.0f, "TimerPlayerReact");

AddTimer("TeleportHowl", 0.5f, "TimerTeleportHowl");
AddTimer("TeleportDone", 3.5f, "TimerTelportDone");

PlaySoundAtEntity("stomp","scare_wall_stomp","Player", 0, false);
PlaySoundAtEntity("darkamb","07_amb_breath","Player", 5, true);
PlaySoundAtEntity("wateramb", "ambience_water_no3d.snt", "sound_idle_1", 5, true);

FadePlayerFOVMulTo(4.0f, 4.0f);
SetRadialBlurStartDist(0.1f);
FadeRadialBlurTo(1.0f, 5.0f);

StartEffectFlash(0.2, 0.1,0.3);

FadeGlobalSoundVolume(0, 0.3);
StopMusic(0.3f, 0);
StartScreenShake(0.1, 4.7, 0.05, 0.5);

FadePlayerFOVMulTo(0.5, 3);
}

void TimerPlayerReact(string &in asTimer)
{
if(asTimer == "scare"){
PlayGuiSound("react_scare", 1.0f);
}
else if(asTimer == "breath"){
PlayGuiSound("react_breath", 0.8f);
}
else if(asTimer == "breathl"){
PlayGuiSound("react_breath", 0.5f);
}
}

void TimerTeleportHowl(string &in asTimer)
{
PlaySoundAtEntity("howl","guardian_activated.snt","Player", 0, false);
SetPlayerActive(false);
SetFogActive(true);
}

void TimerTelportDone(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
FadeGlobalSoundVolume(1,2);
SetPlayerActive(true);
FadePlayerFOVMulTo(1.0f, 0.5f);
FadeRadialBlurTo(0.0f, 1.0f);
FadeIn(1.3);

FadePlayerFOVMulTo(1, 1);

StartUpDarkSide();
}

But - I really do want the player to interact with the lever first, before the screen fades black. Help?

Can you give me an example?
02-09-2014, 10:13 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Interacting with item then teleporting to another area script?

Run the script you want to happen inside a block that is executed when you interact with the lever. One way to do this is to go to the lever's entity tab in the level editor. One of the text boxes should say PlayerInteractCallback. Write a name in there (for example InteractLever).

Then go to your script and make the block for it. From what you quoted, it looks like you cut out the top of it. You can place all of what was originally inside that block inside the new block you made, like this:

void InteractLever(string &in asEntity)
{
    FadeOut(0.3);

    AddTimer("scare", 0.3f, "TimerPlayerReact");    
    AddTimer("breath", 2.0f, "TimerPlayerReact");    
    AddTimer("breathl", 4.0f, "TimerPlayerReact");
    AddTimer("breathl", 6.0f, "TimerPlayerReact");

    AddTimer("TeleportHowl", 0.5f, "TimerTeleportHowl");    
    AddTimer("TeleportDone", 3.5f, "TimerTelportDone");

    PlaySoundAtEntity("stomp","scare_wall_stomp","Player", 0, false);
    PlaySoundAtEntity("darkamb","07_amb_breath","Player", 5, true);
    PlaySoundAtEntity("wateramb", "ambience_water_no3d.snt", "sound_idle_1", 5, true);

    FadePlayerFOVMulTo(4.0f, 4.0f);
    SetRadialBlurStartDist(0.1f);
    FadeRadialBlurTo(1.0f, 5.0f);

    StartEffectFlash(0.2, 0.1,0.3);

    FadeGlobalSoundVolume(0, 0.3);
    StopMusic(0.3f, 0);
    StartScreenShake(0.1, 4.7, 0.05, 0.5);

    FadePlayerFOVMulTo(0.5, 3);
}

You can keep the rest as it is right now, and that should be it. Let me know if it works out Smile

(This post was last modified: 02-09-2014, 10:55 PM by Mudbill.)
02-09-2014, 10:53 PM
Find
Artsy Offline
Member

Posts: 213
Threads: 10
Joined: Feb 2014
Reputation: 9
#3
RE: Interacting with item then teleporting to another area script?

Ok so I put InteractLever in PlayerInteractCallback and when I pulled the level the screen faded to black ever so quickly (which is what I wanted anyway) but the screen remains black like that and I can hear sounds and stuff.
I most definitely did something wrong in the script AGAIN. Probably forgot to do something. I wrote the code there you gave me and saved the document. I also tried putting the rest of the stuff that was in the Cellar Archives script and it gave me a bunch of errors.

Never mind, I fixed it! I forgot to add the rest of the stuff that was in the original script. Thanks a lot!
(This post was last modified: 02-10-2014, 12:12 AM by Artsy.)
02-09-2014, 11:50 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Interacting with item then teleporting to another area script?

Looking more closely at your script I noticed there is no FadeIn. If you fade out it will remain black until you fade back in.

Generally, it's not recommended to copy over Frictional's script into your own because you have less control over what's going on. You can use it as a reference, but I suggest you write it yourself so you can set it up just how you want.

If you want the screen to fade in again, use FadeIn(1); anywhere in your script after fading out. You may change 1 to any time in seconds for how fast you want it to happen.

02-10-2014, 12:30 AM
Find
Artsy Offline
Member

Posts: 213
Threads: 10
Joined: Feb 2014
Reputation: 9
#5
RE: Interacting with item then teleporting to another area script?

Good thing I got it to work just fine either way. I agree that frictional's scripts are complicated and that I don't have much control over them. I deleted the rest of the script that was made by them since I don't need it.
02-10-2014, 12:57 AM
Find




Users browsing this thread: 3 Guest(s)