Frictional Games Forum (read-only)
Questions from beginner - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Questions from beginner (/thread-8598.html)

Pages: 1 2


Questions from beginner - Finska - 06-14-2011

Hello! I started practicing storymaking yesterday and I already know the common things, but I'm new with the events etc.
Well, I'm trying to make a practice story, short and simple. I'm not going to put any events and monsters or that kind of thing, I just need help with items.

1) I've put a crowbar on the bed and I was thinking, is it possible to make the crowbar to open the closet? If it is, how?

2) I know how to lock a door, but how to make a key to open the door?

3) How to make crates that are locked and a key make them unlock?

And I didn't find the solutions even I did try to look for them. Maybe I'm blind or stupid, but I really need some help.


RE: Questions from beginner - Russ Money - 06-14-2011

First off, you'll need this for scripting.

http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

To make the crowbar joint, you'll need to add it to your map. Wedge it in the door to make it look as you want, then in the entity tab, uncheck the active box.

You can do this with chests, making them locked as well.

Now you just need to make the script, I'll assume you know how to set up the text file to read it for the map.

Under OnStart, set up the function for your crowbar, so when the player uses the crowbar on the door, it is taken away from their inventory and the joint is activated. Once the joint reaches the point you want it to break, unlock the door.

Should look like this:

Code:
void OnStart()
{
AddUseItemCallback("crowbar", "crowbar", "door", "AttatchCrowbar", true);
}

void AttatchCrowbar(string &in asItem, string &in asEntity)
{
SetEntityActive("crowbar_joint", true);
RemoveItem(asItem);
}

Now to set it so the door breaks open, make a small area that when the crowbar is bent, it'll collide with an area. Add it to your OnStart, also add the callback to unlock the door. Also, remove the crowbar joint so it's not just floating there.

Code:
void OnStart()
{
AddUseItemCallback("crowbar", "crowbar", "door", "AttatchCrowbar", true);
AddEntityCollideCallback("crowbar_joint", "AreaOpenDoor", "OpenDoor", true, 1);
}

void AttatchCrowbar(string &in asItem, string &in asEntity)
{
SetEntityActive("crowbar_joint", true);
RemoveItem(asItem);
}

void OpenDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("crowbar_joint", false);
void SetSwingDoorLocked("door", false, false);
}


You will use the same callback when using a key to unlock a door, or anything for that matter. Just add an AddUseItemCallback for your script and make it so the key unlocks whatever it's unlocking.


Let me know if this makes sense to you or not.



RE: Questions from beginner - Finska - 06-14-2011

Actually, I do not know, how to set up the text file...


RE: Questions from beginner - Russ Money - 06-14-2011

Simple enough, in your maps folders, open a new text file. Save As "YOURMAPNAME.hps" Open that and just start scripting!


RE: Questions from beginner - Finska - 06-14-2011

Hohoo, derp Big Grin Simple enough, indeed. Thanks, I'll try your solutions right now.


RE: Questions from beginner - Russ Money - 06-14-2011

(06-14-2011, 12:36 PM)Finska Wrote: Hohoo, derp Big Grin Simple enough, indeed. Thanks, I'll try your solutions right now.

You will have to change the names of the stuff in the "parentheses" to match the names of the things in your map.


RE: Questions from beginner - Finska - 06-14-2011

Hmm, doesn't work. I changed all the names and used the crowbar to the closet, but nothing happened :O
Edit: Woops, I accidentally wrote "door". I meant, is it possible to open the closet with crowbar?


RE: Questions from beginner - laser50 - 06-14-2011

It is possible as far as i know. Just change it to the closet. And see what happens.


RE: Questions from beginner - Russ Money - 06-14-2011

Oh, for props that are not doors. You'll need a different function than

SetSwingDoorLocked("door", false, false);
Also, I messed up, remove the void in front of the command.

I think for chests/closets it might be
SetPropObjectStuckState("closet", 0);

Or

BreakJoint ("closet");
but this will break the joint, making the doors removed, haha.





RE: Questions from beginner - Finska - 06-14-2011

Do I remove all the voids? Or the first one? I tried both, but no change...
Edit: OK, so... I have this code:
Quote:void OnStart()
{
AddUseItemCallback("crowbar_1", "crowbar_1", "door_1", "AttatchCrowbar", true);
AddEntityCollideCallback("crowbar_joint", "AreaOpenDoor", "OpenDoor", true, 1);
}

void AttatchCrowbar(string &in asItem, string &in asEntity)
{
SetEntityActive("crowbar_joint", true);
RemoveItem(asItem);
}

void OpenDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("crowbar_joint", false);
SetSwingDoorLocked("door_1", false, false);
}
Crowbar is activated and crowbar_joint isn't. Door is named door_1... Doesn't work?