The Wiki for Tale 5 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.

Takhetu/Code

From ATITD5
Revision as of 02:47, 5 November 2010 by Takhetu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
;Ctrl+R to reload
;Ctrl+P to pause

;~ Info
WinActivate, eGenesis Client
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
StartXGUI := Xmax+win_Xpos-255
StartYGUI := win_Ypos+35
Gui, +AlwaysOnTop +ToolWindow -Border +Background 
Gui, Add, Text,x10 y10,Crematory Macro Running
Gui, Add, Text,x10 y25,CTRL+R - Restart macro
Gui, Add, Text,x10 y40,CTRL+P - Pause macro
Gui, Add, Text,x10 y55 vMyText,CTRL+A - Turn ON Auto mode
Gui, Add, Text,x10 y75,Keep the crematory window away from popups.
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window

;~ Amigos
;~     * B1=S1+S7
;~     * B2=S5
;~     * B3=S2
;~     * B4=S4+S6
;~     * B5=S3 

	;;******* CONFIG *********
		;Singles
		B1 := 2  ;Button Number
		B1S := 5  ;Slider Number

		B2 := 3  ;Button Number
		B2S := 2  ;Slider Number

		B3 := 5  ;Button Number
		B3S := 3  ;Slider Number

		;Pairs
		B4 := 1   ;Button Number
		B4S1 := 1 ;First Slider Number
		B4S2 := 7 ;Second Slider Number
		B4D := 0  ;0 for parallel, 1 for opposite direction

		B5 := 4    ;Button Number
		B5S1 := 4  ;First Slider Number
		B5S2 := 6  ;Second Slider Number
		B5D := 1   ;0 for opposite, 1 for paralel direction

	;;******* END OF CONFIG *********

gosub, Setup

WinActivate, eGenesis Client
lastTimeSlidersMoved := A_Now 
autoMode := false
Loop
{
	If (autoMode=true)
	{
;~ 		check if completed
		ImageSearch, BarX,BarY,ProgressSX,ProgressSY,ProgressEX,ProgressEY,*40 BitRed.png
		if ErrorLevel=1
		{
			;~ 	Knobs not moving - Finished
			gosub, unload
			gosub, load
		} else {
			currentTime := A_Now
			tempLast := LastTimeSlidersMoved
			EnvSub, tempLast,,Seconds 
			If (tempLast<-300)
			{
				gosub, unload
				gosub, load
			}
		}
	} 
	;~ 	Check to make sure the window wasn't moved
		WindowMoved := false 
		ImageSearch, NewLimeX,NewLimeY,0,0,Xmax,Ymax,*40 Lime.png
		If ErrorLevel<1
		{
			If (NewLimeX<>LimeX)
			{
				WindowMoved := true
			} else {
				If (NewLimeY<>LimeY)
				{
					WindowMoved := True
				}	
			}
			If WindowMoved=True
			{
				gosub, Setup
			}
		} else {
			gosub, Setup
		}	
		
			
		ImageSearch, KnobX,KnobY1,SliderSearchSX1,SliderSearchSY,SliderSearchEX1,SliderSearchEY,*40 SliderKnob.png	
		ImageSearch, KnobX,KnobY2,SliderSearchSX2,SliderSearchSY,SliderSearchEX2,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY3,SliderSearchSX3,SliderSearchSY,SliderSearchEX3,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY4,SliderSearchSX4,SliderSearchSY,SliderSearchEX4,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY5,SliderSearchSX5,SliderSearchSY,SliderSearchEX5,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY6,SliderSearchSX6,SliderSearchSY,SliderSearchEX6,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY7,SliderSearchSX7,SliderSearchSY,SliderSearchEX7,SliderSearchEY,*40 SliderKnob.png
		Knob1 := SliderM-KnobY1-1
		Knob2 := SliderM-KnobY2-1
		Knob3 := SliderM-KnobY3-1
		Knob4 := SliderM-KnobY4-1
		Knob5 := SliderM-KnobY5-1
		Knob6 := SliderM-KnobY6-1
		Knob7 := SliderM-KnobY7-1

		NoKnobsMoved := True

If B4D=0
{
	If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
	{
		NoKnobsMoved := False 
		If (Knob%B4S1%>oldKnob%B4S1%) ;knob rose
		{
			If (Knob%B4S1%>Knob%B4S2%) ;Knob%B4S1% is above Knob%B4S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		} else {
			If (Knob%B4S1%<Knob%B4S2%) ;Knob%B4S1% is bellow Knob%B4S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		}
		oldKnob%B4S1% := Knob%B4S1%
		oldKnob%B4S2% := Knob%B4S2%
	}
} else {
	If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
	{
		NoKnobsMoved := False 
		averagePos := floor((Knob%B4S1%+Knob%B4S2%)/2)
		If (Knob%B4S1%>oldKnob%B4S1%) ;knobs are going up
		{
			If averagePos>0 ;averageposition is above center
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		} else { ;knobs are going down
			If averagePos<0 ;averageposition is bellow center
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		}
		oldKnob%B4S1% := Knob%B4S1%
		oldKnob%B4S2% := Knob%B4S2%
	}
}

If B5D=0
{
	If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
	{
		NoKnobsMoved := False 
		If (Knob%B5S1%>oldKnob%B5S1%) ;knob rose
		{
			If (Knob%B5S1%>Knob%B5S2%) ;Knob%B5S1% is above Knob%B5S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		} else {
			If (Knob%B5S1%<Knob%B5S2%) ;Knob%B5S1% is bellow Knob%B5S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		}
		oldKnob%B5S1% := Knob%B5S1%
		oldKnob%B5S2% := Knob%B5S2%
	}
} else {
	If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
	{
		NoKnobsMoved := False 
		averagePos := floor((Knob%B5S1%+Knob%B5S2%)/2)
		If (Knob%B5S1%>oldKnob%B5S1%) ;knobs are going up
		{
			If averagePos>0 ;averageposition is above center
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		} else { ;knobs are going down
			If averagePos<0 ;averageposition is bellow center
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		}
		oldKnob%B5S1% := Knob%B5S1%
		oldKnob%B5S2% := Knob%B5S2%
	}
}


		NumAbove := 0
		NumBellow := 0
		If (Knob%B4S1%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B4S2%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B5S1%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B5S2%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}

		Axis1 := 0
		Axis2 := 0
		If NumAbove=1
		{
			Axis1 := 5
		} else {
			If NumAbove=0
			{
				Axis1 := 5
				Axis2 := 5
			} else {
				If NumBellow=1
				{
					Axis1 := -5
				} else {
					If NumBellow=0
					{
						Axis1 := -5
						Axis2 := -5
					}
				}
			}
		}
		


	;~ 	First Single Slider
		If (Knob%B1S%>oldKnob%B1S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B1S% := Knob%B1S%
			If (Knob%B1S%>Axis1) ;knob Over Line
			{
				MouseClick,Left,ButtonX%B1%,ButtonY
			}
		} else {
			If (Knob%B1S%<oldKnob%B1S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B1S% := Knob%B1S%
				If (Knob%B1S%<Axis1) ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B1%,ButtonY
				}
			}
		}

	;~ 	Second Single Slider
		If (Knob%B2S%>oldKnob%B2S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B2S% := Knob%B2S%
			If (Knob%B2S%>Axis2) ;knob Over Line
			{
				MouseClick,Left,ButtonX%B2%,ButtonY
			}
		} else {
			If (Knob%B2S%<oldKnob%B2S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B2S% := Knob%B2S%
				If (Knob%B2S%<Axis2) ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B2%,ButtonY
				}
			}
		}

	;~ 	Third Single Slider
		If (Knob%B3S%>oldKnob%B3S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B3S% := Knob%B3S%
			If Knob%B3S%>0 ;knob Over Line
			{
				MouseClick,Left,ButtonX%B3%,ButtonY
			}
		} else {
			If (Knob%B3S%<oldKnob%B3S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B3S% := Knob%B3S%
				If Knob%B3S%<0 ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B3%,ButtonY
				}
			}
		}


	
}

Setup:
IfWinExist eGenesis Client
{
	WinGet, GameWinHandle, ID, eGenesis Client
} else {
	Msgbox, eGenesis client not running, exiting...
Exit
}

;~ Base
OriX := 625
OriY := 342

;~ Offsets
offRedLineStartX := OriX-625
offRedLineStartY := OriY-333
offSliderT := OriY-364
offSliderM := OriY-424
offSliderB := OriY-483
offSliderX1 := OriX-618
offSliderX2 := OriX-654
offSliderX3 := OriX-690
offSliderX4 := OriX-726
offSliderX5 := OriX-762
offSliderX6 := OriX-798
offSliderX7 := OriX-834
offButtonY := OriY-503
offButtonX1 := OriX-647
offButtonX2 := OriX-688
offButtonX3 := OriX-729
offButtonX4 := OriX-769
offButtonX5 := OriX-809


;~ Locate Word Lime
WinActivate eGenesis Client
ImageSearch, LimeX,LimeY,0,0,Xmax,Ymax,*40 Lime.png
If ErrorLevel=2
{
	MsgBox,,,Couldn't Find Lime.png
}
If ErrorLevel<1
{
	GuiControl, Text, Label, Found Crematory Window
} else {
	If ErrorLevel<2
	{
		;Didn't find the Word Lime
		MsgBox,,Crematory Macro,Crematory Window not Found, closing macro
		ExitApp
	}
}

RedLineStartX := LimeX-offRedLineStartX
RedLineStartY := LimeY-offRedLineStartY
SliderX1 := LimeX-offSliderX1
SliderX2 := LimeX-offSliderX2
SliderX3 := LimeX-offSliderX3
SliderX4 := LimeX-offSliderX4
SliderX5 := LimeX-offSliderX5
SliderX6 := LimeX-offSliderX6
SliderX7 := LimeX-offSliderX7
SliderT := LimeY-offSliderT
SliderM := LimeY-offSliderM
SliderB := LimeY-offSliderB
ButtonY := LimeY-offButtonY
ButtonX1 := LimeX-offButtonX1
ButtonX2 := LimeX-offButtonX2
ButtonX3 := LimeX-offButtonX3
ButtonX4 := LimeX-offButtonX4
ButtonX5 := LimeX-offButtonX5
ProgressSX := LimeX-2
ProgressSY := LimeY-12
ProgressEX := LimeX+3
ProgressEY := LimeY+5
SliderSearchSX1 := SliderX1-2
SliderSearchSX2 := SliderX2-2
SliderSearchSX3 := SliderX3-2
SliderSearchSX4 := SliderX4-2
SliderSearchSX5 := SliderX5-2
SliderSearchSX6 := SliderX6-2
SliderSearchSX7 := SliderX7-2
SliderSearchEX1 := SliderX1+7
SliderSearchEX2 := SliderX2+7
SliderSearchEX3 := SliderX3+7
SliderSearchEX4 := SliderX4+7
SliderSearchEX5 := SliderX5+7
SliderSearchEX6 := SliderX6+7
SliderSearchEX7 := SliderX7+7
SliderSearchSY := SliderT-10
SliderSearchEY := SliderB+10
oldKnob1 := 100
oldKnob2 := 100
oldKnob3 := 100
oldKnob4 := 100
oldKnob5 := 100
oldKnob6 := 100
oldKnob7 := 100
return

Unload: ;Unload
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Take
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Take.png
	If ErrorLevel<1
	{
		MouseClick,Left,LoadX,LoadY
		sleep,300
		ImageSearch,EveX,EveY,LoadX,LoadY-50,LoadX+133,LoadY+50,*90 Everything.png
		If ErrorLevel<1
		{
			MouseClick,Left,EveX,EveY
			sleep, 300
		} 
	}
	return


Load:
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Load
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Load.png
	If ErrorLevel<1
	{
		;load Limestone
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Leeks
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Flax
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Papyrus
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Wood
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;Fire
		MouseClick,Left,LoadX,LoadY-17
		sleep, 100
	}
	return

Close:
ExitApp

^a:: ;automode
if (autoMode=True)
{
	autoMode := False
	GuiControl,,myText,CTRL+A - Auto Mode is OFF
} else {
	autoMode := True
	GuiControl,,myText,CTRL+A - Auto Mode is ON
}
return

^p::pause
^r::reload