pascal Code:
--- C:/Remake/Scripts/Something Fighter 0.25.simba vr jun 4 13:59:30 2010
+++ C:/Remake/Scripts/Something Fighter 0.26.simba vr jun 4 14:02:14 2010
@@ -6,9 +6,11 @@
Const
LogoutTime = 16;//Play for this many mins then switch/logout
- PickUpWhileFighting = false;//
+ PickUpWhileFighting = false;// Pick up during fight?
+ CheckHPWhileFighting = false; //Check (and heal) during fight?
KillAccuracy = 0.7;//How accurately after attacking it kills it [1.0 = perfect, 0.1 = 1/10th the time]
+
procedure DeclarePlayers;
begin
HowManyPlayers := 1;//Change this accordingly
@@ -46,7 +48,7 @@
PickupNames: array of string;
NPCTol, PickupTol: integer;
end;
- TInvItem = Record
+ TInvItem2 = Record
OutLine, Width, Height, Color: Integer;
end;
@@ -54,21 +56,29 @@
Playas: array [0..99] of TPlaya;
ReportTime: integer;
LeftClickFail: Boolean;//if the Left click fails attacking
- BonesTPA: TInvItem;
+ BonesTPA: TInvItem2;
procedure Debug(S: String);
begin
if DebugOn then
- Writeln(S);
+ Writeln(S)
+ else
+ DebugLn(s);
end;
-Function nInFight: Boolean;//In case someone wants to customize, this is a key function
+function nInFight: Boolean;//In case someone wants to customize, this is a key function
begin
Result := InFight;
end;
-function InvItem(cOutLine, cWidth, cHeight, cColor: Integer): TInvItem;
+procedure nFlag; //In case someone wants to customize the FFlag(0) function
begin
+ FFlag(0);
+end;
+
+
+function InvItem(cOutLine, cWidth, cHeight, cColor: Integer): TInvItem2;
+begin
with Result do
begin
OutLine := cOutLine;
@@ -78,7 +88,7 @@
end;
end;
-function FindInvItem(Item: TInvItem; B: TBox): Boolean;
+function FindInvItem(Item: TInvItem2; B: TBox): Boolean;
var
TPA: TPointArray;
Bt: TBox;
@@ -146,8 +156,13 @@
begin
Mouse(x,y,0,0,false);
if WaitOption('Eat', 400) then
- if (HPPercent > 50) then
+ begin
+ t := GetSystemTime;
+ while ExistsItem(i) and ((GetSystemTime-t) < 2000) do
+ wait(20);
+ if (HPPercent > 60) then
Exit;
+ end;
end;
end;
if (not LoggedIn) or (HPPercent > 50) then
@@ -289,7 +304,7 @@
Function BuryBones: Boolean;
var
- i, x, y: integer;
+ i, x, y,t: integer;
begin
for i := 1 to 28 do
begin
@@ -300,7 +315,15 @@
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
- Wait(900+random(300));
+ wait(900+random(300));
+ t := GetSystemTime;
+ while ExistsItem(i) and ((GetSystemTime-t) < 250) do
+ wait(75 + random(50));
+ if (GetSystemTime - t) >= 250 then //We cannot bury at this place..
+ begin
+ Result := false;
+ Exit;
+ end;
Inc(Players[CurrentPlayer].Integers[12]);
Result := true;
end;
@@ -338,24 +361,19 @@
0..1: begin
Mouse(T.x, T.y, 0, 0, true);
Result := DidClick(True, 100);
- if Result then
- LeftClickFail := false
- else
- LeftClickFail := true;
end;
2: begin
Mouse(T.x, T.y, 0, 0, false);
Result := ChooseOption('ttack');
- if Result then
- LeftClickFail := false;
end;
end;
+ LeftClickFail := not result;
if Result then
begin
Debug('Attack!');
- FFlag(0);
+ nFlag;
Exit;
- end Else Continue;
+ end else Continue;
end;
end;
end;
@@ -371,6 +389,13 @@
Exit;
for i := 0 to High(PickupColors) do
begin
+ if InvFull then
+ begin
+ if Players[CurrentPlayer].Booleans[1] then
+ BuryBones;
+ if InvFull then //Lazy coding, if the inv is still full, stop picking up!
+ exit;
+ end;
x:=MSCX;
y:=MSCY;
if (FindColorSpiralTolerance(x, y, PickupColors[i], MSX1, MSY1, MSX2, MSY2, PickupTol)) then
@@ -388,7 +413,7 @@
Debug('Picking up item');
Inc(Players[CurrentPlayer].Integers[11]);
Wait(100+random(100));
- FFlag(0);
+ nFlag;
end;
end;
end;
@@ -411,17 +436,20 @@
Debug('Killing monster...');
repeat
Wait(150+random(100));
- HpCheck;
+ if CheckHPWhileFighting then
+ HpCheck;
if PickUpWhileFighting then
CustomPickup;
FindNormalRandoms;
until (not nInFight) or (not FightOnScreen) or (not LoggedIn)
+ Debug('Done killing..');
end else
Wait(300);
end;
procedure SetupPlayer;
begin
+ GetAllLevels;
with Players[CurrentPlayer] do
begin
if not Booleans[0] then
@@ -511,8 +539,10 @@
With Players[CurrentPlayer] do
begin
if (NPCsOnScreen = 0) then
- RotateCamera
- else
+ begin
+ CustomPickup;
+ RotateCamera;
+ end else
Begin//Fighting
if not nInFight then
if FightIt then
@@ -523,16 +553,12 @@
end;
end;
+ HPCheck;
CustomPickup;
-
- if Booleans[1] then
- if InvFull then
- BuryBones;
-
- if (GetSystemTime > Integers[0]) then
+ if (GetSystemTime > Integers[0]) or (not LoggedIn) then
begin
Report;
- NextPlayer(true);
+ NextPlayer(LoggedIn);
SetupPlayer;
end;
end;
pascal Code:
program SomethingFighter;
{$include SRL/SRL/misc/smart.scar}
{$include srl/srl.scar}
{$include srl/srl/Skill/Fighting.scar}
{$include srl/srl/Skill/Ranging.scar}
Const
LogoutTime = 16;//Play for this many mins then switch/logout
PickUpWhileFighting = false;// Pick up during fight?
CheckHPWhileFighting = false; //Check (and heal) during fight?
KillAccuracy = 0.7;//How accurately after attacking it kills it [1.0 = perfect, 0.1 = 1/10th the time]
procedure DeclarePlayers;
begin
HowManyPlayers := 1;//Change this accordingly
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name :=''; //Character Name
Pass :=''; //Character Pass
Nick :=''; //Nickname 3 - 4 Letter's of char name
Active := True; //True if you want this player to be ran in the script, false if not
Strings[0] := '';//Skill to train (if blank won't change anything)
Arrays[0] := [];//colors of monster(s)
Arrays[1] := [''];//monster name(s)
Arrays[2] := [];//[Pickup Colors]
Arrays[3] := [''];//[Pickup Names]
//This is options array
//[NPC Color Tolerance, Pickup Tolerance, Bury Bones (true/false)];
Arrays[4] := [3, 0, false];
end;
end;
Const
DebugOn = false;
type
TPlaya = record
NPCNames: TStringArray;
NPCColors: TIntegerArray;
Ranging: Boolean;
Weapon: Array of Array of String;
PickupColors: array of integer;
PickupNames: array of string;
NPCTol, PickupTol: integer;
end;
TInvItem2 = Record
OutLine, Width, Height, Color: Integer;
end;
var
Playas: array [0..99] of TPlaya;
ReportTime: integer;
LeftClickFail: Boolean;//if the Left click fails attacking
BonesTPA: TInvItem2;
procedure Debug(S: String);
begin
if DebugOn then
Writeln(S)
else
DebugLn(s);
end;
function nInFight: Boolean;//In case someone wants to customize, this is a key function
begin
Result := InFight;
end;
procedure nFlag; //In case someone wants to customize the FFlag(0) function
begin
FFlag(0);
end;
function InvItem(cOutLine, cWidth, cHeight, cColor: Integer): TInvItem2;
begin
with Result do
begin
OutLine := cOutLine;
Width := cWidth;
Height := cHeight;
Color := cColor;
end;
end;
function FindInvItem(Item: TInvItem2; B: TBox): Boolean;
var
TPA: TPointArray;
Bt: TBox;
x,y: integer;
begin
FindColorsTolerance(TPA, srl_outline_black, B.x1, B.y1, B.x2, B.y2, 0);
if Length(TPA) < 1 then
Exit;
Bt := GetTPABounds(TPA);
if (Length(TPA) = Item.OutLine) and (iAbs(Bt.x2-Bt.x1) = Item.Width) and (iAbs(Bt.y2-Bt.y1) = Item.Height) then
if Item.Color > -1 then
Result := FindColorTolerance(x, y, Item.Color, Bt.x1, Bt.y1, Bt.x2, Bt.y2, 9)
else
Result := True;
end;
function FightOnScreen: Boolean;
var
TBA: TBoxArray;
x, y: integer;
begin
x := MSCX;
y := MSCY;
TBA := FindAllHPBars(x, y, MSX1, MSY1, MSX2, MSY2);
if Length(TBA) < 1 then
Exit;
if PointInBox(Point((TBA[0].x1+TBA[0].x2)/2, (TBA[0].y1+TBA[0].y2)/2), IntToBox(x-39,y-25,x+39,y+5)) then
Result := (Length(TBA)-1) > 0
else
Result := Length(TBA) > 0;
end;
Function NPCsOnScreen: integer;
var
i: integer;
Mobs : TPointArray;
begin
FindColorsTolerance(Mobs, 195836,MMX1+40,MMY1+40,MMX2-40,MMY2-40, 0);
if High(Mobs) > 0 then
begin
RAaSTPA(Mobs, 4);
for i := 0 to High(Mobs) do
If InAbstractBox(MMCX-30, MMCY-17, MMCX+30, MMCY-17, MMCX+24, MMCY+14, MMCX-24, MMCY+14, Mobs[i].x, Mobs[i].y) then
Inc(Result);
end;
end;
procedure HpCheck;
var
c, T, i, x, y:Integer;
RunDir: String;
begin
if (HPPercent < 50) and LoggedIn then
begin
Writeln('HP low doing HP checks...');
if not InvEmpty then
for c := 0 to 2 do
begin
for i := 1 to 28 do
if ExistsItem(i) then
begin
MMouseItem(i);
GetMousePos(x, y);
if WaitUptext('Eat', 400) then
begin
Mouse(x,y,0,0,false);
if WaitOption('Eat', 400) then
begin
t := GetSystemTime;
while ExistsItem(i) and ((GetSystemTime-t) < 2000) do
wait(20);
if (HPPercent > 60) then
Exit;
end;
end;
end;
if (not LoggedIn) or (HPPercent > 50) then
Exit;
end;
if (HPPercent < 50) then
begin
if (HPPercent < 25) then
if (nInFight) then
begin
RunDir := 'nsewns';
Debug('Running away HP% < 25...');
RunAway(RunDir[random(6)+1], true, 1, 10000 + random(2000));
end;
T := GetSystemTime;
repeat
if not IsResting then
SetRest;
Wait(200+random(200));
FindNormalRandoms;
If ((GetSystemTime - T) > (50000+random(50000)) ) then
begin
case random(2) of
0: BoredHuman;
1: RandomMovement;
end;
T := GetSystemTime;
end;
if not LoggedIn then
Exit;
until (HPPercent > 60);
SetAngle(true);
end;
end;
end;
function GetWeaponData(var DArr: array of TStringArray): Boolean;
var
x, y, i, ii, Len: integer;
TB: TBox;
TP: TPointArray;
begin
Result := False;
if (not LoggedIn) then exit;
SetArrayLength(DArr, 4);
GameTab(tab_Combat);
for I := 0 to 3 do
begin
MMouse(680-(i+1) mod 2*85, 270+2 mod (i+1)*28, 12, 12);
SetArrayLength(DArr[i], 3);
wait(100);
Result := WaitFindColor(X, Y, 10551295, MIX1-10, MIY1-10, MIX2+10, MIY2+10, 0, 3000);
GetClientDimensions(TB.X2, TB.Y2);
TB := IntToBox(0, 0, TB.X2, TB.Y2);
FindColors(TP, 10551295, TB.X1, TB.Y1, TB.X2 - 1, TB.Y2 - 1);
if (Length(TP) = 0) then exit;
TB := GetTPABounds(TP);
Len := Round((TB.x2-TB.x1)/6.2);
for ii := 0 to 2 do
begin
DArr[i][ii] := GetTextAt(TB.x1+1, TB.y1+1, 0, 3, 4, 0, 0, Len, SmallChars);
Writeln(DArr[i][ii]);
IncEx(TB.Y1, 16);
end;
end;
end;
Function SetWeapon(Skill: string; WeaponData: array of TStringArray; SetIt: boolean): boolean;
var
i, ii: integer;
begin
for i := 0 to High(WeaponData) do
for ii := 0 to High(WeaponData[i]) do
if (Pos(Lowercase(skill), Lowercase(WeaponData[i][ii])) <> 0) then
begin
if SetIt then
Result := SetFightMode(i + 1)
else
Result := True;
Exit;
end;
end;
function RotateCamera: boolean;
var
mTPA: TPointArray;
mAng, T: Integer;
begin
FindColorsTolerance(mTPA, 195836,MMX1+40,MMY1+40,MMX2-40,MMY2-40, 0);
if Length(mTPA) < 1 then
Exit;
RAaSTPA(mTPA, 4);
SortTPAFrom(mTPA, Point(MMCx, MMCY));
if (Distance(mTPA[0].x, mTPA[0].y, MMCX, MMCY) > 20) then
begin
T := GetSystemTime + 3000+random(3000);
repeat
Wait(500+random(200));
if (NPCsOnScreen > 0) then
Result := true;
if Result then Exit;
until (GetSystemTime > T) or not LoggedIn;
end
else
begin
mAng := Round(Degrees(ArcTan2(mTPA[0].Y - MMCY, mTPA[0].X - MMCX)) + 90 + rs_GetCompassAngleDegrees);
if (mAng < 0) then
mAng := mAng + 360;
if (mAng > 360) then
mAng := mAng - 360;
mAng := RandomRange(mAng - 12, mAng + 12);
MakeCompass(inttostr(mAng));
//Mouse(mTPA[0].x, mTPA[0].y, 3, 3, true);
end;
if (NPCsOnScreen > 0) then
result := true;
end;
procedure Report;
begin
with Players[CurrentPlayer] do
begin
Writeln('|___Something Fighter Report___|');
Writeln('|__Player: ' + Padr(Capitalize(Name), 18)+'__|');
Writeln('|__Worked: ' + Padr(MSToTime(Worked, Time_Short), 18)+'__|');
Writeln('|__Kills: ' + Padr(IntTostr(Round(Extendeds[10])), 18)+'__|');
if (Integers[11] > 0) then
Writeln('|__Pickups: ' + Padr(IntTostr(Integers[11]), 17)+'__|');
if (Integers[12] > 0) then
Writeln('|__Bones Buried: '+Padr(IntTostr(Integers[12]), 12)+'__|');
end;
ReportTime := GetSystemTime + 10*60000;
end;
Function BuryBones: Boolean;
var
i, x, y,t: integer;
begin
for i := 1 to 28 do
begin
if FindInvItem(BonesTPA, InvBox(i)) then
begin
MMouseItem(i);
if WaitUpText('ury', 500) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
wait(900+random(300));
t := GetSystemTime;
while ExistsItem(i) and ((GetSystemTime-t) < 250) do
wait(75 + random(50));
if (GetSystemTime - t) >= 250 then //We cannot bury at this place..
begin
Result := false;
Exit;
end;
Inc(Players[CurrentPlayer].Integers[12]);
Result := true;
end;
end;
end;
end;
Function FightIt: Boolean;
var
i, r: integer;
T: TPoint;
begin
if nInFight then
if FightOnScreen then
Exit;
With Playas[CurrentPlayer] do
For i := 0 to High(NPCColors) do //Color array
begin
T := Point(MSCX, MSCY);
if FindColorSpiralTolerance(T.x, T.y, NPCColors[i], MSX1, MSY1, MSX2, MSY2, NPCTol) then
begin
if PointInBox(T, IntToBox(MSCX-15, MSCY-25, MSCX+35, MSCY+25)) then
Continue;
if IsFightAt(T.x, T.y) then
Continue;
MMouse(T.x, T.y, 3, 3);
if WaitUpTextMulti(NPCNames, 400) then//Text array
begin
GetMousePos(T.x, T.y);
r := Random(3);
if LeftClickFail then
r := 2;
case r of
0..1: begin
Mouse(T.x, T.y, 0, 0, true);
Result := DidClick(True, 100);
end;
2: begin
Mouse(T.x, T.y, 0, 0, false);
Result := ChooseOption('ttack');
end;
end;
LeftClickFail := not result;
if Result then
begin
Debug('Attack!');
nFlag;
Exit;
end else Continue;
end;
end;
end;
end;
function CustomPickup:boolean;
var
i,x,y:integer;
begin
With Playas[CurrentPlayer] do
begin
if Length(PickupColors) < 1 then
Exit;
for i := 0 to High(PickupColors) do
begin
if InvFull then
begin
if Players[CurrentPlayer].Booleans[1] then
BuryBones;
if InvFull then //Lazy coding, if the inv is still full, stop picking up!
exit;
end;
x:=MSCX;
y:=MSCY;
if (FindColorSpiralTolerance(x, y, PickupColors[i], MSX1, MSY1, MSX2, MSY2, PickupTol)) then
begin
if PointInBox(Point(x, y), IntToBox(MSCX-15, MSCY-25, MSCX+35, MSCY+25)) then
Continue;
MMouse(x,y,3,3);
if WaitUpText('ake', 400) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
if WaitOptionMultiEx(PickupNames, 'All', ClickLeft, 3000) then
begin
Result := True;
Debug('Picking up item');
Inc(Players[CurrentPlayer].Integers[11]);
nFlag;
end;
end;
end;
end;
end
end;
procedure WaitFight;
var
T: integer;
begin
T := GetSystemTime + 5000;
if Playas[CurrentPlayer].Ranging then
T := GetSystemTime + 6000;
while not nInFight and (GetSystemTime < T) do
wait(100);
if nInFight then
begin
Debug('Killing monster...');
repeat
Wait(150+random(100));
if CheckHPWhileFighting then
HpCheck;
if PickUpWhileFighting then
CustomPickup;
FindNormalRandoms;
until (not nInFight) or (not FightOnScreen) or (not LoggedIn)
Debug('Done killing..');
end else
Wait(300);
end;
procedure SetupPlayer;
begin
GetAllLevels;
with Players[CurrentPlayer] do
begin
if not Booleans[0] then
begin
Debug('Setting Angle');
SetAngle(true);
Debug('Setting Retaliate');
Retaliate(True);
GetWeaponData(Playas[CurrentPlayer].Weapon);
if (Strings[0] <> '') then
if SetWeapon(Strings[0], Playas[CurrentPlayer].Weapon, True) then
Debug('Weapon set');
Playas[CurrentPlayer].Ranging := SetWeapon('rang', Playas[CurrentPlayer].Weapon, false);
Booleans[0] := true;
end;
if Playas[CurrentPlayer].Ranging then
if ArrowAmount < 200 then
begin
Writeln('Player is low on ammo < 200');
NextPlayer(false);
SetupPlayer;
end;
Integers[0] := GetSystemTime + RandomRange((LogoutTime-1)*60*1000, (LogoutTime+1)*60*1000);
ReportTime := GetSystemTime + 10*60000;
end;
SetRun(True);
end;
procedure StartUp;
var
i, l: integer;
begin
for i := 0 to HowManyPlayers-1 do
begin
SetArrayLength(Playas[i].NPCColors, Length(Players[i].Arrays[0]));
for l := 0 to High(Players[i].Arrays[0]) do
Playas[i].NPCColors[l] := Players[i].Arrays[0][l];
SetArrayLength(Playas[i].NPCNames, Length(Players[i].Arrays[1]));
for l := 0 to High(Players[i].Arrays[1]) do
Playas[i].NPCNames[l] := Players[i].Arrays[1][l];
SetArrayLength(Playas[i].PickupColors, Length(Players[i].Arrays[2]));
for l := 0 to High(Players[i].Arrays[2]) do
Playas[i].PickupColors[l] := Players[i].Arrays[2][l];
SetArrayLength(Playas[i].PickupNames, Length(Players[i].Arrays[3]));
for l := 0 to High(Players[i].Arrays[3]) do
Playas[i].PickupNames[l] := Players[i].Arrays[3][l];
Try
Playas[i].NPCTol := Players[i].Arrays[4][0];
Playas[i].PickupTol := Players[i].Arrays[4][1];
Players[i].Booleans[1] := Players[i].Arrays[4][2];
Except;
end;
end;
BonesTPA := InvItem(98, 24, 18, -1);//Regular bones
//InvItem(84, 22, 19, -1);//Big bones
end;
{ Integers[0] = Logout timer
*
* Extendeds[10] = Kill count
* Integers[11] = Pick up count
* Integers[12] = Bones buried
*
* Booleans[0] = initial player setup
* Booleans[1] = Bury bones
*
}
begin
Smart_Server := 1;
Smart_Members:= True;
Smart_Signed := True;
SetupSRL;
DeclarePlayers;
StartUp;
LoginPlayer;
SetupPlayer;
Repeat
FindNormalRandoms;
With Players[CurrentPlayer] do
begin
if (NPCsOnScreen = 0) then
begin
CustomPickup;
RotateCamera;
end else
Begin//Fighting
if not nInFight then
if FightIt then
begin
WaitFight;
Extendeds[10] := Extendeds[10] + KillAccuracy;
FindNormalRandoms;
end;
end;
HPCheck;
CustomPickup;
if (GetSystemTime > Integers[0]) or (not LoggedIn) then
begin
Report;
NextPlayer(LoggedIn);
SetupPlayer;
end;
end;
if (GetSystemTime > ReportTime) then
Report;
until(AllPlayersInactive);
end.