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
Fancy door + quest scripting.
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#11
RE: Fancy door + quest scripting.

Wow, brilliant. That one simple fix (Changing true to false) fixed everything. The fire and key puzzle works like a charm now, thank you very much.

On to my next question (I'm finally getting the hang of this, I've written a few of my own fairly complex scripts since I started this thread, and they work!); How do I make a sound entity not play instantly when the map loads? I want a sound to wait until I hit an area to play, then play once. I've unchecked 'active' on the sound itself, I've activated it and told it to play in the script, and so on. It still plays as soon as the level loads.

Also, could you please elaborate on what exactly I need to be putting in OnEnter and OnLeave? I do understand what they actually do, but I don't know what to tell them to do to make it check if I have the lantern or not in the next level. Should I tell it to remember something when I leave the level, or tell it to check something when I enter the level?

[Image: signature-2.png]
03-19-2011, 09:11 AM
Find
Nye Offline
Senior Member

Posts: 250
Threads: 8
Joined: Jan 2011
Reputation: 2
#12
RE: Fancy door + quest scripting.

Try using the function,
HasItem(string& asName);

So, you would put
if(HasItem("lantern") == true
{
   STUFF
}
if(HasItem("lantern") == false (or put != true)
{
   STUFF
}

I have never done the above code, but it should work! Blush

Second, you don't need to put anything inside the OnLeave() and OnEnter().

Although, inside the OnLeave(), I put sounds (eg. creepy whispers) and also specify the loading screen and text I want the player to load.

Here is an example from one of my scripts:
void OnEnter()
{
}
void OnLeave()
{
    PlaySoundAtEntity("", "insanity_whisper.snt", "Player", 0.0f, true);    
    SetupLoadScreen("LoadingText", "catacombs", 0, "");                
    StopMusic(3.0f, 10);
}

Also, it's up to you what you do with the lantern check. Maybe it would be cooler if you entered the area, created a 'Block Box' entity and created a trigger in the darkness, just before the block box. Then, when the player collides with the trigger, if he has the lantern, the callback removes the block box ((SetEntityActive, "BlockBox", false)Wink. Else, it triggers a message telling the player that they should go back to get a lantern.


Finally, with regards to your sound question. ONLY use the level editor for repeated sounds (eg. waterfall streams, water drips, machine humming).

Every other sound, you should create triggers and use the PlaySoundAtEntity function to call. (Create a script area for the entity and place it where you want the sound source to be). Otherwise, the game will just play every single sound and it gets really buggy Tongue

(This post was last modified: 03-19-2011, 10:18 AM by Nye.)
03-19-2011, 10:15 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#13
RE: Fancy door + quest scripting.

Okay, I'm sorry I can't ever get these things right, but you've been immensely helpful thus far. If you want to see the fruits of your labors, check my thread in the Showcase. Smile

Anyways, here's my code, I'm totally stumped as to why it won't work. It seems fine to me.
void OnStart()
    {
    AddEntityCollideCallback("Player", "needlantern", "lantern_warn", true, 1);
    }
void lantern_warn(string &in asParent, string &in asChild, int alState)
    if (HasItem("lantern_1") == true);
        {
        PlaySoundAtEntity("scare_dog", "scare_animal_squeal2.snt", "needlantern", 0, true);
        AddTimer("dogreact", 0.5f, "scaredgasp2");
        SetEntityActive("block_box_1", false);
        }
if (HasItem("lantern_1") != true);
        {
        PlaySoundAtEntity("scare_dog", "scare_animal_squeal2.snt", "needlantern", 0, true);
        SetPlayerCrouching(true);
        AddTimer("dogreact", 0.5f, "scaredgasp2");
        SetMessage("house", "TooDark", 0);
        AddQuest("questtext2","questtext2");
        }
void scaredgasp2(string &in asTimer)
    {
    PlayMusic("react_scare3",false,100.0f,0.0f,1,false);
    GiveSanityDamage(10.0f,true);
    GiveHint("sanity", "Hints", "Sanity", 0);
    }

It says 'expected "," or ";", and unexpected "if". What does that mean, unexpected if?

[Image: signature-2.png]
03-19-2011, 10:33 AM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#14
RE: Fancy door + quest scripting.

The lantern_warn function doesn't seem to have its own brackets. Try adding those.

[Image: 2exldzm.png]
03-19-2011, 10:50 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#15
RE: Fancy door + quest scripting.

If you want to use vars between levels, you will have to use GlobalVars.

03-19-2011, 11:51 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#16
RE: Fancy door + quest scripting.

I fixed it, I was missing some damn brackets... Oscar House got it right, boy do I feel dumb. <.<

Anyways, progress is pretty solid at this point. No real issues anymore, although I do have a question: is it possible to make Entity decals active or inactive in a script? I used the blood decal entities (I know you can't activate or deactivate normal decals), and set them to inactive, then in the script told them to activate but it just doesn't seem to work. It's not a very complex code at all, I don't see what could be wrong.

[Image: signature-2.png]
(This post was last modified: 03-20-2011, 06:39 AM by Streetboat.)
03-20-2011, 06:38 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#17
RE: Fancy door + quest scripting.

As far as I know you can't (de)activate decals. You would probably have to create new entities and apply the decal texture to them via the model editor.

03-20-2011, 11:40 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#18
RE: Fancy door + quest scripting.

I can't appear to activate anything via script, though, including areas and whatnot.

[Image: signature-2.png]
03-20-2011, 11:41 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#19
RE: Fancy door + quest scripting.

Okay so yeah, this is weird. Setting things to active or not seems to only affect a few items, and only when it feels like it. Things that I set to inactive appear anyways at the start of the map, and won't change states in my script. What gives?

[Image: signature-2.png]
03-21-2011, 12:53 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#20
RE: Fancy door + quest scripting.

As I said, you can only set entities inactive aswell as areas.

03-21-2011, 01:46 AM
Find




Users browsing this thread: 3 Guest(s)