3Garrett3
2011-01-02 22:53:40
I have completed this now :D
Here is the Banking.Simba I have prepared.
To explain roughly what I've done, you'll notice that I have a simple NPC opener basically, it will work with the current TMSObjects, which I think would be the best way to implement the NPC.
Here is Globals.Simba:
The only change I've made is to add NPC to the TBank type:
This means that objects do not have to be changed at all, and NPC bankers can be declared the same way a bank booth would, because they act the same. You just need to set the bank type to NPC in the script setup.
Since this is a relatively major update (says NCDS ;)) I would like people to verify whether or not I've done this the most efficient way, and to also comment on the verification of opening the 'bank'. I don't know exactly how to do this the best way, but if FindObject works properly it should indeed work.
Here is the Banking.Simba I have prepared.
{==============================================================================\
| MSI Group Scripting Include |
| Banking.scar |
|==============================================================================|
| All Banking related routines. |
| |
| * function MSI_BankCheck: Boolean; * by MSI Team |
| * function MSI_OpenBank(): Boolean; * by Coh3n |
| * function MSI_Deposit(): Boolean; * by Coh3n |
| * function MSI_Withdraw(): Boolean; * by Naum |
| * function MSI_WithdrawBestTool: Boolean; * by Coh3n |
\_____________________________________________________________________________}
{******************************************************************************}
{ function MSI_OpenBank(...): Boolean; }
{ By: Coh3n }
{ Date: 08 October 2010 }
{ Description: Opens the bank 'which' (refer to bank constants). Will attempt }
{ to relocate if bank isn't found after 15 tries. Valid arguments }
{ for bankType: Bank, DBox or NoBank }
{******************************************************************************}
function MSI_OpenBank(which: Integer; tPin: String): Boolean;
var
t, x, y: Integer;
bankType: TBank;
begin
if (not LoggedIn) then
Exit;
if (BankScreen) then
begin
Result := True;
Exit;
end;
bankType := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType;
if (bankType = NoBank) then
Exit;
try
MSI_AddHeader('MSI_OpenBank');
t := 0;
repeat
Inc(t);
if (bankType = Bank) then
begin
if (MSI_FindObject(which, ClickRight)) then
begin
if WaitFunc(@PinScreen, 100, 1000) then
if (Length(tPin) = 4) then
InPin(tPin)
else
begin
MSI_Debug(MSI_Players[CurrentPlayer].Nick+': PIN is incorrect.');
Exit;
end;
Result := WaitFunc(@BankScreen, 200, 10000);
end;
end else
if (bankType = DBox) then
if (MSI_FindObject(which, ClickLeft)) then
Result := WaitFunc(@DepositScreen, 200, 10000);
if (t = 15) then
begin
SymbolAccuracy := BANK_SYMBOL_ACCURACY;
if (FindSymbol(x, y, 'bank')) then
begin
Mouse(x, y, 5, 5, True);
MSI_Flag;
Wait(RandomRange(250, 750));
end;
SymbolAccuracy := 0.8;
end;
until(Result or (t >= 30));
finally
MSI_CloseHeader('MSI_OpenBank: ' + BoolToStr(Result) + '(' + MSI_Objects[which].Name + ')');
end;
end;
{******************************************************************************}
{ function MSI_BankNPC(...): Boolean; }
{ By: 3Garrett3 }
{ Date: 03 January 2011 }
{ Description: 'Banks' at the NPC 'which' (refer to bank constants). }
{******************************************************************************}
function MSI_BankNPC(which : Integer) : Boolean;
var
t : Integer;
bankType: TBank;
begin
if (not LoggedIn) then
Exit;
if (BankScreen) then
begin
Result := True;
Exit;
end;
bankType := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType;
if (bankType = NoBank) then
Exit;
try
MSI_AddHeader('MSI_BankNPC');
t := 0;
repeat
Inc(t);
if (bankType = NPC) then
begin
if (MSI_FindObject(which, ClickRight)) then
Result := True;
end else Exit; // If not NPC then shouldn't use this.
until(Result or (t >= 30));
finally
MSI_CloseHeader('MSI_BankNPC: ' + BoolToStr(Result) + '(' + MSI_Objects[which].Name + ')');
end;
end;
{******************************************************************************}
{ function MSI_Deposit(...): Boolean; }
{ By: Coh3n }
{ Date: 25 July 2010 }
{ Description: Deposits all items in the array 'Items'. The 'Amounts' array }
{ corresponds to the Items array. Set as [] to deposit all of }
{ every item. Valid argument for BankType: Bank, DBox, NoBank }
{******************************************************************************}
function MSI_Deposit(Items, Amounts: TIntegerArray; var DepAll: Boolean): Boolean;
var
i, t, x, y: Integer;
b: TBox;
itemsDeposited: TBooleanArray;
slots: TIntegerArray;
s: TStringArray;
begin
if (not LoggedIn) then
Exit;
if (not BankScreen) then
if (not DepositScreen) then
Exit;
MSI_AddHeader('MSI_Deposit');
SetLength(itemsDeposited, Length(Items));
if (Length(Amounts) <= 0) then
begin
SetLength(Amounts, Length(Items));
for i := 0 to High(Amounts) do
Amounts[i] := 28;
end;
if (Length(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions) <= 0) then
begin
Result := DepositAll; // Deposits all if there are no exceptions
DepAll := Result;
if (Result) then
MSI_Debug('Deposited all items in the inventory');
end else begin
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
itemsDeposited[i] := True;
Continue;
end;
if (Length(slots) = 1) then
s := ['osit']
else
s := ['-All'];
if (Amounts[i] >= 28) or (Amounts[i] = 1) then
itemsDeposited[i] := MSI_ClickItemSlot(slots[0], s)
else
if (InIntArray([5, 10], Amounts[i])) then
itemsDeposited[i] := MSI_ClickItemSlot(slots[0], ['-'+IntToStr(Amounts[i])])
else
if (MSI_ClickItemSlot(slots[0], ['-X'])) then
if (WaitColor(254, 401, ClBlack, 0, 1200)) then
begin
TypeSend(IntToStr(Amounts[i]));
itemsDeposited[i] := True;
end;
case MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType of
Bank: b := IntToBox(MIX1, MIY1, MIX2, MIY2);
DBox: b := IntToBox(DBX1, DBY1, DBX2, DBY2);
end;
if (itemsDeposited[i]) then
begin
t := (GetSystemTime + 5000);
// For a lag failsafe; sometimes it takes a while for the items to disappear from the inventory
while (GetSystemTime < t) do
begin
Wait(RandomRange(300, 500));
if (not FindDTM(MSI_Items[Items[i]].DTM, x, y, b.x1, b.y1, b.x2, b.y2)) then
Break;
end;
end;
end;
end;
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
begin
MSI_CloseHeader('MSI_Deposit: ' + BoolToStr(Result) + ' (' + MSI_Items[Items[i]].Name + ')');
Exit;
end else
MSI_Debug('Deposited '+Capitalize(MSI_Items[Items[i]].Name));
Result := True;
end;
MSI_CloseHeader('MSI_Deposit: ' + BoolToStr(Result));
end;
{******************************************************************************}
{ Function MSI_Withdraw(Items, Amount: TIntegerArray): Boolean }
{ By: Coh3n }
{ Date: 06 December 2010 }
{ Description: Withdraws 'Amount' of 'Items' }
{******************************************************************************}
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;
MSI_AddHeader('MSI_Withdraw');
if (Length(Amounts) = 0) then
begin
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;
SetLength(itemsWithdrew, Length(Items));
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));
if (Amounts[i] = 1) then
begin
Mouse(x, y, 4, 4, True);
itemsWithdrew[i] := True;
Continue;
end else
Mouse(x, y, 4, 4, False);
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 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 else
MSI_Debug('Withdrew '+Capitalize(MSI_Items[Items[i]].Name));
Result := True;
MSI_CloseHeader('MSI_Withdraw: ' + BoolToStr(Result));
end;
{******************************************************************************}
{ function MSI_WithdrawBestTool(): Boolean; }
{ By: Coh3n }
{ Date: 06 October 2010 }
{ Description: Withdraws the best tool for the current script }
{******************************************************************************}
function MSI_WithdrawBestTool(): Boolean;
var
i: Integer;
begin
with MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name] do
if (MSI_OpenBank(WhichBank, MSI_Players[CurrentPlayer].Pin)) then
begin
for i := MSI_BestTool downto MSI_WorstTool do
if (MSI_Withdraw([i], [1])) then
begin
Result := True;
Break;
end;
// Equip tool if possible
if (not Result) then
begin
CloseBank;
MSI_Debug('Couldn''t withdraw best tool');
end;
end else
MSI_Debug('Unable to open ' + MSI_Objects[WhichBank].Name);
end;
{******************************************************************************}
{ procedure MSI_CountItems; }
{ By: Coh3n }
{ Date: 07 November 2010 }
{ Description: Counts the materials and calculates the experience gained }
{ from items in the inventory }
{******************************************************************************}
procedure MSI_CountItems;
var
itemCount, expCount, j, k: Integer;
objs: TIntegerArray;
begin
if (not LoggedIn) then
Exit;
GameTab(TAB_INV);
with MSI_Players[CurrentPlayer] do
begin
case (MSI_Scripts[Scripts[CurrentScript].Name].SkillConst) of
SKILL_WOODCUTTING:
objs := Scripts[CurrentScript].Trees;
SKILL_MINING:
objs := Scripts[CurrentScript].Rocks;
SKILL_FISHING:
objs := Scripts[CurrentScript].FishSpots;
SKILL_COOKING:
objs := Scripts[CurrentScript].CookingSpot;
end;
for j := 0 to High(objs) do
for k := 0 to High(ReportInfo.Items[CurrentScript][j]) do
begin
itemCount := CountItems('dtm', MSI_Items[ReportInfo.Items[CurrentScript][j][k]].DTM, []);
expCount := Round(ReportInfo.Experiences[CurrentScript][j][k] * itemCount);
MSI_AddToProggy(PROG_ADD_EXP, -1, -1, expCount); // Adds experience
MSI_AddToProggy(PROG_ADD_ITEMS, j, k, itemCount); // Adds items
MSI_Debug('MSI_CountItems: Found '+IntToStr(itemCount)+' of '+
MSI_Items[ReportInfo.Items[CurrentScript][j][k]].Name+' ('+
IntToStr(expCount) + ' XP)');
end;
end;
end;
{******************************************************************************}
{ function MSI_BankMaterials: Boolean; }
{ By: The MSI Team }
{ Date: 04 August 2010 }
{ Description: Banks the specified materials }
{******************************************************************************}
function MSI_BankMaterials: Boolean;
var
intItems: TIntegerArray;
itemsDeposited: TBooleanArray;
i, x, y: Integer;
depAll: Boolean;
Script: TScript;
b: TBox;
begin
if (not LoggedIn) then
Exit;
MSI_AddHeader('MSI_BankMaterials');
Script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name];
MSI_CountItems;
with MSI_Players[CurrentPlayer] do
begin
SetLength(itemsDeposited, Length(ReportInfo.Items[CurrentScript]));
for i := 0 to High(ReportInfo.Items[CurrentScript]) do
begin
intItems := ReportInfo.Items[CurrentScript][i];
itemsDeposited[i] := MSI_Deposit(intItems, [], depAll);
if (depAll) then
Break;
end;
end;
if (MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType) = NPC then
begin
if (MSI_Players[CurrentPlayer].Location = Script.PathInfo.StartLoc) then
if not BankNPC then
begin
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := 'Failed to open bank: '+MSI_Objects[Script.WhichBank].Name;
Exit;
end;
end else //End NPC banking
begin
if (MSI_Players[CurrentPlayer].Location = Script.PathInfo.StartLoc) then
if (not MSI_OpenBank(Script.WhichBank, MSI_Players[CurrentPlayer].Pin)) then
begin
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := 'Failed to open bank: '+MSI_Objects[Script.WhichBank].Name;
Exit;
end;
// Deposits other items such as gems, or random rewards
for i := 1 to 28 do
begin
if (InIntArray(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Exceptions, i)) then
Continue;
case MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript].Name].BankType of
Bank: b := InvBox(i);
DBox: b := DepositItemBox(i);
end;
if (FindColor(x, y, SRL_OUTLINE_BLACK, b.x1, b.y1, b.x2, b.y2)) then
begin
MMouse(x, y, 5, 5);
if (WaitUptext('osit', 500)) then
if (GetAmount(x, y) > 1) then
begin
Mouse(x, y, 0, 0, False);
WaitOption('osit-All', 500);
end else
Mouse(x, y, 0, 0, True);
Wait(RandomRange(200, 500));
end;
end;
if (not depAll) then
for i := 0 to High(itemsDeposited) do
if (not itemsDeposited[i]) then
begin
Result := False;
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := 'Failed to deposit items';
MSI_CloseHeader('MSI_BankMaterials: ' + BoolToStr(Result));
Exit;
end;
CloseBank;
end; //End all other banking (not NPC)
MSI_AddToProggy(PROG_ADD_LOADS, -1, -1, -1);
Inc(Stats_CustomVars[STATS_BANKS]);
MSI_SendStats;
Result := True;
MSI_CloseHeader('MSI_BankMaterials: ' + BoolToStr(Result));
end; To explain roughly what I've done, you'll notice that I have a simple NPC opener basically, it will work with the current TMSObjects, which I think would be the best way to implement the NPC.
Here is Globals.Simba:
{==============================================================================\
| MSI Group Scripting Include |
| Globals.scar |
|==============================================================================|
| Used to store all necessary global types, consts and vars |
| |
\_____________________________________________________________________________}
(**
* Abbreviations:
* - FS: Fishing Spot
* - GS: General Store
* - GE: Grand Exchange
* - VE: Varrock East
* - VW: Varrock West
* - FW: Falador West
* - FE: Falador East
* - CG: Castle Guards
* - DW: Dark Wizards
* - SO: Stronghold Of *
* - AK: Al Kharid
* - SW: Spinning Wheel
* - LB: Lumby
* - EV: EdgeVille
* - BV: Barbarian Village
* - DB: Draynor Bank
* - RM: Rimmington
* - PS: Port Sarim
* - SV: Seers Village
*)
{==============================================================================\
| Constants |
\==============================================================================}
(**
* The miscellaneous constants
*)
const
ANTI_BAN_CHANCE = 10; // The chance (in %) of performing antiban
BANK_SYMBOL_ACCURACY = 0.45; // The symbol accuracy of the bank
TOLERANCE_FLAG = 15; // The amount of pixels from the flag to player
RANDOM_TIME_PERCENT = 0.20; // The percent of BreakLoads/TotalLoads/BreakTime/TotalTime to use for randomness.
ENERGY_MIN = 0;
ENERGY_MAX = 50;
(**
* All of MSI's suppoted script constants; used in player setup
*)
const
// Woodcutting
SCRIPT_POWER_CHOP = 10;
SCRIPT_VE_TREES = 11;
SCRIPT_VE_OAKS = 12;
SCRIPT_GE_YEWS = 13;
SCRIPT_DB_WILLOWS = 14;
SCRIPT_DB_TREES = 15;
SCRIPT_DB_OAKS = 16;
SCRIPT_RM_YEWS = 17;
SCRIPT_PS_WILLOWS = 18;
SCRIPT_PS_YEWS = 19;
SCRIPT_SV_MAGICS = 20;
SCRIPT_SV_MAPLES = 21;
SCRIPT_SV_YEWS = 22;
SCRIPT_EV_YEWS = 23;
// Mining
SCRIPT_POWER_MINER = 30;
SCRIPT_VE_MINER = 31;
SCRIPT_VW_MINER = 32;
SCRIPT_LSW_MINER = 33;
SCRIPT_BBV_MINER = 34;
SCRIPT_RM_CLAY = 35;
SCRIPT_RM_TIN = 36;
SCRIPT_RM_COPPER = 37;
SCRIPT_RM_IRON_1 = 38;
SCRIPT_RM_IRON_2 = 39;
SCRIPT_RM_GOLD = 40;
SCRIPT_GUILD_MINER = 41;
// Fishing
SCRIPT_POWER_FISHER = 50;
SCRIPT_DB_FISHER = 51;
SCRIPT_BBV_FISHER = 52;
// Cooking
SCRIPT_AK_COOKER = 70;
// Magic
SCRIPT_ALCHER = 80;
// Fighting
SCRIPT_FIGHTER = 90;
SCRIPT_ARRAY_LENGTH = 90; // Change to the highest script constant
(**
* Constants representing different paths for files used for MSI
*)
const
PATH_PLAYER = IncludePath + 'MSI\Player.txt'; // Path for all the player information
PATH_REMOTE = IncludePath + 'MSI\Remote.txt'; // Path for the player remote information
PATH_REPORT = IncludePath + 'MSI\Progress Reports\'; // Path for progress report
PATH_DEBUG = IncludePath + 'MSI\Debug Logs\'; // Path for debug
PATH_SETTINGS = IncludePath + 'MSI\Settings.txt'; // Path for script settings
PATH_FORM_BITMAPS = IncludePath + 'MSI\MSI\Form\Bitmaps\'; // Path to all the form images
(**
* Represents the stats system's custom variable array indexes
*)
const
STATS_LINK = 'http://scriptmanager.freehostia.com/submit.php';
STATS_LOGINS = 1;
STATS_BANKS = 2;
STATS_LOADS = 3;
STATS_RANDOMS = 4;
STATS_LEVELS = 5;
STATS_EXP = 6;
STATS_LOGS = 7;
STATS_ORES = 8;
STATS_FISH = 9;
STATS_CASTS = 10;
STATS_COOKED = 11;
(**
* Represents all the possible player locations; used for the indexes in
* the MSI_Location global array
*)
const
// Undefined
LOC_POWER_SKILL = 0;
LOC_LOST = 1;
// Varrock
// East
LOC_VE_TREES = 10;
LOC_VE_OAKS = 11;
LOC_VE_BANK = 12;
LOC_VE_MINE = 13;
// West
LOC_VW_BANK = 14;
LOC_VW_MINE = 15;
// Grand Exchange
LOC_GE_BANK = 20;
LOC_GE_YEWS = 21;
// Draynor
LOC_DB_BANK = 30;
LOC_DB_WILLOWS = 31;
LOC_DB_TREES = 32;
LOC_DB_OAKS = 33;
LOC_DB_FISH = 34;
// Rimmington
LOC_RM_YEWS = 40;
LOC_RM_CLAY = 41;
LOC_RM_TIN = 42;
LOC_RM_COPPER = 43;
LOC_RM_IRON_1 = 44;
LOC_RM_IRON_2 = 45;
LOC_RM_GOLD = 46;
// Falador
LOC_FE_BANK = 50;
// Port Sarim
LOC_PS_WILLOWS = 60;
LOC_PS_YEWS = 61;
LOC_PS_DBOX = 62;
// Lumbridge
LOC_LSW_MINE = 70;
LOC_LSE_MINE = 71;
// Edgeville
LOC_EV_BANK = 80;
LOC_EV_YEWS = 81;
// Barbarian Village
LOC_BBV_MINE = 90;
LOC_BBV_FISH = 91;
// Seers Village
LOC_SV_MAGICS = 100;
LOC_SV_BANK = 101;
LOC_SV_MAPLES = 102;
LOC_SV_YEWS = 103;
// Guilds
LOC_GUILD_MINE = 110;
// Al-Kharid
LOC_AK_BANK = 120;
LOC_AK_RANGE = 121;
LOC_ARRAY_LENGTH = 121; // Change to the highest location constant
(**
* Color constants used in MSI's custom autocoloring functions
*)
const
COLOR_ROAD_GENERAL = 6579821;
COLOR_ROAD_VARROCK = 8686729;
COLOR_ROAD_FALLY = 7831173;
COLOR_ROAD_LUMBY = 8225677;
COLOR_ROAD_DRAYNOR = 7171953;
COLOR_ROAD_DIRT = 1853272;
COLOR_BANKER = 1179390;
COLOR_WATER = 10850700;
COLOR_ROCK = 5789528;
COLOR_TREE = 1532978;
COLOR_SAND = 0;
COLOR_DB_BANK_FLOOR = 3026991;
COLOR_NPC = 195836;
COLOR_GE_FLOOR = 5600640;
COLOR_GE_PATH = 6720921;
COLOR_PS_PATH = 1324616;
COLOR_PS_WILLOW_MM = 1063963;
(**
* The different color walking points; used similar to reflection paths where
* instead of a TPointArray (or TTileArray), it's a TIntegerArray
*)
const
WALK_WC_VE_TREE_1 = 0;
WALK_WC_VE_TREE_2 = 1;
WALK_WC_VE_TREE_3 = 2;
WALK_WC_VE_TREE_4 = 3;
WALK_WC_VE_OAKS_1 = 4;
WALK_WC_VE_OAKS_2 = 5;
WALK_WC_VE_BANK_1 = 6;
WALK_WC_VE_BANK_2 = 7;
WALK_WC_VE_BANK_3 = 8;
WALK_WC_VE_BANK_4 = 9;
WALK_WC_DB_WILLOWS_1 = 10;
WALK_WC_DB_WILLOWS_BANK_1 = 11;
WALK_MINE_LSW_1 = 12;
WALK_MINE_LSW_2 = 13;
WALK_MINE_LSW_3 = 14;
WALK_MINE_LSW_4 = 15;
WALK_MINE_LSW_5 = 16;
WALK_MINE_LSW_6 = 17;
WALK_MINE_LSW_7 = 18;
WALK_MINE_LSW_8 = 19;
WALK_MINE_LSW_BANK_1 = 20;
WALK_MINE_LSW_BANK_2 = 21;
WALK_MINE_LSW_BANK_3 = 22;
WALK_MINE_LSW_BANK_4 = 23;
WALK_MINE_LSW_BANK_5 = 24;
WALK_MINE_LSW_BANK_6 = 25;
WALK_MINE_LSW_BANK_7 = 26;
WALK_FISH_DB_1 = 27;
WALK_FISH_DB_BANK_1 = 28;
WALK_WC_GE_YEW_1 = 29;
WALK_WC_GE_YEW_2 = 30;
WALK_WC_GE_YEW_3 = 31;
WALK_WC_GE_YEW_BANK_1 = 32;
WALK_WC_GE_YEW_BANK_2 = 33;
WALK_WC_GE_YEW_BANK_3 = 34;
WALK_WC_PS_WILLOW_1 = 35;
WALK_WC_PS_WILLOW_2 = 36;
WALK_WC_PS_WILLOW_BANK_1 = 37;
WALK_WC_PS_WILLOW_BANK_2 = 38;
(**
* All the different indexes for MSI_WalkInfo global variable; each index is
* used in MSI_WalkTPA by 3Garrett3 in Walking_Color.simba
*)
const
WALK_VE_MINE_1 = 10;
WALK_VE_MINE_2 = 11;
WALK_ARRAY_LENGTH = 11; // Change to the highest walk constant
(**
* Constants used for MSI_WalkTPA for splitting and sorting methods
*)
const
SPLIT_TPA_TO_ATPA = 0;
SPLIT_TPA_TO_ATPA_EX = 1;
SPLIT_SPLIT_TPA = 2;
SPLIT_SPLIT_TPA_EX = 3;
SORT_ATPA_FROM = 0;
SORT_FIRST_LARGE = 1;
SORT_FIRST_SMALL = 2;
(**
* All the different color minimap areas used for relocating
*)
const
AREA_GE_YEWS_1 = 10;
AREA_GE_YEWS_2 = 11;
AREA_RM_YEWS_1 = 20;
AREA_RM_YEWS_2 = 21;
AREA_EV_YEWS_1 = 30;
AREA_EV_YEWS_2 = 31;
AREA_ARRAY_LENGTH = 31; // Change to the highest area constant
(**
* Constants used for (D)DTMs in ItemInfo.scar; each point constant corresponds
* to the TPointArray returned in MSI_GetDTMPoints();
*)
const
DTM_TOLERANCE = 15;
DTM_POINT_1 = 0;
DTM_POINT_2 = 1;
DTM_POINT_3 = 2;
DTM_POINT_4 = 3;
DTM_POINT_5 = 4;
(**
* Represents the required level to use the different tools
*)
const
// Hatchets and pickaxes
REQ_BRONZE = 1;
REQ_IRON = 1;
REQ_STEEL = 6;
REQ_MITHRIL = 21;
REQ_ADAMANT = 31;
REQ_RUNE = 41;
REQ_DRAGON = 61;
REQ_MAX_LEVEL = 99;
(**
* All the different items used throughout the MSI scripts
*)
const
PICKAXE_BRONZE = 10;
PICKAXE_IRON = 11;
PICKAXE_STEEL = 12;
PICKAXE_MITHRIL = 13;
PICKAXE_ADAMANT = 14;
PICKAXE_RUNE = 15;
PICKAXE_DRAGON = 16;
HATCHET_BRONZE = 20;
HATCHET_IRON = 21;
HATCHET_STEEL = 22;
HATCHET_MITHRIL = 23;
HATCHET_ADAMANT = 24;
HATCHET_RUNE = 25;
HATCHET_DRAGON = 26;
LOGS_NORMAL = 30;
LOGS_OAK = 31;
LOGS_WILLOW = 32;
LOGS_MAPLE = 33;
LOGS_YEW = 34;
LOGS_MAGIC = 35;
ORE_CLAY = 40;
ORE_COPPER = 41;
ORE_TIN = 42;
ORE_IRON = 43;
ORE_SILVER = 44;
ORE_COAL = 45;
ORE_GOLD = 46;
ORE_MITHRIL = 47;
ORE_ADAMANTITE = 48;
ORE_RUNITE = 49;
FISH_SMALLNET = 60;
FISH_CAGE_CRAYFISH = 61;
FISH_ROD_BAIT = 62;
FISH_BAIT = 63;
FISH_ROD_FLY = 64;
FISH_HARPOON = 65;
FISH_POT_LOBSTER = 66;
FISH_RAW_SHRIMP = 70;
FISH_RAW_CRAYFISH = 71;
FISH_RAW_SARDINE = 72;
FISH_RAW_HERRING = 73;
FISH_RAW_ANCHOVIE = 74;
FISH_RAW_TROUT = 75;
FISH_RAW_PIKE = 76;
FISH_RAW_SALMON = 77;
FISH_RAW_TUNA = 78;
FISH_RAW_LOBSTER = 79;
FISH_RAW_SWORDFISH = 80;
FISH_COOKED_SHRIMP = 100;
FISH_COOKED_CRAYFISH = 101;
FISH_COOKED_SARDINE = 102;
FISH_COOKED_HERRING = 103;
FISH_COOKED_ANCHOVIE = 104;
FISH_COOKED_TROUT = 105;
FISH_COOKED_PIKE = 106;
FISH_COOKED_SALMON = 107;
FISH_COOKED_TUNA = 108;
FISH_COOKED_LOBSTER = 109;
FISH_COOKED_SWORDFISH = 110;
GEM_UNCUT_SAPPHIRE = 120;
GEM_UNCUT_EMERALD = 121;
GEM_UNCUT_RUBY = 122;
GEM_UNCUT_DIAMOND = 123;
MISC_BIRD_NEST = 130;
MISC_FEATHER = 131;
STAFF_AIR = 150;
STAFF_WATER = 151;
STAFF_EARTH = 152;
STAFF_FIRE = 153;
// These constants have to match the rune constants in SRL's magic.simba
MSI_RUNE_AIR = 160; // Has 'MSI_' because there are other rune constants in SRL
MSI_RUNE_BODY = 161;
MSI_RUNE_MIND = 162;
MSI_RUNE_EARTH = 163;
MSI_RUNE_FIRE = 164;
MSI_RUNE_WATER = 165;
MSI_RUNE_CHAOS = 166;
MSI_RUNE_LAW = 167;
MSI_RUNE_COSMIC = 168;
MSI_RUNE_DEATH = 169;
MSI_RUNE_NATURE = 170;
MSI_RUNE_BLOOD = 171;
MSI_RUNE_SOUL = 172;
MSI_RUNE_ASTRAL = 173;
ITEM_ARRAY_LENGTH = 173; // Change to the highest item constant
(**
* All the different objects used throughout the MSI scripts
*)
const
// Trees
TREE_NORMAL = 10;
TREE_OAK = 11;
TREE_WILLOW = 12;
TREE_MAPLE = 13;
TREE_YEW = 14;
TREE_MAGIC = 15;
// Rocks
ROCK_CLAY = 20;
ROCK_TIN = 21;
ROCK_COPPER = 22;
ROCK_IRON = 23;
ROCK_SILVER = 24;
ROCK_COAL = 25;
ROCK_GOLD = 26;
ROCK_MITHRIL = 27;
ROCK_ADAMANTITE = 28;
ROCK_RUNITE = 29;
// Banks; includes the 'MSI_' because there are bank constants in SRL's Bank.scar
MSI_BANK_VE = 30;
MSI_BANK_VW = 31;
MSI_BANK_DB = 32;
MSI_BANK_GE = 33;
MSI_BANK_FE = 34;
MSI_BANK_EV = 35;
MSI_BANK_SV = 36;
MSI_BANK_AK = 37;
DBOX_PS = 40;
// Fishing spots
FISHSPOT_NET = 50;
FISHSPOT_BAIT = 51;
FISHSPOT_LURE = 52;
FISHSPOT_CAGE = 53;
FISHSPOT_HARPOON = 54;
// Cooking spots
COOKSPOT_FIRE = 60;
COOKSPOT_RANGE = 61;
COOKSPOT_EITHER = 62;
// Obstacles
LADDER_DOWN_MINE_GUILD = 70;
LADDER_UP_MINE_GUILD = 80;
// NPCs
NPC_CHICKEN_WHITE = 90;
NPC_CHICKEN_BROWN = 91;
NPC_RAT_GIANT = 92;
// Misc Objects
OBJ_BIRD_NEST = 100;
BIRD_NEST_CBMESSAGE = 'nest falls out of';
LOOT_FEATHERS = 101;
OBJ_ARRAY_LENGTH = 101; // Change to the highest object constant
(**
* Constants representing all the different MSI obstacles
*)
const
OBS_LADDER_DOWN_MINE_GUILD = 10;
OBS_LADDER_UP_MINE_GUILD = 20;
OBS_ARRAY_LENGTH = 20; // Change to the highest obstacle constant
(**
* Constants representing all the different spells
*)
const
ALCH_COIN_MESSAGE = 'oins are';
SPELL_WIND_STRIKE = 0;
SPELL_WIND_BOLT = 1;
SPELL_WIND_BLAST = 2;
SPELL_WIND_WAVE = 3;
SPELL_WATER_STRIKE = 4;
SPELL_WATER_BOLT = 5;
SPELL_WATER_BLAST = 6;
SPELL_WATER_WAVE = 7;
SPELL_EARTH_STRIKE = 8;
SPELL_EARTH_BOLT = 9;
SPELL_EARTH_BLAST = 10;
SPELL_EARTH_WAVE = 11;
SPELL_FIRE_STRIKE = 12;
SPELL_FIRE_BOLT = 13;
SPELL_FIRE_BLAST = 14;
SPELL_FIRE_WAVE = 15;
SPELL_CONFUSE = 16;
SPELL_WEAKEN = 17;
SPELL_CURSE = 18;
SPELL_BIND = 19;
SPELL_TELE_HOME = 20;
SPELL_TELE_VARROCK = 21;
SPELL_TELE_LUMBRIDGE = 22;
SPELL_TELE_FALADOR = 23;
SPELL_ALCH_LOW = 24;
SPELL_ALCH_HIGH = 25;
SPELL_TELEGRAB = 26;
SPELL_SUPERHEAT = 27;
(**
* Constants representing every recipes there is.
*)
const
RECIPE_SHRIMP = 0;
RECIPE_CRAYFISH = 1;
RECIPE_SARDINE = 2;
RECIPE_HERRING = 3;
RECIPE_ANCHOVIE = 4;
RECIPE_TROUT = 5;
RECIPE_PIKE = 6;
RECIPE_SALMON = 7;
RECIPE_TUNA = 8;
RECIPE_LOBSTER = 9;
RECIPE_SWORDFISH = 10;
RECIPES_ARRAY_LENGTH = 11;
(**
* Used in MSI_AddToProggy in Debug.scar to determine what to add to the
* progress report
*)
const
PROG_ADD_EXP = 0;
PROG_ADD_ITEMS = 1;
PROG_ADD_LOADS = 2;
PROG_ADD_CASTS = 3;
(**
* Used for any array indexes in DeclarePlayers
*)
const
L_BREAK = 0;
L_TOTAL = 1;
L_COUNT = 2;
(**
* Stores the indexes of the script setup array
*)
const
// Booleans
SETUP_DEBUG_SMART = 10;
SETUP_SAVE_DEBUG = 11;
SETUP_HUMAN_BREAK = 12;
SETUP_SWITCH_WORLDS = 13;
// Integers
SETUP_BREAK_TIME = 20;
SETUP_DEBUG_LEVEL = 21;
SETUP_ANTIBAN_WAIT = 22;
SETUP_RANDOMS_WAIT = 23;
// Strings
SETUP_STATS_ID = 30;
SETUP_STATS_PASS = 31;
SETUP_ARRAY_LENGTH = 31;
{==============================================================================\
| Types |
\==============================================================================}
(**
* The type that holds all the attributes of any main screen objects used
* throughout MSI scripts
*)
type
TMSObject = record
X, Y : Integer;
Name : string;
UpText : string; // Set to '' if RightClickOnly := True
Option : string;
Exp : Extended;
Colors : TIntegerArray;
FindAllColors : Boolean; // Result False if not ALL colors are found
Tol : Integer;
Hue : Extended;
Sat : Extended;
W, H : Integer;
Accuracy : Integer; // Min pixels to be found
ExcludeSelf : Boolean; // Exclude pixels in a box, the box might need revamping / making it dynamic
RightClickOnly : Boolean;
Tries : Integer;
Anim : Boolean; // Result False if not animating
WaitToMove : Boolean; // When ClickLeft, wait till we have stopped moving?
BadColors : TIntegerArray;
BadColorTolerance: Integer;
AssociatedItems : TIntegerArray;
end;
TMSObjectArray = array of TMSObject;
(**
* Stores all the attributes of each item used in MSI scripts
*)
type
TItem = record
Name : string;
UpText : TStringArray;
InvSlot : Integer;
Stackable: Boolean;
Colors : TIntegerArray;
Tol : Integer;
DTM : Integer;
BlackList: Integer;
end;
TItemArray = array of TItem;
(**
* Stores all the attributes of each recipe.
*)
type
TRecipe = record
Name : string;
Ingredients : TIntegerArray;
Produces : TIntegerArray;
MemberOnly : Boolean;
Level : Integer;
CookingSpot : Integer;
end;
TRecipeArray = array of TRecipe;
(**
* Used in the banking functions to determine the type of bank
*)
type
TBank = (Bank, DBox, NoBank, Drop, NPC);
(**
* Used when setting up magic scripts to determine which staff to use
*)
type
TStaffType = (LeastCasts, MostCasts, Cheapest);
(**
* Stores all the different path information. Used in the TScript type
*)
type
TPath = record
StartLoc : Integer;
EndLoc : Integer;
Reflection : T2DPointArray;
ColorTo : TIntegerArray;
ColorFrom : TIntegerArray;
Obstacles : TIntegerArray;
end;
(**
* Used to make it easier for users to setup and for scripters to follow the
* code around the include
*)
type
TScriptSetup = record
Name : Integer;
MaxLevel : Integer; // The level you want to stop autoing at (not working yet)
// Woodcutting, Mining, and Fishing
Rocks : TIntegerArray;
Trees : TIntegerArray;
FishSpots : TIntegerArray;
CookingSpot : TIntegerArray;
Recipe : Integer;
Priority : 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
Time : Integer; // Also not used yet until we have multiple script support
// Magic
Spells : TIntegerArray;
Staffs : TIntegerArray;
StaffType : TStaffType;
AlchSlots : TIntegerArray;
// Fighting
Monsters : TIntegerArray;
Loot : TIntegerArray;
RunDirection : String;
// 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
end;
TScriptSetupArray = array of TScriptSetup;
(**
* Stores all the necessary script information for ease of adding new scripts
*)
type
TScript = record
Name : string;
Constant : Integer;
SkillName : string;
SkillConst : Integer;
BankType : TBank;
WhichBank : Integer;
ClickClosest: Boolean;
AutoObjects : function: Boolean;
BankObjects : function: Boolean;
PlayerSetup : function: Boolean;
Defaults : TScriptSetup;
PathInfo : TPath;
end;
TScriptArray = array of TScript;
(**
* Stores the necessary information for a player's progress report; used in
* the TPlayerInfo type only
*)
type
TProggy = record
LoadsDone : Integer;
PlayerTime : Integer;
ScriptTimes : TIntegerArray; // Time for each script
SkillLevels : TIntegerArray; // Skill level for each script
GainedExps : TIntegerArray; // Exp gained for each script
ScriptCounts : TIntegerArray; // Counts for each script (i.e. loads, casts, kills)
FalseReason : string;
// Script | Object | Multiple per object
Items : array of array of TIntegerArray; // Logs, drop items, ores, fish, etc.
ItemAmounts : array of array of TIntegerArray;
Experiences : array of array of TExtendedArray; // Item, object (depending on skill)
Casts : array of TIntegerArray; // Number of casts per spell
end;
TProggyArray = array of TProggy;
(**
* MSI's custom player record; used to setup each player. TUser can be found in
* SRL (Players.scar)
*)
type
TPlayerInfo = record
Name : string;
Pass : string;
Nick : string;
Pin : string;
Active : Boolean;
Member : Boolean;
Location : Integer;
TotalLoads : Integer;
BreakLoads : Integer;
TotalTime : Integer;
BreakTime : Integer;
Scripts : TScriptSetupArray;
// Not setup by the user
ReportInfo : TProggy;
end;
TPlayerInfoArray = array of TPlayerInfo;
(**
* A record that stores all the properties of the different MSI player
* locations. Used in the MSI relocater
*)
type
TLocation = record
Name : string;
Constant : Integer;
AtBank : Boolean;
RelocatePoints: TPointArray; // Reflection tiles
RelocateAreas : TIntegerArray; // Area constants
RelocateDist : Integer; // Min distance (in pixels) for the player to be from the relocation point
end;
(**
* A record that stores all the color properties for relocating to certain
* locations. Used in the MSI relocater
*)
type
TMMColorArea = record
Name : string;
Symbol : string;
DTM : Integer;
W, H : Integer;
Colors : TIntegerArray;
Tolerances : TIntegerArray;
Counts : TIntegerArray;
Bounds : TBox;
end;
TMMColorAreaArray = array of TMMColorArea;
(**
* A record that stores all the color properties for individual points for
* walking paths
*)
type
TWalkInfo = record
Name : string;
Color : Integer;
Tolerance : Integer;
SplitMethod : Integer; // See the split method constants
SortMethod : Integer; // See the sort method constants
Filter : Boolean; // Use FilterPointsPie?
CTS2 : Boolean; // Use ColorToleranceSpeed 2?
HueMod : Extended;
SatMod : Extended;
StartRadial : Integer;
EndRadial : Integer;
MinRadius : Integer;
MaxRadius : Integer;
SortPoint : TPoint; // Point to sort from (for SortTPAFrom only)
SplitDist : Integer; // For TPAToATPA/SplitTPA only
W, H : Integer; // For TPAToATPAEx/SplitTPAEx only
end;
TWalkInfoArray = array of TWalkInfo;
(**
* A record that stores all the necessary information for the many obstacles
* around Runescape
*)
type
TObstacle = record
Name : string;
Constant : Integer; // Obstacle constant
MirConst : Integer; // Obstacle's mirror constant
ObjConst : Integer; // Object constant
ObjMir : Integer; // Object's mirror constant
StartTiles : TPointArray; // The tiles the obstacle is on
EndTiles : TPointArray; // Possible tiles the player will end up on
Solve : function(i: Integer): Boolean;
end;
TObstacleArray = array of TObstacle;
{==============================================================================\
| Variables |
\==============================================================================}
(**
* Miscellaneous variables used throughout the include
*)
var
CurrentScript : Integer;
ReflectionBroken : Boolean;
MSIRev : string;
ScriptStart : string;
NextAntiban : Integer;
NextRandCheck : Integer;
MSI_SetupVars : array[0..SETUP_ARRAY_LENGTH] of Variant;
// Temporary array to hopefully increase the amount of random detection (called only in MSI_Relocate)
RelocateAttempts : TIntegerArray;
(**
* Arrays that store all the necessary "go-to" information for MSI
*)
var
MSI_Players : TPlayerInfoArray;
MSI_Items : array[0..ITEM_ARRAY_LENGTH] of TItem;
MSI_Objects : array[0..OBJ_ARRAY_LENGTH] of TMSObject;
MSI_Locations : array[0..LOC_ARRAY_LENGTH] of TLocation;
MSI_Scripts : array[0..SCRIPT_ARRAY_LENGTH] of TScript;
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_Recipes : array[0..RECIPES_ARRAY_LENGTH] of TRecipe;
(**
* The global variables used throughout the stats system (Stats.scar)
*)
var
Stats_UserID : string;
Stats_Password : string;
Stats_ScriptID : string;
Stats_LastTime : Integer;
Stats_CustomVars: array [1..20] of Integer;
The only change I've made is to add NPC to the TBank type:
type
TBank = (Bank, DBox, NoBank, Drop, NPC);This means that objects do not have to be changed at all, and NPC bankers can be declared the same way a bank booth would, because they act the same. You just need to set the bank type to NPC in the script setup.
Since this is a relatively major update (says NCDS ;)) I would like people to verify whether or not I've done this the most efficient way, and to also comment on the verification of opening the 'bank'. I don't know exactly how to do this the best way, but if FindObject works properly it should indeed work.