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
Questions from beginner
Finska Offline
Member

Posts: 102
Threads: 6
Joined: Jun 2011
Reputation: 0
#1
Questions from beginner

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.

Creeps, creeps everywhere...
(This post was last modified: 06-14-2011, 12:47 PM by Finska.)
06-14-2011, 11:53 AM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#2
RE: Questions from beginner

First off, you'll need this for scripting.

http://wiki.frictionalgames.com/hpl2/amn..._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:

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.

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.

(This post was last modified: 06-14-2011, 12:22 PM by Russ Money.)
06-14-2011, 12:20 PM
Find
Finska Offline
Member

Posts: 102
Threads: 6
Joined: Jun 2011
Reputation: 0
#3
RE: Questions from beginner

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

Creeps, creeps everywhere...
06-14-2011, 12:30 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#4
RE: Questions from beginner

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

06-14-2011, 12:31 PM
Find
Finska Offline
Member

Posts: 102
Threads: 6
Joined: Jun 2011
Reputation: 0
#5
RE: Questions from beginner

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

Creeps, creeps everywhere...
06-14-2011, 12:36 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#6
RE: Questions from beginner

(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.

06-14-2011, 12:38 PM
Find
Finska Offline
Member

Posts: 102
Threads: 6
Joined: Jun 2011
Reputation: 0
#7
RE: Questions from beginner

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?

Creeps, creeps everywhere...
(This post was last modified: 06-14-2011, 12:47 PM by Finska.)
06-14-2011, 12:44 PM
Find
laser50 Offline
Member

Posts: 242
Threads: 22
Joined: Apr 2011
Reputation: 0
#8
RE: Questions from beginner

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

Current Project: [WIP] Lost Memories
Progress: 15%
CLICK FOR MY MODDB PAGE
06-14-2011, 12:51 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#9
RE: Questions from beginner

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.



06-14-2011, 01:02 PM
Find
Finska Offline
Member

Posts: 102
Threads: 6
Joined: Jun 2011
Reputation: 0
#10
RE: Questions from beginner

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?

Creeps, creeps everywhere...
(This post was last modified: 06-14-2011, 01:07 PM by Finska.)
06-14-2011, 01:05 PM
Find




Users browsing this thread: 1 Guest(s)