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
Script Help Determine angle on object
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
Determine angle on object

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?

Derp.
07-03-2015, 02:00 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Determine angle on object

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

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

Trying is the first step to success.
07-03-2015, 02:07 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#3
RE: Determine angle on object

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

Derp.
07-03-2015, 02:15 PM
Find
Rahmerh Offline
Member

Posts: 66
Threads: 7
Joined: Jun 2015
Reputation: 3
#4
RE: Determine angle on object

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

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#5
RE: Determine angle on object

(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
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.

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.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
07-03-2015, 03:19 PM
Find
Rahmerh Offline
Member

Posts: 66
Threads: 7
Joined: Jun 2015
Reputation: 3
#6
RE: Determine angle on object

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.
(This post was last modified: 07-03-2015, 03:24 PM by Rahmerh.)
07-03-2015, 03:23 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#7
RE: Determine angle on object

(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.

Derp.
07-03-2015, 04:31 PM
Find
SwingsDarkCreeps Offline
Junior Member

Posts: 26
Threads: 3
Joined: Jun 2015
Reputation: 0
#8
RE: Determine angle on object

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:


.rar   LevelEditor the area.rar (Size: 224.25 KB / Downloads: 95)

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
(This post was last modified: 07-05-2015, 08:32 PM by SwingsDarkCreeps.)
07-05-2015, 08:11 PM
Find




Users browsing this thread: 1 Guest(s)