i need a function to walk to bank, deposit empty jug and withdraw jug of wine, and walk back pls.
also which part shd i edit/del to remove tool detection in the code below (yet ensuring the script works):
thanks v much!
function MSI_SetupFishing(): Boolean;
var
i, j, t, x, y: Integer;
tools, intObjs, newObjs: TIntegerArray;
toWithdraw: array of TIntegerArray;
objReady: TBooleanArray;
curScript: TScript;
fishSpot: TMSObject;
b, canBank, found: Boolean;
begin
if (not LoggedIn) then
Exit;
MSI_AddHeader('MSI_SetupFishing');
with MSI_Players[CurrentPlayer] do
begin
SetLength(objReady, Length(Scripts[CurrentScript].FishSpots));
SetLength(toWithdraw, Length(Scripts[CurrentScript].FishSpots));
curScript := MSI_Scripts[Scripts[CurrentScript].Name];
intObjs := Scripts[CurrentScript].FishSpots;
MSI_Debug('FishSpots: ' + ToStr(Scripts[CurrentScript].FishSpots));
// Loops through the player objects checking for the required tools for each
for i := 0 to High(intObjs) do
begin
tools := MSI_FishingTools(intObjs[i]); // Gets the required fishing tools for the fishing spot
for j := 0 to High(tools) do
begin
found := MSI_FindTool(tools[j], TAB_INV, x, y);
if (not found) then
if (MSI_Items[tools[j]].EquipLevel > 0) then
found := MSI_FindTool(tools[j], TAB_EQUIP, x, y);
if (not found) then
begin
setLength(toWithdraw[i], length(toWithdraw[i]) + 1);
toWithdraw[i][high(toWithdraw[i])] := tools[j]; // Adds to the array if the tool isn't found
end;
end;
end;
// In a separate loop so it only opens the bank once
for i := 0 to High(intObjs) do
if (Length(toWithdraw[i]) <= 0) then // If all tools are found
objReady[i] := True
else begin // if 1+ tools aren't found
canBank := MSI_Locations[Location].AtBank;
if (not canBank) then
canBank := MSI_WalkPath(curScript.pathInfo, false);
if (canBank) then
if (MSI_OpenBank(curScript.WhichBank, Pin)) then
if (MSI_Withdraw(toWithdraw[i], [])) then
begin
for j := 0 to High(toWithdraw[i]) do
begin
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;
end;
end;
for i := 0 to High(objReady) do
if (objReady[i]) then
begin
setLength(newObjs, length(newObjs) + 1);
newObjs[high(newObjs)] := intObjs[i];
end else begin
fishSpot := MSI_GetObject(intObjs[i]);
MSI_Debug(fishSpot.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;
Result := (Length(Scripts[CurrentScript].FishSpots) > 0);
for i := 0 to High(Scripts[CurrentScript].FishSpots) do
begin
fishSpot := MSI_GetObject(Scripts[CurrentScript].FishSpots[i]);
MSI_Debug('Fishing spot ' + IntToStr(i) + ': ' + fishSpot.name);
end;
if (MSI_Locations[Location].AtBank) or
(MSI_Scripts[Scripts[CurrentScript].Name].BankType = NPC) then
if (InvFull) then
MSI_Scripts[Scripts[CurrentScript].Name].BankObjects();
end;
MSI_CloseHeader('MSI_SetupFishing: ' + BoolToStr(Result));
end;