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
Keys and Doors
tehwhynot Offline
Junior Member

Posts: 4
Threads: 1
Joined: Oct 2012
Reputation: 0
#1
Keys and Doors

Hello here is the thing, i want to have some keys to open some doors but i dont know how to make a script for, I dont know, 10 doors or something.If you guys can help i apreciated.

Smile
(This post was last modified: 10-14-2012, 12:29 PM by tehwhynot.)
10-14-2012, 12:28 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#2
RE: Keys and Doors

Don't even think of having 10 keys in one map, it kills the gameplay.
But i could still help you out just so you can understand the script. Tell me what you already know.
Can you open one door with a key or do you want the learn the whole script?

[Image: 18694.png]
10-14-2012, 12:33 PM
Find
tehwhynot Offline
Junior Member

Posts: 4
Threads: 1
Joined: Oct 2012
Reputation: 0
#3
RE: Keys and Doors

Yeah i watch a tutorial on how to use a key to open a door and this is the script:

////////////////////////////
//Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_1");
}


I tried to copy everything exept run first time and voidOnstart and I got a ERROR.
Help me pls
10-14-2012, 12:36 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#4
RE: Keys and Doors

So basically what you did was copy UsedKeyOnDoor.
This caused the script to have the same function 2 times, with the same name.
When you use the key on the door the script doesn't know which function to execute, which causes the error. But even if the script would work, it would open the same door with the same key all the time.
So what you have to do is:
////////////////////////////
//Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "mansion_1", "UsedKeyOnDoor1", true);
AddUseItemCallback("", "key_2", "mansion_2", "UsedKeyOnDoor2", true);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_1");
}


void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_2");
}
Now you have to create 2 keys, one called key_1 and the other key_2.
Create 2 mansion doors, called mansion_1 and mansion_2.
With key_1 you can open mansion_1 and with key_2 mansion_2.
Important: It has to be key_1 and not Key_1!
C++ is case-sensitive.

[Image: 18694.png]
(This post was last modified: 10-14-2012, 12:57 PM by Ongka.)
10-14-2012, 12:56 PM
Find
tehwhynot Offline
Junior Member

Posts: 4
Threads: 1
Joined: Oct 2012
Reputation: 0
#5
RE: Keys and Doors

Man you are the best now i can finally make my custom story and i have anhoter question how can i add a description and a name to a key?
10-14-2012, 01:01 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#6
RE: Keys and Doors

This should be useful for you:

http://wiki.frictionalgames.com/hpl2/tut...or?s[]=key

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-14-2012, 01:11 PM
Find
tehwhynot Offline
Junior Member

Posts: 4
Threads: 1
Joined: Oct 2012
Reputation: 0
#7
RE: Keys and Doors

yeah i watch that but it didnt explain how to make for more doors and didnt show how to describe and name the keys.
And i want to describe and name the key.
10-14-2012, 01:13 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#8
RE: Keys and Doors

Open your custom story folder, create a textfile called extra_english.lang and open it with a text editor.
Now insert this code:
<LANGUAGE>
<CATEGORY Name="Inventory">
    <Entry Name="ItemDesc_key_1">This key opens mansion_1</Entry>
    <Entry Name="ItemName_key_1">Key number one</Entry>
    <Entry Name="ItemDesc_key_2">This key opens mansion_2</Entry>
    <Entry Name="ItemName_key_2">Key number two</Entry>
</CATEGORY>
</LANGUAGE>
And change the description how you like.

[Image: 18694.png]
10-14-2012, 02:31 PM
Find




Users browsing this thread: 1 Guest(s)