SRL Archive - Non-RuneScape Scripts

Silly little bot


Flyboy

2012-01-25 11:04:51

Script for Galaxy 2.0 (facebook app)

Target Audience:

  • -SRL forum members
  • -Members of Excessive Corp

Description:
This is a script that simulates a human using the computer, it looks at the screen and based on what it finds, it will move the mouse and click it just like a normal user. As such, programing this is a bit of an art form, very elegant vs the traditional 'bot' approach that simply reads the code directly from the site and sends packets back. Kind of like the difference of hunting game with a bow and arrow vs a 50cal sniper rifle at 3km away…

As of Ver: 0.01.70 this script will attack a range of instances for you. During the battle it will harvest resources, and check your mail, remove box from mail and delete. After it is done that and waiting for battle to end, you can:
-press '6' to end the script
-press '5' and it will open the collected boxes for you (very handy after running all night)

Directions:

  1. -Install Simba (please follow directions and post Simba questions in appropriate category not is this thread). Simba found here http://villavu.com/forum/showthread.php?t=47714
  2. -All Fleet to be sent to instance must be renamed to "Instance-1, Instance-2" and be visible on the first page. Up to 9 fleet may be sent to an instance.
  3. -Move Warehouse (see post below with picture showing where to put it)
  4. -Copy script (bottom of this post) into Simba and save.
  5. -In Simba, read over code lines: 25-136(ver: 0.01.70)
  6. -Personalize the script for your needs in lines: 138, 139, 141
  7. Game MUST be played in HD
  8. -Select the client (see FAQ on how to do this) by dragging green target onto game
  9. -Press Play
  10. -Show gratitude by farming instances Flyboy can't reach yet ;)

Trouble shooting:

  1. -Any questions about installing Simba and setting up SRL, SPS and MSI, or associating file extensions, please read FAQ and post questions there.
  2. -If you keep getting the messages that the bitmaps are not found, please adjust your computer as close as possible to my configuration as it works flawlessly on mine.
  3. -If you continue to have problems with finding bitmaps go to script line 143 and set it to <TestBitmaps := true;> then run the script as normal with the console window visible as it will give you instructions to follow, pressing <6> to continue script after you have completed instructions. When done, click on the wide window at the bottom of Simba and press <ctrl> + <a> (select all) then <ctrl> + <c> (copy). Please post your problem here stating: Operating System, Browser used, Resolution of monitor, number of screens, Script version used (ie: Ver: 0.01.70), and then paste the bit you copied into <Code> brackets.

Script is tuned to run on these specs:

  • OS: Windows 7 pro
  • browser: Firefox
  • screen: 1680 x 1050
  • # of screens: 1

Enjoy!

version: 0.02.02

Script:

{******************************************************************************
Jump down to blue text below and read
******************************************************************************}
program new;
var
Debug, TestBitmaps, TestProcedure, GetCommander: Boolean; //Control switches
He3: Boolean; //Error Triggers -End Script
bmpEnvolope, bmpSpaceStation, bmpSSUpgrade, bmpInstance: Integer; //Bitmaps
bmp03, bmp05, bmp06, bmpIncreaseFleet, bmpGoToGround, bmpWarehouse: Integer;
bmpBoxInBag, bmpHarvest, bmpGoToSpace, bmpZero, bmpClose: Integer;
bmpBox, bmpUse, bmpBackToBag, bmpOpenInventory, bmpCloseBag: Integer;
bmpAttackResultPage, bmpMailStillHasBoxOK, bmpMskRW: Integer;
mskRW: TMask;
x, y, x1, y1, x2, y2: Integer;
Tol, ContTol, TimeMouseMoved: Integer;
iLow, iHigh, MaxFleet: integer; //instance to attack
i01, i02, i03, i04, i05, i06, i07, i08, i09, i10: Integer;

Params: TVariantArray;
Report3, Report5, Report6, ReportLastAttack: Integer;
mStart, mEnd: String;
Report: Array[1..30] of Integer;

Procedure Init;
begin

{******************************************************************************
*******************************************************************************
Start Reading here!!!!
-------------------------------------------------------------------------------

GalaxyII AutoBot
by Flyboy
version: 0.02.02
Script to run on Simba revision 982
Copywrite Flyboy@2012

Directions:
1. **IMPORTANT** Place the Resource Warehouse on the boarder, 4th square to
the left of the Top Center corner with no building beside it.
2. Open Empire II in high Def.
3. Size window so entire playing area is visible
4. Rename Fleet you want to send: Instance-1, Instance-2 etc. in order you
want them sent in.
***Note this version only looks for Fleet on 1st page***
4. Open Simba on the same monitor as the game (if you have multiple monitors)
5. Move Simba window so you can see some of the game at the same time.
6. move and rezise the black console window so you can see all of it when the
game window is the active window
7. Save this script in the Script folder ..\Simba\script
9. Open the script <File->Open->most current version of this script
10. click on the target (Green Target in the tool bar above) and drag it onto
the game
11. click Play (tool bar -> the green arrow)
12. Go do something useful while the bot plays the game for you.
13. press '6' to end the script.
14. press '5' to open all the boxes you collected.
****if you press '5' to open boxes. WARNIGj. it only looks on the first
page of your inventory.

To Do:
-test He3 low detection
->mWait: instanse report
->mWait: Friend request accepted
->mWait: disconnected
-mWait: Add iReportDetected: Boolean, add sensor Function and refer to it during
waits/sleeps
->mWait: ???
-mWait: Include into custom wait a procedure that keeps computer from going to sleep
-mWait: Add Error correction.
->if something screws up game... deal with it and get back to fighting
-dynamicly set window dimentions
-make possible to load fleet greater than 9 ships, flip pages
-Add Version number, date, time to TestBitmaps output (1st line)
-Find Procedure to find Wearhouse
-make find fleet able to search multi pages of fleet

Development log:
0.02.02
-Find/Center Procedure that can center <Space Station> or <Wearhouse>
-Fixed mouse twitch to keep computer awake
-Fixed GoToSpace... was clicking on... who knows where??? lol
-Added Recruit Commander, allows you to hire common commanders
0.02.01
-mWait: Keep computer awake. Twitch mouse ever 3 minutes
-Added bmp to find Space Station when under construction (grey)

0.02.00
-called script with Try..Finally, this should guarantee freeing memory if crash
-fixed Report Last Attack
-added new wait procedure that will be used to test for all Errors
-rewrote structure of Failsafe
-moved testing for user input (5 or 6) to mWait, now you can open <5> boxes
anytime or end script <6> anytime
-added Check for He3 prior to sending out fleet.
-Cranked default tol up to 25... hopefully that should get most up and going.
-Changed Mail box opener... click on button instead of box.
Now it handles Sales, and Failed Sales mail.
-reset some of the wait times
0.01.70
-Changed constants to variables so user can select instance etc.
-Updated header to make user friendly variable changing possible
-Add Max # fleet to send out
-should send whichever # is lowest (Max Fleet, Fleet for Instance)
-Limit Mail to only open 3 mail per cycle
-While opening mail or boxes must handle end of instence screen.
-Fix Report now that it can do Instance 1-30
-Find Fleet by seaching for Name of fleet on 1st page ONLY
-make possible to load fleet of 9 ships
-convert bmps to txt
0.01.6
-add tolerance to bitmap searches
-confirm open boxes still works with new bitmap
-at start of each cycle, click on gotospace
-make possible to attack any insidence
0.01.5
-Confirmed all bitmaps working correctly
-changed open mail from icon clicking to using toolbar at bottom
-Fixed method of finding boxes in mail
-Changed Attack Report detection
0.01.4
-Due to complaints that bitmaps were not detected on other systems I added a
Bitmap test procedure so I can get results from other machines to test
against my results. Set constant <TestBitmaps = true> to turn on feature.
0.01.3
-Move Pictures and use 'ScriptPath' instead of full path desc.
0.01.2
-Mail now opens up to 5 mail at one time
0.01.1
-Added Open Boxes
-Broke up the huge blob of code into smaller procedures
0.01
-Simple point and click with minimal error correction
-Started with this process:
1. Check mail and click box then delete
2. Harvest resorces
3. Refuel ships
4. Randomly choose instance 3, 5, 6 and attack
5. Check for zero losses and then repeat

*******************************************************************************
*******************************************************************************
In the next few lines you will be able to control how the script works
these are the variables you can change:
iLow := ??? <= this sets the lowest instance you want to attack
iHigh := ??? <=this sets the highest instance you want to attack

TestBitmaps := ??? <= if script does not run as you think it should,
set this to true and run script
then select all [<ctrl> + a] from output box at bottom
copy [<ctrl> + c]
then post this on forum with your report of what you think
was wrong or suggestion how I can improve it.
******************************************************************************}
//Set lowest and highest instance to attack
iLow := 2; //(1 - 30) Lowest instance to attack
iHigh := 8; //(1 - 30) Highest instance to attack

MaxFleet := 6; //Set to Max number of fleets you want to send to an Instance

TestBitmaps := false; //(true - false)
//Set this to 'true' to test all bitmaps, copy results
//to forum when reporting issues with script as failed
//bitmaps is the main reason for errors

GetCommander:= true; //Do you want to hire common Commanders?
{******************************************************************************
************ !!!Do not change anything blow this line!!! *******************
************ if you know what you are doing and make changes ******************
*** please post changes on forum so we can incorporat into main script ********
*******************************************************************************
******************************************************************************}

ActivateClient;
TestProcedure := false; //true = only run <procedure TestProc;>
Debug := true; //don't touch this till script is out of beta stage

Tol := 25; //tolerance of Bitmap search
ContTol := 5; //ContourTolerance (used in Mask Searches)

//normal variables below
x1 := 1; y1 := 1; //window top left corner
x2 := 1020; y2 := 647; //window bottom right corner
Report3 := 0;
Report5 := 0;
Report6 := 0;
ReportLastAttack := 0;
He3 := true;
mStart := '*****************\/ USER INPUT NEEDED \/*****************';
mEnd := '*****************/\ USER INPUT NEEDED /\*****************';

//Load Bitmaps from string
bmpEnvolope := BitmapFromString(22, 2, 'meJwBhAB7/2Z6rRo0iQIkkwAmnAAikRBTuBVo' +
'ySsrU4iKrNPY8OLr+ODr8uHq79/m8ODl9ebp//f4/5qbtEVHXYiLn7O2ya2xwX' +
'2NuwcYbyU7tA0lrDxc4059/wVCxVVafm93k5+qvMPS2c7d3c7e3MnX2rzI0cHJ' +
'2Gpxg1JZa52ltLrD0K23waCnsmdbTvc=');
bmpSpaceStation := BitmapFromString(18, 2, 'meJwBbACT/3Z4S3R1WGllWlNIR2BNTW1W' +
'S2xXPot+WdDRrn+JdGVvbVBTWZyTlP/z4MKmh9SUbdWTZ+2qdbmygIqFXH10Vn' +
'FlUHRjUJeDb7ynj9PDpqObgX17cHt5gIh+jK+ZnP/iy8OdcNaWb9OSYsmITWvS' +
'OZo=');
bmpSSUpgrade := BitmapFromString(28, 4, 'meJyb0jd5YveEpprGuIjYzuaOeTP' +
'mLp2/ZMGs+bOmzFw4ewGQPWvq9DnTZwLJrtZ2ICotKMrNyMpKTY8I' +
'DnVzdDbWM/D38nGytXe0sbOztNbT1E6JS46PjIsJi/ZwctdR0y7Iy' +
'm9raJ0xafr8mfPWLFu9YdV6ILlq6XIgWrti1YLZcyFmRoWGW5ma66' +
'hraqtpSIqIOds5BPr4pSYkBfn6B3j7lhWUOtk42prbaCipK8sqmRm' +
'Y2phZO9s6hQeGAS3y9/Tz8/AFOsPTxc3WwspE31BLVV1XQwuOZCWk' +
'VOQVgeYkxsQBEVBlZkpaVUklxEx1RTUFKXkZMWkgkhWX0VTWAHLlJ' +
'eX0NfWA3gG6B6hXX0vH2swC6EGgI4FuA7KBDHEhkfCgkPiomNCAIK' +
'DhPu6eNqZWAMUfbtA=');
bmpInstance := BitmapFromString(32, 2, 'meJz7f3vzs229/29vhqBl0QadBixABBcBomMd' +
'cchciDI0BXBdaKZBGBBZiBSQATEQIghUAxSH64ULQhhwxRARTNMA26l0nQ==');
bmp03 := BitmapFromString(13, 8, 'meJz7/x8Erl69YGAg5mDO6mHHamWl/OjRPbDw/z9//h' +
'QXJ0V7M/X1NS5cOA0osmfPFksL+YRQZgdLRnd3/Z6e+lmz+r58+fT+/Vs7OxUh' +
'fkZtLX4g9/HjByEhdrHBzMoKDDo6grKyTNpaQjduXAaakJwcoKLAZG4m+eXL53' +
'v3bgUEWNmbsbi46AG1/IeBAwd2mOgxKskymRiJApXdv387KNAaqExTlSkkxKG3' +
't2H27P5Pnz48fHjXzkZOWZnPzU3/27evDx/eA5oG9IW8DMgZQEs1NYRu3rwKND' +
'AtLfjfv78Qwxsbi5QV2R0t2CCW/vv3DyK+f/8OW1PWzZtXbd68srW1XFGOEagG' +
'iHTVmePjfTZuXLFp08o1axY5Oagl+TIAAFQtnow=');
bmp05 := BitmapFromString(14, 8, 'meJwLDrb/+PH9fzC4evWCgb6YlRmzqSFTWVnanz+/Ie' +
'Lfvn0NC3N++fLZq1cv+voaFy6cBhTcs2eLhYW8lSlTZWUmkLtv37bOzrqUlCAj' +
'bUYg9/jx/QL8DFpa/F++fHr8+EFoiF2IN1NFRQZQqro6W0yMQUKCIcydGcg9de' +
'qwojyjmZnkly+f7927FRRoFR/CVFeXD7H616+fa9cu0VJlALJPnjwkL8tobCQK' +
'VHn//u2gIOuoACYfb9O+voaOjtoTJw4A1aSmBgPJ8+dPKivxubnpA13+8OG9gA' +
'CryABmIz1GEREGcTEGoAOAapYsmbFx4wog49+/vxC7GhuLFBXYAj2ZDfRFzp49' +
'DhH//Pmjva2KuRHfggVTN29etXnzytbWcnk5BmAoeTgxJyT4bN26BmgOEOXnx+' +
'VHMAAAZUu8OA==');
bmp06 := BitmapFromString(13, 8, 'meJz7+PH9fzC4evWCgb5YiDezqx2Tr6/lp08fIeKfP3' +
'8MCXF89epFX1/jwoXTgCJ79myxtJTX0uS9cOEUkLty5byurrrYWG8Lfcbjx/cL' +
'8DNoafF/+fLp8eMHISF2+fkxQDWPHt0zMBCXlWWWEGcId2c+deqwkjyjuZnkly' +
'+f7927FRhoVVWV/R8Gfvz4vnjxDB1VhpMnD8nLMhobiQKV3b9/OyjIGqLszZtX' +
'kya13r59HchOSws6f/6kshKfm5v+t29fHz68BzTN39/q16+fQGX6+mJz504AKl' +
'uyZAaQ/PfvL8SKxsYiLQ02JQXG6dO74PYC1VtayC5YMHXz5lWbN69sbS1XUmCI' +
'CWa2NmMG+gjo902bVm7cuDw5ObApjQEAuu24uw==');
bmpIncreaseFleet := BitmapFromString(48, 2, 'meJz7/6DgPxitjWIHkgerFeFciAgEvT0' +
'UCeTCZSHo2jwbNGVYBSF60RCySggCciH2QmyBm4BVC4QNVImmHSgCNwdiFMR2T' +
'L1EugcA41ObAg==');
bmpGoToGround := BitmapFromString(20, 3, 'meJy7ePFiWlqap6dnbm7u3Llz161' +
'bd/DgQS8vr8TExKy8dH1JFg8JBndxECrVZjicJJcQFQhEVRWl9bU1' +
'FzH0rlmzxs7ODqLXSI7dX4rRD4ZaDBlmxxsB9abEhdXV1Bw6dMjEx' +
'ASr3uKOKpN0axNd/gB55nBZxjAZxlAZxlVODBPjzIHai/KyAUJAQ18=');
bmpWarehouse := BitmapFromString(21, 13, 'meJwFwU1P22YAAOB3NCWExOCv4DixYzt24j' +
'i2X5Mvx3G+yFcLISttIUlpCm3WUcJIByll1baMdSrdKoS4jPZQoba7Teph0sRh' +
'h102adq1qrTTDvsD+wO77XlWLJgmLtYlnx1is7MpBeYFOS/wWYYIR3wBifLYkN' +
'64WR3u94bPRrcf7d272zrpFc63zdNO5OuNRvLLQbhThTVDjvm4IGbXCkRMoTI5' +
'PGES0CAjoptC2QCKBSk8HvcXKomC9dEl9fRO8slqsmRKF948x49G8nZHq8j9rW' +
'b9sgprMW9Rmy5mkGwOMSxCtaZZHuA04PVxWMbVZEINtvNsPoZ6+UDpz3fw7DW6' +
'ssiaog5xQ3YO718rVI0QlClJjcSrbKRIqSm3ODuh2CCcd3CqYoSvNww7G4pkrf' +
'azH2r7x0RhkSmVmIw6WzJmDeHDovV050G3vnTJrJdSdS1ThNm5aLpCiimME3O5' +
'2MNB8+FuS8skyvnljZ2j7I1drNGl7t5H1zbSe6NPv3+lZ6tCMGzBRFpR2YCvbK' +
'a7C83u4pVbS/P9TuH4s8aLb9a+GKyRTGCalWlrIdo/AGv7V9//u/LPf5Vf31df' +
'vi0/+BxhAxxDZnXxsL/+09Ovzo+e/HZ2/Meb0bsfH/319vHvLw8BPQ6wcQdJAZ' +
'QD5hIYnICT8/AvfwsvfgZh08XLAu2Py+zB7eXvWpfXI3RPozdNYttyDZLunTTn' +
'pIGX/IBHnTOTCLhIgXERpFbB/BDEO0AsT+KywugsR927Wu8o/q7o3bUjW2liN4' +
'vsmcRApSUC0UhPgnQrqFtjONfYNAC42xmV+ZqVaglC0edPKhl9eTF3RZtpK1gX' +
'4m15rGeMbcKJj6O4jgQhGpQIn4/AXO4LWlTKx/SMX1I8DIOF3LSMaBbCT4VEpy' +
'2BTtKzDB0rGuglwB0d9FME54wyLgWf5MenZiY4n9G0raVCfM4IQyGgcC7BB2am' +
'VJuZK3m32vzhFvx2Uz0dxs+GxvNP4MENGXOI3jGJBMyUk5RScb5hIg3d04gFmj' +
'B1PWPYIRwDMc1TyblvNjy35h29Bcdo3TtaRfdb2OY17//gC7iM');
bmpHarvest := BitmapFromString(42, 2, 'meJzrNGA51hH3//bmZdEGQARkwBFQvNOABYggs' +
'nBBCBciBZFFVglBz7b1oonA9SKjTlTb4WYi2wJXCTcQbjhEGVZnANnIskCjILq' +
'QtQMAPsyLmg==');
bmpGoToSpace := BitmapFromString(22, 3, 'meJzbtKM7YV+Kz/1uv7dz/T4s9H0x3etqvdv' +
'eeKdFNratEm6V/DX5yk0OYu0xFmUZzuF2KvkabI3aTHC0wZFx1545ezd29KxLD' +
'jxd7HmpyuN0YeTKAOflLp3JIvM9uPts2SsNmPu8FBMtFVMCjPITrIJNZArVmMv' +
'VmeBo74EFG9b3b9w4aeKqfO9NYS5rvdemSPXlSPWH8Exw4qo2Yauy4J8WquOtz' +
'OutK5EXb5nopxOsxJmrwghHAMPIR7k=');
bmpZero := BitmapFromString(85, 16, 'meJztl/1PGnccx3+hdusS19b0qmgBFbjjeKYcJwj' +
'iE1hEcaAIeIDydHB4Yn24bllW58y6JTVmbba6Ju3aTmqaNc34F/cpt97Y8VCUZ' +
'suSJZ8f+H7ve+/7vj7fz8MXDpVw/1sjo2zyOc/8Jn7jX9/JP2OsRsJpLgvDKKl' +
'E8+V6/F1UQoRylvgDDr38oT59zgMiZN5bkU2trEOdoMs8vHYPYX9H2Iqy8Nod+' +
'qJowlrgz3rHA95gh/ju2SBBHXYiErMNqpmTDvFj5LC8+HjBG9/W9eYM3QsuqyF' +
'xhzHjtfisGTZ5sbXOhrlbNLMDkwaY/LgZviXxsBk+o+3isJ7WgmfCt7sl19gKG' +
'Ofeq513zYUt8R849IowU0QlWxopjx9wkorMIUQFlj1J2e1/vuIPO5a/4V2nzT7' +
'xj9nlmSNYg9KnKbuDX+P1eKSFxzA5wFbskYP6TTbDT5l6sPhX8GI/WxkNf72t6' +
'WsoGCNM/fTPUrYio1+AeQIlWLNiU8DvpamQSBPz475UhUNxGpVcS2WikYrwyDk' +
'XMSYfbWO9olcAX8r+Zlw9XhmboQi5PrJtXTni0B4en4x+x+Mj7Ctj4ifK5aEIh' +
'TnM6tJPwHUx25CSebbi9G5gyAqhsC+m2sRn0C40cXciyG3pZWtmBI99Prb4ZfW' +
'gxYJp01DIboTTTxFk2qpmrSoeH2HLIvwoILN7wqFDGNghBtCZd8E/1Lv+FAIAE' +
'Ha00lr82txfcuhQunwbHxDho4WygLZmunaj+IhyTs1OusAP9S59L37IaYSvCIL' +
'gdiXzPG/RNxSsD/6c6dMkqSsSmCjsMeC1ZvihzwreOK5NgbAD18buIOxpH1sxx' +
'x9SY556fHCsiimXtIoW+AzWNZz6fnFqMTKiVrDl6UCJuanj0Avt43s83psUxNg' +
'lfljAPhqkj5IOd0PBNnNfhM8HA+0/Fi1jNG+P2Li0Mbj+Jk2SInzKKlMxJ+/BR' +
'y9A2gZmEpuoZNI331dNVRX9asFLtYnvCFCO5f3aXFCu3QtPBhsKflj8dw6/OJg' +
'5nJ3NngO/+u79qNvHDzerMTMSSIA/MzaivdOfsdadfmJ0vKFg5/jrkLCjrjr8+' +
'6Hp5XPgQ/WDVKWtptumv6Bo/BN5/gHlnG4HP+Qy/y33rbJh5lneYmgoWN3Sr/y' +
'WeMsZu9dsGF8Gm+HX5j7gG6JbE8HdLEnsYj1ZfbfbF8Ry5XWjuk18ZfE0NB0um' +
'pXLI5gqeTAafisLTcrvS5cMQ5uYJDBmU+efwkWiIf6qDRcsa8OheqiT+xOf7e7' +
'opGnjVV10t4Vg2nBFzvwIX8/re5MuC3f2yg/hBEUVjd9F2NeQVki19GVIG1ctf' +
'Rj9vBZfQ/8i4EPn5fHVhTL0O4R9I2MrzvAeX5wD46Ry9Vv+GonmXkbH/fUxCfg' +
'DhZe1xpNCv1Ml96+zlV7o78sHfK9pJjh5ax5hX8Ck0PcHCmJ8rmXf562kkRQNP' +
'Tta8UWrtQnBX8JgeFX0FP5EbOn7zyQoWF5/icOvtyMIJ7jdxrab3fo6MVHu/+f' +
'sD19l5x8=');
bmpClose := BitmapFromString(34, 4, 'meJxLV2BIV2DYM3fC////gWQ6mAtEQC6EnBDrBhe' +
'kEAFNe/XgDlZxiC1A8j8MwO2FuA0O4FogANnNcBOwuhkuDtcFMRlTF9zvENdCZ' +
'DFtweVHoCzcZLggUASiC9nBaOYgywIAD/utBw==');

bmpBox := BitmapFromString(13, 3, 'meJzzlGDyJA6V2TD+X82MiYDiaMo' +
'utjHVxLr3lsThQgCb5yOb');
{
bmpBox := BitmapFromString(23, 2, 'meJwBigB1//73h5O2sCyYpxm60Te' +
'4ygAuVBMXaAcBSpyOeezOVtizOLeOV41QM+qJPMlyGRYOHgAWqT5H' +
'QsX89k6qoR5mXSIvJDITAf//c1m4dQKUhx/F1FLDzgAgRQsAZBIBY' +
'JWCVPDNF8+mGDkcLU80hduwnp12E05WVQAAkyYwL8b79VqtpR9gVi' +
'MqHTEQAIkFOQs=');
}
bmpUse := BitmapFromString(25, 2, 'meJz7//9/pwELBK3M8PgP4/6HgXeP7qCJAJXBtSCj' +
'/9iMOr1kIlwcYhTcTGQpNAQADHtMUg==');
bmpBackToBag := BitmapFromString(26, 2, 'meJz7M4H3Dxh97uI5kcs5N5Ct3Ix5ig3rRm' +
'f27S7sRabMmGhjsEC2o4qWtjYE9fT0zIKBKd6s25M4gIbUmjPPsmMFmnDOixO' +
'CVjuxYTWtzpr1bJKUiZ4mxDRvH5+pMAAAJbUzXg==');
bmpOpenInventory := BitmapFromString(14, 4, 'meJz783jLn7sb/9ze8Pf5jn9f9354tH' +
'JnZ3Kvl0mrixGQnOBvMD/M1FiA1VGa8f//k/9+nPz359y/X6cOz6ucGGjVBlY' +
'zPchsRojJwhjTOcEmRoIsnvJML1Zl//9/5caB+VOjnIFqejyNpweaLYq0XJNo' +
'My/SZHum/YIwqMqb5Sb//19cUhRV7ajV5qm3EKxmW6bdrly7pXHme3MdlkSaQ' +
'VQCALERT/o=');
bmpCloseBag := BitmapFromString(6, 7, 'meJz7P1/o/3yhhgBOJkYGCPoPFlmfywMXud/N' +
'DxEMNGKFiDhqsEBEgFKCXIwQwQmRXBBBIAMiApTaX84LQYoiTHAD4QgAgL4dH' +
'Q==');
bmpAttackResultPage := BitmapFromString(39, 2, 'meJxjUgtj888TOrMTinbsEZp9UGj' +
'uIaH5R4QWHxVaelRo+TGhFce5C6ZxZfZzZYFR9gSunAlcuRO48ibyNCwQXHtU' +
'aMdZob3nhQ5eBKFDl4Ak34yNHPHNTGphuBCKpUC0YS+mpUKrTgitOSG07qTQ+' +
'pNCG08JbT4ttOW00LYzQtvPghDQ0l1nhXafE9pzDmT7vvNC+y8AkcDqA1xFk5' +
'n1Y9FsBABjdGCq');
bmpMailStillHasBoxOK := BitmapFromString(100, 2, 'meJy9kMkyA1EYRk9V3kEeIenWi' +
'c486BBE8hCsbG3acxgS8xgJIYgYIoZSKIVSbO1jwROkvAD/1WVvlVtndYf/ft' +
'+xNZetub7yhnCeopnizKJhcdqrOElynOQoQT3BYVxRi3MQYz/GXpRqlN2IYid' +
'MJcx2iK0Q5SClIJsBRTHAhsm6yVoPq4KfFT9vlcL332p/tOa7mdOZ1Sno5DVm' +
'BC/TXqY8THqojWXlmmzKkdxxXi0aLPvUNBkrw4smpYD6V36XGJKnGlHxJKekr' +
'cdVfikidaRa0+IixWUfV/1cp7lJczvA3SD3QzxkeMzwNMxzlpccrznex7tES2' +
'PEbf9amtAVHXPV/mxJ2SUf0nfBwNH1T1eOKHnVaVejbsfSD4uEzt4=');
bmpBoxInBag := BitmapFromString(23, 2, 'meJwBigB1/9Xw2P73h5O2sCyYpxm60Te4ygA' +
'uVBMXaAcBSpyOeezOVtizOLeOV41QM+qJPMlyGRYOHgAWqT5HQsX89k6qoR5m' +
'XSIvJISqrf//c1m4dQKUhx/F1FLDzgAgRQsAZBIBYJWCVPDNF8+mGDkcLU80h' +
'duwnp12E05WVQAAkyYwL8b79VqtpR9gViMqHa9CPPw=');
i01 := BitmapFromString(75, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYckS8w3AhoGt' +
'JMoRuHiQ15Al6EMKAA7gv4CJP79/5jwqQRYBsPIYgmwN3M1ZltItBCAOYaJ1g' +
'SReZAUQQL2B1D0QvkMRqCNwvaC6HGIisjLoeBADMxxFi');
i02 := BitmapFromString(59, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYEvQfCSCLA20' +
'n3rV0czDQiqf370DYQAayC+EOhjDgAO4quAhEIzJAFoGYj8sQrCGGVRlWx+Nx' +
'MDCROMGSCjID4lNcIQzRCySxGgJ3G1pMQQxEVoYVwUMYABLpBYE=');
i03 := BitmapFromString(59, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYEvQfCSDbCGQ' +
'T71q6ORhoxdP7dyBsIAPZhXAHQxiYnoKLQDQiA2QRiPm4DEELMTQR/CGAFqRo' +
'DgYmEidYUkFmQHyKK4QheoEkVkPgbkOLKYiByMpwxSlEJQCTJQY4');
i04 := BitmapFromString(58, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYcgRxIZwLtJp' +
'4p9LZtRC3YXUtXAoC4E6Cizy9f+c/KkAWAbLxGIJsDtx2rMowQwaPa4Ehjxz+' +
'yBEBcQ9WwyF6gSRWQ+AOQ3MJxEC0uEZWADEHIgsAAbMAOg==');
i05 := BitmapFromString(60, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYEvQfFQCdCpc' +
'COoB4B9PZzcjuREZwN0MYcAB3GFzk6f07aH5HFgGy8RiCFm5oIlgDgXg3Q5RB' +
'0gwyA4ggrsJqBUQvkMRqCNx5aE6CGIisDFfagDseAN5cDyA=');
i06 := BitmapFromString(62, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYQoTfeUBnEO9' +
'serr86f07+B0GdzmEAQdw58FFIEYhA2QRIBuPIcjmwN2DVRmyevxeQ3M5MILg' +
'0YTMgAQCrjCH6AWSWA2BOxLNYRADkZVhTSdwlXAEACKaDko=');
i07 := BitmapFromString(60, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYbPT0/p3/qAD' +
'ZUiCbeAfTzc3ICNOFcBEIA9NfcBFMvyOLANl4DEE2B+4ArMqwhhLEcFxuBqYW' +
'J1iaQWZA4gtXOEP0AkmshsCdh9UlyMoIBjIA4rkIAQ==');
i08 := BitmapFromString(60, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYEoTsNiAbWQr' +
'oAOIdTDc3Q1wFsQiZjeZmCAMO4GrgIk/v3/mPCpBFgGw8hiCbAw8irMqQAxlZ' +
'L3JQo7kZIgXXgqwX4iqsVsCDAqshcOehxRfEQDTnofkRTQEAYq0Q1A==');
i09 := BitmapFromString(60, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYEoTsNjQbgVz' +
'iHUw3N0NcBbHo6f07aC6EuxnCwPQaXASiFxkgiwDZeAxBNgfuAFzBiOlOIBsY' +
'7LjcDJGCxAsyA2IOrnCGBwtWQ+DOQ4sviIHIyvC4GaIYAKCHEiE=');
i10 := BitmapFromString(66, 4, 'meJxzEmdaM3PCfxhwEmciBgFVloa5E6mYcoTpMKwOBjq' +
'J' +
'eC/Q0xdYXQvkAkPeCRb+mL6AMOAA7lS4yNP7d/6jAmQRIBuPIcjmwG3Hqgx/X' +
'MC5aIGP5gs0nyJ7GeJOrJZC9AJJrIbAHYzmHoiBaKGKxxfILoezAeDDIWE=');
bmpMskRW := BitmapFromString(83, 19, 'meJzllVEKACAIQ7v/pe0rsCChMJ' +
'3tHaD2plFr1MggO0goMpMd5zlak0qZRPYU3QxVPx9sxXX4utbuU6u' +
'+A3ew/XoLOOIgg4i/OtcaofN4YpaNqlINyFs+wv0bxRc3osoe+7TH' +
'kd2oMiM2OsLKD/8=');

mskRW := CreateMaskFromBitmap(bmpMskRW);

{
//Load Bitmaps
bmpEnvolope := LoadBitmap(ScriptPath + '\bmps\envolope.bmp');
bmpSpaceStation := LoadBitmap(ScriptPath + '\bmps\SpaceStation.bmp');
bmpInstance := LoadBitmap(ScriptPath + '\bmps\Instance.bmp');
bmp03 := LoadBitmap(ScriptPath + '\bmps\03.bmp');
bmp05 := LoadBitmap(ScriptPath + '\bmps\05.bmp');
bmp06 := LoadBitmap(ScriptPath + '\bmps\06.bmp');
bmpIncreaseFleet := LoadBitmap(ScriptPath + '\bmps\IncreaseFleet.bmp');
bmpGoToGround := LoadBitmap(ScriptPath + '\bmps\GoToGround.bmp');
bmpWarehouse := LoadBitmap(ScriptPath + '\bmps\Warehouse.bmp');
bmpHarvest := LoadBitmap(ScriptPath + '\bmps\Harvest.bmp');
bmpGoToSpace := LoadBitmap(ScriptPath + '\bmps\GoToSpace.bmp');
bmpZero := LoadBitmap(ScriptPath + '\bmps\Zero.bmp');
bmpClose := LoadBitmap(ScriptPath + '\bmps\Close.bmp');
bmpBox := LoadBitmap(ScriptPath + '\bmps\Box.bmp');
bmpUse := LoadBitmap(ScriptPath + '\bmps\Use.bmp');
bmpBackToBag := LoadBitmap(ScriptPath + '\bmps\BackToBag.bmp');
bmpOpenInventory := LoadBitmap(ScriptPath + '\bmps\OpenInventory.bmp');
bmpClosebag := LoadBitmap(ScriptPath + '\bmps\CloseBag.bmp');
bmpAttackResultPage := LoadBitmap(ScriptPath + '\bmps\AttackResultPage.bmp');
bmpMailStillHasBoxOK := LoadBitmap(ScriptPath + '\bmps\MailStillHasBoxOK.bmp');
bmpBoxInBag := LoadBitmap(ScriptPath + '\bmps\BoxInBag.bmp');
i01 := LoadBitmap(ScriptPath + '\bmps\i-01.bmp');
i02 := LoadBitmap(ScriptPath + '\bmps\i-02.bmp');
i03 := LoadBitmap(ScriptPath + '\bmps\i-03.bmp');
i04 := LoadBitmap(ScriptPath + '\bmps\i-04.bmp');
i05 := LoadBitmap(ScriptPath + '\bmps\i-05.bmp');
i06 := LoadBitmap(ScriptPath + '\bmps\i-06.bmp');
i07 := LoadBitmap(ScriptPath + '\bmps\i-07.bmp');
i08 := LoadBitmap(ScriptPath + '\bmps\i-08.bmp');
i09 := LoadBitmap(ScriptPath + '\bmps\i-09.bmp');
i10 := LoadBitmap(ScriptPath + '\bmps\i-10.bmp');
}

end;

Procedure Msg(Message: String);
begin
if Debug then Writeln(Message);
end;

Procedure ReportMsg;
var
i: Integer;
begin
Writeln('*************************************************');
for i := 1 to 30 do
if Report[i] > 0 then
writeln('Insedence ' + IntToStr(i) + ' - Times attacked: '
+ IntToStr(Report[i]));
Writeln('*************************************************');
Writeln('Last attack was on Instance #: ' + IntToStr(ReportLastAttack) );
writeln('Press 6 to end script');
writeln('Press 5 to open boxes while fleet fights');
end;

Procedure FreeMemory;
Begin
FreeBitmap(bmpEnvolope);
FreeBitmap(bmpSpaceStation);
FreeBitmap(bmpSSUpgrade); //Space Station while being upgraded (grey)
FreeBitmap(bmpInstance);
FreeBitmap(bmp03);
FreeBitmap(bmp05);
FreeBitmap(bmp06);
FreeBitmap(bmpIncreaseFleet);
FreeBitmap(bmpGoToGround);
FreeBitmap(bmpWarehouse);
FreeBitmap(bmpHarvest);
FreeBitmap(bmpGoToSpace);
FreeBitmap(bmpZero);
FreeBitmap(bmpClose);
FreeBitmap(bmpBox);
FreeBitmap(bmpUse);
FreeBitmap(bmpBackToBag);
FreeBitmap(bmpOpenInventory);
FreeBitmap(bmpCloseBag);
FreeBitmap(bmpAttackResultPage);
FreeBitmap(bmpMailStillHasBoxOK);
FreeBitmap(bmpBoxInBag);
FreeBitmap(i01);
FreeBitmap(i02);
FreeBitmap(i03);
FreeBitmap(i04);
FreeBitmap(i05);
FreeBitmap(i06);
FreeBitmap(i07);
FreeBitmap(i08);
FreeBitmap(i09);
FreeBitmap(i10);
FreeBitmap(bmpMskRW);
end;

Function CheckBmp(bmp, x1, y1, x2, y2: Integer): Boolean;
begin
result := FindBitmapToleranceIn(bmp, x, y, x1, y1, x2, y2, Tol)
end;
Procedure mWait(Time: Integer);
var
Start: Integer;
begin
Start := GetSystemTime;
while(GetSystemTime < (Start + Time)) do begin

//low He3
if (not He3) then begin
Msg('He3 low... terminating script');
TerminateScript;
end;

//Key <6> - Terminate Script
if (IsKeyDown(54)) then begin //is '6' pressed?
Msg('He3 low... terminating script');
TerminateScript;
end;

//Key <5> - Open Boxes
if (IsKeyDown(53)) then //is '5' pressed?
ThreadSafeCall('OpenBox', Params); //lets open som boxes

wait(100);
// FindBitmapToleranceIn(bmp, x, y, x1, y1, x2, y2, Tol)
// writeln('mWait running');
// ThreadSafeCall('TestProc2', Params);

//Keep computer awake. Twitch mouse ever 3 minutes
if( (GetSystemTime - TimeMouseMoved) > 180000 )then begin
GetMousePos(x, y);
MoveMouse(x+5, y+5);
wait(5);
MoveMouse(x, y);
TimeMouseMoved := GetSystemTime;
end;

end;
end;

Procedure PauseScript;
var
done: boolean;
begin
done := false
repeat
if (IsKeyDown(50)) then //is '2' pressed?
done := true;
mWait(100);
until done;
end;

Procedure mMouse(x, y: Integer);
begin
MoveMouse(x,y);
mWait(1000);
ClickMouse(x,y,1);
mWait(2000);
TimeMouseMoved := GetSystemTime;
end;

Function ClickBmp(bmp: Integer): Boolean;
Begin
If (FindBitmapToleranceIn(bmp, x, y, x1, y1, x2, y2, Tol)) Then begin //This will search the screen for the bitmap
result := true;
Msg('Found the bitmap');
mMouse(x,y);
end
Else
Msg('Could not find bmp'); //Tells us we didn't find it
End;

Procedure MoveScreen(xx1, yy1,xx2, yy2: Integer);
begin
MoveMouse(xx1, yy1);
wait(200);
HoldMouse(xx1, yy1,1);
wait(200);
MoveMouse(xx2, yy2);
wait(200);
ReleaseMouse(xx2, yy2, 1);
wait(200);
end;

Function CenterBmp(Bmp: Integer): Boolean;
begin

if( FindBitmapToleranceIn(Bmp, x, y, x1, y1, x2, y2, Tol) )then begin
If(not ((x>513) and (x<652) and (y>226) and (y<308)) )then begin
MoveScreen( 600, 250, (600-(x-600)), (250-(y-250)) );
MoveMouse(100, 100);
wait(100);
end else begin
result := true;
end;
end;
end;


Procedure LoadFleet(size: Integer);
var
i: Integer;
found: Boolean;
begin
for i := 1 to Min(size, MaxFleet) do
begin
found := false;
case i of
1 : if ClickBmp(i01) then found := true;
2 : if ClickBmp(i02) then found := true;
3 : if ClickBmp(i03) then found := true;
4 : if ClickBmp(i04) then found := true;
5 : if ClickBmp(i05) then found := true;
6 : if ClickBmp(i06) then found := true;
7 : if ClickBmp(i07) then found := true;
8 : if ClickBmp(i08) then found := true;
9 : if ClickBmp(i09) then found := true;
10 : if ClickBmp(i10) then found := true;
end;
if found then
if FindColoredAreaTolerance(x, y, 65332, x+88, y+14, x+113, y+76, 2, Tol) then
He3 := true;
mWait(500);
end;
end;

Procedure Mail;
var
i: Integer;
done: boolean;
begin
done := false;

//open mail
Msg('**** Procedure Mail; ****');
mMouse(927, 614); //click My Tools
mWait(1000);
mMouse(927, 547); //click Mail
mWait(1500);

for i := 1 to 3 do begin
//Msg('looking for mail color');
if FindColor(x, y, 65280, 300, 235, 333, 241) then begin //msg in mailbox
//click on mail in box
Msg('Found Mail Color, clicking on color');
mMouse(x, y);
mWait(2000);

mMouse(627, 500); //open all boxes in mail
mWait(1000);

mMouse(244, 500); //delete msg
mWait(3000);
end;
mWait(100);
end;
mMouse(826, 55); //close window
mWait(1000);
end;

Procedure Harvest;
begin
Msg('**** Procedure Harvest; ****');
Msg('*** Harvesting ***');
Msg('Looking for GoToGround');
if not ClickBmp(bmpGoToGround) then
mMouse(730, 613);
mWait(3000);

//move Warehouse to ensure it is visable
msg('Moving Warehouse');
CenterBmp(bmpWarehouse);
if(not CenterBmp(bmpWarehouse) )then begin
MoveMouse(183, 125);
mWait(1000);
HoldMouse(183, 125, 1);
mWait(500);
MoveMouse(527, 374);
mWait(500);
ReleaseMouse(527,374, 1);
mWait(500);
end;

Msg('Looking for Warehouse');
ClickBmp(bmpWarehouse);
wait(50);
Msg('Looking for Harvest');
ClickBmp(bmpHarvest);
wait(50);
Msg('Looking for GoToSpace');
if not ClickBmp(bmpGoToSpace) then
mMouse(691, 597);
mWait(3000);

//Return to Instance
Msg('looking for SpaceStation');
if( not ClickBmp(bmpSpaceStation) )then
ClickBmp(bmpSSUpgrade);
mWait(500);
MoveMouse(30, 30);
mWait(700);
Msg('Looking for Instance');
ClickBmp(bmpInstance);
mWait(1000);
end;

Procedure CenterSS;
begin

MoveScreen(403, 602, 938, 129);
MoveScreen(599, 419, 938, 129);
MoveScreen(818, 204, 938, 129);
MoveScreen(995, 95, 405, 614);

MoveScreen(257, 116, 976, 546);
MoveScreen(519, 262, 976, 546);
MoveScreen(718, 403, 976, 546);
MoveScreen(718, 403, 976, 546);
MoveScreen(718, 403, 976, 546);
MoveScreen(789, 432, 110, 93);
MoveScreen(535, 416, 479, 304);
MoveMouse(100, 100);

MoveMouse(100, 100);
end;

Procedure AttackInstance;
var
Target: Integer;
Begin
Msg('**** Procedure AttackInstance; ****');
//Select Target
Target := RandomRange(iLow, (iHigh + 1));
//update Report Variables
Report[Target] := Report[Target] + 1;
ReportLastAttack := Target;

//Center Space Station on screen
// *******************************************************

//Start Instance Attack
Msg('looking for SpaceStation');
if( not CenterBmp(bmpSpaceStation) )then
CenterSS;

if( not ClickBmp(bmpSpaceStation) )then
ClickBmp(bmpSSUpgrade);
mWait(1000);
MoveMouse(149, 146);
mWait(1000);
Msg('Looking for Instance');
ClickBmp(bmpInstance);
mWait(1000);
Msg('Looking for Target: ' + IntToStr(Target));

//Co-ordinates of Insidance 1-30
case Target of
1: mMouse(260, 140);
2: mMouse(303, 177);
3: mMouse(255, 249);
4: mMouse(322, 224);
5: mMouse(375, 152);
6: mMouse(387, 218);
7: mMouse(374, 279);
8: mMouse(296, 296);
9: mMouse(260, 368);
10: mMouse(254, 435);
11: mMouse(290, 477);
12: mMouse(308, 412);
13: mMouse(363, 459);
14: mMouse(429, 484);
15: mMouse(363, 351);
16: mMouse(435, 328);
17: mMouse(453, 266);
18: mMouse(435, 195);
19: mMouse(484, 147);
20: mMouse(555, 140);
21: mMouse(573, 177);
22: mMouse(506, 207);
23: mMouse(555, 243);
24: mMouse(501, 297);
25: mMouse(489, 357);
26: mMouse(435, 405);
27: mMouse(490, 465);
28: mMouse(550, 356);
29: mMouse(561, 411);
30: mMouse(566, 477);
end;

Msg('Looking for Increase Fleet');
ClickBmp(bmpIncreaseFleet);

//refuel
Msg('Refuel Fleet');
mMouse(595, 502); //click fuel
mWait(1000);
mMouse(355, 119); //click Supply All
mWait(1000);
mMouse(723, 121); //Click Confirmed
mWait(1000);

Msg('Looking for Increase Fleet');
ClickBmp(bmpIncreaseFleet);
Msg('Loading Fleet to send out');

//Max number of fleet able to send to each Insidence 1-30
Case Target of
1: LoadFleet(3);
2: LoadFleet(4);
3: LoadFleet(4);
4: LoadFleet(5);
5: LoadFleet(5);
6: LoadFleet(6);
7: LoadFleet(8);
8: LoadFleet(8);
9: LoadFleet(8);
10: LoadFleet(10);
11: LoadFleet(10);
12: LoadFleet(10);
13: LoadFleet(10);
14: LoadFleet(10);
15: LoadFleet(12);
16: LoadFleet(12);
17: LoadFleet(12);
18: LoadFleet(12);
19: LoadFleet(12);
20: LoadFleet(12);
21: LoadFleet(15);
22: LoadFleet(15);
23: LoadFleet(15);
24: LoadFleet(15);
25: LoadFleet(15);
26: LoadFleet(15);
27: LoadFleet(15);
28: LoadFleet(15);
29: LoadFleet(15);
30: LoadFleet(15);
end;
mMouse(763, 503);
mWait(1000);
mMouse(709, 114);
mWait(1000);

End;

Procedure RecruitCommander;
begin
if GetCommander then begin
Msg('Hire Commander if possible');
mMouse(832, 615);
mWait(200);
mMouse(834, 490);
mWait(200);
mMouse(233, 487);
mWait(200);
mMouse(840, 91);
mWait(200);
end;
end;
Procedure OpenBox;
var
done: Boolean;
begin
Msg('**** Procedure OpenBox; ****');
//open Inventory
Msg('Opening Bag');
mMouse(928, 613);
MoveMouse(185,213);
mWait(2000);
Msg('Looking for If bmpOpenInventory');
if ClickBmp(bmpOpenInventory) then begin
mWait(2000);
//open box
Msg('Start Loop: Looking for bmpBoxInBag');
repeat
if ClickBmp(bmpBoxInBag) then begin
MoveMouse(185,213);
mWait(2000);
Msg('clicking on bmpUse');
ClickBmp(bmpUse);
mWait(2000);
Msg('Clicking on bmpBackToBag');
ClickBmp(bmpBackToBag);
mWait(2000);
Msg('at Loop End, Repeat if Clicking on bmpBoxInBag');
end else begin
Msg('No more boxes... endding loop');
done := true;
end;
until done;
Msg('Loop Ended, Closing Inventory Window');

//close bag
Msg('Close bag');
if (not ClickBmp(bmpCloseBag)) then begin
Msg('bmpCloseBag not found trying to blind click the close');
mMouse(759, 155); //this is just a failsafe
end;
end;
end;

Procedure Attack;
var
FailSafe: LongWord;
Done: Boolean;
begin
//keep attacking till failsafe or <6>
Msg('**** Procedure Attack; ****');
repeat
FailSafe := GetSystemTime;
Done := false;

//make sure we are in space
if( not ClickBmp(bmpGoToSpace) )then
mMouse(695, 597);
mWait(3000);
AttackInstance;
mWait(3000);
Harvest;
mWait(3000);
Mail;
mWait(3000);
RecruitCommander;
mWait(500);
//keep looking for attack result page
While (not Done) do begin
if FindBitmap(bmpAttackResultPage, x, y) then begin
mWait(2000);
if FindBitmap(bmpZero, x, y) then begin
ClickBmp(bmpClose);
mWait(5000);
done := true;
end else begin
Msg('I think you lost some ships... Failsafe Triggered');
FailSafe := 0;
end;
end;
mWait(500);
if ((GetSystemTime - FailSafe) > 2400000) then begin
Msg('Something must be wrong, took too long... terminating script');
done := true;
end;

if (IsKeyDown(54)) then //is '6' pressed?
FailSafe := 0;
if (IsKeyDown(53)) then //is '5' pressed?
OpenBox; //lets open som boxes
end;
ReportMsg;
until ((GetSystemTime - FailSafe) > 2400000);
end;

Procedure TestBmp(BmpName: String; Bmp: Integer);
begin
If FindBitmap(bmp, x, y) then begin
Msg(BmpName + ' - found (x/y): ' + IntToStr(x) + '/' + IntToStr(y));
MoveMouse(x,y);
mWait(1000);
end else begin
Msg(BmpName + ' - NOT FOUND!!!!');
end;
end;

Procedure BitmapTest;
begin
Msg('');
Msg('*****************************************************')
Msg('Testing all Bitmaps');
Msg('*****************************************************')
Msg('');
//Go to space
mMouse(692, 597);
wait(2000);
TestBmp('bmpGoToGround', bmpGoToGround);
TestBmp('bmpGoToSpace', bmpGoToSpace);
TestBmp('bmpSpaceStation', bmpSpaceStation);

//click on Space Station
Msg('');
Msg(mStart);
Msg('Click on <Space Station>');
Msg('press <2> once menue from Space Station is visible');
Msg(mEnd);
PauseScript;

//look for Instance in menu
TestBmp('bmpInstance', bmpInstance);

//click on Instance
Msg('');
Msg(mStart);
Msg('Click on <Instance>')
Msg('Press <2> after instance window opens');
Msg(mEnd);
PauseScript;

//find instance numbers 3, 5, 6
TestBmp('bmp03', bmp03);
TestBmp('bmp05', bmp05);
TestBmp('bmp06', bmp06);
TestBmp('bmpIncreaseFleet', bmpIncreaseFleet);

//manually attack i1 and wait to finish
Msg('');
Msg(mStart);
Msg('Send your fleet to intance #1 (because its fast) and wait for it to finish attack');
Msg('press <2> when result screen is visible to continue');
Msg(mEnd);
PauseScript;

//battle result page
TestBmp('bmpZero', bmpZero);
TestBmp('bmpClose', bmpClose);

//auto close result page
mMouse(734, 501);
wait(3000);
//Check for mail icon
TestBmp('bmpEnvolope', bmpEnvolope);

//Auto go to ground base
mMouse(729, 611);
wait(2000);

//manually move warehouse so it is center of screen
Msg('');
Msg(mStart);
Msg('manually move warehouse so it is center of screen');
Msg('press <2> when warehouse is visible to continue');
Msg(mEnd);
PauseScript;

//find warehouse
TestBmp('bmpWarehouse', bmpWarehouse);

//Manually click on Warehouse
Msg('');
Msg(mStart);
Msg('Click on <Resource Warehouse>');
Msg('press <2> when menu from warehouse is visible to continue');
Msg(mEnd);
PauseScript;

//find harvest and retest goto ground and space from ground screen
TestBmp('bmpHarvest', bmpHarvest);
TestBmp('bmpGoToGround(g)', bmpGoToGround);
TestBmp('bmpGoToSpace(g)', bmpGoToSpace);

//Auto open inventory
mMouse(928, 612);
wait(2000);
TestBmp('bmpOpenInventory', bmpOpenInventory);

//Auto inventory/bag
mMouse(927, 578);
wait(2000);
TestBmp('bmpBox', bmpBox);

//manually click on box
Msg('');
Msg(mStart);
Msg('Click on <Treasure Box>');
Msg('press <2> when Box menu is visible to continue');
Msg(mEnd);
PauseScript;
wait(1000);
TestBmp('bmpUse', bmpUse);
TestBmp('bmpCloseBag', bmpCloseBag);

//manually click on use box
Msg('');
Msg(mStart);
Msg('Click on <Use> from menu of Treasure Box');
Msg('press <2> when Box Contents are visible to continue');
Msg(mEnd);
PauseScript;
wait(1000);
TestBmp('bmpBackToBag', bmpBackToBag);
mMouse(516, 438);
wait(2000);
mMouse(761, 154);
wait(500);

//final Message
Msg('');
Msg('');
writeln(IntToStr(GetSystemTime));
Writeln('****************************************************');
Writeln('end of test please copy above test and post on forum');
Writeln('****************************************************');

end;

procedure TestProc;
begin

if( FindBitmapToleranceIn(bmpSpaceStation, x, y, x1, y1, x2, y2, Tol) )then begin
If(not ((x>513) and (x<652) and (y>226) and (y<308)) )then begin
MoveScreen( 600, 250, (600-(x-600)), (250-(y-250)) );
MoveMouse(100, 100);
wait(100);
end;
end;

if( FindBitmapToleranceIn(bmpSpaceStation, x, y, x1, y1, x2, y2, Tol) )then
Msg('x/y: ' + IntToStr(x) + ' / ' + IntToStr(y) );

end;

begin
Try
Init;
Msg('');
Msg('');
writeln(IntToStr(GetSystemTime));
Writeln('*********************************************************');
Writeln('Start of Script... go have a coffee while I fight for you');
Writeln('*********************************************************');
if TestProcedure then
TestProc
else
if TestBitmaps then begin
ClearDebug;
writeln(IntToStr(GetSystemTime));
BitmapTest;
end else begin
ReportMsg;
Sleep(100);
Attack;
end;
Finally
FreeMemory;
end; //end of Try..Finally
end.

Main

2012-01-25 11:22:54

Still got it after all these years flyboy :p

Home

2012-01-25 11:24:34

Blah unable to Open. Is you Zip file damaged?


~Home

footballjds

2012-01-25 11:26:42

From: Home
Blah unable to Open. Is you Zip file damaged?


~Home

same here
bad zip?

Flyboy

2012-01-25 11:28:27

Hey guys!

I just downloaded it and it unzipped for me…

rezipped and reposted

Main

2012-01-25 11:58:32

Its for the facebook game right?

P1nky

2012-01-25 16:35:10

Woah! Haven't seen you for a while!

Flyboy

2012-01-25 19:58:15

@ Main: Yes, its the facebook game. I wanted to have a play with Simba and thought RS would be too tough to start with given how much the game has changed and their anti bot efforts are a bit extreme. Figured this would be an easy way to try and remember Pascal and get failure with Simba.

@Pinky: Yup, its been a day or two. Thanks for the welcome back.

I am running into a few minor issues that you might be able to help me with:
1. Where / how do I find an inclusive list of all the special words to be used by Simba. Last night I spent ages trying to find the term to reference the script path ('ScriptPath'). In SCAR I would just enter a period (.) and a list would pop up of all the terms, variables, and constants available.

2. How do I get this game to automatically load into a window, and is it possible to use some form of ghost mouse so it can run in the background freeing up the computer monitor to be used for other stuff? A sample script that did this for anything (other than RS, as that might use built in features that are RS specific)

I have many more questions, but those two are enough to get me heading in the right direction.

Geo

2012-01-25 20:04:24

From: Flyboy

I am running into a few minor issues that you might be able to help me with:
1. Where / how do I find an inclusive list of all the special words to be used by Simba. Last night I spent ages trying to find the term to reference the script path ('ScriptPath'). In SCAR I would just enter a period (.) and a list would pop up of all the terms, variables, and constants available.

2. How do I get this game to automatically load into a window, and is it possible to use some form of ghost mouse so it can run in the background freeing up the computer monitor to be used for other stuff? A sample script that did this for anything (other than RS, as that might use built in features that are RS specific)

I have many more questions, but those two are enough to get me heading in the right direction.


1: If I'm understanding you correctly try using CTRL + Spacebar

2: You could run it in a Virtual Machine.

Flyboy

2012-01-25 21:43:15

From: Geo
1: If I'm understanding you correctly try using

2: You could run it in a Virtual Machine.


@Geo: Thanks the <CTRL + Spacebar> is exactly what I was looking for. Is there a list of all commands with explanations (ie: repeat, for, etc.) as I did not see these common ones covered in the help file. What version of Pascal is Samba using (Free Pascal, Turbo Pascal, Borland Pascal, etc), or is it still a hybird like SCAR was?

I was trying to remember how I used to catch errors, and force the script to run the free bitmaps code every time the script ends (or is stopped). I think it had something to do with using the ThreadSafeCall…

New Problem:
I was just informed that this does not work on my beta testers computers. none of the bitmaps are being found. It works like a charm on my system. Does screen resolution make a difference? How do I get bitmaps to work universally for everyone this game has no anti bot methods implemented… so I had hoped a bitmap with zero tolerance would work for everyone. Any thoughts guys???

Sin

2012-01-25 22:07:02

But… But…
You're an Admin?!?
Admin's are gods :s

NCDS

2012-01-25 22:14:37

From: Flyboy
@Geo: Thanks the <CTRL + Spacebar> is exactly what I was looking for. Is there a list of all commands with explanations (ie: repeat, for, etc.) as I did not see these common ones covered in the help file. What version of Pascal is Samba using (Free Pascal, Turbo Pascal, Borland Pascal, etc), or is it still a hybird like SCAR was?

The language is the same as Scar's, besides freddy's newly implemented c++ identifiers.

From: Flyboy

I was trying to remember how I used to catch errors, and force the script to run the free bitmaps code every time the script ends (or is stopped). I think it had something to do with using the ThreadSafeCall…

SRL has a Pointer called onScriptTerminate, which is called whenever TerminateScript is called, so as long as you set that, TerminateScript is all you should need to call.

From: Flyboy

New Problem:
I was just informed that this does not work on my beta testers computers. none of the bitmaps are being found. It works like a charm on my system. Does screen resolution make a difference? How do I get bitmaps to work universally for everyone this game has no anti bot methods implemented… so I had hoped a bitmap with zero tolerance would work for everyone. Any thoughts guys???

You are using safe mode, highest brightness, fixed screen, etc? Regardless, searching with a little tolerance is never a bad idea. :)

Flyboy

2012-01-26 00:55:44

@S1N lol, gods forget which planet they created the munchkins on… a few years away and I forget how to turn on a computer… :) Hopefully the finished product will restore your faith in me.

@NCDS Thanks for that onScroptTerminate, that sounds like it should do the trick. I still can't figure out why the bitmaps are not found on other computers… Setting up a bitmap test script so I can determine if its really not finding them or just a setup issue on the users end. Tolerance is not a bad idea.

Daniel

2012-01-26 01:13:08

From: P1nky
Woah! Haven't seen you for a while!


Likewise! :p

Welcome back Flyboy! :p

Flyboy

2012-01-26 02:22:11

To Beta Testers:

Please download attachment and run, follow instrutions given in window at bottom of Samba.

When its done please copy all text from window at bottom (where the instructions were) to a reply here. This will test every bitmap and tell me if your system is finding them or not.

Thanks!

***Edit***
Script removed, Latest script found in first post above

trials6112

2012-01-26 02:26:34

=) welcome back, i did not know you before but i see your a fellow Australian, :) so happy Aussie day to you, and hopefully i can get to know you :)

welcome back

Tickyy

2012-01-26 08:08:16

From: Flyboy
Please download attachment and run, follow instrutions given in window at bottom of Samba.


That samba made me lol, anyways i came here to say hi i never had a chance to see you posting, i hope you stay longer this time. Welcome back!

Oh and my fresh image at my signature fits with you :).

EvilmanK

2012-01-26 19:15:24

From: Flyboy
snip



719320

*****************************************************
Testing all Bitmaps
*****************************************************

bmpGoToGround - NOT FOUND!!!!
bmpGoToSpace - NOT FOUND!!!!
bmpSpaceStation - found (x/y): 516/305

*****************\/ USER INPUT NEEDED \/*****************
Click on <Space Station>
press <6> once menue from Space Station is visible
*****************/\ USER INPUT NEEDED /\*****************

Flyboy

2012-01-26 23:19:43

Newest version attached, make sure you update the bitmaps as I replaced some of them.

You can read the script in any text editor (like notepad).
If you run into any issues, follow the directions in the header to test the bitmaps… if you get errors with that, there is a 90% chance you have installed it incorrectly as I have tested this on multiple platforms successfully… not to say errors won't happen :)

Here is the progress log. See Script header for more details as I use it as my reminder board.
log:
0.01.70
-lol, no idea yet. I'll tell you next version
0.01.6
-add tolerance to bitmap searches
-confirm open boxes still works with new bitmap
-at start of each cycle, click on gotospace
-make possible to attack any insidence

0.01.5
-Confirmed all bitmaps working correctly
-changed open mail from icon clicking to using toolbar at bottom
-Fixed method of finding boxes in mail
-Changed Attack Report detection
0.01.4
-Due to complaints that bitmaps were not detected on other systems I added a
Bitmap test procedure so I can get results from other machines to test
against my results. Set constant <TestBitmaps = true> to turn on feature.
0.01.3
-Move Pictures and use 'ScriptPath' instead of full path desc.
0.01.2
-Mail now opens up to 5 mail at one time
0.01.1
-Added Open Boxes
-Broke up the huge blob of code into smaller procedures
0.01
-Simple point and click with minimal error correction
-Started with this process:
1. Check mail and click box then delete
2. Harvest resorces
3. Refuel ships
4. Randomly choose instance 3, 5, 6 and attack
5. Check for zero losses and then repeat
@trials: After Aussie day, I need a holiday from the holiday ;)

Tickyy: hahaha, now that you pointed it out I see that is not the first time I messed up that spelling. Clearly proof reading is not my strong point… must be why it takes me forever editing typos in my scripts. Love that signature! did you make it? If so might I use it? its classic!!!

KABLE: Thanks for running the test for me. From that alone, I can see there is an issue with bitmap detection… Could you be so kind as to run it again but this time click in the bottom section of Simba and press <ctrl> + <a> to select all then <ctrl> + <c> to copy it. Thanks! oh, just to be thural, I'm guessing you did drag the green target to the game correctly?

EvilmanK

2012-01-27 04:09:59

Yeah, I did have the game targeted. I need a little clarification on where we should place our buildings, though. The game doesn't have a grid (at least for me) that we can align our buildings on so I sort of eyed it. I ran the newest version but Simba would crash whenever I would stop the script because it was looping trying to find a bitmap.

Flyboy

2012-01-27 05:11:51

From: KABLE
Yeah, I did have the game targeted. I need a little clarification on where we should place our buildings, though. The game doesn't have a grid (at least for me) that we can align our buildings on so I sort of eyed it. I ran the newest version but Simba would crash whenever I would stop the script because it was looping trying to find a bitmap.


Rg: placement of Warehouse

The script drags the screen from point "A' to 'B' until screen does not move anymore, place warehouse so its easily visable without any buildings blocking it as shown below.

Edit:
dang why didn't that resize smaller… oh well sorry to all who tried to look at this via cell phone. :)



Uploaded with ImageShack.us



Tickyy

2012-01-27 09:50:33

From: Flyboy
Tickyy: hahaha, now that you pointed it out I see that is not the first time I messed up that spelling. Clearly proof reading is not my strong point… must be why it takes me forever editing typos in my scripts. Love that signature! did you make it? If so might I use it? its classic!!!


Sure thing, go ahead! :D!

EvilmanK

2012-01-27 19:39:29



Simba crashed again. I took a screenshot before it closed.

Flyboy

2012-01-28 06:38:52

Here is the latest update, I have no idea why your bitmaps are not been found… I added tolerance to the searches and redid some of the bitmaps in this one. I also got rid of needing the extra bitmap folder… read header for full list of items changed.

Just copy and paste the code below into Simba and save it

**edit**
Script removed… see first post for most current version

grats

2012-01-28 07:09:40

From: Flyboy
@Geo: Thanks the <CTRL + Spacebar> is exactly what I was looking for. Is there a list of all commands with explanations (ie: repeat, for, etc.) as I did not see these common ones covered in the help file. What version of Pascal is Samba using (Free Pascal, Turbo Pascal, Borland Pascal, etc), or is it still a hybird like SCAR was?

I was trying to remember how I used to catch errors, and force the script to run the free bitmaps code every time the script ends (or is stopped). I think it had something to do with using the ThreadSafeCall…

New Problem:
I was just informed that this does not work on my beta testers computers. none of the bitmaps are being found. It works like a charm on my system. Does screen resolution make a difference? How do I get bitmaps to work universally for everyone this game has no anti bot methods implemented… so I had hoped a bitmap with zero tolerance would work for everyone. Any thoughts guys???


What game is it? a normal flash game would have set resolution for their images so if your screen was 2000x2000 (for easy maths sake) and the images were 100x100 that means they would be pretty tiny, vs if your screen was 1000x1000 the images would still be 100x100 but they would appear bigger.. therefore they wouldn't matter in that example


but if it's a game that goes full screen lets say, World of warcraft.. where if you are zoomed out more or zoomed in more the creatures sizes and resolutions differ on nearly every screen

using a DTM would maybe help for different systems as bitmaps have problems since they're so super specific





oh it's the starcraft looking game I see, I logged in facebook for the first time in like a year to check it out lol
yea those images will change but I'd assume your tolerance could solve that :S maybe better luck with DTM's I'm not sure, I just know bitmaps usually have troubles for weird reason






oh by the way, different browsers will display different colors.. there's sometimes a noticeable change, most of the time colorpicker with photoshop will show you a different hex on the same page / two different browsers it depends what it is.. like java app colors vs flash, flash are usually more similar in different browsers but can still be different.. java is always pretty different

Flyboy

2012-01-28 23:20:08

@grats: Thanks for the info. I was starting to think I was going mad, but what you said made sense… as the main purpose of this script was to remember how to script and to give Simba a trial run. I could have written this script as a very dumb… click on the co-ordinates, but where is the fun/challenge in that. I am marking this project up to a great success. The reason I picked this game was to avoid all the issues you just mentioned… lol

I think I will just tell folks what my browser and resolution are… if they are desperate enough to use this script they will adapt to make it work or learn to script themselves :p…

EvilmanK

2012-01-29 00:44:21

1900x1200 here ^_^

Script crashed again. Couldn't find any bitmaps. It was pretty much the same as the Simba screenshot I posted.

Flyboy

2012-01-29 19:31:56

Updated Script:
See 1st post

Koolstorybro

2012-02-01 01:15:29

screen shot as requested


thanks for all the stuff youve done

Flyboy

2012-02-01 06:08:46

New update in 1st post

The new bitmap of Space Station while being upgraded is untested as it will be a while before I can upgrade mine… If someone could test and let me know if it works… that would be awesome!

Development log:
0.02.01
-mWait: Keep computer awake. Twitch mouse ever 3 minutes
-Added bmp to find Space Station when under construction (grey)

0.02.00
-called script with Try..Finally, this should guarantee freeing memory if crash
-fixed Report Last Attack
-added new wait procedure that will be used to test for all Errors
-rewrote structure of Failsafe
-moved testing for user input (5 or 6) to mWait, now you can open <5> boxes
anytime or end script <6> anytime
-added Check for He3 prior to sending out fleet.
-Cranked default tol up to 25… hopefully that should get most up and going.
-Changed Mail box opener… click on button instead of box.
Now it handles Sales, and Failed Sales mail.
-reset some of the wait times

Koolstorybro

2012-02-01 11:23:33

i let it cycle through twice. works just fine. :)

Flyboy

2012-02-05 03:54:41

Small Changes but the important one is it now hires Common Commanders in the hopes that you hit the jackpot on a good one. Don't forget to throw out the useless ones.

Development log:
0.02.02
-Find/Center Procedure that can center <Space Station> or <Wearhouse>
-Fixed mouse twitch to keep computer awake
-Fixed GoToSpace… was clicking on… who knows where??? lol
-Added Recruit Commander, allows you to hire common commanders

Koolstorybro

2012-02-08 05:09:13

keep up the good work :)

fre

2012-02-08 05:39:58

Seems very good.
I used simba alot for playing FB games :p

Flyboy

2012-02-08 23:35:00

Thanks fre for the comment,
I guess I'm my worst critique, as I see this script poorly written… but not too bad as I am having to relearn every command.

Currently I'm stumped how to use this on multiple accounts, I remember in the past using different windows and being able to switch between them… but for the life of me cannot remember how I did it. I think it was Freddy or Squirrel who had showed me the trick to it… Anyone have experience of running a script for fb game using multiple accounts?

My initial plan was to open all the accounts in separate windows and have program pause to let me manually select correct window and it would just remember the handle, then pause while I select the next one… etc. creating an array of handles (actually it would be an array of records as each account would need different settings). It sure would be helpful if someone could point me to a script that already does this, or to a primer that would teach me how to handle multiple windows, as I can't remember what the commands are to switch active window, bring to front, etc. In a perfect world I would love to strip the game out of the window and put it into it own container like SMART does… but that might be aiming a little too high for my current level :)

Koolstorybro

2012-02-15 04:17:47

im sure youll think of a way. just gotta get creative ;)

Bam Bam

2012-02-16 10:24:26

Flyboy can you keep an array of client handles or something to that effect and loop between them?

Flyboy

2012-02-22 21:09:21

From: Bam Bam
Flyboy can you keep an array of client handles or something to that effect and loop between them?

Thanks Bam Bam, Yes, that is the approach I am taking. I wish it would work with firefox tabs… but separate windows will do the trick.

Koolstorybro

2012-02-24 02:37:14

you mean we'll be able to use alts in the future? cuz thatd be really helpful, lol

Koolstorybro

2012-04-15 03:42:38

you done with this bot for now flyboy?

Flyboy

2012-08-30 23:22:46

Yes Koolstorybro I have it running unlimited number of alts so all can farm at the same time. Given the small size of this game I have not released it to the public as it would quickly kill the dynamics of the game. I hope you understand. So for all intents and purposes this is now an abandoned project. Please feel free to use the code however you like.