Frictional Games Forum (read-only)

Full Version: How to make things like crowbar and surgical needle.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering wat the code to make the crowbar usable on a door or something, just the the code for those general things like crowbar, needle, all that good stuffs.
It's called the AddUseItemCallback command function. Go ahead and search it in the script functions page.

To make a needle open a door is like making a key open a door.

Code:
void OnStart()
{
     AddUseItemCallback("needle_1", "DoorName", "Func01", false);
}
void Func01(string &in asItem, string &in asEntity)
{
     RemoveItem(asItem);
     SetSwingDoorLocked(asEntity, false, true);
     PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
}
(08-24-2011, 12:59 AM)Kyle Wrote: [ -> ]It's called the AddUseItemCallback command function. Go ahead and search it in the script functions page.

To make a needle open a door is like making a key open a door.

Code:
void OnStart()
{
     AddUseItemCallback("needle_1", "DoorName", "Func01", false);
}
void Func01(string &in asItem, string &in asEntity)
{
     RemoveItem(asItem);
     SetSwingDoorLocked(asEntity, false, true);
     PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
}

Would that be the same with a crowbar and everything? I understand basic scripting pretty good, but the more complicated stuff I have no clue, so, lol. Sad
Kyle, if you use crowbar like that, does it set crowbar automatically into that effect that you have to push it or script it Smile?
(08-24-2011, 01:14 AM)Elven Wrote: [ -> ]Kyle, if you use crowbar like that, does it set crowbar automatically into that effect that you have to push it or script it Smile?

That requires more scripting, if you ever looked "deep enough" into the script functions page where it talks about prop connection and rotation and movement. That's when you can make things move by themselves when doing some of that stuff. For the crowbar script, I looked into Amnesia's script files and saw that it used other types of crowbar objects like the item type and then the one that can be moved, and then the other one that is broken. I was able to get it working once, but I never really wanted to try it.

Crowbar Opening Door = Old

:/
Hell yes it is ^^. But if I would use crowbar on something, then not on opening door. On more puzzle way and stuff. That's why I asked Smile.
(08-24-2011, 01:21 AM)Kyle Wrote: [ -> ]Crowbar Opening Door = Old

:/

So true.
crowbar opening a door is old, but as long as you use it in an unusual / unexpected way, I have no problem with it. There are so many things you could do with items what HPL is capable of, you just need to learn your way around the model editor. Smile

For example, if you look through all of the entities, every single one can be turned into an item, which opens the possiblities for hundreds of unique puzzles! Also, anything can be turned into a lever, a wheel, or even a door! so you can increase interactivity greatly by simply turning for example an old broom into a makeshift lever or something...


For your question, it's simple.
1. when you interact with the puzzle, set a crowbar joint entity active
2. when the crowbar joint entity touches a set area - ie: it has bent too much - break the door Smile
Quote:For your question, it's simple.
1. when you interact with the puzzle, set a crowbar joint entity active
2. when the crowbar joint entity touches a set area - ie: it has bent too much - break the door Smile

Thanks! That answers my question Smile!!!