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
I Just Don't Understand
Crunchygoblin Offline
Junior Member

Posts: 15
Threads: 7
Joined: Jan 2011
Reputation: 0
#1
I Just Don't Understand

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!
01-15-2011, 11:30 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: I Just Don't Understand

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

For "asFunction" part, write a new function like:
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

(This post was last modified: 01-16-2011, 03:35 AM by Tanshaydar.)
01-16-2011, 03:34 AM
Website Find
Crunchygoblin Offline
Junior Member

Posts: 15
Threads: 7
Joined: Jan 2011
Reputation: 0
#3
RE: I Just Don't Understand

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.
01-16-2011, 12:11 PM
Find
Tottel Offline
Senior Member

Posts: 307
Threads: 9
Joined: Nov 2010
Reputation: 0
#4
RE: I Just Don't Understand

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:

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
(This post was last modified: 01-16-2011, 12:29 PM by Tottel.)
01-16-2011, 12:29 PM
Find
Makiavel Offline
Junior Member

Posts: 13
Threads: 2
Joined: Jan 2011
Reputation: 0
#5
RE: I Just Don't Understand

My advice - spend a day recreating the examples from tutorials, it is really worth it.

Silentium est argentum.
01-16-2011, 09:33 PM
Find
Crunchygoblin Offline
Junior Member

Posts: 15
Threads: 7
Joined: Jan 2011
Reputation: 0
#6
RE: I Just Don't Understand

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");
01-17-2011, 09:19 AM
Find
Andross Offline
Junior Member

Posts: 38
Threads: 1
Joined: Oct 2010
Reputation: 0
#7
RE: I Just Don't Understand

150 is by far not enough. Try a ten- or hundredfold.
01-17-2011, 10:20 AM
Find
Crunchygoblin Offline
Junior Member

Posts: 15
Threads: 7
Joined: Jan 2011
Reputation: 0
#8
RE: I Just Don't Understand

Tried different values but the door still just twitches open a little then closes.
01-17-2011, 09:38 PM
Find
Tottel Offline
Senior Member

Posts: 307
Threads: 9
Joined: Nov 2010
Reputation: 0
#9
RE: I Just Don't Understand

Check in the level editor if you're going along the proper axis.
01-17-2011, 09:50 PM
Find
Andross Offline
Junior Member

Posts: 38
Threads: 1
Joined: Oct 2010
Reputation: 0
#10
RE: I Just Don't Understand

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:
SetSwingDoorLocked("door1", false, false);
SetSwingDoorClosed("door1", false, false);
SetSwingDoorDisableAutoClose("door1", true);
01-18-2011, 11:21 PM
Find




Users browsing this thread: 1 Guest(s)