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
Help what is wrong in my script
EpicLisbe Offline
Junior Member

Posts: 13
Threads: 4
Joined: Dec 2011
Reputation: 0
#1
Help what is wrong in my script

So i am working on a customstory project and when i use key_1 it also unlocks the prisondoor can you help me?


void OnStart()
{
AddUseItemCallback("", "key_1", "monsterdoor_1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
AddEntityCollideCallback("Player", "Scriptarea_1", "func_bam", true, 1);
AddUseItemCallback("", "rust_1", "prisondoor_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("Player", "banish", "BanishFunction", true, 1);

}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("monsterdoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "monsterdoor_1", 0, false);
RemoveItem("key_1");


}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("servant_grunt_1", true);
ShowEnemyPlayerPosition("servant_grunt_1");
SetSwingDoorLocked("prisondoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prisondoor_1", 0, false);

}


void func_bam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("monsterdoor_1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}






void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", true);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_5", 0, "");

}
void BanishFunction(string &in asParent, string &in asChild, int alState)

{
SetEnemyDisabled("servant_grunt_2", true);
SetEntityActive("servant_grunt_2", false);
}

12-27-2011, 08:22 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Help what is wrong in my script

It doesn't unlock when you use the key, it unlocks when you pick up the key.

Tutorials: From Noob to Pro
12-27-2011, 09:28 PM
Website Find
EpicLisbe Offline
Junior Member

Posts: 13
Threads: 4
Joined: Dec 2011
Reputation: 0
#3
RE: Help what is wrong in my script

(12-27-2011, 09:28 PM)Your Computer Wrote: It doesn't unlock when you use the key, it unlocks when you pick up the key.
can you show me the right script because i am amateur scripter and i think its not unlocking when i pickup because the rust_1 is supposed to unlock prisondoor not key_1.
12-28-2011, 12:35 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Help what is wrong in my script

(12-28-2011, 12:35 AM)EpicLisbe Wrote: can you show me the right script because i am amateur scripter and i think its not unlocking when i pickup because the rust_1 is supposed to unlock prisondoor not key_1.

Well, this is what you did that makes picking up the key unlock the prisondoor:

You set a callback to "key_1" with SetEntityCallbackFunc in OnStart; the callback being OnPickup. SetEntityCallbackFunc calls the callback when interacting with the item specified. Therefore upon interacting with the key, in this case picking up the key, the callback, OnPickup, gets called.

If we look inside the OnPickup function, we see SetSwingDoorLocked("prisondoor_1", false, true). You passed in false for the second argument. This tells the game to unlock the door called "prisondoor_1". So, all the player has to do is interact with "key_1" in order to unlock the door "prisondoor_1".

The only way to correct your code is for you to understand what you are telling the game to do. This requires understanding of every function you are making use of, starting with OnStart. You can read the descriptions of most of the other functions used here: http://wiki.frictionalgames.com/hpl2/amn..._functions That should at least provide you with basic understanding of their use.

Tutorials: From Noob to Pro
12-28-2011, 01:02 AM
Website Find
EpicLisbe Offline
Junior Member

Posts: 13
Threads: 4
Joined: Dec 2011
Reputation: 0
#5
RE: Help what is wrong in my script

(12-28-2011, 01:02 AM)Your Computer Wrote:
(12-28-2011, 12:35 AM)EpicLisbe Wrote: can you show me the right script because i am amateur scripter and i think its not unlocking when i pickup because the rust_1 is supposed to unlock prisondoor not key_1.

Well, this is what you did that makes picking up the key unlock the prisondoor:

You set a callback to "key_1" with SetEntityCallbackFunc in OnStart; the callback being OnPickup. SetEntityCallbackFunc calls the callback when interacting with the item specified. Therefore upon interacting with the key, in this case picking up the key, the callback, OnPickup, gets called.

If we look inside the OnPickup function, we see SetSwingDoorLocked("prisondoor_1", false, true). You passed in false for the second argument. This tells the game to unlock the door called "prisondoor_1". So, all the player has to do is interact with "key_1" in order to unlock the door "prisondoor_1".

The only way to correct your code is for you to understand what you are telling the game to do. This requires understanding of every function you are making use of, starting with OnStart. You can read the descriptions of most of the other functions used here: http://wiki.frictionalgames.com/hpl2/amn..._functions That should at least provide you with basic understanding of their use.
TY SO MUCH. never tought it would be so easy! Shy


12-28-2011, 01:48 AM
Find
EpicLisbe Offline
Junior Member

Posts: 13
Threads: 4
Joined: Dec 2011
Reputation: 0
#6
RE: Help what is wrong in my script

Now i got my .lang file fail Blush can you tell me what is wrong in it <LANGUAGE>

<CATEGORY Name="Inventory">
<Entry Name="ItemName_key1">a scary key</Entry>
<Entry Name="ItemDesc_key1">nice key and you are supposed to use it to a door.</Entry>
<Entry Name="ItemName_Crowbar">A crowbar</Entry
<Entry Name="ItemName_Crowbar">You can use this to break a lock from a door.</Entry>

</CATEGORY>

<CATEGORY Name="Journal">
<Entry Name="Note_theletter_Name">Letter from unknown</Entry>
<Entry Name="Note_theletter_Text">Hello, Daniel.[br]You know you shouldn't mess up with my investigation[br]ps. you might have some hallucinations because of my potion.</Entry>
<Entry Name="Note_thewarning_name"> warning from unknown</Entry>
<Entry Name="Note_thewarning_Text">Hello again daniel.[br][br]You have reached my dungeons where i have done tests with human bodies. I recommend you to avoid the bodies because they might still be alive....</Entry>
<Entry Name="Note_thetest_Name">My test diary page.</Entry>
<Entry Name="Note_thetest_Text">It's 14th may 3:00 Pm.[br][br]I woke up to reality and i understood that i have to finish this and get back to home![br]Tomorrow i do final test if it fails.. well... then WE ALL DIE</Entry>

</CATEGORY>

</LANGUAGE>
12-30-2011, 11:05 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#7
RE: Help what is wrong in my script

You are missing a closing ">" on one of your entry tags. If you get lang file problems a good website to visit is:

http://www.w3schools.com/xml/xml_validator.asp

Fixed code:
http://pastebin.com/xX3HUtWR
12-30-2011, 03:27 PM
Find
EpicLisbe Offline
Junior Member

Posts: 13
Threads: 4
Joined: Dec 2011
Reputation: 0
#8
RE: Help what is wrong in my script

(12-30-2011, 03:27 PM)Apjjm Wrote: You are missing a closing ">" on one of your entry tags. If you get lang file problems a good website to visit is:

http://www.w3schools.com/xml/xml_validator.asp

Fixed code:
http://pastebin.com/xX3HUtWR
TY Shy


12-31-2011, 01:08 PM
Find




Users browsing this thread: 1 Guest(s)