[TRIAL] Urban Rivals Bot

12/29/2013 17:43 mahdin_dvf#1
Hey guys,

Here is an [Only registered and activated users can see links. Click Here To Register...] script ready for testing and customization. Feel free to contribute your own advice for further development. If you plan on releasing your own version, please release it to the general public at no cost at all so that others can make use of it.

If you have any issues, try tweaking the card location coordinates.

You can download AutoIt on its main website. Click [Only registered and activated users can see links. Click Here To Register...]


Here is the code:
Code:
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

;Globals
HotKeySet("{ESC}", "Terminate")
Global $oIE = _IECreateEmbedded()   
Global $URL = "http://www.urban-rivals.com/game/flash/" 
Global $botname = "Ikariam UR Bot"


#Region ### START Koda GUI section ### Form=
GUICreate($botname, 1206, 712, -1, -1)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 50, 1186, 612)
GUISetState(@SW_SHOW)
$settings = GUICreate("Settings", 300, 200, "", "", -1, -1, $botname)
GUISetState(@SW_SHOW)
$card11 = GUICtrlCreateCombo("4", 10, 35, 100, 20) ; input COMBO boxes
GUICtrlSetData(-1, "1|2|3|4")
$card22 = GUICtrlCreateCombo("1", 10, 70, 100, 20)
GUICtrlSetData(-1, "1|2|3|4")
$card33 = GUICtrlCreateCombo("2", 10, 105, 100, 20)
GUICtrlSetData(-1, "1|2|3|4")
$card44 = GUICtrlCreateCombo("3", 10, 140, 100, 20)
GUICtrlSetData(-1, "1|2|3|4")
$pillz11 = GUICtrlCreateCombo("0", 120, 35, 100, 20) ; input COMBO boxes
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
$pillz22 = GUICtrlCreateCombo("6", 120, 70, 100, 20)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
$pillz33 = GUICtrlCreateCombo("6", 120, 105, 100, 20)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
$pillz44 = GUICtrlCreateCombo("6", 120, 140, 100, 20)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
#EndRegion ### END Koda GUI section ###




_IENavigate ($oIE, $URL)
_IELoadWait ($oIE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/6)
Local $card1[2] = ["411", "626"] ; card location
Local $card2[2] = ["581", "626"]
Local $card3[2] = ["751", "626"]
Local $card4[2] = ["921", "626"]
Local $var = 0
Local $x = 0
Local $y = 0
Local $z = 0
Local $pos
GUISetState(@SW_SHOW)
While 1
Select ; REFRESH WORKING ULTIMATE FAILSAFE!!!!!!!!!!!!!!
Case $var >= 25
   _IEAction($oIE,"refresh")
   $var = $var - $var ; $var countdown REFRESH!!! COUNTDOWN RESTART
   $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/6)
EndSelect
Select ; REFRESH WORKING ULTIMATE FAILSAFE!!!!!!!!!!!!!!
Case $x >= 25
   _IEAction($oIE,"refresh")
   $x = $x - $x ; $var countdown REFRESH!!! COUNTDOWN RESTART
   $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/6)
EndSelect
Select ; REFRESH WORKING ULTIMATE FAILSAFE!!!!!!!!!!!!!!
Case $y >= 25
   _IEAction($oIE,"refresh")
   $y = $y - $y ; $var countdown REFRESH!!! COUNTDOWN RESTART
   $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/6)
EndSelect
Select ; REFRESH WORKING ULTIMATE FAILSAFE!!!!!!!!!!!!!!
Case $z >= 25
   _IEAction($oIE,"refresh")
   $z = $z - $z ; $var countdown REFRESH!!! COUNTDOWN RESTART
   $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/6)
EndSelect
$coord = PixelSearch(478, 376, 942, 622, 0x595451 ) ; back to room button
If Not @error Then
MouseClick ("left", $coord[0], $coord[1], 1, 1)
EndIf
MouseClick("Left", 671, 521, 1) 
Sleep(100)
$input1 = GUICtrlRead($card11) ; reads the input number e.g. 1 = 1st card
$input2 = GUICtrlRead($card22)
$input3 = GUICtrlRead($card33)
$input4 = GUICtrlRead($card44)
$pinput1 = GUICtrlRead($pillz11) ; reads the input number e.g. 1 = 1st pillz
$pinput2 = GUICtrlRead($pillz22)
$pinput3 = GUICtrlRead($pillz33)
$pinput4 = GUICtrlRead($pillz44)
Select ; CARD SELECTION PROCESS STARTS  ; #1 2nd card  CARD CHECK BEGINS!!!!
Case $input1 = 1
   Local $pos[2] = ["411", "626"]
Case $input1 = 2
   Dim $pos[2] = ["581", "626"]
Case $input1 = 3
   Local $pos[2] = ["751", "626"]
Case $input1 = 4
   Local $pos[2] = ["921", "626"]
EndSelect ; CARD SELECTION PROCESS ENDS
MouseClick("Left", $pos[0], $pos[1], 1, 1)
$pos = MouseGetPos()
MouseClick("Left", $pos[0]+31, $pos[1]+31, 1, 1) ; #1 2nd card
Sleep(500)
$coord = PixelSearch(776, 536, 913, 541, 0x0F7499 ) ; TESTS if previous is used by detect plus button - true means not used
   If Not @error Then ; if statement is true
	  Select
	  Case $pinput1 > 0
		 MouseClick("Left", 943, 483, $pinput1, 1) ; + PLUS BUTTON
	  EndSelect
	  MouseClick("Left", 840, 542, 6, 1) ; FIGHT BUTTON	
	  $var = $var - $var ; $var countdown REFRESH!!! COUNTDOWN RESTART
	  $x = $x + 1 ; $x countdown begins!!!!!!! to REFRESH!!!
	  $y = $y - $y ; $y countdown REFRESH!!! COUNTDOWN RESTART
	  $z = $z - $z ; $z countdown REFRESH!!! COUNTDOWN RESTART
   Else ; move to next card
	  Select
	Case $input2 = 1
   Local $pos[2] = ["411", "626"]
Case $input2 = 2
   Dim $pos[2] = ["581", "626"]
Case $input2 = 3
   Local $pos[2] = ["751", "626"]
Case $input2 = 4
   Local $pos[2] = ["921", "626"]
	  EndSelect
	  MouseClick("Left", $pos[0], $pos[1], 1, 1) ; #2 4th card no pillz
	  $pos = MouseGetPos()
	  MouseClick("Left", $pos[0]-27, $pos[1]-4, 1, 1) ; #2 4th card no pillz
	  $var = $var + 1 ; $var countdown begins!!!!!!! to REFRESH!!!
	  $coord = PixelSearch(776, 536, 913, 541, 0x0F7499 ) ; TESTS if previous is used by detect plus button - true means not used
   If Not @error Then ; if statement is true
	  Select
	  Case $pinput2 > 0
		 MouseClick("Left", 943, 483, $pinput2, 1) ; + PLUS BUTTON
	  EndSelect
	  MouseClick("Left", 840, 542, 6, 1) ; FIGHT BUTTON	
			$var = $var - $var ; $var countdown REFRESH!!! COUNTDOWN RESTART
			$y = $y + 1 ; $y countdown begins!!!!!!! to REFRESH!!!
			$x = $x - $x ; $x countdown REFRESH!!! COUNTDOWN RESTART
			$z = $z - $z ; $z countdown REFRESH!!! COUNTDOWN RESTART
         Else 
			Select
			Case $input3 = 1
			   Local $pos[2] = ["411", "626"]
			Case $input3 = 2
			   Dim $pos[2] = ["581", "626"]
			Case $input3 = 3
			   Local $pos[2] = ["751", "626"]
			Case $input3 = 4
			   Local $pos[2] = ["921", "626"]
			EndSelect
	        MouseClick("Left", $pos[0], $pos[1], 1, 1) ; #3 3rd card no pillz
			$pos = MouseGetPos()
			MouseClick("Left", $pos[0]+5, $pos[1]-10, 1, 1) ; #3 3rd card no pillz
        $coord = PixelSearch(776, 536, 913, 541, 0x0F7499 ) ; TESTS if previous is used by detect plus button - true means not used
   If Not @error Then ; if statement is true
	  Select
	  Case $pinput3 > 0
		 MouseClick("Left", 943, 483, $pinput3, 1) ; + PLUS BUTTON
	  EndSelect
	  MouseClick("Left", 840, 542, 6, 1) ; FIGHT BUTTON	
				  $var = $var - $var ; $var countdown REFRESH!!! COUNTDOWN RESTART
				  $z = $z + 1 ; $z countdown begins!!!!!!! to REFRESH!!!
				  $x = $x - $x ; $x countdown REFRESH!!! COUNTDOWN RESTART
				  $y = $y - $y ; $y countdown REFRESH!!! COUNTDOWN RESTART
               Else 
			        Select
			   Case $input4 = 1
			   Local $pos[2] = ["411", "626"]
			Case $input4 = 2
			   Dim $pos[2] = ["581", "626"]
			Case $input4 = 3
			   Local $pos[2] = ["751", "626"]
			Case $input4 = 4
			   Local $pos[2] = ["921", "626"]
				    EndSelect				  
				  MouseClick("Left", $pos[0], $pos[1], 6, 1) ; #4 MOVE DIRECTLY TO 1st card no pillz
				  $pos = MouseGetPos()
				  MouseClick("Left", $pos[0]+31, $pos[1]-3, 6, 1) ; 1st card
				  Select
	  Case $pinput4 > 0
		 MouseClick("Left", 943, 483, $pinput4, 1) ; + PLUS BUTTON
	  EndSelect	              
	              MouseClick("Left", 840, 542, 6, 1) ; FIGHT BUTTON
			   EndIf
		 EndIf
			
   EndIf ; END OF CARDS CHECK
MouseClick("Left", 703, 454, 6) ; CANCEL CARD!!!
Sleep(500) 
WEnd

 
 Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
Feel free to post your suggestions and comments ! Cheers!
12/29/2013 23:29 kurpiq#2
hi, try use controlclick not mouseclick if you can.
for what resolution you do this script ?, ps this is not trial but alpha ^^ else autoit is great to make small bots try use contolclick (in your program window) and make simply pause func and exit in other key (for other people who can't change)

and make instruction what coord is for what click (1 for 2 for 3 for etc...)
12/30/2013 09:02 mahdin_dvf#3
Thank you very much !

For instructions:
-the Escape button exits the app
-You can modify the coordinates at "CARD SELECTION PROCESS STARTS" position where $pos contains the coordinates


This needs some little bit of adjustment for example the missions and fight buttons. If you could make these adjustments maybe others can make better use of the bot.

Hopefully this New Year, more folks will want to use this bot.
The controlclick option is underway and should be ready soon
01/04/2014 17:10 mahdin_dvf#4
any luck yet folks?
01/10/2014 12:26 malakiangtiyan#5
its better to create a fight window then do all the x and y calculations on it. because not all users have the same resolution as you have. and its very troublesome to make non programmer users to set the coordinates themselves.
01/12/2014 17:44 mahdin_dvf#6
hello malakiangtiyan,

Could you tell me how I can do this and how you can read the game data from the flash player ?
01/13/2014 01:54 malakiangtiyan#7
hi,

i dont mean reading the fight from flash. like what you had in your bot. it uses x and y coordinates to click. just create a program where UR loads then use it as your bots basis. So that you dont have to worry about the users resolution.
01/14/2014 00:20 MaouKami#8
Or go more advanced, and stop reading colors and pressing cords, but just read the protocol and act upon that, not sure if you saw my short time post, that was later removed.

With a new version of my bot ?
No more need for focus etc, able to read cards, all there stats including opponent etc.
01/14/2014 09:44 mahdin_dvf#9
Quote:
Originally Posted by MaouKami View Post
Or go more advanced, and stop reading colors and pressing cords, but just read the protocol and act upon that, not sure if you saw my short time post, that was later removed.

With a new version of my bot ?
No more need for focus etc, able to read cards, all there stats including opponent etc.
Exactly, how did you read the cards from the game, thats like impossible in so many ways ! Did you use pointers or something ?

Also, just for clarification, what does ' read the protocol ' mean ? Am i supposed to decode with incoming requests or what is it ?

Cheers for the advice and your comments !
01/14/2014 14:00 MaouKami#10
It is not impossible to read cards, simply read the data that the server sends and parse it.
And with server data, i mean protocol what is simply json though.

Using the data the server sends, you can make out what state the bot is in,
Like is it in battle if so is it his turn, if so make a choice etc.