PDA

View Full Version : N1ke!'s Function corner!



Naike
05-01-2008, 02:05 PM
Welcome to N1ke!'s Function corner!

Here i will post all my functions useless or not they all be here!.

SafeRadial
{************************************************* ************************************************
Function SafeRadial(Color: Integer; MaxStartRadial, MaxEndRadial: Integer; Radius: Integer): Boolean;
By: N1ke!
Description: Starts searching between MaxStartRadial & MaxEndRadial then
adds a 5 every time it fails until its more then MaxStartRadial & MaxEndRadial.
************************************************** ***********************************************}
Function SafeRadial(Color: Integer; MaxStartRadial, MaxEndRadial: Integer; Radius: Integer): Boolean;
Var
MSR, MER: Integer;
begin
If(Not(LoggedIn))Then Exit;
MSR := MaxStartRadial + MaxEndRadial / 2;
MER := MSR - 1;
Repeat
If RadialWalk(Color, MSR, MER, Radius, 0, 0)then Result := True;
If Result = True then
Begin
Writeln('Found Color with :');
Writeln('StartRadial = ' + IntToStr(MSR));
Writeln('EndRadial = ' + IntToStr(MER));
Exit;
end;
MSR := MSR - 5;
MER := MER + 5;
Until(MSR < MaxStartRadial)or(MER > MaxEndRadial);
Writeln('SafeRadial failed!');
Result := false;
End;

Can be used like this SafeRadial(FindRoadColor, 90, 270, 60)


__________________________________________________ __________________________________________________ __________________________________________________ _


GetAngle
{************************************************* ************************************************
Function GetAngle(GetAngleFrom : Boolean): Integer;
By: N1ke!
Description: Gets the minimap angle. True = Clockwise , False = Not Clockwise
************************************************** ***********************************************}
Function GetAngle(GetAngleFrom : boolean): Integer;
Var Angle : extended;
Begin
If(Not(LoggedIn))Then Exit;
Angle := (rs_GetCompassAngleDegrees);
If GetAngleFrom = True then Angle := 360 - Angle;
Result := Round(Angle);
End;
Can be used like this
GetAngle(True)

__________________________________________________ __________________________________________________ __________________________________________________ _



SafeAngleRadial

Needs GetAngle!
{************************************************* ************************************************
Function SafeAngleRadial(Color: Integer; MaxStartRadial, MaxEndRadial: Integer; Radius: Integer): Boolean;
By: N1ke!
Description: Starts searching between MaxStartRadial & MaxEndRadial then
adds a 5 every time it fails until its more then MaxStartRadial & MaxEndRadial.
Will work if your minimap is South, west, east etc..
************************************************** ***********************************************}
Function SafeAngleRadial(Color: Integer; MaxStartRadial, MaxEndRadial: Integer; Radius: Integer): Boolean;
Var
MSR, MER, Angle: Integer;
begin
If(Not(LoggedIn))Then Exit;
Angle := GetAngle(True);
MSR := MaxStartRadial + MaxEndRadial / 2 - Angle;
MER := MSR - 1 - Angle;
If MSR < 0 then
begin
MSR := MSR + 360;
MER := MER + 360;
end;
If MSR > 360 then
begin
MaxStartRadial := MaxStartRadial + 360;
MaxEndRadial := MaxEndRadial + 360;
End;
Repeat
If RadialWalk(Color, MSR, MER, Radius, 0, 0)then Result := True;
If Result = True then
Begin
Writeln('Found Color with :');
Writeln('StartRadial = ' + IntToStr(MSR));
Writeln('EndRadial = ' + IntToStr(MER));
Writeln('Angle = ' + IntToStr(Angle));
Exit;
end;
MSR := MSR - 5;
MER := MER + 5;
Until(MSR < MaxStartRadial)or(MER > MaxEndRadial);
Writeln('SafeRadial failed!');
Result := False;
End;


How to use SafeAngleRadial
Lets say you made a walking script, Edgeville to fallador.
When using Radialwalk your minimap needs to be North most of the time. With SafeAngleRadial you can walk without even care if the minimap is east or west etc.. Let me show you!

If SafeAngleRadial(RoadColor, 20, 90, 60) then Blabla
I made that when my minimap was set to North.
Then my minimap goes east for some reason.
SafeAngleRadial will still walk to the right location!.





More to come!

Naike
05-01-2008, 02:06 PM
Reserved.

EvilChicken!
05-01-2008, 07:45 PM
Nice function, really creative. Keep them coming!

(By the way, you should just edit more functions into first post of this thread instead of reserving posts.)

Naike
05-02-2008, 10:39 AM
2 new function added!

GetAngle & SafeAngleRadial