Frictional Games Forum (read-only)
Need help with scripts - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Need help with scripts (/thread-9828.html)

Pages: 1 2


Need help with scripts - NumsefisK - 08-17-2011

Hey. I'm new to modding/making custom maps and I was wondering how you make a key match a door and I'm also trying to make the monster spawn when you pick up the key. And when the monster enters the room and checks it, how can I make him walk out after a while and despawn? Does the monster make the sound itself, or do i have to find the sound file too?

And how do you make a note that can be picked up and read by the player?

I heard theres something that has to be done in the .hps file, but isn't there something in Callback in the level editor too?

Edit: typos


RE: Need help with scripts - palistov - 08-17-2011

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

Peruse this thread, it should answer all of your questions Smile


RE: Need help with scripts - JetlinerX - 08-17-2011

To make keys, use this:
void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

asName - (Leave this as "" all the time)
asItem - (Name of the item)
asEntity - (Name of the door to use on)
asFunction - (Name of what to do when you use the key)
abAutoDestroy - determines whether the item is destroyed when used

EXAMPLE:
AddUseItemCallback("", "YourKey", "YourDoor", "UsedKeyOnDoor", true);
**ONLY CHANGE "YourKey" to the name of your key, and only change "YourDoor" to the name of the door.**

To make a monster spawn when you pick up an item, place the monster with the level editor, and make it "inactive." Then use this script:

{
SetEntityCallbackFunc("Name_of_item", "OnPickup");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("Name_of_monster", true);
}

Just change Name of Item, and Name of Monster above, to the names that they are in the level editor. You will need to program Nodes for the monster to walk around, and thats something I have yet to learn.

Notes:
Just place a note in the editor, NOTE: IT MUST SAY "note" in the start. Example: "note_paper" so that it is able to be picked up. And then name it what ever you like.

Then the rest is in the Extra_eng.lang file. Use this:

<Entry Name="NAME_OF_YOUR_NOTE">This is the title of the note</Entry>
<Entry Name="NAME_OF_YOUR_NOTE">Everything here is what the note will say.</Entry>

Ask any questions! Big Grin


RE: Need help with scripts - NumsefisK - 08-17-2011

Nothing I've done seems to work.

I'll put in my .hps and .lang file below.

Quote:////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "Bedroom_Key", "Bedroom_Door", "UsedKeyOnDoor", true);
}

{
SetEntityCallbackFunc("Name_of_item", "OnPickup");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("grunt_01", true);
}
///////////////////////////////////
//Run when entering map
void OnEnter()
{

}


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

}

The monster doesn't seem to spawn, and the key doesn't work with the door, nor does the key have any name or text attached to it in-game.

Quote:<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You wake up an unknown castle you must escape quickly before darkness will kill you!</Entry>
</CATEGORY>
<CATEGORY Name="Journal">

<Entry Name="Note_diary_1">Diary Entry 1</Entry>
<Entry Name="Note_diary_1_Text">I sometimes wake up in the middle of the night, because of the noises coming from the closet, but as I wake up, they suddenly dissapear. I think I'm going to have to leave this place soon...</Entry>
</CATEGORY>
<CATEGORY>
<Entry Name ="Inventory"
<Entry Name="ItemDesc_Bedroom_Key">The Key to the Bedroom"</Entry>
<Entry Name="ItemDesc_Bedroom_Key">Bedroom Key"</Entry>
</CATEGORY>
</LANGUAGE>

The note does not have any name it is just a blank piece of paper when i pick it up in-game.

I saw someone else put the key thing in the .lang file too, but I'm a little confused now.



RE: Need help with scripts - JetlinerX - 08-17-2011

make sure you add the same key name in the other tab of the level editor. I think its subitemname for something?


RE: Need help with scripts - NumsefisK - 08-17-2011

Yes, I have actually done that, it is in CustomSubItemTypeName.


RE: Need help with scripts - JetlinerX - 08-17-2011

Then hit "Enter" after you type it in?
You also have 2 "Desc" in your Extra Eng so thats why the key isnt working.


RE: Need help with scripts - NumsefisK - 08-17-2011

(08-17-2011, 09:36 PM)JetlinerX Wrote: Then hit "Enter" after you type it in?
You also have 2 "Desc" in your Extra Eng so thats why the key isnt working.

Oops, i didn't hit Enter, i feel like a dork right now.


RE: Need help with scripts - JetlinerX - 08-17-2011

Thats alright, I have done that a lot. Also, to fix your Extra Eng, use this:

Code:
<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You wake up an unknown castle you must escape quickly before darkness will kill you!</Entry>
</CATEGORY>
<CATEGORY Name="Journal">
<Entry Name="Note_diary_1_Name">Diary Entry 1</Entry>
<Entry Name="Note_diary_1_Text">I sometimes wake up in the middle of the night, because of the noises coming from the closet, but as I wake up, they suddenly disappear. I think I'm going to have to leave this place soon...</Entry>
</CATEGORY>
<CATEGORY>
<Entry Name ="Inventory"
<Entry Name="ItemName_Bedroom_Key">Bedroom Key</Entry>  
<Entry Name="ItemDesc_Bedroom_Key">The Key to the Bedroom</Entry>
</CATEGORY>
</LANGUAGE>

Let me know if that worked Wink


RE: Need help with scripts - Your Computer - 08-17-2011

You might want to fix the following syntax issue:
Code:
<Entry Name ="Inventory"