SRL Archive - OSR Help

Facing Direction


VastlySuperior

2012-09-21 05:06:25

Is there anyway to determine in which direction you character is facing when performing a task or when coming to a stop?

Lets say there are 4 trees, I`m standing in the middle of them. I choose the one on the west to chop down but I was facing north, now My character is facing the tree to the west as that was the one I have chosen, I don`t want to find the direction by the object I have chosen, but rather by the way I`m currently facing.

Is there any way in which to do just that?

riwu

2012-09-21 05:27:25

rs_GetCompassAngleRadians?

VastlySuperior

2012-09-21 06:02:43

From: riwu
rs_GetCompassAngleRadians?


That Only works if your compass heading change, but if you are facing in a direction it does not give you a compass heading except the heading that the compass originally had to start with.

If you are standing still and face a new direction the compass does not change direction with you.

riwu

2012-09-21 07:02:01

Oh so you mean the direction your character is facing? You could possibly consider the differences in color pixels (hair, armor etc) when it is facing in different directions.

But that's not going to be reliable when you wear different armors.

masterBB

2012-09-21 07:51:13

The spot where you click to perform the task can be translated into a angle if you know the height of the object.

VastlySuperior

2012-09-21 09:22:30

From: masterBB
The spot where you click to perform the task can be translated into a angle if you know the height of the object.


How do you find the height masterBB?

Runaway

2012-09-21 12:37:40

I think Bart's referring to the z value of the camera. If you have your camera at the highest angle, it shouldn't matter much though. You can use a vector like this:


type
TRadial = record
Length: Integer;
Angle: Extended;
end;

function RadialFromPts(P1, P2: TPoint): TRadial;
begin
Result.Length := Round(Hypot(P2.x - P1.x, P2.y - P1.y));
Result.Angle := Degrees(FixRad((ArcTan2(P1.y - P2.y, P1.x - P2.x) + Radians(90)) - Pi));
end;

// Somewhere in your tree chopping proc:

//...
FindTree(x, y);
MMouse(x, y, 3, 3);
if WaitUptext('Chop', 500) then
begin
r := RadialFromPts(Point(MSCX, MSCY), Point(x, y));
Dir := Round(r.Angle);
ClickMouse2(mouse_left);
//Result := True;
//Break;
end;
//...

the var Dir should then give you a good approximation of what direction your character is facing.

VastlySuperior

2012-09-22 03:47:32

Thanks for the info, I will test it out over the weekend.