Frictional Games Forum (read-only)

Full Version: I Just Don't Understand
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm wondering if someone could make a small room with a door that opens when you walk into a the corner. And then send a download link.
Feel free to add anything else you feel would be beneficial to learning.
just make sure you state what you've done.

I've tried to figure this out, but i've have no luck. So im hoping i might be able to understand by see how its done.

Thanks!
Make a script area in the corner, write the function*:
Code:
void  AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

For "asFunction" part, write a new function like:
Code:
void ThisIsAFunction()
{
      open the door, add a force or something like that.
}

For good examples, open the main games's hps files, in the maps folder.

*http://wiki.frictionalgames.com/hpl2/amnesia/script_functions
I've looked at the main games scripting, but it kind of over whelming. that why I'd like to see a map and scripting for that map.
It can be very overwhelming if you have no experience with things like this. Trial and error is probably the best way to learn. Smile

Although, we can still help you though. In short, this is what you do:

1. You place an area-script in your map. This doesn't do anything yet, because there's no script linked to it. Give this entity a clear name, since you will use it to make it do something in the script.

2. You should have a script file linked with your map (same folder as your map, MapName.hps, with default stuff in it. See wiki).

3. In AtStart(), place
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

in between those curly parenthesis. This will make your script aware there's an area that will be triggered once you move into it.
Now, note that what you see above is a general method. To make it work for you, you need to FILL IN what you have. It's good to know what it all means:
asParentName, here you fill in WHAT will trigger the area, in the form of a STRING (because of the 's' in front of ParentName). so, for example: "Player" (for a string, you always put "").
asChildName, is the name of your area in the level editor; again as a STRING, so "".
Now, the next one is very important as well, it is the name of the function that will be called when you trigger the area (you could see it as: Where do I jump to in the script; what scripts do I run when the player enters the area). Name this something logically and related to what happens, you don't HAVE to do this, but it helps if you're getting more and more lines to quickly find it back and know what it is.
And so on..

4. Make a new function with the name of asFunction, which you filled in in AddEntityCollideCallback();

For example:

Code:
void CollideTriggerSound(string &in asParent, string &in asChild, int alState)
{
    ...
}


In my case, the function is named "CollideTriggerSound", since it will trigger a sound once the player collides with the area. Note that the name could have been picked even better: where is it triggered, ..?

In this case, you leave: string &in asParent, string &in asChild, int alState
Those are called parameters, and they get a value assigned when you call the function. Which you do when you trigger the area, and it gets the values that you've put in AddEntityCollideCallback().

5. Put in this function what you want to happen when you trigger the area.

6. All done. Smile
My advice - spend a day recreating the examples from tutorials, it is really worth it.
Success!!!

Just one thing tho, the door doesn't really open. It twitches open a little. I've played with the forces and this is what I got.

AddPropForce("door1", 0.0f, 0.0f, 150.0f, "local");
150 is by far not enough. Try a ten- or hundredfold.
Tried different values but the door still just twitches open a little then closes.
Check in the level editor if you're going along the proper axis.
As far as I know, all doors will open along the Z-axis when "Local" is used, yet two possible directions remain. So try negative values, too.

Also, make sure to unlock the door and apply the necessary magic before you "force" it open:
Code:
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
SetSwingDoorDisableAutoClose("door1", true);
Pages: 1 2