Coh3n
2010-12-06 18:12:07
I've decided that I'm going to start posting any major changes I make to the include. That includes, changes to any types, global variables, creating new functions/procedures, etc.
- I rewrote MSI_Deposit. It now works 100% better. Before, it would hover over any item that had a similar color to the one that needed to be found.
- I got rid of MSI_Exceptions and added an Exceptions attribute to TScriptSetup. That just makes a lot more sense, plus it would have needed to be done for multiple script support as the exceptions will vary for different scripts. This attribute can be set by users if they wish.
- Various other small fixes (see the diff).
Index: C:/Simba/Includes/MSI/Objects.simba
===================================================================
--- C:/Simba/Includes/MSI/Objects.simba (revision 400)
+++ C:/Simba/Includes/MSI/Objects.simba (revision 401)
@@ -62,13 +62,13 @@
Name := 'Oak tree';
UpText := 'wn Oak';
Option := 'Chop down Oak';
- Colors := [736046];
- Tol := 5;
- Hue := 1.54;
- Sat := 5.00;
+ Colors := [5343613];
+ Tol := 8;
+ Hue := 0.05;
+ Sat := 0.36;
FindAllColors := False;
- W := 30;
- H := 30;
+ W := 50;
+ H := 50;
Accuracy := 10;
ExcludeSelf := True;
RightClickOnly := False;
Index: C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_DOWN_1DEC2010.aca
===================================================================
--- C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_DOWN_1DEC2010.aca (revision 0)
+++ C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_DOWN_1DEC2010.aca (revision 401)
@@ -0,0 +1,10 @@
+4548474
+4812161
+4944005
+4482424
+4878211
+4021100
+4680318
+5141899
+5207693
+5075849
Index: C:/Simba/Includes/MSI/ACA/TREE_OAK_9DEC2010.aca
===================================================================
--- C:/Simba/Includes/MSI/ACA/TREE_OAK_9DEC2010.aca (revision 0)
+++ C:/Simba/Includes/MSI/ACA/TREE_OAK_9DEC2010.aca (revision 401)
@@ -0,0 +1,11 @@
+4619633
+4618349
+6330764
+5343099
+4223847
+6398099
+5211769
+5344896
+4487019
+6133129
+4750962
Index: C:/Simba/Includes/MSI/ACA/FISHSPOT_DB_2DEC2010.aca
===================================================================
--- C:/Simba/Includes/MSI/ACA/FISHSPOT_DB_2DEC2010.aca (revision 0)
+++ C:/Simba/Includes/MSI/ACA/FISHSPOT_DB_2DEC2010.aca (revision 401)
@@ -0,0 +1,10 @@
+11577251
+11577250
+11642788
+10656921
+11117471
+11642787
+11708322
+9997960
+11775659
+11312275
Index: C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_UP_1DEC2010.aca
===================================================================
--- C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_UP_1DEC2010.aca (revision 0)
+++ C:/Simba/Includes/MSI/ACA/LADDER_MINE_GUILD_UP_1DEC2010.aca (revision 401)
@@ -0,0 +1,5 @@
+4607569
+4475726
+5133914
+5265500
+4870741
Index: C:/Simba/Includes/MSI/Locations.simba
===================================================================
--- C:/Simba/Includes/MSI/Locations.simba (revision 400)
+++ C:/Simba/Includes/MSI/Locations.simba (revision 401)
@@ -162,7 +162,7 @@
Constant := LOC_DB_FISH;
AtBank := False;
RelocatePoints := [Point(3087, 3228)];
- RelocateDist := 20;
+ RelocateDist := 25;
end;
LOC_RM_YEWS:
Index: C:/Simba/Includes/MSI/Skills.simba
===================================================================
--- C:/Simba/Includes/MSI/Skills.simba (revision 400)
+++ C:/Simba/Includes/MSI/Skills.simba (revision 401)
@@ -228,17 +228,17 @@
begin
t := (GetSystemTime + (5 * 60000));
- with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
- case (MSI_Scripts[Name].SkillConst) of
- SKILL_WOODCUTTING: tObjects := Trees;
- SKILL_MINING: tObjects := Rocks;
- SKILL_FISHING: tObjects := FishSpots;
- end;
-
repeat
while (not InvFull) and (LoggedIn) do
with MSI_Players[CurrentPlayer] do
begin
+ with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
+ case (MSI_Scripts[Name].SkillConst) of
+ SKILL_WOODCUTTING: tObjects := Trees;
+ SKILL_MINING: tObjects := Rocks;
+ SKILL_FISHING: tObjects := FishSpots;
+ end;
+
if (not MSI_Scripts[Scripts[CurrentScript].Name].ClickClosest) then
newObjects := MSI_RearrangeArray(tObjects, Scripts[CurrentScript].Priority)
else
Index: C:/Simba/Includes/MSI/Skills/Woodcutting.simba
===================================================================
--- C:/Simba/Includes/MSI/Skills/Woodcutting.simba (revision 400)
+++ C:/Simba/Includes/MSI/Skills/Woodcutting.simba (revision 401)
@@ -114,6 +114,8 @@
B := IntToBox(MSI_Objects[TreeID].X - HalfWidth, MSI_Objects[TreeID].Y - HalfHeight,
MSI_Objects[TreeID].X + HalfWidth, MSI_Objects[TreeID].Y + HalfHeight);
+ SMART_DrawBoxEx(False, B, clRed);
+
L := Length(MSI_Objects[TreeID].Colors);
SetLength(ATPA, L);
Dec(L);
Index: C:/Simba/Includes/MSI/Skills/Fishing.simba
===================================================================
--- C:/Simba/Includes/MSI/Skills/Fishing.simba (revision 400)
+++ C:/Simba/Includes/MSI/Skills/Fishing.simba (revision 401)
@@ -57,6 +57,7 @@
toWithdraw: array of TIntegerArray;
objReady: TBooleanArray;
curScript: TScript;
+ b: Boolean;
begin
MSI_AddHeader('MSI_SetupFishing');
@@ -92,16 +93,18 @@
if (MSI_Withdraw(toWithdraw[i], [])) then
for j := 0 to High(toWithdraw[i]) do
begin
- if (not MSI_FindTool(toWithdraw[i][j], TAB_INV, x, y)) then
- Break;
+ t := GetSystemTime + 2000;
+ while (GetSystemTime < t) do
+ begin
+ Wait(300 + Random(200));
+ if (MSI_FindTool(toWithdraw[i][j], TAB_INV, x, y)) then
+ Break;
+ end;
if (j = High(toWithdraw[i])) then
objReady[i] := True;
end;
- if (BankScreen) then
- CloseBank;
-
t := 0;
for i := 0 to High(objReady) do
if (objReady[i]) then
@@ -109,8 +112,10 @@
SetLength(newObjs, t + 1);
newObjs[t] := intObjs[i];
Inc(t);
- end else
+ end else begin
MSI_Debug(MSI_Objects[intObjs[i]].Name + ': Required tools not found');
+ MSI_Deposit(MSI_FishingTools(intObjs[i]), [], b);
+ end;
// Resets the objects so if the tools aren't found it will still fish in the spots for which the tools were found
Scripts[CurrentScript].FishSpots := newObjs;
@@ -486,9 +491,9 @@
// Remove tools from exceptions array
tools := MSI_FishingTools(Which[Index]);
for i := 0 to High(tools) do
- if (InIntArrayEx(MSI_Exceptions[CurrentPlayer], t, MSI_Items[tools[i]].InvSlot)) then
+ if (InIntArrayEx(Scripts[CurrentScript].Exceptions, t, MSI_Items[tools[i]].InvSlot)) then
begin
- DeleteValueInIntArray(MSI_Exceptions[CurrentPlayer], t);
+ DeleteValueInIntArray(Scripts[CurrentScript].Exceptions, t);
MSI_Items[tools[i]].InvSlot := 0;
end;
end;
Index: C:/Simba/Includes/MSI/Banking.simba
===================================================================
--- C:/Simba/Includes/MSI/Banking.simba (revision 400)
+++ C:/Simba/Includes/MSI/Banking.simba (revision 401)
@@ -115,7 +115,7 @@
Amounts[i] := 28;
end;
- if (Length(MSI_Exceptions[CurrentPlayer]) <= 0) then
+ if (Length(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions) <= 0) then
begin
Result := DepositAll; // Deposits all if there are no exceptions
DepAll := Result;
@@ -123,6 +123,7 @@
for i := 0 to High(Items) do
begin
slots := MSI_FindItemSlots(Items[i]);
+
// If items aren't found, sets the deposit array to true and continues
if (Length(slots) <= 0) then
begin
@@ -168,7 +169,7 @@
end;
end;
- if (Length(MSI_Exceptions[CurrentPlayer]) > 0) then
+ if (Length(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions) > 0) then
begin
for i := 0 to High(itemsDeposited) do
if (not itemsDeposited[i]) then // Returns false if it fails to deposit one item
@@ -184,83 +185,73 @@
end;
{******************************************************************************}
-{ Function MSI_Withdraw(Items, Amount : TIntegerArray) : Boolean }
-{ By: Naum }
-{ Date: 25 June 2010 }
-{ Description: Widthraws an Item using the TItem type }
+{ Function MSI_Withdraw(Items, Amount: TIntegerArray): Boolean }
+{ By: Coh3n }
+{ Date: 06 December 2010 }
+{ Description: Withdraws 'Amount' of 'Items' }
{******************************************************************************}
-Function MSI_Withdraw(Items, Amount : TIntegerArray) : Boolean;
-Var
- ATPA2 : Array Of TPointArray; //The length is the same as items.colors
- ATPA : T2DPointArray;
- I, BX, BY, II, DX, DY, XX, YY: Integer;
- TextCheck, DTMCheck : Boolean;
- WithdrawP : TPoint;
- TB : TBox;
- theItems: TItemArray;
-Begin
+function MSI_Withdraw(Items, Amounts: TIntegerArray): Boolean;
+var
+ i, x, y: Integer;
+ itemsWithdrew: TBooleanArray;
+begin
if (not LoggedIn) or (not WaitFunc(@BankScreen, 70, 1300)) then
Exit;
- if (Length(Amount) = 0) then
+ MSI_AddHeader('MSI_Withdraw');
+
+ if (Length(Amounts) = 0) then
begin
- SetLength(Amount, Length(Items));
- for i := 0 to High(Amount) do
- Amount[i] := 1;
+ SetLength(Amounts, Length(Items));
+ for i := 0 to High(Amounts) do
+ if (MSI_Items[Items[i]].Stackable) then
+ Amounts[i] := -1
+ else
+ Amounts[i] := 1;
end;
- try
- MSI_AddHeader('MSI_Withdraw');
+ SetLength(itemsWithdrew, Length(Items));
- SetLength(theItems, Length(Items));
- theItems := MSI_GetItems(Items);
- For I := 0 To High(Items) Do
- Begin
- SetArrayLength(ATPA2, High(theItems[i].Colors)+1)
+ for i := 0 to High(Items) do
+ begin
+ if (FindItem(x, y, 'dtm', MSI_Items[Items[i]].DTM, MBX1, MBY1, MBX2, MBY2, [])) then
+ begin
+ MSI_Debug('Found item in bank: '+Capitalize(MSI_Items[Items[i]].Name));
- For II := 0 To High(theItems[i].Colors) Do
- FindColorsTolerance(ATPA2[II], theItems[i].Colors[II], MBX1, MBY1, MBX2, MBY2, 15);
+ if (Amounts[i] = 1) then
+ begin
+ Mouse(x, y, 4, 4, True);
+ itemsWithdrew[i] := True;
+ Continue;
+ end else
+ Mouse(x, y, 4, 4, False);
- ATPA2[0] := MergeATPA(ATPA2);
- ATPA := SplitTPA(ATPA2[0], 5);
+ if (Amounts[i] = -1) then
+ itemsWithdrew[i] := WaitOption('-All', 500)
+ else
+ if (InIntArray([5, 10], Amounts[i])) then
+ itemsWithdrew[i] := WaitOption('-'+IntToStr(Amounts[i]), 500)
+ else
+ if (WaitOption('-X', 500)) then
+ if (WaitColor(254, 401, ClBlack, 0, 1200)) then
+ begin
+ TypeSend(IntToStr(Amounts[i]));
+ itemsWithdrew[i] := True;
+ end;
+ end;
+ end;
- For II := 0 To High(ATPA) Do
- Begin
- TB := IntToBox(ATPA[II][0].x - 50, ATPA[II][0].y - 50,
- ATPA[II][0].x + 50, ATPA[II][0].y + 50);
+ for i := 0 to High(itemsWithdrew) do
+ if (not itemsWithdrew[i]) then // Returns false if it fails to withdraw one item
+ begin
+ MSI_CloseHeader('MSI_Withdraw: ' + BoolToStr(Result) + ' (' + MSI_Items[Items[i]].Name + ')');
+ Exit;
+ end;
- DTMCheck := DTMRotated(theItems[i].DTM, DX, DY, TB.x1, TB.y1, TB.x2, TB.y2);
- MMouse(DX, DY, 2, 3);
- TextCheck := WaitUpTextMulti(theItems[i].UpText, 150+Random(30));
- If TextCheck Then Break;
- End;
+ Result := True;
+ MSI_CloseHeader('MSI_Withdraw: ' + BoolToStr(Result));
+end;
- If TextCheck Then
- Begin
- If BX + BY > 0 Then
- MMouse(BX, BY, 2, 3);
-
- TextCheck := WaitUpTextMulti(theItems[i].UpText, 1200);
- GetMousePos(XX, YY);
- Result := TextCheck;
-
- If Result Then
- Begin
- WithDrawP := MSTPointToBankPoint(Point(XX, YY));
- Withdraw(WithDrawP.X, WithDrawP.Y, Amount[I]);
- MSI_Debug('Withdrew Amount '+IntToStr(Amount[I])+
- ' Of Item : ''' +theItems[i].Name+'''');
- End else
- MSI_Debug('Failed to withdraw' + IntToStr(Amount[i]) +
- ' of item: ' + theItems[i].Name);
- End;
- End;
-
- finally
- MSI_CloseHeader('MSI_Withdraw: ' + BoolToStr(Result));
- end;
-End;
-
{******************************************************************************}
{ function MSI_WithdrawBestTool(): Boolean; }
{ By: Coh3n }
Index: C:/Simba/Includes/MSI/Mainloop.simba
===================================================================
--- C:/Simba/Includes/MSI/Mainloop.simba (revision 400)
+++ C:/Simba/Includes/MSI/Mainloop.simba (revision 401)
@@ -233,7 +233,7 @@
// Deposits other items such as gems, or random rewards
for i := 1 to 28 do
begin
- if (InIntArray(MSI_Exceptions[CurrentPlayer], i)) then
+ if (InIntArray(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions, i)) then
Continue;
case MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType of
@@ -663,7 +663,6 @@
begin
// Again, temporary
SetLength(RelocateAttempts, HowManyPlayers);
- SetLEngth(MSI_Exceptions, HowManyPlayers);
MSI_SetScriptLength;
MSI_SetPlayerInfo;
@@ -713,7 +712,7 @@
MSI_SubDebug('Player NOT at ' + MSI_Locations[MSI_Players[CurrentPlayer].Location].Name);
// If in the middle of the path with inventory items, will walk to bank and deposit
- if (InvCount > Length(MSI_Exceptions[CurrentPlayer])) then
+ if (InvCount > Length(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions)) then
begin
MSI_Players[CurrentPlayer].Location := script.PathInfo.EndLoc;
goto WalkToBank;
@@ -732,7 +731,7 @@
if (not (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType = NoBank)) then
begin
if (MSI_Locations[MSI_Players[CurrentPlayer].Location].AtBank) then
- if (InvCount > Length(MSI_Exceptions[CurrentPlayer])) then
+ if (InvCount > Length(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions)) then
goto AtBank;
if (not MSI_Walk(True)) then
Index: C:/Simba/Includes/MSI/Items.simba
===================================================================
--- C:/Simba/Includes/MSI/Items.simba (revision 400)
+++ C:/Simba/Includes/MSI/Items.simba (revision 401)
@@ -856,7 +856,7 @@
with MSI_Items[whichItem] do
begin
Name := 'Fishing Rod';
- UpText := ['ishing rod'];
+ UpText := ['Fishing'];
Colors := [5197651];
Tol := 5;
Stackable := False;
@@ -1569,25 +1569,28 @@
{******************************************************************************}
{ procedure MSI_AddException(Slot: Integer); }
{ By: Coh3n }
-{ Date: 03 December 2010 }
+{ Date: 06 December 2010 }
{ Description: Adds Slot to the current player's exceptions array }
{******************************************************************************}
procedure MSI_AddException(Item, Slot: Integer);
begin
- // If exception slot already exists, exit
- if (InIntArray(MSI_Exceptions[CurrentPlayer], Slot)) then
- Exit;
+ with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
+ begin
+ // If exception slot already exists, exit
+ if (InIntArray(Exceptions, Slot)) then
+ Exit;
- SetLength(MSI_Exceptions[CurrentPlayer], Length(MSI_Exceptions[CurrentPlayer]) + 1);
- MSI_Exceptions[CurrentPlayer][High(MSI_Exceptions[CurrentPlayer])] := Slot;
+ SetLength(Exceptions, Length(Exceptions) + 1);
+ Exceptions[High(Exceptions)] := Slot;
- // Set the item's inventory slot
- MSI_Items[Item].InvSlot := Slot;
+ // Set the item's inventory slot
+ MSI_Items[Item].InvSlot := Slot;
- ClearSameIntegers(MSI_Exceptions[CurrentPlayer]);
+ ClearSameIntegers(Exceptions);
- MSI_SubDebug('Exception Added: ' + MSI_Items[Item].Name + ' in slot ' + IntToStr(Slot));
- MSI_SubDebug('There are now ' + IntToStr(Length(MSI_Exceptions[CurrentPlayer])) + ' exceptions');
+ MSI_SubDebug('Exception Added: ' + MSI_Items[Item].Name + ' in slot ' + IntToStr(Slot));
+ MSI_SubDebug('There are now ' + IntToStr(Length(Exceptions)) + ' exceptions');
+ end;
end;
{******************************************************************************}
@@ -1678,10 +1681,6 @@
end;
end;
- for i := 0 to High(Result) do
- if (InIntArray(MSI_Exceptions[CurrentPlayer], Result[i])) then
- DeleteValueInIntArray(Result, i);
-
// If the item is stackable and more than one is found, will check uptext to remove bad items
if (MSI_Items[Item].Stackable) then
if (Length(Result) > 1) then
@@ -1825,27 +1824,21 @@
{******************************************************************************}
procedure MSI_DropAll;
var
- exceptions: TIntegerArray;
- i, x, y: Integer;
+ i: Integer;
begin
MSI_AddHeader('MSI_DropAll');
with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
begin
- exceptions := MSI_Exceptions[CurrentPlayer];
-
if (Length(DontDrop) > 0) then
for i := 0 to High(DontDrop) do
- exceptions := CombineIntArray(exceptions, MSI_FindItemSlots(DontDrop[i]));
+ Exceptions := CombineIntArray(Exceptions, MSI_FindItemSlots(DontDrop[i]));
- if (FindCoins(x, y, 'inv')) then
- exceptions := CombineIntArray(exceptions, [CoordsToItem(x, y)]);
-
- ClearSameIntegers(exceptions);
- if (Length(exceptions) <= 0) then
+ ClearSameIntegers(Exceptions);
+ if (Length(Exceptions) <= 0) then
DropAll
else
- DropAllExcept(exceptions);
+ DropAllExcept(Exceptions);
end;
MSI_CloseHeader('MSI_DropAll: Done');
Index: C:/Simba/Includes/MSI/Globals.simba
===================================================================
--- C:/Simba/Includes/MSI/Globals.simba (revision 400)
+++ C:/Simba/Includes/MSI/Globals.simba (revision 401)
@@ -646,7 +646,8 @@
Trees : TIntegerArray;
FishSpots : TIntegerArray;
Priority : TIntegerArray;
- DontDrop : TIntegerArray;
+ DontDrop : TIntegerArray; // The items the user doesn't want dropped/banked
+ Exceptions: TIntegerArray; // The inventory slots the user doesn't want dropped/banked
Loads : Integer; // Not used yet because we don't support multiple scripts
// Magic
@@ -658,7 +659,7 @@
// Not setup by the user
Items : array of TIntegerArray;
MaxCasts : TIntegerArray; // Maximum casts for each spell (calculated in MSI_SetupMagic)
- LeftTree : Boolean; // Used for GE Yews color relocating
+ LeftTree : Boolean; // Used for GE Yews color relocating
end;
TScriptSetupArray = array of TScriptSetup;
@@ -838,7 +839,6 @@
MSI_Obstacles : array[0..OBS_ARRAY_LENGTH] of TObstacle;
MSI_ColorAreas: array[0..AREA_ARRAY_LENGTH] of TMMColorArea;
MSI_WalkInfo : array[0..WALK_ARRAY_LENGTH] of TWalkInfo;
- MSI_Exceptions: array of TIntegerArray;
(**
* The global variables used throughout the stats system (Stats.scar)