[Guide] AutoIt template to teleport

03/07/2013 03:50 168Atomica#1
To those who wants to go to different map (for botting, etc.). Here is the code I use. If you are following my threads, I only use scripts to bot and still enjoy the game :P

Ok enough with the talk. Here is the function
Code:
Func _teleport($mapcode)
	Sleep(2000)
	Switch $mapcode
		;Teleport Map Codes
		Case $BI1
		Case $BI2
		Case $DS1
		Case $DS2
		Case $GD1
		Case $GD2
		Case $PL1
			_chooseMap($PL)
			MouseClick("left",430, 306)
			Sleep(2000)
		Case $PL2
		Case $PL3
		Case $FRUINA1
		Case $FRUINA2
		Case $UG1
		Case $UG2
		Case $FRUINS1
		Case $FRUINS2
		Case $FRUINS2
		Case $LS1
		Case $LS2
		Case $LS3
		Case $MF1
			_chooseMap($MF)
			MouseClick("left",513, 523)
			Sleep(2000)
		Case $MF2
		Case $PF1
		Case $PF2
	EndSwitch
	Sleep(10000)	;WAIT FOR MAP TO LOAD
EndFunc
Here is the Map selector (_chooseMap) called by that function. What this function does is open the map and select the map based on the mapcode specified.
Code:
Func _chooseMap($mapcode)
	_openMap()
	MouseMove(732,326)	;
	MouseWheel("up",3)	;this resets the map
	Switch $mapcode
		Case $BI
			$mapPos =  $mapstarty + (41 * 0)
			MouseClick("left",$mapstartx,$mapPos)
		Case $DS
			$mapPos =  $mapstarty + (41 * 1)
			MouseClick("left",$mapstartx,$mapPos)
		Case $GD
			$mapPos =  $mapstarty + (41 * 2)
			MouseClick("left",$mapstartx,$mapPos)
		Case $PL
			$mapPos =  $mapstarty + (41 * 3)
			MouseClick("left",$mapstartx,$mapPos)
		Case $FRUINA
			$mapPos =  $mapstarty + (41 * 4)
			MouseClick("left",$mapstartx,$mapPos)
		Case $UG
			$mapPos =  $mapstarty + (41 * 5)
			MouseClick("left",$mapstartx,$mapPos)
		Case $FRUINS
			$mapPos =  $mapstarty + (41 * 6)
			MouseClick("left",$mapstartx,$mapPos)
		Case $LS
			$mapPos =  $mapstarty + (41 * 7)
			MouseClick("left",$mapstartx,$mapPos)
		Case $MF
			Sleep(100)
			MouseWheel("down",1)
			Sleep(100)
			$mapPos =  $mapstarty + (41 * 7)
			MouseClick("left",$mapstartx,$mapPos)
		Case $PF
			Sleep(100)
			MouseWheel("down",2)
			Sleep(100)
			$mapPos =  $mapstarty + (41 * 7)
			MouseClick("left",$mapstartx,$mapPos)
		EndSwitch
	Sleep(1500)	;WAIT FOR MAP TO LOAD
EndFunc
And here is the function to open the map.
Code:
Func _openMap()
	if not _isMapOpen() Then
		Send("m")
	EndIf
EndFunc
Remember that we need to check whether the map is open or not. (I use a special color that is unique with the map window to detect if it is open). So I device a little code to check if the map is already open.
Code:
Func _isMapOpen()
	$coord = PixelSearch(520,214,520,214, 0x618AA4, 10, 1)
	if not @error Then
		Return True
	Else
		Return False
	EndIf
EndFunc
And finally you need to declare these constants at the top of your code.
Code:
;-------------------------------MAP CODE CONSTANTS ------------------------------------
;Map Codes
Const $BI 	= "Bloody Ice"
Const $DS	= "Desert Scream"
Const $GD	= "Green Despair"
Const $PL	= "Port Lux"
Const $FRUINA = "Fort Ruina"
Const $UG	= "Undead Ground"
Const $FRUINS = "Frogotten Ruins"
Const $LS	= "Lakeside"
Const $MF	= "Mutant Forest"
Const $PF	= "Pontus Ferrum"

;Teleport Map Codes
Const $BI1	= 0X1
Const $BI2 	= 0X2
Const $DS1	= 0X3
Const $DS2	= 0X4
Const $GD1	= 0X5
Const $GD2	= 0X6
Const $PL1	= 0X7
Const $PL2	= 0X8
Const $PL3	= 0X9
Const $FRUINA1	= 0XA
Const $FRUINA2	= 0XB
Const $UG1	= 0XC
Const $UG2	= 0XD
Const $FRUINS1	= 0XE
Const $FRUINS2	= 0XF
Const $LS1	= 0X10
Const $LS2	= 0X11
Const $LS3	= 0X12
Const $MF1	= 0X13
Const $MF2	= 0X14
Const $PF1	= 0X15
Const $PF2	= 0X16

$mapstarty = 263
$mapstartx = 732
mapstarty and mapstartx are the coordinates where to begin searching for the minimap (right side of the map). Each minimap are almost fixed in distance with each other so I just need a reference point to detect how many down arrow i need to go to a specific map. :P

FAQ
1. Does this work without TP stone?
Nope. This only mimics the usual play scenario of opening the map and teleporting to a specific place.

2. Where do I use this?

You could use to anywhere you want. I use this code + my farming script to farm on different maps.
You could use that code to TP back to a place after certain period of farming with scripts.

3. Does this work on every screen sizes?
Nope. If are following my threads, I am working on a 1024x800 screen size (as i have a big monitor :p)

4. So why bother put that useless code here.
It is not meant for you to copy and paste 'as-is'. It is working for me. If you could adjust the coordinates properly, then you could use make this work for you too.
03/07/2013 08:16 chengman#2
Nice Script Mr.168Atomica. But i still cannot use any script in my cabal (TH)client. I still wanna guide to bypass that. ^^ pls.
03/07/2013 11:16 joxof#3
Nice share.

Thanks :handsdown:
03/07/2013 13:57 geosnuk#4
awesome my master strikes again ^_^..
03/07/2013 22:41 TotallyRed#5
Nice work.