The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Cegaiel/Macros/Mining/Code

From A Tale in the Desert
Jump to navigationJump to search
;Ctrl+P to pause script and Ctrl+P again to resume
;The AHK icon in system tray will turn red while paused.
;Ctrl+R to reload script
;Release Date: 10/24/2010
;Author: Cegaiel
;Credits to Takhetu for the loop/code that generates the combinations, of which mines to click.

;Last Update: 10/26/2010 - Major Revision - The combinations was still incorrect. Now they are 100% accurate. This reduces the time to run the script by 50%
;Last Update: 10/29/2010 - Removed FileAppend line, which was a debugging thing for me, but likely to give an error to you.




	ChatWarning = 0


	Start:


;	// START CONFIGURATION AREA

	;Set the speed in microseconds (100 = 1/10th second, 1000 = 1 second, etc)
	;If you got a slower computer or lag, then try raising it 50 or 100 at a time, ie 200, 250, 300
	;This is the speed that it highlights your mine crystals

		Delay = 200  ;Safe (lag) is 200+, Fast is 100 (fast computer, no lag)

	;If you have problems with it not closing the popup, then try adjusting this number higher.

		PopUpDelay = 300  ;Safe (lag) is 300+, Fast is 200 (fast computer, no lag)

	;This is the shade at which is searches the for the color of the popup box.
	;If you find yourself running all the time, ie its confusing sand with the popup, then try lowering 5 at a time (ie 20,15,etc).
	;If you find it is not even seeing the popup box, then try raising 5 at a time and finetune 1 at a time (ie 30,35,etc)

		Shade = 24  ;Original is 24

;	// END CONFIGURATION AREA




MineNum = 0

IfWinExist eGenesis Client
{
	;WinActivate



	Gui, +AlwaysOnTop +ToolWindow
	Gui, Font, bold
	Gui, Add, Text, vMineNumText, Record crystal positions
	Gui, Font, norm
	Gui, Add, Text,,
	( LTrim
	Hover and middle-click (Click mouse-wheel) on each ore stone, one by one,
	until you've clicked on all the crystals. 

	AFTER setting (middle clicking) all your stones, then click the OK button.

	(Drag this box out of the way if any stones are hidden)


	Reminder: Ctrl+P to Pause  -  Ctrl+R to Reload

	)

	Gui, Add, Button, default gMineSetLoops, OK
	Gui, Show


	WinGet, GameWinHandle, ID, eGenesis Client
	loop
	{

		;WinActivate
		CoordMode, Mouse, Relative
		KeyWait, MButton, D
		KeyWait, MButton
		MouseGetPos, TestX, TestY, WinHandle
		if (WinHandle = GameWinHandle)
		{
			Gosub, MineRecord
		}
		else
		{
			Gui, Destroy
			break
		}
	}
	return

	MineRecord:
	MineNum++
	MouseGetPos, MineX%MineNum%, MineY%MineNum%
	GuiControl, Text, MineNumText, %MineNum% crystals captured
	return


	MineSetLoops:
	Gui, Submit
	Gui, Destroy



	SetDefaultMouseSpeed, 0


	if ChatWarning = 0
	Msgbox, Make sure your chat is MINIMIZED!`n`nThis message will not display again :)


			WinActivate, eGenesis Client
			WinWait, eGenesis Client

			WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos 

			;Get coordinates, for your resolutions'  X,Y location of the popups that will occur later.
			CenterX := Floor(Xmax/2)
			CenterY := Floor(Ymax/2)+103





Sleep 1000

MainLoop := MineNum-2

Loop %MainLoop%
{

	FirstStone := A_Index
;	NumToRun1 := 6-A_Index
	NumToRun1 := MineNum-A_Index-1

	Loop, %NumToRun1%
	{
		SecondStone := FirstStone+A_Index
		;NumToRun2 := 5-A_Index 
		NumToRun2 := MineNum-SecondStone

		Loop, %NumToRun2%
		{
			ThirdStone := SecondStone+A_Index





MouseMove, MineX%FirstStone%, MineY%FirstStone%
;Msgbox, FirstStone: MineX%FirstStone%, MineY%FirstStone%
Sleep %Delay%
Send {A}
Sleep %Delay%
MouseMove, MineX%SecondStone%, MineY%SecondStone%
;Msgbox, SecondStone: MineX%SecondStone%, MineY%SecondStone%
Sleep %Delay%
Send {A}
Sleep %Delay%
MouseMove, MineX%Thirdstone%, MineY%Thirdstone%
;Msgbox, ThirdStone: MineX%Thirdstone%, MineY%Thirdstone%
Sleep %Delay%
;Send {A}
;Sleep %Delay%
Send {S}
Sleep %Delay%




Gosub, Popup

		}
	}
}



	if ChatWarning = 0
	{
	Msgbox, Done, Click the mine and get a new workload!`n`nThis message will not display again :)
	ChatWarning = 1
	}

	Gosub, Start
	return
}

Popup:

			;Search for the RBG color of 0xECDFBD (Same as HTML code: #ECDFBD)

			PixelSearch, Px, Py, %CenterX%, %CenterY%, %CenterX%, %CenterY%, 0xEBDDBB, %shade%, Fast|RGB

			if ErrorLevel = 0
			{
			Sleep %PopupDelay%
			MouseMove, %CenterX%, %CenterY%
			Sleep %PopupDelay%
			Click
			Sleep %PopupDelay%
			}
			return





^r::reload
^p::Pause