Frictional Games Forum (read-only)

Full Version: Lever opening bookshelf?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I'm working on my first custom story mod. It's more of a practice thing for myself, because I'm just learning scripting for HPL2 and want to understand all the mechanics I can before going into my big project idea.

I've got a hunk of code to fix. I'm trying to make a lever move a bookshelf.

Code:
void OnStart()
{
    SetEntityConnectionStateChangeCallback("lever_1, "PullLever");
}

void PullLever(string &in asEntity, int alState)
{
    if (alState == 1)
    {
    AddBodyForce("secret_shelf_1", 0, 0, -3, "world");
    }
}

Can someone tell me exactly what's up? Should I be using AddBodyForce, AddBodyImpulse, AddPropForce, or AddPropImpulse? And what's the difference? Remember, I'm brand-spanking-new to this. Mostly. I have also made a readable note and an unlock-able door.
I would suggest looking at 01_old_archives in the original Amnesia maps. They have a secret bookshelf there and that code is short and simple Smile
(04-27-2012, 11:45 PM)SilentStriker Wrote: [ -> ]I would suggest looking at 01_old_archives in the original Amnesia maps. They have a secret bookshelf there and that code is short and simple Smile
:O
It never occurred to me all the original code is right there in the Amnesia folders! I thought it was magically compiled and stuffed into a secret suitcase or something.
This job is now about 600x easier, thank you
Frictional Games used two general ways of moving the shelves in the game(s).
The first secret door was moved through a direct ConnectEntities() connection made between the state of the bookshelf, and the state of the lever.
The other two were moved through SetMoveObjectState().

I think I understand, but I don't want the shelf to rotate open; I want it to slide open along the z-axis.

This is more in the Level Editor category, but how do I set something like that up?
(04-28-2012, 01:43 PM)Biscuitbarrel Wrote: [ -> ]I think I understand, but I don't want the shelf to rotate open; I want it to slide open along the z-axis.

This is more in the Level Editor category, but how do I set something like that up?
If by "z-axis" you mean "sideways", then simply use the "shelf_secret_door" entity. It normally slides to the left, but it's easy to rig it to slide to the right by reversing its states.

In Level Editor or otherwise, how do I tell the game where I want the shelf to go? Just saying its state is "1" isn't going to mean anything by itself.

(on a related note, I'd like to complain about how unhelpful the "tutorials" at the wiki are...are there any other resources I can use for info on making Amnesia stories? May I ask where you picked your knowledge up?)
If a move object's state's amount to 1 for open and 0 for closed, then setting its state to 1 will absolutely open it. As Cranky suggested, check out how Frictional did it in Amnesia. You have their objects, look at how they use them. The direction and amount to move will be set in the model editor, try opening up the object in the model editor and play with the settings to find a something that works for you. Alternatively, just follow Cranky's advice and set it's state to the opposite of whatever state moves it left (if 1 opens it left, set it to -1 and see what happens)

As great as the tutorials are, they are not sufficient for learning 'scripting' in general. People who can work this stuff out for themselves usually have scripting or programming experience outside of HPL2. Keep in mind those tutorials are made by people who are writing or recording a tutorial purely for the benefit of the community. They often assume knowledge on the part of the audiance, because to write every tutorial for someone who has no concept of scripting would be an enormous waste of time. Better you learn from tutorials that cover the basics, then move on to HPL2 tutorials demonstrating more advanced ways of doing things specific to HPL2 scripting.
(05-10-2012, 11:05 PM)Biscuitbarrel Wrote: [ -> ]are there any other resources I can use for info on making Amnesia stories? May I ask where you picked your knowledge up?)
The YouTube series "From Noob to Pro" helped at first, and from there I picked apart a lot of Amnesia maps. You will need an intelligent and scientific mind too, or else you'll never make sense of any kind of programming.
There is an Tut on dev wiki how to follow that one Smile