theipacc
2012-06-02 16:40:43
Sorry if this is not the correct section, but it should be quick if you are creating scripts.
I am using the mobilising armies script by Cephaxz, but the script ends the minigame 1 minute too early when in the minigame.
The full minigame lasts for 30 minutes, but the script is supposed to be set to end the minigame after 4 minutes (killing the player, "suiciding"), which means it should suicide at 26 minutes. The problem is that it suicides at 27 minutes instead of 26, so I do not gain any rank. How can I change the time?
Could someone please help me fix this? I would appreciate it!
Heres the code:
Thanks in advance!
I am using the mobilising armies script by Cephaxz, but the script ends the minigame 1 minute too early when in the minigame.
The full minigame lasts for 30 minutes, but the script is supposed to be set to end the minigame after 4 minutes (killing the player, "suiciding"), which means it should suicide at 26 minutes. The problem is that it suicides at 27 minutes instead of 26, so I do not gain any rank. How can I change the time?
Could someone please help me fix this? I would appreciate it!
Heres the code:
Program FFFFFFFFUUUUUUUUUUUUUUU;
{$I SRL/SRL/Misc/Smart.simba}
{$I SRL/SRL.simba}
{$i srl/srl/misc/paintsmart.simba}
{$i sps/sps.simba}
const
//All = Max investment
//0 = None
INVESTMENT = '0'; {How Much Invest Per Suicide}
var
Sst: Integer;
Ver: string;
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //How many players in the script. (No Need To Touch. For Those Players What You Don't Wan't To Use Put Active := False;)
CurrentPlayer := 0; //Current player in the Players array.
NumberOfPlayers(HowManyPlayers); //Don't change.
with Players[0] do
begin
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Active := True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;
end;
Procedure getposition;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['3_13']);
repeat
wait(1000);
SPS_GetMyPos();
until (false);
end;
//Special unit screen?
//Not working very well, idk why
function SpecialUnitScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 34, 41, 475, 68, 20) > 500;
end;
//Checks minimap
function AfterWaitRoomScreen :Boolean;
begin
Result := CountColorTolerance(0, 573, 37, 679, 129, 0) < 500;
end;
//Walk from recuiter to special units, redo when free
Procedure SpecialUnit;
var
myPath:TPointArray;
begin
writeln('Walking to Special Unit');
SPS_Setup(RUNESCAPE_SURFACE, ['3_13']);
//myPath := [Point(1451, 5359), Point(1451, 5353), Point(1453, 5347), Point(1458, 5343), Point(1464, 5340), Point(1471, 5338), Point(1478, 5335), Point(1484, 5331), Point(1491, 5327), Point(1497, 5322), Point(1501, 5319), Point(1505, 5317), Point(1509, 5314), Point(1516, 5313), Point(1520, 5312)];
//New path, testing
myPath := [Point(1460, 5346), Point(1466, 5345), Point(1470, 5341), Point(1478, 5337), Point(1486, 5335), Point(1492, 5334), Point(1497, 5332), Point(1505, 5326), Point(1512, 5321), Point(1517, 5319)];
SPS_WalkPath(myPath);
//SPS_BlindWalk(Point(1523, 5319));
wait(RandomRange(1000, 1500));
end;
//SPS suck
Procedure WalktoBank;
var
myPath:TPointArray;
begin
writeln('Walking to Bank');
SPS_Setup(RUNESCAPE_SURFACE, ['3_13']);
myPath := [Point(1451, 5358), Point(1452, 5352), Point(1451, 5346), Point(1452, 5340), Point(1451, 5333), Point(1451, 5326), Point(1451, 5319), Point(1448, 5315), Point(1443, 5314)];
SPS_WalkPath(myPath);
while IsMoving do
begin
wait(300);
end;
end;
//Find banker, works everytime if walking success
Procedure FindBanker;
var
a, Tries: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
begin
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.05, 9.40);
if not FindColorsTolerance(TPA, 9794929, MSX1, MSY1, MSX2, MSY2, 8) then
begin
writeln('Cant find banker');
repeat
WalktoBank;
Inc(Tries);
until (FindColorsTolerance(TPA, 9794929, MSX1, MSY1, MSX2, MSY2, 8)) or (Tries = 5);
end;
If (Tries = 5) then
begin
writeln('Cant find banker after 5 times');
TerminateScript;
end;
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 100, 100);
SortATPAFromSize(ATPA, 1000, true);
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
{$IFDEF SMART}
SMART_DrawDotsEx(false, ATPA[a], clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 2, 2);
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Procedure OpeningBank;
begin
if WaitUpTextMulti(['alk', '-to', 'anker'], 3000) then
begin
ClickMouse2(mouse_Right);
WaitOption('ank Bank', 3000);
Flag;
if WaitFunc(@BankScreen, 100, 5000) then
writeln('Opened bank');
end;
end;
Procedure BankFailsafe;
begin
if not BankScreen then
begin
repeat
FindBanker;
OpeningBank;
until BankScreen;
end;
end;
//Set withdrawing 24500 seeds before script start
//Failsafe added
//Withdraw seeds for investment at bank slot 1
Procedure WithdrawSeeds;
begin
MouseBankSlot(1, mouse_Right);
if WaitOption('24500', 5000) then
begin
writeln('Withdrawing');
end else
begin
writeln('No 24500 set or found');
end;
if WaitInvMaxCount(12, 5000) then
begin
writeln('Successfully withdraw seeds');
Exit;
end else
begin
writeln('No seeds yet, withdrawing again');
WithdrawSeeds;
end;
end;
//Banking procedure
Procedure GetBankOpened;
begin
FindBanker;
OpeningBank;
BankFailsafe;
WithdrawSeeds;
end;
//Exchange credit screen
function ExchangeScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 158,43, 352, 58, 20) > 450;
end;
//Confirm exchange
function ConfirmCreditScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 303, 255, 371,278, 20) > 210;
end;
//Failsafe added for waiting players to move away
//Walk to investment guy
Procedure GoToInvest;
var
x, y, I: Integer;
begin
if not FindColorTolerance(x, y, 581337, 653, 60, 694, 87, 50) then
begin
writeln('Cant find NPC');
repeat
wait(1000);
Inc(I);
until (FindColorTolerance(x, y, 581337, 653, 60, 694, 87, 50)) or (I = 60);
if (I = 60) then
begin
writeln('Cant find NPC after 1 minute');
TerminateScript;
end;
end;
writeln('Found NPC guy');
Mouse(x, y, 0, 0, mouse_Left);
wait(RandomRange(1000, 1500));
Flag;
wait(RandomRange(1000, 1500));
end;
//Never fail
//Finds investment guy
Procedure InvestmentGuy;
begin
Mouse(304, 198, 3, 3, mouse_Right);
if WaitOption('nvest', 3000) then
begin
writeln('Found investment guy');
end else
begin
writeln('Trying second find method');
Mouse(299, 167, 3, 3, mouse_Right);
if WaitOption('nvest', 3000) then
begin
writeln('Found investment guy');
end else
begin
writeln('No investment guy found');
TerminateScript;
end;
end;
if WaitFunc(@ExchangeScreen, 100, 5000) then
begin
writeln('Found exchange screen');
Exit;
end else
begin
writeln('Exchange screen not found');
Exit;
end;
end;
Procedure ExchangeFailsafe;
begin
if not ExchangeScreen then
begin
repeat
wait(2000);
InvestmentGuy;
until ExchangeScreen;
end;
end;
Procedure ExchangeCredit;
begin
if ExchangeScreen then
begin
InvMouse(12, mouse_Right);
WaitOption('All', 3000);
MouseBox(420, 133, 486, 155, mouse_Left);
if WaitFunc(@ConfirmCreditScreen, 100, 5000) then
begin
MouseBox(304, 256, 370, 278, mouse_Left);
end;
end;
end;
//From Investment guy to recruiter
Procedure WalktoRecruiter;
var
myPath:TPointArray;
begin
writeln('Walking to Recruiter');
SPS_Setup(RUNESCAPE_SURFACE, ['3_13']);
myPath := [Point(1489, 5317), Point(1483, 5324), Point(1476, 5327), Point(1467, 5332), Point(1461, 5337), Point(1456, 5343), Point(1453, 5348), Point(1453, 5353), Point(1452, 5360), Point(1452, 5365)];
SPS_WalkPath(myPath);
wait(RandomRange(1000,1500));
end;
Procedure Reinvesting;
begin
GoToInvest;
InvestmentGuy;
ExchangeFailsafe;
ExchangeCredit;
end;
//Works everytime now
//Replace special unit screen function
Function FindAddButton :Boolean;
var
a: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
begin
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 0.21);
FindColorsTolerance(TPA, 6516602, 405, 88, 412, 95, 6);
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 15, 15);
SortATPAFromSize(ATPA, 300, true);
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
{$IFDEF SMART}
SMART_DrawDotsEx(false, ATPA[a], clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 2, 2);
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
Result := True
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//Works 98%
//Find and buy cannons
Procedure ContractSpecial;
var
a,t: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
begin
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.56, 6.23);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 14676469, MSX1, MSY1, MSX2, MSY2, 6);
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 15, 15);
//Removing, testing
//Readded, countering clan vex
SortATPAFromSize(ATPA, 500, true);
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
{$IFDEF SMART}
SMART_DrawDotsEx(false, ATPA[a], clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 4, 4);
if WaitUpTextMulti(['pecia', 'l uni'], 2000) then
begin
ClickMouse2(mouse_Left);
writeln('Recontracting special units');
MarkTime(t);
repeat
wait(RandomRange(2000,2500));
if ClickContinue(True, False) then
begin
writeln('Special units full');
Break;
end;
until (FindAddButton) or (TimeFromMark(t) > 10000);
writeln('Found Special Unit Screen');
if TimeFromMark(t) > 10000 then
begin
writeln('Find again');
ContractSpecial;
end;
if FindAddButton then
begin
ClickMouse2(mouse_Left);
ClickMouse2(mouse_Left);
ClickMouse2(mouse_Left);
ClickMouse2(mouse_Left);
ClickMouse2(mouse_Left);
MouseBox(416, 308, 484, 321, mouse_Left);
end;
end else
begin
writeln('Cant find special unit');
writeln('Walking failsafe');
SpecialUnit;
ContractSpecial;
end;
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//Works 95% now
//From special units to ladder, need redo when free
Procedure RuntoLadder;
var
myPath:TPointArray;
begin
SPS_Setup(RUNESCAPE_SURFACE, ['3_13']);
myPath := [Point(1514, 5318), Point(1508, 5326), Point(1503, 5333), Point(1499, 5341), Point(1495, 5347), Point(1492, 5354), Point(1489, 5361), Point(1489, 5367), Point(1490, 5374)];
SPS_WalkPath(myPath);
//SPS_BlindWalk(Point(1491, 5375));
wait(RandomRange(1000, 1500));
end;
procedure SDebug(Debug: string);
begin
Writeln('[' + TheTime + '] - ' + 'Debug: ' + Debug);
end;
function ScenarioScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 20, 29, 474, 47, 20) > 250;
end;
function SiegeScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 20, 29, 474, 47, 20) > 400;
end;
function RecruitScreen :Boolean;
begin
Result := CountColorTolerance(2071039, 21, 14, 466, 34, 20) > 100;
end;
function InvestmentScreen :Boolean;
begin
Result := CountColorTolerance(3512831, 279, 58, 481, 77, 20) > 300;
end;
//For people investing 0
function PlayAnywayScreen :Boolean;
begin
Result := CountColorTolerance(3355647, 55, 94, 469, 156, 30) > 150;
end;
//removed ismoving, buggy
function FindRecruiter :Boolean;
var
TPA: TPointArray;
aTPA : T2DPointArray;
MiddlePoint :TPoint;
Hi, I, TempCTS :Integer;
begin
Flag;
wait(RandomRange(700,1000));
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04, 0.29);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 7492688, MSX1, MSY1, MSX2, MSY2, 19);
If Length(TPA) = 0 Then Exit;
aTPA := TPAToATPAEx(TPA, 5, 5);
SortATPAFromFirstPoint(aTPA, Point(MSCX, MSCY));
Hi := Length(aTPA);
for I := 0 to Hi - 1 do
begin
MiddlePoint := MiddleTPA(aTPA[I]);
MMouse(MiddlePoint.X, MiddlePoint.Y, 2, 2);
If WaitUpTextMulti(['Recr', 'ecru', 'uiter'], 150) then
begin
ClickMouse2(Mouse_Right);
If WaitOptionMulti(['Manage', 'anage', 'nage'], 350) then
begin
Flag;
Result := WaitFunc(@RecruitScreen, RandomRange(100, 250), 3500);
If Result then
Break;
end;
end;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
function OutOfCredits :Boolean;
begin
Result := CountColorTolerance(6710886, 32, 298, 121, 316, 2) > 200;
end;
//Reinvesting support added
function ReSupply :Boolean;
begin
If FindRecruiter then
begin
If OutOfCredits then
begin
SDebug('Out Of Credits. Reinvesting');
WalktoBank;
GetBankOpened;
Reinvesting;
WalktoRecruiter;
FindRecruiter;
end;
Mouse(78, 308, 5, 5, mouse_Left);
Wait(RandomRange(350, 550));
Mouse(327, 226, 5, 5, mouse_Left);
end;
end;
function LadderPointExists(var Ladder :TPoint) :Boolean;
var
TempCTS :Integer;
TPA :TPointArray;
begin
Result := False;
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.64, 3.76);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 536665, MMX1, MMY1, MMX2, MMY2, 3);
FilterPointsDist(TPA, 0, 75.5, MMCX, MMCY);
if Length(TPA) <> 0 then
begin
Ladder := TPA[0];
Result := True;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//Only using for resupply walking from ladder
function Walk(Where :String) :Boolean;
var
LadderPoint :TPoint;
begin
SDebug('Walking To ' + Where);
If LadderPointExists(LadderPoint) then
begin
If Where = 'ReSupply' then
Mouse(LadderPoint.X - 35, LadderPoint.Y - 10, 2, 2, mouse_Left)
else
Mouse(LadderPoint.X, LadderPoint.Y + 5, 2, 2, mouse_Left);
end
else
begin
If Where = 'ReSupply' then
Mouse(601, 86, 2, 2, True)
else
Mouse(664, 96, 2, 2, True)
end;
Flag;
wait(RandomRange(1000,1500));
end;
//Fixed, failsafe added, 1% failure rate
//Fails sometimes
Procedure FindEntrance2;
var
TPA: TPointArray;
aTPA : T2DPointArray;
MP :TPoint;
I, TempCTS :Integer;
begin
Flag;
SDebug('Finding Entrance');
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 2.45);
//Changed colors, size and something else to work better
FindColorsTolerance(TPA, 12376802, MSX1, MSY1, MSX2, MSY2, 8);
aTPA := TPAToATPAEx(TPA, 100, 100);
SortATPAFromSize(ATPA, 5000, true);
for I := 0 to High(ATPA) do
begin
MP := MiddleTPA(aTPA[I]);
{$IFDEF SMART}
SMART_DrawDotsEx(false, ATPA[I], clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 2, 2);
If WaitUpTextMulti(['limb', 'room', 'rance'], 3000) then
begin
writeln('Found entrance');
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
Break;
end;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//flawless now
Procedure ClickingEntrance;
begin
If WaitUpTextMulti(['limb', 'room', 'rance'], 3000) then
begin
ClickMouse2(mouse_Left);
if WaitFunc(@DidRedClick, 10, 5000) then
begin
writeln('Clicked Entrance');
Flag;
Exit;
end else
begin
writeln('Wrong click!');
end;
end;
end;
//Failsafe if not yet resupplied, goes resupply and cannon
Procedure NotResupplied;
begin
wait(1500);
if ClickContinue(True, False) then
begin
writeln('Squads not resupplied');
writeln('Resupplying');
Walk('ReSupply');
ReSupply;
SpecialUnit;
ContractSpecial;
RuntoLadder;
FindEntrance2;
ClickingEntrance
end else
begin
Exit;
end;
end;
Procedure EnteringEntrance;
begin
FindEntrance2;
ClickingEntrance;
NotResupplied;
end;
//Failsafe for entering entrance
Procedure EntranceFailsafe;
begin
if not WaitFunc(@ScenarioScreen, 100, 5000) then
begin
writeln('Entrance failsafe');
repeat
RuntoLadder;
FindEntrance2;
ClickingEntrance;
WaitFunc(@ScenarioScreen, 100, 5000)
until ScenarioScreen;
end else
begin
writeln('Found scenario screen');
Exit;
end;
end;
function FindWall(SP :TPoint) :Boolean;
var
TPA: TPointArray;
aTPA : T2DPointArray;
MiddlePoint :TPoint;
Hi, I, TempCTS :Integer;
begin
MMouse(SP.X, SP.Y, 5, 5);
If WaitUpTextMulti(['Castle', 'astle', 'sle', 'wall'], 2500) then
begin
ClickMouse2(Mouse_Right);
If WaitOptionMulti(['ttack C', 'ack Ca'], 3500) then
begin
Result := True
Exit;
end;
end;
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.58);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 9544365, MSX1, MSY1, MSX2, MSY2, 14);
If Length(TPA) = 0 Then Exit;
aTPA := TPAToATPAEx(TPA, 40, 40);
SortATPAFromFirstPoint(aTPA, SP);
Hi := Length(aTPA);
for I := 0 to Hi - 1 do
begin
MiddlePoint := MiddleTPA(aTPA[I]);
MMouse(MiddlePoint.X, MiddlePoint.Y, 0, 0);
If WaitUpTextMulti(['Castle', 'astle', 'sle', 'wall'], 1500) then
begin
ClickMouse2(Mouse_Right);
If WaitOptionMulti(['ttack C', 'ack Ca'], 3500) then
begin
Result := True
Break;
end;
end;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//Best function made ever, learnt a lot
function GetArmyLocation(var Dir : Integer; var StartPoint :TPoint) : String;
var
DirArr, Colors :TIntegerArray;
I :Integer;
Loc :TStringArray;
TPA :TPointArray;
begin
SDebug('Searching Army Location');
Loc := ['W', 'S', 'E', 'N'];
{Green = 297 Red = 280 Yellow = 280 Blue 270}
Colors := [441136, 592313, 567264, 13504519]
{0 = Up 1 = Right 2 = Down, 3 = Left}
DirArr := [1, 0, 3, 2];
TPA := [Point(359, 117), Point(244, 140), Point(185, 134), Point(280, 220)]
for I := 0 to 3 do
If CountColorTolerance(Colors[I], MCX1, MCY1, MCX2, MCY2, 20) > 100 then
begin
Dir := DirArr[I];
StartPoint := TPA[I];
Result := Loc[I];
SDebug('Location Is ' + Result);
Exit;
end;
end;
//Fixed, never fail anymore
//Fails many times, a bit too advanced for me to read
//Changed this to the beginner way
function MoveToCastle(var SP :TPoint) :String;
var
Loc :String;
Dir, I, C :Integer;
StartPoint :TPoint;
begin
Loc := GetArmyLocation(Dir, StartPoint);
SDebug('Moving To Castle ' + Result);
If Loc = '' then Exit;
If (Loc = 'E') or (Loc = 'W') then
C := 1
else
C := 2;
SDebug('We Need ' + IntToStr(C + 1) + ' Moves');
//Changing this in v16
for I := 0 to C do
begin
SendArrowWait(Dir, RandomRange(200, 250));
wait(RandomRange(500,700));
end;
SP := StartPoint;
Result := Loc;
SDebug('Moved Succesfully');
Wait(RandomRange(500, 700));
end;
function TroopsTab :Boolean;
var
TPA :TPointArray;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.70);
FindColorsTolerance(TPA, 8762062, MIX1, MIY1, MIX2, MIY2, 14);
Result := Length(TPA) > 150;
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
function NotTroopsTab :Boolean;
begin
Result := not TroopsTab;
end;
function WaitTroopsTab(Time :Integer) :Boolean;
var
T :Integer;
begin
If TroopsTab then
begin
Result := True;
Exit;
end;
MarkTime(T);
while (TimeFromMark(T) < Time) do
begin
If Not LoggedIn then Exit;
TypeByte(112);
Wait(RandomRange(250, 355));
if TroopsTab then
begin
Result := True;
Break;
end;
end;
end;
//Fixed, works 99% now
//Need fixing, always left out 1-3 troops
procedure MobiliseArmy;
var
Loc :String;
TPA :TPointArray;
aTPA :T2DPointArray;
MiddlePoint, StartPoint :TPoint;
I, Hi :Integer;
begin
MoveToCastle(StartPoint);
WaitTroopsTab(RandomRange(10000, 15000));
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.70);
FindColorsTolerance(TPA, 8762062, MIX1, MIY1, MIX2, MIY2, 14);
If Length(TPA) <> 0 then
begin
aTPA := TPAtoATPAEx(TPA, 10, 10)
Hi := Length(aTPA);
for I := 0 to Hi - 1 do
begin
aTPA := TPAtoATPAEx(TPA, 10, 10)
{$IFDEF SMART}
SMART_DrawDotsEx(false, ATPA[I], clYellow);
{$ENDIF}
SDebug('Troop ' + IntToStr(I) + ' Attack!');
WaitTroopsTab(RandomRange(10000, 15000));
MiddlePoint := MiddleTPA(aTPA[I]);
Mouse(MiddlePoint.X, MiddlePoint.Y, 3, 3, mouse_Left);
FindWall(StartPoint);
WaitFunc(@NotTroopsTab, RandomRange(25, 50), 10000);
end;
end;
{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
SDebug('All Troops Are Attacking Castle');
end;
function BlackMM(Percent, Time :Integer) :Boolean;
var
T :Integer;
begin
MarkTime(T);
while (TimeFromMark(T) < Time) do
begin
If Not LoggedIn then Exit;
Wait(RandomRange(10, 25));
if PercentBlackMM >= Percent then
begin
Result := True;
Break;
end;
end;
end;
//Rewrote some parts
//Added few new things
function GetIn :Boolean;
begin
EnteringEntrance;
EntranceFailsafe;
Mouse(341, 127, 10, 10, mouse_Left);
if WaitFunc(@SiegeScreen, RandomRange(100, 250), 5000) then
begin
Mouse(438, 294, 5, 5, mouse_Left);
end else
//Stuck here sometimes
begin
writeln('Cant find screen after clicking Siege');
TerminateScript;
{RuntoLadder;
GetIn;}
end;
if WaitFunc(@InvestmentScreen, RandomRange(100, 250), 5000) then
begin
Wait(RandomRange(100, 250));
if (INVESTMENT = 'All') then
begin
writeln('Investing ' + INVESTMENT + ' Points');
MouseBox(232, 114, 257, 128, mouse_Left);
Mouse(385, 303, 5, 5, mouse_Left);
Result := BlackMM(100, 5000);
//testing
if Result then
begin
writeln('Going to waiting room');
Exit;
end else
begin
writeln('Not in waiting room yet');
RuntoLadder;
GetIn;
end;
end;
//Improvements in future, lazy now
if (INVESTMENT = '0') then
begin
writeln('Investing ' + INVESTMENT + ' Points');
Mouse(385, 303, 5, 5, mouse_Left);
repeat
wait(500);
until PlayAnywayScreen;
if PlayAnywayScreen then
MouseBox(127, 179, 225, 203, mouse_Left);
Result := BlackMM(100, 5000);
Exit;
end;
Mouse(284, 209, 5, 5, mouse_Left);
While not GetColor(472, 394) = 0 do
begin
If Not LoggedIn Then Exit;
Wait(RandomRange(300, 450));
end;
Wait(RandomRange(900, 1000));
writeln('Investing ' + INVESTMENT + ' Points');
TypeSend(INVESTMENT);
Mouse(385, 303, 5, 5, mouse_Left);
Result := BlackMM(100, 5000);
end;
end;
//Made a new one
function InBattle :Boolean;
var
I :Integer;
Colors :TIntegerArray;
begin
{Green = 297 Red = 280 Yellow = 280 Blue 270}
{ Colors := [441136, 592313, 567264, 13504519]
for I := 0 to 3 do }
//Changed, chatbox is covered sometimes
if CountColorTolerance(1989103, 678, 176, 698, 198, 20) > 20 then
Result := True;
end;
function MiniGameArea :Boolean;
begin
Result := Length(GetMiniMapDots('NPC')) > 3;
end;
//Removed wait
function WaitRoom :Boolean;
var
T :Integer;
begin
MarkTime(T);
SDebug('In Waiting Room');
while (TimeFromMark(T) < 300000) do
begin
If Not LoggedIn then Exit;
Wait(RandomRange(10, 25));
if InBattle then
begin
Result := True;
SDebug('Out of wait room');
Break;
end;
end;
end;
//Changed function
function SimpleClose :Boolean;
begin
If CountColorTolerance(0, 218, 63, 311, 79, 0) > 200 then
begin
SDebug('Closing Result Screen');
MMouse(457, 57, 3, 3);
If WaitUpTextMulti(['Click', 'ick'], 3500) then
ClickMouse2(mouse_Left);
Wait(RandomRange(500, 600));
end;
end;
//Rewrote without internet, cant test
//simple close removed
Procedure GetLadder2;
var
TPA: TPointArray;
aTPA : T2DPointArray;
MiddlePoint :TPoint;
Hi, I, TempCTS :Integer;
begin
SDebug('Finding MainScreen Ladders');
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.40);
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3557721, MSX1, MSY1, MSX2, MSY2, 13) then
begin
writeln('Cant find ladder color');
TerminateScript;
end;
aTPA := TPAToATPAEx(TPA, 30, 30);
SortATPASize(aTPA, True);
for I := 0 to High(ATPA) do
begin
MiddlePoint := MiddleTPA(aTPA[I]);
MMouse(MiddlePoint.X, MiddlePoint.Y, 2, 2);
If WaitUpTextMulti(['limb', 'tairs', 'up'], 5000) then
begin
writeln('Found ladder uptext, clicking');
ClickMouse2(mouse_Left);
if WaitFunc(@MiniGameArea, 100, 6000) then
begin
writeln('Out of ending room');
Break;
end;
end;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
//Wrote without internet
Procedure LadderFailsafe;
var
Tries: Integer;
begin
if not MiniGameArea then
begin
writeln('Not outside of ending room');
repeat
GetLadder2;
WaitFunc(@MiniGameArea, 100, 3000);
Inc(Tries);
until (MiniGameArea) or (Tries = 20);
end;
end;
Procedure EndingRoom;
begin
SimpleClose;
GetLadder2;
LadderFailsafe;
end;
//Might add the talking in game in future
//Changed, since moving the map while in battle will fail the script
procedure AntiBan;
var r: Integer;
begin
if not LoggedIn then Exit;
r := (RandomRange(1, 14));
if (r = 4) then
begin
SDebug('AntiBan');
case Random(20) of
0:
begin
PickUpMouse;
end;
1:
begin
RandomRClick;
end;
2:
PickUpMouse;
3:
RandomRClick;
4:
MMouse(MIX1, MIY1, MIX2, MIY2);
5:
MMouse(MMX1, MMY1, MMX2, MMY2);
end;
SDebug('Sleeping..');
end;
end;
//Stopped using, number color not fixed
function CannonCountZero :Boolean;
var
x, y: Integer;
begin
Result := FindColorTolerance(x, y, 248, 663, 289, 667, 308, 50);
end;
//Checks if its on the cannon tab
function CannonTab :Boolean;
begin
Result := CountColorTolerance(5689074, 620, 167, 636, 203, 59) > 30;
end;
//Antiban before reach 26 minutes
Procedure WaitforCannon;
begin
AntiBan;
wait(RandomRange(5000, 8000));
end;
//Changed new coordinates for cannon placing
//CANNON TIME!
Procedure CannonTime;
var
Loc :String;
T, Dir, I :Integer;
StartPoint :TPoint;
begin
Loc := GetArmyLocation(Dir, StartPoint);
if Loc = 'W' then
begin
repeat
if not CannonTab then
begin
writeln('Changing to cannon tab');
MouseBox(618, 177, 637, 195, mouse_Left);
wait(RandomRange(500,1000));
end;
MouseBox(559, 235, 589, 267, mouse_move); //Shoot north
if WaitUpTextMulti(['lace', 'anno'], 1500) then
begin
ClickMouse2(mouse_Left);
//mousebox(284, 232, 312, 257, mouse_Left);
//new, testing
MouseBox(285, 308, 314, 328, mouse_Left);
Inc(I);
end;
if I = 5 then
begin
writeln('Used 5 times cannons');
repeat
wait(300);
until not InBattle;
end;
until not InBattle;
writeln('Finished');
if not InBattle then
begin
Wait(RandomRange(1500, 2500));
SDebug('War Is Over!');
Exit;
end;
end;
if Loc = 'S' then
begin
repeat
if not CannonTab then
begin
writeln('Changing to cannon tab');
MouseBox(618, 177, 637, 195, mouse_Left);
wait(RandomRange(500,1000));
if not InBattle then
end;
MouseBox(694, 236, 726, 268, mouse_move); //Shoot west
if WaitUpTextMulti(['lace', 'anno'], 1500) then
begin
ClickMouse2(mouse_Left);
//mousebox(391, 194, 419, 220, mouse_Left);
//New one, testing
MouseBox(463, 196, 493, 215, mouse_Left);
Inc(I);
end;
if I = 5 then
begin
writeln('Used 5 times cannons');
repeat
wait(300);
until not InBattle;
end;
until not InBattle;
writeln('Finished');
if not InBattle then
begin
Wait(RandomRange(1500, 2500));
SDebug('War Is Over!');
Exit;
end;
end;
if Loc = 'E' then
begin
repeat
if not CannonTab then
begin
writeln('Changing to cannon tab');
MouseBox(618, 177, 637, 195, mouse_Left);
wait(RandomRange(500,1000));
end;
MouseBox(559, 235, 589, 267, mouse_move); //Shoot north
if WaitUpTextMulti(['lace', 'anno'], 1500) then
begin
ClickMouse2(mouse_Left);
//mousebox(245, 231, 275, 258, mouse_Left);
mousebox(244, 304, 273, 326, mouse_Left);
Inc(I);
end;
if I = 5 then
begin
writeln('Used 5 times cannons');
repeat
wait(300);
until not InBattle;
end;
until not InBattle;
writeln('Finished');
if not InBattle then
begin
Wait(RandomRange(1500, 2500));
SDebug('War Is Over!');
Exit;
end;
end;
if Loc = 'N' then
begin
repeat
if not CannonTab then
begin
writeln('Changing to cannon tab');
MouseBox(618, 177, 637, 195, mouse_Left);
wait(RandomRange(500,1000));
end;
MouseBox(604, 236, 635, 268, mouse_move); //Shoot east
if WaitUpTextMulti(['lace', 'anno'], 1500) then
begin
ClickMouse2(mouse_Left);
//mousebox(182, 165, 189, 175, mouse_Left);
//new, testing
MouseBox(74, 172, 92, 186, mouse_Left);
Inc(I);
end;
if I = 5 then
begin
writeln('Used 5 times cannons');
repeat
wait(300);
until not InBattle;
end;
until not InBattle;
writeln('Finished');
if not InBattle then
begin
Wait(RandomRange(1500, 2500));
SDebug('War Is Over!');
Exit;
end;
end;
end;
//Cannontab 620, 167, 636, 203. color= 5689074 tol=59
//Cannonleft number 663, 289, 677, 308 color=39168 tol=50
//West 284, 232, 312, 257 Shoot north
//South 391, 194, 419, 220 Shoot west
//East 245, 231, 275, 258 Shoot north
//North 182, 165, 189, 175 Shoot East
//New inside battle procedure
Procedure InsideWar;
var
T: Integer;
begin
if WaitFunc(@AfterWaitRoomScreen, 100, 10000) then
begin
MarkTime(T)
MobiliseArmy;
repeat
WaitforCannon;
if not InBattle then
begin
Wait(RandomRange(1500, 2500));
SDebug('War Is Over!');
Exit;
end;
until TimeFromMark(T) > 180000;
if TimeFromMark(T) > 180000 then
begin
writeln('CANNON TIME!!!');
CannonTime;
end;
end;
end;
procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx, my);
Pic := BitmapFromString(mx, my, '');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], SmallChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;
procedure DoSmartPrint;
var
Wet, Wst, Cst, Srt, Tih, Tim, Tis, Awt, Sec: Integer;
begin
Cst := GetSystemTime;
Srt := (cst - sst) / 1000;
Tih := srt / 3600;
tim := (srt / 60) - tih * 60;
Tis := srt - tim * 60 - tih * 3600;
Awt := wet - wst
Sec := GetTimeRunning div 1000 + 1;
PrintOnSmart([' Home'#39's Mobilising Armies Suicider 0,1 ' + Ver], Point(15, 30), clRed, 131072);
PrintOnSmart([
'Name : ' + Capitalize(Players[CurrentPlayer].Name),
'',
'Suicide Trips / Hour : ' + IntToStr(Round(3600 * Players[CurrentPlayer].Integers[2] / Sec)),
'',
'Suicide Trips Done : ' + IntToStr(Players[CurrentPlayer].Integers[2]),
'',
'Worked : ' + TimeRunning,
'',
''], Point(20, 60), 1959605, 131072)
end;
procedure PlayerStats;
var
Wet, Wst, Cst, Srt, Tih, Tim, Tis, Awt, Sec: Integer;
begin
Cst := GetSystemTime;
Srt := (cst - sst) / 1000;
Tih := srt / 3600;
tim := (srt / 60) - tih * 60;
Tis := srt - tim * 60 - tih * 3600;
Awt := wet - wst
Sec := GetTimeRunning div 1000 + 1;
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln(' Home'#39's Mobilising Armies Suicider 0,1 ');
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
writeln('Name : ' + Capitalize(Players[CurrentPlayer].Name));
Writeln('Suicide Trips / Hour : ' + IntToStr(Round(3600 * Players[CurrentPlayer].Integers[2] / Sec)));
Writeln('Suicide Trips Done : ' + IntToStr(Players[CurrentPlayer].Integers[2]));
Writeln('Worked : ' + TimeRunning);
Writeln('Time : ' + TheTime)
Writeln('-------------------------------------------------------');
end;
procedure ProgressReport;
begin
PlayerStats;
WriteLn(' ');
DoSmartPrint;
end;
procedure checking;
begin
if OutOfCredits then
begin
writeln('Found');
Exit;
end else
begin
writeln('Not found');
Exit;
end;
end;
//Alert sound on termination of script
procedure AlertSound;
begin
PlaySound('C:/Simba/alarm.wav');
end;
Procedure SellSeeds;
begin
repeat
Mouse(476, 301, 5, 5, mouse_Left)
until (false);
end;
begin
ClearDebug;
Smart_Server := 39;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;
//Login to world 76
if not LoggedIn then
begin
repeat
LoginPlayerToLob;
until LobbyScreen;
OpenWorldScreen;
if not WorldScreen then
OpenWorldScreen;
if WorldScreen then
begin
writeln('picking world 76');
SelectWorld(76);
LogInPlayer;
end;
end;
repeat
wait(500);
until LoggedIn;
SMART_ClearCanvas;
SDebug('Welcome To Home''s MA!'); //Not gonna change this lol
ClickNorth(SRL_ANGLE_HIGH);
ExitSquealOfFortune; {Annoying SoF}
//Got the sound from Harry :p
AddOnTerminate('AlertSound');
repeat
RuntoLadder; //Running to the ladder first
GetIn;
WaitRoom;
InsideWar;
EndingRoom;
Inc(Players[CurrentPlayer].Integers[2]);
Walk('ReSupply');
ReSupply;
SpecialUnit;
ContractSpecial;
ProgressReport;
until not LoggedIn;
end.
Thanks in advance!