ok, due to me forgetting my googlecode account pass and shit (I don't think I have the rights to commit to the new url anyways) I am just going to post these here.
Walking_Color.scar- added WalkPath(index: byte): Boolean;
- failsafes for everything but entering the tree's and the bank
{==============================================================================\
| MSI Group Scripting Include |
| Walking_Color.scar |
|==============================================================================|
| For all the walking functions that are color based. |
| |
\_____________________________________________________________________________}
{ const Varrock East Woodcutting
Description: Constants used for the walking to and from the trees at the
Varrock east bank. }
const
WALK_WC_VE_TREE_1 = 0; // rock
WALK_WC_VE_TREE_2 = 1; // road
WALK_WC_VE_TREE_3 = 2; // path
WALK_WC_VE_TREE_4 = 3; // final
WALK_WC_VE_BANK_1 = 4; // rock
WALK_WC_VE_BANK_2 = 5; // path
WALK_WC_VE_BANK_3 = 6; // road
WALK_WC_VE_BANK_4 = 7; // final
{ const AutoColor
Description: Constants used for the walking autocoloring. }
const
SRLAC_RoadColour = 6579821;
SRLAC_VarrockRoadColour = 8291719;
SRLAC_FallyRoadColour = 7831173;
SRLAC_LumbyRoadColour = 8225677;
SRLAC_DirtRoadColour = 1853272;
SRLAC_WaterColour = 10850700;
SRLAC_RockColour = 5789528;
SRLAC_SandColour = 0;
SRLAC_BankerColour = 1179390;
SRLAC_TreeColour = 1532978;
Procedure SortColors(var Colors: tIntegerArray; col: Integer);
var
tempB: tIntegerArray;
Tol: ShortInt;
I: Integer;
timer, L: LongInt;
begin
timer := getsystemtime;
tempB := Colors;
SetArrayLength(Colors, 0);
Tol := 0;
while Length(Colors) < (Length(tempB)/2 or 5) do
begin
if Getsystemtime-timer > 100 then Break;
for i := 0 to High(tempB) do
begin
if SimilarColors(tempB[i], col, Tol) then
begin
L := GetArrayLength(Colors);
SetArrayLength(Colors, L+1);
Colors[L] := tempB[i];
end;
if Tol > 10 then Break;
Inc(Tol);
end;
end;
end;
{******************************************************************************}
{ Function FindMMLocation(Var X, Y: Integer; Location: TMMLocation): Boolean; }
{ By: marpis }
{ Rev: 35 }
{ Date: 30 Nov 09 }
{ Description: Finds a location in minimap. First tries to find DTM, then }
{ colors, and if still not found it will find it by symbol }
{******************************************************************************}
Function MSI_FindMMLocation(Var X, Y: Integer; Location: TMMLocation): Boolean;
Var
SA, EA, tmp_Ang: Extended;
N, I, II, III, H, HH, Score, Step: Integer;
ATPA: T2DPointArray;
tmp_TPA: TPointArray;
X1, Y1, X2, Y2: Integer;
Begin
If (Not LoggedIn) Then Exit;
X := -1;
Y := -1;
Step := (Location.W * Location.H) / 10;
{ DTM Search }
If (Location.DTM > -1) Then
While (N < 10) Do
Begin
If FindDTMRotated(Location.DTM, X, Y, MMX1, MMY1, MMX2, MMY2, SA, EA, 0.02, tmp_Ang) Then
Begin
Result := True;
Exit;
End;
Inc(N);
SA := SA - (N * 0.02);
EA := EA + (N * 0.02);
End;
{ Color search }
If (Length(Location.Colors) = 0) Then
Exit;
H := High(Location.Colors);
SetLength(ATPA, H + 1);
For I := 0 To H Do
Begin
FindColorsSpiralTolerance(MMCX, MMCY, ATPA[I], Location.Colors[I], MMX1, MMY1, MMX2, MMY2, Location.Tolerances[I]);
FilterPointsPie(ATPA[I], 0.0, 360.0, 0.0, 76.0, MMCX, MMCY);
End;
{ Go through every TPA that contains one color. }
For I := 0 To H Do
Begin
HH := High(ATPA[I]);
{ Go through every 10th point in ATPA[I] to avoid lag. }
For II := 0 To HH Do
Begin
If ((II Mod Step) <> 0) Then
Continue;
Score := 0;
X1 := ATPA[I][II].X - (Location.W / 2);
Y1 := ATPA[I][II].Y - (Location.H / 2);
X2 := ATPA[I][II].X + (Location.W / 2);
Y2 := ATPA[I][II].Y + (Location.H / 2);
{ Go through every TPA again, calculating surrounding color counts. }
For III := 0 To H Do
Begin
tmp_TPA := MSI_ReturnPointsInBox(ATPA[III], IntToBox(X1, Y1, X2, Y2));
If (Length(tmp_TPA) >= Location.Counts[III]) Then
Inc(Score);
End;
{ If there are enough points of all colors, the location has been found. }
If (Score = H) Then
Begin
Result := True;
X := (X1 + X2) shr 1;
Y := (Y1 + Y2) shr 1;
Exit;
End;
End;
End;
{ Symbol Search }
If (Location.Symbol <> '') Then
If FindSymbol(X, Y, Location.Symbol) Then
Begin
Result := True;
Exit;
End;
End;
Function AutoColorMM(const color: Integer): Integer;
var
TPA: tPointArray;
List: tIntegerArray;
I: Integer;
begin
for i := 0 to 20 do
begin
FindColorsTolerance(TPA, color, MMx1, MMy1, MMx2, MMy2, 5+i);
if Length(TPA) > 0 then Break;
end;
if Length(TPA) <= 0 then Exit;
List := getColors(TPA);
sortColors(List, color);
if Length(List) <= 0 then Exit;
result := List[0];
end;
Function FindNewVarrockRoadColor: Integer;
begin
Result := AutoColorMM(SRLAC_VarrockRoadColour);
end;
Function CreateWalkTPA(x, y, color, width, height, tolerance: Integer): TpointArray;
var
TPA: tPointArray;
aTPA: t2DPointArray;
i: Integer;
L, P: Integer;
begin
FindColorsSpiralTolerance(x, y, TPA, color, MMx1, MMy1, MMx2, MMy2, tolerance);
aTPA := TPAtoATPAEx(TPA, width, height);
for i := 0 to High(aTPA) do
begin
if Length(aTPA) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTpa(aTPA[i]);
end;
end;
if Length(result) = 0 then Exit;
for i := 0 to High(Result) do
if rs_OnMiniMap(result[i].x, result[i].y) then Inc(p);
if p = 0 then SetArrayLength(Result, 0);
end;
Function walkTPApoint(TPA: tPointArray; sortP: tPoint; flagDist: shortInt): Boolean;
var
i: Integer;
t: LongInt;
begin
t := getSystemTime;
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, sortP);
for i := 0 to High(TPA) do
begin
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
Mouse(TPA[i].x, TPA[i].y, random(8), random(8), true);
wait(randomRange(1000, 2000));
while not FlagPresent do
begin
wait(250+randomRange(150, 350));
if getSystemTime-t > randomRange(2500, 3750) then
continue;
end;
FFlag(flagDist);
Result := True;
Exit;
end;
end;
end;
Function CreateColorBox(Color: Integer): TBox;
var
TPA: tPointArray;
begin
FindColors(TPA, Color, MMx1, MMy1, MMx2, MMy2);
if Length(TPA) <= 0 then Exit;
Result := GetTPABounds(TPA);
end;
Function FindColorInBox(Color: Integer; Box: TBox): Boolean;
var
TPA: tPointArray;
i: Integer;
begin
FindColorsTolerance(TPA, Color, Box.x1-5, Box.y1-5, Box.x2+5, Box.y2+5, 15);
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, Point(687, 50));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x, TPA[i].y, 5, 5, True);
Wait(750+random(450));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
Function CreateWalkIndex(index: Integer): Boolean;
var
i: Integer;
aTPA: t2DPointArray;
TPA: tPointArray;
p: tPoint;
RockColor, TreeColor, BC: Integer;
t: LongInt;
begin
case index of
WALK_WC_VE_TREE_1:
begin
if countColor(RoadColor, MMx1, MMy1, MMx2, MMy2) <= 5 then RoadColor := FindNewVarrockRoadColor;
if FindColorInBox(RoadColor, CreateColorBox(FindRockColor)) then
begin
Result := True;
Exit;
end;
TPA := CreateWalkTPA(MMx2, MMy1, RoadColor, 2, 2, 8);
if Length(TPA) <= 0 then Exit;
Result := walkTPApoint(TPA, Point(MMx2-randomRange(5, 15), MMy1), random(10));
Exit;
end;
WALK_WC_VE_TREE_2:
begin
TPA := CreateWalkTPA(MMx2, MMcy, RoadColor, 2, 2, 8);
if Length(TPA) <= 0 then Exit;
Result := walkTPAPoint(TPA, Point(MMx2, MMcy), random(15));
if Result then Exit;
if not LinearWalkTolerance(RoadColor, randomRange(80, 90), randomRange(59, 68), random(8), random(8), 8) then
if not RadialWalkTolerance(RoadColor, 80, 90, randomRange(55, 69), random(8), random(8), 10) then
begin
WriteLn('Walking Failed Here. Submit a Fix.');
logOut;
NextPlayer(False);
Exit;
end;
Result := True;
Exit;
end;
WALK_WC_VE_TREE_3:
begin
RockColor := AutoColorMM(SRLAC_RockColour);
TPA := CreateWalkTPA(MMcx, MMy1, RockColor, 2, 2, 8);
if length(TPA) <= 0 then Exit;
for i := 0 to High(TPA) do
begin
if TPA[i].y > MMcy then continue;
Mouse(TPA[i].x, TPA[i].y, 5, 5, true);
t := getSystemTime;
while not flagPresent() do
begin
if getSystemTime-t > randomRange(2000, 2500) then
Exit;
wait(250+random(500));
end;
FFlag(random(8));
Result := True;
Exit;
end;
end;
WALK_WC_VE_TREE_4:
begin
TreeColor := AutoColorMM(SRLAC_TreeColour);
writeLn('Tree AutoColor = '+IntToStr(TreeColor));
FindColorsTolerance(TPA, TreeColor, MMx1, MMy1, MMx2, MMy2, 8);
if Length(TPA) <= 0 then Exit;
aTPA := SplitTPAEx(TPA, 10, 10);
if Length(aTPA) <= 0 then Exit;
SortATPASize(aTPA, true);
p := MiddleTPA(aTPA[0]);
if (p.x < MMcx+20) and (p.y < MMcy) then
begin
Mouse(p.x, p.y, 5, 5, true);
Flag();
Result := True;
Exit;
end;
end;
WALK_WC_VE_BANK_1:
begin
RockColor := AutoColorMM(SRLAC_RockColour);
TPA := CreateWalkTPA(MMcx, MMy2, RockColor, 2, 2, randomRange(5, 10));
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, point(700, 150));
for i := 0 to High(TPA) do
begin
if (TPA[i].y < MMcy-10) then continue;
Mouse(TPA[i].x-5, TPA[i].y, Random(8), Random(8), true);
t := getSystemTime;
while not flagPresent() do
begin
if getSystemTime-t > randomRange(2000, 2500) then
Exit;
wait(250+random(500));
end;
FFlag(RandomRange(5, 10));
Result := True;
Exit;
end;
end;
WALK_WC_VE_BANK_2:
begin
RoadColor := FindNewVarrockRoadColor();
FindColorsTolerance(TPA, RoadColor, MMx1, MMCy, MMCx, MMy2, 4);
if Length(TPA) <= 0 then
Exit;
SortTPAFrom(TPA, Point(MMCx, MMCy));
for t := 0 to 4 do
begin
i := Length(TPA) - RandomRange(1, 4);
try
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
BC := 1;
except
Continue;
end;
if BC = 1 then
Break;
end;
if t = 4 then
begin
MSI_Debug('CreatWalkIndex(WALK_WC_VE_BANK_2)', 'Failed to find road on minimap', Debug_Functions);
Exit;
end;
Mouse(TPA[i].x, TPA[i].y, 0, 0, True);
FFlag(5);
Result := True;
Exit;
end;
WALK_WC_VE_BANK_3:
begin
TPA := CreateWalkTPA(MMx1, MMcy, RoadColor, 3, 3, 8);
if Length(TPA) <= 0 then
Exit;
SortTPAFrom(TPA, point(MMx1-10, MMcy));
for i := 0 to High(TPA) do
begin
if not RS_onMinimap(TPA[i].x, TPA[i].y) then Continue;
Mouse(TPA[i].x, TPA[i].y, 5, 5, true);
t := getSystemTime;
while not flagPresent() do
begin
if getSystemTime-t > randomRange(2000, 2500) then
Exit;
wait(250+random(500));
end;
FFlag(RandomRange(3, 7));
Result := True;
Exit;
end;
end;
WALK_WC_VE_BANK_4:
begin
for i := 0 to 2 do
begin
BC := AutoColorMM(SRLAC_BankerColour);
FindColorsTolerance(TPA, BC, MMx1, MMCy + 18, MMCx, MMy2, 1);
if Length(TPA) > 5 then
Break;
if i = 2 then
begin
MSI_Debug('CreateWalkIndex(WALK_BANK_Final);', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
SortTPAFrom(TPA, Point(MMCx, MMCy));
for i := 0 to High(TPA) do
begin
t := Random(High(TPA));
if rs_OnMiniMap(TPA[t].x, TPA[t].y) then
Break;
if i = High(TPA) then
begin
MSI_Debug('CreateWalkIndex(WALK_BANK_Final);', 'Points not on MiniMap!', Debug_Functions);
Exit;
end;
end;
Mouse(TPA[t].x, TPA[t].y - RandomRange(3, 7), 3, 3, True);
t := getSystemTime;
while not flagPresent() do
begin
if getSystemTime-t > randomRange(2000, 2500) then
Exit;
wait(250+random(500));
end;
FFlag(3);
Result := True;
end;
end;
end;
Function WalkPath(index: byte): Boolean;
var
i: Integer;
begin
if not CreateWalkIndex(index) then
begin
case index of
WALK_WC_VE_TREE_1:
begin
if not RadialWalkTolerance(RoadColor, 45, 90, randomRange(60, 70), random(8), random(8), 10) then
if not RadialWalkTolerance(findRockColor, 45, 90, randomRange(60, 70), 3, 3, 10) then
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_TREE_2:
begin
if not RadialWalkTolerance(RoadColor, 75, 105, randomRange(60, 70), random(5), random(5), 10) then
if not RadialWalkTolerance(RoadColor, 65, 115, randomRange(60, 70), random(5), random(5), 10) then
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_TREE_3:
begin
if not RadialWalkTolerance(RoadColor, 0, 35, randomRange(60, 70), 10, 10, 10) then
if not RadialWalkTolerance(findRockColor, 345, 35, 60, 2, 2, 10) then
if not RadialWalkTolerance(RoadColor, 0, 45, randomRange(60, 70), 5, 5, 10) then
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_TREE_4:
begin
Exit; // Not sure of any other failsafe for this. A (D)DTM perhaps?
end;
WALK_WC_VE_BANK_1:
begin
if not RadialWalkTolerance(findRockColor, 350, 50, 65, 5, 5, 10) then
begin
mouseBox(631, 114, 667, 130, 1); // random co-ord clicking
wait(randomRange(1000, 2000));
if FlagPresent then
begin
result := true;
FFlag(randomRange(8, 14));
end;
end else
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_BANK_2:
begin
if not RadialWalkTolerance(RoadColor, 180, 200, randomRange(60, 70), random(5), random(5), 10) then
if not RadialWalkTolerance(RoadColor, 170, 220, randomRange(60, 70), 3, 3, 10) then
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_BANK_3:
begin
if not RadialWalkTolerance(RoadColor, 255, 280, randomRange(60, 70), random(8), random(8), 10) then
if not RadialWalkTolerance(RoadColor, 245, 290, randomRange(60, 70), 5, 5, 10) then
begin
MSI_Debug('WalkPath('+inttoStr(index)+');', 'Failed to find bankers on MiniMap.', Debug_Functions);
Exit;
end;
end;
WALK_WC_VE_BANK_4:
begin
Exit; // add a DTM of Bankers here.
end;
end;
end;
result := true;
end;
Mainloop.scar{==============================================================================\
| MSI Group Scripting Include |
| Mainloop.scar |
|==============================================================================|
| For all the script Artificial Inteligence |
| |
| * function MSI_BestTool: Integer; * by Coh3n |
| * function MSI_WorstTool: Integer; * by Coh3n |
| * function MSI_SetupPlayer: Boolean; * by Coh3n |
| * function MSI_GetObjectList: TIntegerArray; * by Coh3n |
| * function MSI_WalkToLoc: Boolean; * by The MSI Team |
| * function MSI_WalkToBank: Boolean; * by The MSI Team |
| * function MSI_DoSkill: Boolean; * by The MSI Team |
| * procedure MSI_CountItems: Boolean; * by Coh3n |
| * function MSI_BankMaterials: Boolean; * by The MSI Team |
| * function MSI_MainLoop: Boolean; * by The MSI Team |
\_____________________________________________________________________________}
{ const Hatchet/Pickaze requirements.
Constants representing the requirements to use each pickaxe/hatchet. }
const
REQ_BRONZE = 1;
REQ_IRON = 1;
REQ_STEEL = 6;
REQ_MITHRIL = 21;
REQ_ADAMANT = 31;
REQ_RUNE = 41;
REQ_MAX_LEVEL = 99;
{******************************************************************************}
{ function MSI_BestTool: Integer; }
{ By: Coh3n }
{ Rev: 55 }
{ Date: 26 Dec 09 }
{ Description: Determines the best tool for the job at hand. }
{******************************************************************************}
function MSI_BestTool: Integer;
var
skillsArr: TStringArray;
currSkill, currLevel: Integer;
begin
if (not Loggedin) then
Exit;
{ In order for this to work properly, the skillsArr indexes must correspond
to the skills constants in SRL's Players.scar }
skillsArr := [ 'attack', 'strength', 'defence', 'range', 'prayer', 'magic',
'runecrafting', 'hitpoints', 'agility', 'herblore', 'thieving',
'crafting', 'fletching', 'slayer', 'mining', 'smithing',
'fishing', 'cooking', 'firemaking', 'woodcutting', 'farming',
'construction', 'hunting', 'summoning' ];
{ Get the current level of the chosen skill, and then look for the required
tool, starting with the best one for that player's skill level. }
currSkill := PlayerSkills[CurrentPlayer][CurrentSkill] - 1;
currLevel := GetSkillLevel(skillsArr[currSkill]);
MSI_Debug('MSI_PlayerSetup', 'Current ' + Capitalize(skillsArr[currSkill])
+ ' level is ' + IntToStr(currLevel) + '.', debug_Functions);
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING, SKILL_MINING:
case (currLevel) of
REQ_RUNE..REQ_MAX_LEVEL: Result := HATCHET_RUNE;
REQ_ADAMANT..REQ_RUNE: Result := HATCHET_ADAMANT;
REQ_MITHRIL..REQ_ADAMANT: Result := HATCHET_MITHRIL;
REQ_STEEL..REQ_MITHRIL: Result := HATCHET_STEEL;
else
Result := HATCHET_IRON;
end;
end;
end;
{******************************************************************************}
{ function MSI_WorstTool: Integer; }
{ By: Coh3n }
{ Rev: 55 }
{ Date: 23 Feb 2010 }
{ Description: Determines the worst tool for the job at hand. }
{******************************************************************************}
function MSI_WorstTool: Integer;
begin
if (not LoggedIn) then
Exit;
case (PlayerSkills[CurrentPlayer][CurrentSkill]) of
SKILL_WOODCUTTING:
Result := HATCHET_BRONZE;
end;
end;
{******************************************************************************}
{ function MSI_SetupPlayer: Boolean; }
{ By: Coh3n }
{ Rev: 54 }
{ Date: 21 Dec 09 }
{ Description: Sets up the player for autoing. }
{******************************************************************************}
function MSI_SetupPlayer: Boolean;
var
bestTool, worstTool, x, y, i, j , k: Integer;
bankCheck: Boolean;
gameTabs: TIntegerArray;
begin
if (not LoggedIn) then
LoginPlayer;
SetAngle(True);
SetRun(True);
{ Starts by looking for the best tool for that player's skill level, and
moves down from there. }
bestTool := MSI_BestTool;
worstTool := MSI_WorstTool;
gameTabs := [tab_Equip, tab_Inv];
for j := 0 to High(gameTabs) do
for i := bestTool downto worstTool do
begin
Result := MSI_FindTool(i, gameTabs[j], x, y);
if (Result) then
Exit;
end;
{ If the required tool isn't found, then will open the bank and attempt to
withdraw the proper tool. }
if (not Result) then
begin
case (Players[CurrentPlayer].Integers[P_LOC]) of
LOC_VE_BANK:
bankCheck := MSI_OpenBank(OBJ_BANK_VE, Players[CurrentPlayer].Pin);
else
MSI_Debug('MSI_SetupPlayer', 'Invalid Player.Integers[P_LOC].',
debug_Functions);
end;
if bankCheck then
for k := bestTool downto 0 do
begin
Result := MSI_Withdraw([k], [1]);
if (Result) then
Break
else
begin
CloseBank;
MSI_Debug('MSI_PlayerSetup', 'Couldn''t Withdraw Tool.',
debug_Functions);
end;
end
else
MSI_Debug('MSI_SetupPlayer', 'Unable to Open Bank.', debug_Functions);
end;
end;
{******************************************************************************}
{ function MSI_GetObjectList: TIntegerArray; }
{ By: Coh3n }
{ Rev: 5 }
{ Date: 24 Feb 2010 }
{ Description: Converts the variant array to an integer array }
{******************************************************************************}
function MSI_GetObjectList(whichPlayer, whichSkill: Integer): TIntegerArray;
var
i: Integer;
tempStr: String;
objects: TVariantArray;
begin
objects := PlayerObjects[whichPlayer][whichSkill];
SetLength(Result, Length(objects));
try
for i := 0 to High(objects) do
begin
tempStr := IntToStr(objects[i]);
Result[i] := StrToInt(tempStr);
end;
except
MSI_Debug('MSI_GetObjectList', 'Invalid object type in DeclarePlayers!', debug_Functions);
Exit;
end;
end;
{******************************************************************************}
{ function MSI_GetItemList: TIntegerArray; }
{ By: Coh3n }
{ Rev: 5 }
{ Date: 24 Feb 2010 }
{ Description: Gets the materials required depending on the object autoed }
{******************************************************************************}
function MSI_GetItemList(whichPlayer, whichSkill: Integer): TIntegerArray;
var
i: Integer;
objects: TIntegerArray;
begin
objects := MSI_GetObjectList(whichPlayer, whichSkill);
SetLength(Result, Length(objects));
for i := 0 to High(objects) do
case objects[i] of
OBJ_TREE: Result[i] := LOGS_NORMAL;
OBJ_OAK: Result[i] := LOGS_OAK;
end;
end;
{******************************************************************************}
{ function MSI_GetExpList: TIntegerArray; }
{ By: Coh3n }
{ Rev: 5 }
{ Date: 24 Feb 2010 }
{ Description: Gets the experience gained by obtaining items in the item list }
{******************************************************************************}
function MSI_GetExpList: TExtendedArray;
var
i: Integer;
objects: TIntegerArray;
msObjs: TMSObjectArray;
begin
objects := MSI_GetObjectList(CurrentPlayer, CurrentSkill);
SetLength(Result, Length(objects));
msObjs := MSI_GetObjects(objects);
for i := 0 to High(objects) do
Result[i] := msObjs[i].Exp;
end;
{******************************************************************************}
{ function MSI_WalkToLoc: Boolean; }
{ By: The MSI Team }
{ Rev: 5 }
{ Date: 23 Feb 2010 }
{ Description: Walks to the proper location depending on skill/location }
{******************************************************************************}
function MSI_WalkToLoc: Boolean;
var
i: Integer;
begin
if (not LoggedIn) then
Exit;
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case Players[CurrentPlayer].Integers[P_LOC] of
LOC_VE_BANK:
begin
RoadColor := FindNewVarrockRoadColor();
for i := WALK_WC_VE_TREE_1 to WALK_WC_VE_TREE_3 do
WalkPath(i);
Result := WalkPath(WALK_WC_VE_TREE_4);
if Result then
Players[CurrentPlayer].Integers[P_LOC] := LOC_VE_TREES;
end;
LOC_VE_TREES: Result := True;
else
MSI_Debug('MSI_WalkToLoc', 'Invalid location for woodcutting skill.', debug_Functions);
end;
else
MSI_Debug('MSI_WalkToLoc', 'Invalid player skill!', debug_Functions);
end;
end;
{******************************************************************************}
{ function MSI_WalkToBank: Boolean; }
{ By: The MSI Team }
{ Rev: 5 }
{ Date: 23 Feb 2010 }
{ Description: Walks to the bank depending on skill/location }
{******************************************************************************}
function MSI_WalkToBank: Boolean;
var
i: Integer;
begin
if (not InvFull) or (not LoggedIn) then
Exit;
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case Players[CurrentPlayer].Integers[P_LOC] of
LOC_VE_TREES:
begin
RoadColor := FindNewVarrockRoadColor;
for i := WALK_WC_VE_BANK_1 to WALK_WC_VE_BANK_3 do
WalkPath(i);
Result := WalkPath(WALK_WC_VE_BANK_4);
if Result then
Players[CurrentPlayer].Integers[P_LOC] := LOC_VE_BANK;
end;
LOC_VE_BANK: Result := True;
else
MSI_Debug('MSI_WalkToBank', 'Invalid location for woodcutting skill.', debug_Functions);
end;
else
MSI_Debug('MSI_WalkToBank', 'Invalid player skill!', debug_Functions);
end;
end;
{******************************************************************************}
{ function MSI_DoSkill: Boolean; }
{ By: The MSI Team }
{ Rev: 5 }
{ Date: 23 Feb 2010 }
{ Description: Performs the specified skill }
{******************************************************************************}
function MSI_DoSkill: Boolean;
var
objectTypes: TIntegerArray;
begin
if (not LoggedIn) then
Exit;
objectTypes := MSI_GetObjectList(CurrentPlayer, CurrentSkill);
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
Result := MSI_ChopInvFull(objectTypes);
else
MSI_Debug('MSI_WalkToBank', 'Invalid player skill!', debug_Functions);
end;
end;
{******************************************************************************}
{ procedure MSI_CountItems; }
{ By: Coh3n }
{ Rev: 5 }
{ Date: 24 Feb 2010 }
{ Description: Counts the materials and calculates the experience gained }
{ from items in the inventory }
{******************************************************************************}
procedure MSI_CountItems;
var
itemCount, expCount, i: Integer;
items: TIntegerArray;
exps: TExtendedArray;
begin
if (not LoggedIn) then
Exit;
items := MSI_GetItemList(CurrentPlayer, CurrentSkill);
exps := MSI_GetExpList;
for i := 0 to High(items) do
begin
MSI_GetItem(items[i]);
itemCount := CountItems('dtm', MSI_Item[items[i]].DTM, []);
expCount := Round(exps[i] * itemCount);
AddToProggy(i, itemCount, ADD_ITEMS); //Adds amount of item
AddToProggy(-1, expCount, ADD_EXP); //Adds exp to skill
MSI_Debug('MSI_CountItems', 'Found ' + IntToStr(itemCount) + ' of item '
+ MSI_Item[items[i]].Name, DEBUG_FUNCTIONS);
end;
end;
{******************************************************************************}
{ function MSI_BankMaterials: Boolean; }
{ By: The MSI Team }
{ Rev: 5 }
{ Date: 23 Feb 2010 }
{ Description: Banks the specified materials }
{******************************************************************************}
function MSI_BankMaterials: Boolean;
begin
if (not LoggedIn) then
Exit;
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case Players[CurrentPlayer].Integers[P_LOC] of
LOC_VE_BANK:
begin
MSI_CountItems;
if (not MSI_OpenBank(OBJ_BANK_VE, Players[CurrentPlayer].Pin)) then
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to open bank: OBJ_BANK_VE';
Result := MSI_Deposit([LOGS_NORMAL, LOGS_OAK], [28, 28]);
if (not Result) then
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to deposit items'
else
AddToProggy(-1, -1, ADD_LOADS);
end;
else
MSI_Debug('MSI_BankMaterials', 'Invalid location for woodcutting skill.', debug_Functions);
end;
else
MSI_Debug('MSI_BankMaterials', 'Invalid player skill!', debug_Functions);
end;
end;
{******************************************************************************}
{ procedure MSI_HandleBreaking; }
{ By: MSI_HandleBreaking }
{ Description: Simple procedure for breaking }
{******************************************************************************}
procedure MSI_HandleBreaking;
begin
if (not LoggedIn) then
Exit;
if (BankScreen) then
CloseBank;
if (HowManyPlayers > 1) then
begin
MSI_Debug('MSI_HandleBreaking', 'Taking a short break', Debug_PlayerActions);
ExitToLobby;
Wait((BreakTime * 60000) + RandomRange(-300000, 300000));
MSI_Debug('MSI_MainLoop', 'Break over, continuing to play', Debug_PlayerActions);
if (AtLobbyScreen) then
MouseBox(80, 450, 560, 470, 1);
end else
begin
MSI_Debug('MSI_MainLoop', 'Switching players', Debug_PlayerActions);
NextPlayer(True);
end;
end;
{******************************************************************************}
{ procedure MSI_MainLoop; }
{ By: The MSI Team }
{ Date: 23 Feb 2010 }
{ Description: The MainLoop - performs all actions of the script }
{******************************************************************************}
procedure MSI_MainLoop;
var
loadTime, totalLoads, i: Integer;
begin
repeat
if (AllPlayersInactive) then
begin
MSI_Debug('MSI_MainLoop', 'All players are now inactive, terminating script...', Debug_PlayerActions);
ProgressReport;
TerminateScript;
end;
if (not MSI_SetupPlayer) then
begin
MSI_Debug('MSI_MainLoop', 'Failed to setup player!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to setup player';
ProgressReport;
NextPlayer(False);
Continue;
end;
repeat
MarkTime(loadTime);
if (not MSI_WalkToLoc) then
begin
MSI_Debug('MSI_MainLoop', 'Failed to walk to location!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to walk to location';
Players[CurrentPlayer].Integers[P_LOC] := LOC_LOST;
ProgressReport;
NextPlayer(False);
Break;
end;
if (not MSI_DoSkill) then
begin
MSI_Debug('MSI_MainLoop', 'Failed to perform skill!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to perform skill: ' + IntToStr(CurrentSkill);
ProgressReport;
NextPlayer(False);
Break;
end;
if (not MSI_WalkToBank) then
begin
MSI_Debug('MSI_MainLoop', 'Failed to walk to bank!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to walk to bank';
Players[CurrentPlayer].Integers[P_LOC] := LOC_LOST;
ProgressReport;
NextPlayer(False);
Break;
end;
if (not MSI_BankMaterials) then
begin
MSI_Debug('MSI_MainLoop', 'Failed to bank materials!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReport;
NextPlayer(False);
Break;
end;
ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].SkillTime :=
ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].SkillTime + TimeFromMark(loadTime);
ProgressReport;
for i := 0 to High(PlayerSkills[CurrentPlayer]) do
IncEx(totalLoads, ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].TotalLoads);
Writeln('Total Loads: ' + IntToStr(totalLoads)); // Just for testing
if (totalLoads >= BreakAfter) then
MSI_HandleBreaking;
until(not Players[CurrentPlayer].Active);
until(AllPlayersInactive);
end;
things I noticed while running the script…
1. the tree finding is really good, but it only right clicks.
2. script banks too fast, the player hasn't stopped moving. this is why the bank finding is everywhere, a simple wait(randomRange(750, 1500)); would fix that problem.
3. some walking is still an issue. I'll get to fixing the main part of the walking now, just thought I'd run by the new walking routine and see if it's what you guys are looking for or if I'm going in the wrong direction.