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.
Nye Offline
Senior Member

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

As for your first problem, regarding the callback being removed upon being run, when you declare the callback, for example:

AddEntityCollideCallback("Player", "needlantern", "lantern_warn", true, 1);

The boolean expression, 'true' in the above case is the answer to "Delete on collide?". Changing this to false will stop it deleting on collide. So, in your case, to allow the player to use the key more than once. I always find the 'Script Functions' page on the Wiki is handy

http://wiki.frictionalgames.com/hpl2/amn..._functions

So, if we use an entity collide callback, the syntax is
AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

If we wanted to allow two entities to collide and run the associated procedure more than once, we would change the boolean value 'bool abDeleteOnCollide' to false.

Regarding the key on the door, the syntax and your syntax for the using key on door callback is:
AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

Notice the 'boola abAutoDestroy'. We want this to be false, so that it doesn't remove the key each time. It's a little more complicated with items, since, you will then need to add another local variant check, when you run the procedure. For example:

void OnStart()
{
    AddUseItemCallback("", "shop_key", "cellar_wood01", "UsedKeyOnDoor", false);
}

void  UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    if (GetLocalVarInt("FireLit") != 1)
    {
        SetMessage("woodshop", "HandsTooCold", 0);
    }
      if (GetLocalVarInt("FireLit") == 1)
    {
          RemoveItem("shop_key");
          GiveSanityBoost();
          SetSwingDoorLocked("cellar_wood01", false, true);
          PlaySoundAtEntity.... etc etc
    }
}

Also, you can use an 'else' statement, to make it a bit quicker, as Pandemoneus says, but I find it is easier to understand what you were doing, using just if statements where possible.
--------------------------------------------------------------------
With your second script, try ensuring that you have
void OnLeave()
{

}
AND
void OnEnter()
{


}
in your script file somewhere, else it wont run.

(This post was last modified: 03-19-2011, 08:49 AM by Nye.)
03-19-2011, 08:47 AM
Find


Messages In This Thread
Fancy door + quest scripting. - by Streetboat - 03-18-2011, 07:47 PM
RE: Fancy door + quest scripting. - by Nye - 03-18-2011, 09:09 PM
RE: Fancy door + quest scripting. - by Streetboat - 03-18-2011, 09:45 PM
RE: Fancy door + quest scripting. - by Nye - 03-18-2011, 10:00 PM
RE: Fancy door + quest scripting. - by Streetboat - 03-18-2011, 10:27 PM
RE: Fancy door + quest scripting. - by Nye - 03-19-2011, 12:21 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-19-2011, 02:43 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-19-2011, 08:05 AM
RE: Fancy door + quest scripting. - by Nye - 03-19-2011, 08:47 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-19-2011, 09:11 AM
RE: Fancy door + quest scripting. - by Nye - 03-19-2011, 10:15 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-19-2011, 10:33 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-20-2011, 06:38 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-20-2011, 11:41 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-21-2011, 12:53 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-21-2011, 04:10 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-21-2011, 08:08 PM
RE: Fancy door + quest scripting. - by Streetboat - 03-21-2011, 09:57 PM
RE: Fancy door + quest scripting. - by Streetboat - 03-22-2011, 10:16 PM
RE: Fancy door + quest scripting. - by Streetboat - 03-23-2011, 01:59 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-23-2011, 02:26 AM
RE: Fancy door + quest scripting. - by Streetboat - 03-24-2011, 09:59 AM



Users browsing this thread: 3 Guest(s)