Frictional Games Forum (read-only)
[SCRIPT] Determine angle on object - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Determine angle on object (/thread-30200.html)



Determine angle on object - Neelke - 07-03-2015

Basically, I was making a puzzle where you use a broken pipe to leverage open a portcullis door. My original idea was to update the door depending on where the pipe is with script areas. But is it possible with math calculation instead?


RE: Determine angle on object - FlawlessHappiness - 07-03-2015

I don't think you can GetRotation or something like that.

You'll have to use different script areas to determine it.


RE: Determine angle on object - Neelke - 07-03-2015

Alright, thanks for the heads up. Anyone else can share what they know if they wish.


RE: Determine angle on object - Rahmerh - 07-03-2015

You could make it a custom entity. Save it as a lever, and when you move it up, you can use
Code:
int GetLeverState(string& asName);
perhaps. I'm not sure if it's worth all the hassle, scriptareas are easier imo.


RE: Determine angle on object - Romulator - 07-03-2015

(07-03-2015, 02:40 PM)Rahmerh Wrote: You could make it a custom entity. Save it as a lever, and when you move it up, you can use
Code:
int GetLeverState(string& asName);
perhaps. I'm not sure if it's worth all the hassle, scriptareas are easier imo.

The problem is that GetLeverState(); only allows 3 possible outcomes.

Code:
1 - Up
0 - Middle
-1 - Down

You can use scriptareas though, just keep in mind it may be difficult to get it to respond to one particular scriptarea if it is colliding with 2 of them at the same time.


RE: Determine angle on object - Rahmerh - 07-03-2015

Oh I see. Not sure what it's supposed to do. Is it just going to call a function when it's at max or does it have to call functions every time it goes further?

(07-03-2015, 03:19 PM)Romulator Wrote: You can use scriptareas though, just keep in mind it may be difficult to get it to respond to one particular scriptarea if it is colliding with 2 of them at the same time.
That shouldn't be a problem when you make the script areas thin. Size shouldn't matter when it's definitely going through it.


RE: Determine angle on object - Neelke - 07-03-2015

(07-03-2015, 03:23 PM)Rahmerh Wrote: Oh I see. Not sure what it's supposed to do. Is it just going to call a function when it's at max or does it have to call functions every time it goes further?

(07-03-2015, 03:19 PM)Romulator Wrote: You can use scriptareas though, just keep in mind it may be difficult to get it to respond to one particular scriptarea if it is colliding with 2 of them at the same time.
That shouldn't be a problem when you make the script areas thin. Size shouldn't matter when it's definitely going through it.

Well I got working guys. Kinda sloppy and a little bit "Lol?" imo, but it works.


RE: Determine angle on object - SwingsDarkCreeps - 07-05-2015

Hello Smile, I think that the better way to do that is to use a lever(custom entity)-that when is attached at a mount(support) and the player move the lever in the right direction the result will be something like: unlock a door/ opens a way/unlock a gate for the next path. Using a ScriptArea is one of the easiest way in order to make the lever to attach at the specific mount (the lever is hidden somewhere "random" in the map).Here is my ScriptArea:

[attachment=5157]

That ScriptArea has an EntityCollideCallback function:

AddEntityCollideCallback("Handle", "ConnectTheLever", "AttachLeverToMount", true, 1);

And the rest sequence of the HPS file:

void AttachLeverToMount(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Lever_1", true);//So I place a compound(lever and the mount) -which I set them Inactive in the level editor

SetEntityActive(asParent, false);
SetEntityActive("Mount", false);
}

//the next part is for unlocking the door depending on the lever's state(position):
//so as Romulator said before the up state is marked with number 1 which i usedSmile
void UnlockDoor(string &in asEntity, int LeverState)
{
if(LeverState == 1) {
SetSwingDoorLocked("Mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Mansion_1", 0, false);
SetLeverStuckState(asEntity, LeverState, true);//this locks the lever in the position in which the player move it
}
}

it worksBig Grin