rj
2013-03-31 19:37:49
So I am trying to make a "MakeCompassNorth" for soulsplit, and I am basing this function off @DannyRS's function, here is what I have for MakeCompass:
Here is the meat:
And
I have made a DTM of the compass at perfect North but it still seems not to make the compass north(it does not turn it at all)
Any ideas?
EDIT: I have my own function to get it to work but it is off-set a little:
Procedure P07_MakeCompass(Direction :String);
Var
CurAngle: Integer;
Begin
If (Not SS_LoggedIn) Then
Exit;
case LowerCase(Direction) of
'North':
Begin
CurAngle:=P07_GetCompassAngle;
If CurAngle > 180 Then
P07_MakeCompassDegree(355)
Else
P07_MakeCompassDegree(5);
End;
'East':
Begin
P07_MakeCompassDegree(270);
End;
'West':
Begin
P07_MakeCompassDegree(90);
End;
'South':
Begin
P07_MakeCompassDegree(180);
End;
End;
End;Here is the meat:
Procedure P07_MakeCompassDegree(MakeAngle: Integer);
Var
WaitsDone,CurAngle,CurAngleR,CurAngleL,LeftDist,RightDist,StepsL,StepsR: Integer;
KeyToHold: Word;
Begin
//LOL At How Bad This Math Is, Meh Works - Danny
WaitsDone:=0;
KeyToHold:=37;
//If (Not SS_LoggedIn) Then
//Exit;
CurAngle:=P07_GetCompassAngle;
CurAngleR:=CurAngle+5;
If (CurAngleR>360) Then
CurAngleR:=CurAngleR-360;
CurAngleL:=CurAngle-5;
If (CurAngleL<0) Then
CurAngleL:=(360-(CurAngleL*-1));
If (MakeAngle < 5) Then
MakeAngle:=5;
If (MakeAngle > 355) Then
MakeAngle:=355;
If (MakeAngle < CurAngleR) And (MakeAngle > CurAngleL) Then
Exit;
StepsL:=0;
LeftDist:=CurAngle;
Repeat Begin
LeftDist:=LeftDist-1;
If (LeftDist<0) Then
LeftDist:=360;
StepsL:=StepsL+1;
End; Until (LeftDist=MakeAngle)
StepsR:=0;
RightDist:=CurAngle;
Repeat Begin
RightDist:=RightDist+1;
If (RightDist>360) Then
RightDist:=0;
StepsR:=StepsR+1;
End; Until (RightDist=MakeAngle)
If StepsL > StepsR Then
KeyToHold:=39;
KeyDown(KeyToHold);
Repeat Begin
WaitsDone:=WaitsDone+1;
CurAngle:=P07_GetCompassAngle;
CurAngleR:=CurAngle+10;
If (CurAngleR>360) Then
CurAngleR:=CurAngleR-360;
CurAngleL:=CurAngle-10;
If (CurAngleL<0) Then
CurAngleL:=(360-(CurAngleL*-1));
Wait(10);
End; Until ((MakeAngle < CurAngleR) And (MakeAngle > CurAngleL)) Or (WaitsDone>700)
wait(RandomRange(10,90));
KeyUp(KeyToHold);
End;And
Function P07_GetCompassAngle: Integer; {}
Var
X,Y: Integer; {}
AtAngle,AngleResult: Extended; {}
Begin
If FindDTMRotated(SS_CompassDTM,X,Y,SS_CompassX1,SS_CompassY1,SS_CompassX2,SS_CompassY2, 0, (2*Pi), Pi/180, AtAngle) Then
Begin
AngleResult:=Degrees(AtAngle);
End
Else
AngleResult:=0;
Result:=Round(AngleResult);
End; I have made a DTM of the compass at perfect North but it still seems not to make the compass north(it does not turn it at all)
Any ideas?
EDIT: I have my own function to get it to work but it is off-set a little:
Procedure SS_MakeCompassNorth;
Var
T,X,Y:Integer;
Begin
If Not FindDTM(SS_CompassDTM,X,Y,SS_CompassX1,SS_CompassY1,SS_CompassX2,SS_CompassY2) Then
Begin
MarkTime(T)
KeyDown(37);
Repeat
Wait(RandomRange(100,200));
Until (FindDTM(SS_CompassDTM,X,Y,SS_CompassX1,SS_CompassY1,SS_CompassX2,SS_CompassY2)=True) or (TimeFromMark(T) > 3000)
KeyUp(37);
End;
End;