Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Gametee


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginning Scripting, Requesting a [More thorough] Tutorial
Author Message
ErichK Offline
Junior Member

Posts: 2
Joined: Sep 2010
Reputation: 0
Post: #1
Beginning Scripting, Requesting a [More thorough] Tutorial

Hi there! Long time fan, first time poster.

Anyway, I've been searching around and trying countless different things, but I have finally given up and resorted to posting on here.

I was trying to refer to this thread:

http://www.frictionalgames.com/forum/thread-4425.html

In order to make a "scary door." However, I have a few issues that the HPL2 tutorial didn't seem to want to go over.

Firstoff, here is my .hps file:

//The Waking Up Feature that starts as soon as map loads.
void wakeUp () {
    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);
    FadePlayerRollTo(0, 33, 33);        // Change all settings to defaults
    FadeRadialBlurTo(0.0, 1);
    FadeSepiaColorTo(0, 4);
    SetPlayerCrouching(false);
    FadeImageTrailTo(0,1);
}

////////////////////////////
// Run first time starting map
void OnStart()
{  
    //Allows you to wake up
    wakeUp();

    //Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");

        for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
    }
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

Everything on there works perfectly, but when I try to add the "scary door" code from the above link, all hell breaks loose.

I was wondering if anyone could please help me with the following issues:

1. Could you please provide a completed example of how the code would look in finished form, i.e. adding it to what code I posted here?

2. Elaborate on what needs to go where (in terms of in the script itself - for example, in:

SetEntityPlayerInteractCallback("name_of_door_here", "FunctionToCall", true);

Does "FunctionToCall" mean "insert text here," and if so, are these the functions?:

void FunctionToCall(string &in entity)
{
    PlaySoundAtEntity("instance_name", "soundfile.ogg/snt", "name_of_entity_to_play_sound_from", 0, false);
    SetEntityActive("name_of_grunt_or_brute", true); //Spawn monster
}

3. And lastly, what snippets of code do I put in the entity tab of the door, under the Callback function boxes?

Thanks for any help. I've been trying to pull up the developer code as well as examples from other custom stories, but I'm still too new at it to be able to figure it out on my own. I'm sure, however, that if I get an example of a finished (or close to finished) product, I can get the rest on my own. Thanks!

-Erich
09-21-2010 08:13 PM
Find all posts by this user Quote this message in a reply
MulleDK19 Offline
Senior Member

Posts: 545
Joined: Jun 2009
Reputation: 10
Post: #2
RE: Beginning Scripting, Requesting a [More thorough] Tutorial

The code below assumes that your door is called "mansion_1" (without the quotes), and your monster is called "servant_brute_1" (without the quotes).

//The Waking Up Feature that starts as soon as map loads.
void wakeUp () {
    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);
    FadePlayerRollTo(0, 33, 33);        // Change all settings to defaults
    FadeRadialBlurTo(0.0, 1);
    FadeSepiaColorTo(0, 4);
    SetPlayerCrouching(false);
    FadeImageTrailTo(0,1);
}

////////////////////////////
// Run first time starting map
void OnStart()
{  
    //Allows you to wake up
    wakeUp();

    //Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");

        for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
    }
    
    SetEntityPlayerInteractCallback("mansion_1", "InteractedWithDoor", true);
}

void InteractedWithDoor(string &in entity)
{
    PlaySoundAtEntity("", "insanity_monster_roar02.ogg", "mansion_1", 0, false);
    SetEntityActive("servant_brute_1", true); //Spawn monster
    GiveSanityDamage(15.0f, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

[Image: 16455.png]
09-21-2010 11:56 PM
Find all posts by this user Quote this message in a reply
ErichK Offline
Junior Member

Posts: 2
Joined: Sep 2010
Reputation: 0
Post: #3
RE: Beginning Scripting, Requesting a [More thorough] Tutorial

Thanks! This helps a lot! But what snippet of code do I put in the callback function box for the entity in the editor? This one? :

void InteractedWithDoor(string &in entity)
09-22-2010 04:51 AM
Find all posts by this user Quote this message in a reply
jens Offline
Frictional Games

Posts: 4,095
Joined: Apr 2006
Reputation: 202
Post: #4
RE: Beginning Scripting, Requesting a [More thorough] Tutorial

None, this script is written so it does not use the level editor.

void InteractedWithDoor(string &in entity) is triggered by the line SetEntityPlayerInteractCallback("mansion_1", "InteractedWithDoor", true);

but

You can remove the line SetEntityPlayerInteractCallback("mansion_1", "InteractedWithDoor", true);

and then select the mansion_1 door in the editor, go to the entity tab, and there is an input named SetInteractCallback (or something like that) in which you would enter InteractedWithDoor to accomplish the same thing as the script line you removed.
09-22-2010 05:08 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)