#NoEnv #SingleInstance, Force #Include Gdip.ahk CoordMode, Mouse, Screen ;================================================================================================================================================================================================================================================================================================================================ Buddy := new SlyphBuddy() ;================================================================================================================================================================================================================================================================================================================================ f1:: Loop { Buddy.ScanForTarget( 0, 0, A_ScreenWidth, A_ScreenHeight ) } return f2::pause ^LButton::Buddy.TargettingSystemClicked() ~Ctrl:: while( GetKeyState("Ctrl") ) { Buddy.DisplayTargettingSystem() } Buddy.ClearGraphics() return ;================================================================================================================================================================================================================================================================================================================================ Class SlyphBuddy { __New() { this.iProgramStartTime := A_TickCount this.bDebugMode := false this.bInterpolateSearchArea := true Gui, New, +Hwndhwnd Gui %hwnd%: -Caption +E0x80000 +ToolWindow +AlwaysOnTop +OwnDialogs +Hwndhwnd ;WinSet, ExStyle, +0x00000020, ahk_id %hwnd% ;WinSet, Transparent, 128, ahk_id %hwnd% Gui %hwnd%: Show, NA oHBM := CreateDIBSection( A_ScreenWidth, A_ScreenHeight ) oHDC := CreateCompatibleDC() oOBM := SelectObject(oHDC, oHBM) oGraphics := Gdip_GraphicsFromHDC(oHDC) if ( oGraphics < 1 ) { pToken := Gdip_Startup() oGraphics := Gdip_GraphicsFromHDC(oHDC) this.pToken := pToken } Gdip_SetSmoothingMode( oGraphics, 4 ) Gdip_SetInterpolationMode( oGraphics, 7 ) this.iPenWidth := 3 oPen := Gdip_CreatePen( "0x" "ffff0000" , this.iPenWidth ) UpdateLayeredWindow( hwnd, oHDC, 0, 0, A_ScreenWidth, A_ScreenHeight ) this.hwnd := hwnd this.oHBM := oHBM this.oHDC := oHDC this.oOBM := oOBM this.oGraphics := oGraphics this.oPen := oPen this.iAxisPixelCompensationX := -20 this.iAxisPixelCompensationY := 20 this.iTargetMissedSearchPixelLength := 5 this.iMouseMovementSpeed := 20 this.iMouseOverGauntletIconSize := 35 this.sMouseOverCursorFlag := "Unknown" this.iAttemptAtTargettingMob := 0 this.iMaxAttemptAtTargettingMob := 10 this.iMobCaptureTime := 6000 this.iQTEButtonIntervalTime:= 250 this.iSkillIntervalTime := 250 this.iMaxPlayerRunToTargetTime := 6000 this.iWaitBeforeStartAttackingTime := 500 this.iReticleWidth := 6 this.iMobSearchAreaStartingX := 0 this.iMobSearchAreaStartingY := 0 this.iMobSearchAreaWidth := 80 this.iMobSearchAreaHeight := 65 this.iNumSearchInterpolations := 10 this.iReticleX := 0 this.iReticleY :=0 this.iInterpolateSearchAreaDistanceX := 0 this.iInterpolateSearchAreaDistanceY := 0 this.sMobImage := "Mob.png" this.sHandImage := "Hand.png" this.sCaptureBarImage := "CaptureBar.png" this.sInBattleImage := "InBattle.png" this.sIdleImage := "Idle.png" this.sWButtonImage := "W.png" this.sAButtonImage := "A.png" this.sSButtonImage := "S.png" this.sDButtonImage := "D.png" this.aSkills := Object() Loop, Read, AbilityPriority.txt { this.aSkills.Insert(A_LoopReadLine) } } ;================================================================================================================================================================================================================================================================================================================================ CheckForImage( ByRef Ax, ByRef Ay, x1, y1, x2, y2, image ) { ImageSearch, Ax, Ay, x1 , y1, x2, y2, %image% if ErrorLevel = 0 { return true } else { return false } } ;================================================================================================================================================================================================================================================================================================================================ ScanForTarget( x1, y1, x2, y2 ) { this.Debugger( "Searching!" ) if this.CheckForImage( Ax, Ay, x1, y1, x2, y2, this.sMobImage ) { this.Debugger( "Found Target!") if(this.AttackTarget( Ax , Ay ) ) { this.iAttemptAtTargettingMob := 0 this.MoveToAttack() } else { this.iAttemptAtTargettingMob++ if(this.iAttemptAtTargettingMob < this.iMaxAttemptAtTargettingMob ) { this.ScanForTarget(0, Ay + this.iTargetMissedSearchPixelLength, A_ScreenWidth, A_ScreenHeight ) } else { this.iAttemptAtTargettingMob := 0 return } } } } ;================================================================================================================================================================================================================================================================================================================================ CalculateMobAttackInfo( Ax, Ay ) { this.iMobSearchAreaStartingX := Ax + this.iAxisPixelCompensationX this.iMobSearchAreaStartingY := Ay + this.iAxisPixelCompensationY this.iReticleX := this.iMobSearchAreaStartingX + ( this.iMobSearchAreaWidth / 2 ) - ( this.iReticleWidth / 2 ) this.iReticleY := this.iMobSearchAreaStartingY + ( this.iMobSearchAreaHeight / 2 ) - ( this.iReticleWidth / 2 ) this.iInterpolateSearchAreaDistanceX := this.iMobSearchAreaWidth / this.iNumSearchInterpolations this.iInterpolateSearchAreaDistanceY := this.iMobSearchAreaHeight / this.iNumSearchInterpolations } ;================================================================================================================================================================================================================================================================================================================================ AttackTarget( Ax, Ay ) { this.CalculateMobAttackInfo( Ax, Ay ) MouseMove, this.iReticleX + ( this.iReticleWidth / 2 ), this.iReticleY + ( this.iReticleWidth / 2 ), this.iMouseMovementSpeed If ( A_Cursor = this.sMouseOverCursorFlag ) { if this.CheckForImage( Ax, Ay, this.iReticleX - this.iMouseOverGauntletIconSize , this.iReticleY - this.iMouseOverGauntletIconSize, this.iReticleX + this.iMouseOverGauntletIconSize , this.iReticleY + this.iMouseOverGauntletIconSize , this.sHandImage ) { Mouseclick, Left return true } } if this.bInterpolateSearchArea = true && this.iNumSearchInterpolations != 0 { this.iReticleX := this.iMobSearchAreaStartingX + ( this.iReticleWidth / 2 ) this.iReticleY := this.iMobSearchAreaStartingY + ( this.iReticleWidth / 2 ) i := this.iNumSearchInterpolations Loop %i% { MouseMove, this.iReticleX, this.iReticleY, 0 If (A_Cursor = this.sMouseOverCursorFlag) { if this.CheckForImage( Ax, Ay, this.iReticleX - this.iMouseOverGauntletIconSize , this.iReticleY - this.iMouseOverGauntletIconSize, this.iReticleX + this.iMouseOverGauntletIconSize , this.iReticleY + this.iMouseOverGauntletIconSize , this.sHandImage ) { Mouseclick, Left return true } } this.iReticleX += this.iInterpolateSearchAreaDistanceX this.iReticleY += this.iInterpolateSearchAreaDistanceY } } return false } ;================================================================================================================================================================================================================================================================================================================================ MoveToAttack() { startTime := A_TickCount Loop { this.Debugger( "Running!" ) if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sCaptureBarImage ) { this.Debugger( "Capturing!" ) wait( this.iMobCaptureTime ) this.AttackOrGo() return } if A_TickCount - startTime >= this.iMaxPlayerRunToTargetTime { return } } } ;================================================================================================================================================================================================================================================================================================================================ AttackOrGo() { Loop { if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sInBattleImage ) { this.Debugger( "Fighting!" ) this.Attack() return } else { if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sIdleImage ) { this.Debugger("Finished Attacking!") return } } } } ;================================================================================================================================================================================================================================================================================================================================ Attack() { wait( this.iWaitBeforeStartAttackingTime ) Loop { if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sIdleImage ) { return } for i, e in this.aSkills { send {%e%} this.QTE() } wait( this.iSkillIntervalTime ) } } ;================================================================================================================================================================================================================================================================================================================================ QTE() { if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sWButtonImage ) { send {W} } if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sAButtonImage ) { send {A} } if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sSButtonImage ) { send {S} } if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sDButtonImage ) { send {D} } } ;================================================================================================================================================================================================================================================================================================================================ TargettingSystemClicked() { if this.CheckForImage( Ax, Ay, 0, 0, A_ScreenWidth, A_ScreenHeight, this.sMobImage ) { this.CalculateMobAttackInfo( Ax, Ay ) mouseGetPos, mX, mY Hotkey := RegExReplace( A_ThisHotkey, ( A_IsUnicode = 1 ) ? "(*UCP)^(\w* & |\W*)" : "^(\w* & |\W*)" ) if this.IsInside( mX, mY, this.iMobSearchAreaStartingX - this.iPenWidth, this.iMobSearchAreaStartingY - this.iPenWidth, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth - this.iPenWidth, this.iMobSearchAreaStartingY + this.iPenWidth) || this.IsInside( mx, mY, this.iMobSearchAreaStartingX - this.iPenWidth, this.iMobSearchAreaStartingY - this.iPenWidth, this.iMobSearchAreaStartingX + this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight + this.iPenWidth ) { diffX := -Abs( this.iMobSearchAreaStartingX - mX ) diffY := -Abs( this.iMobSearchAreaStartingY - mY ) While (GetKeyState(Hotkey, "p") = 1) { mouseGetPos, mouseX, mouseY this.iMobSearchAreaStartingX := diffX + mouseX this.iMobSearchAreaStartingY := diffY + mouseY this.iAxisPixelCompensationX := this.iMobSearchAreaStartingX - Ax this.iAxisPixelCompensationY := this.iMobSearchAreaStartingY - Ay this.CalculateMobAttackInfo( Ax, Ay ) this.DisplayTargettingSystem() } } else if this.IsInside( mX, mY, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth - this.iPenWidth, this.iMobSearchAreaStartingY - this.iPenWidth, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth + this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight - this.iPenWidth ) { While (GetKeyState(Hotkey, "p") = 1) { mouseGetPos, mouseX, mouseY this.iMobSearchAreaWidth := Abs( this.iMobSearchAreaStartingX - mouseX ) this.CalculateMobAttackInfo( Ax, Ay ) this.DisplayTargettingSystem() } } else if this.IsInside( mX, mY, this.iMobSearchAreaStartingX - this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight - this.iPenWidth, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth - this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight + this.iPenWidth ) { While (GetKeyState(Hotkey, "p") = 1) { mouseGetPos, mouseX, mouseY this.iMobSearchAreaHeight := Abs( this.iMobSearchAreaStartingY - mouseY ) this.CalculateMobAttackInfo( Ax, Ay ) this.DisplayTargettingSystem() } } else if this.IsInside( mX, mY, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth - this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight - this.iPenWidth, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth + this.iPenWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight + this.iPenWidth ) { While (GetKeyState(Hotkey, "p") = 1) { mouseGetPos, mouseX, mouseY this.iMobSearchAreaWidth := Abs( this.iMobSearchAreaStartingX - mouseX ) this.iMobSearchAreaHeight := Abs( this.iMobSearchAreaStartingY - mouseY ) this.CalculateMobAttackInfo( Ax, Ay ) this.DisplayTargettingSystem() } } } this.ClearGraphics() } ;================================================================================================================================================================================================================================================================================================================================ DisplayTargettingSystem() { Gdip_DrawLine( this.oGraphics, this.oPen, this.iMobSearchAreaStartingX, this.iMobSearchAreaStartingY, this.iMobSearchAreaStartingX + this.iMobSearchAreaWidth, this.iMobSearchAreaStartingY + this.iMobSearchAreaHeight ) Gdip_DrawRectangle( this.oGraphics, this.oPen, this.iReticleX , this.iReticleY , this.iReticleWidth, this.iReticleWidth) Gdip_DrawRectangle( this.oGraphics, this.oPen, this.iMobSearchAreaStartingX, this.iMobSearchAreaStartingY , this.iMobSearchAreaWidth, this.iMobSearchAreaHeight ) UpdateLayeredWindow( this.hwnd, this.oHDC ) Gdip_GraphicsClear( this.oGraphics ) } ;================================================================================================================================================================================================================================================================================================================================ IsInside( c1, c2, x1, y1, x2, y2 ) { if ( c1 >= x1 && c1 <= x2 ) { if ( c2 >= y1 && c2 <= y2 ) { return true } } return false } ;================================================================================================================================================================================================================================================================================================================================ ClearGraphics() { Gdip_GraphicsClear( this.oGraphics ) UpdateLayeredWindow( this.hwnd, this.oHDC, 0, 0, A_ScreenWidth, A_ScreenHeight ) } ;================================================================================================================================================================================================================================================================================================================================ Debugger( msg ) { if this.bDebugMode = true { Tooltip, %msg% } } ;================================================================================================================================================================================================================================================================================================================================ __Delete() { Gdip_DeletePen( this.oPen ) Gdip_DeleteGraphics( this.oGraphics ) SelectObject( this.oHDC, this.oOBM ) DeleteObject( this.oHBM ) DeleteDC( this.oHDC ) if ( this.pToken != "" ) Gdip_Shutdown( this.pToken ) } ;================================================================================================================================================================================================================================================================================================================================ } wait( waitTime ) { startTime := A_TickCount while( A_TickCount - startTime <= waitTime ) { } }