i need someone help for this code i still new but i why i cnt get it 100% working
Code:
; Set the Escape hotkey to terminate the script.
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

HotKeySet("{HOME}", "ToggleBox")

Local $hDLL = DllOpen("user32.dll")
Local $combodelays[3] = [0, 800, 500]
Local $curDelay = 0;
Local $curStep = 0;
Global $g_bPaused = False
Global $gotAttacked = 0;
Global $frames = 5;
Global $hasRed = False;
Global $isGuard = 0;

Global $paused = False
Global $drawBox = False
Global $hRectangle_GUI


Global $pause_btn = IniRead("config.ini", "options", "pausebtn", "05")
Global $btn = IniRead("config.ini", "guardbreak", "button", "06")

;Global $guardTopBtn = IniRead("config.ini", "block", "buttonTop", "4B")
;Global $guardLeftBtn = IniRead("config.ini", "block", "buttonLeft", "4A")
;Global $guardRightBtn = IniRead("config.ini", "block", "buttonRight", "4C")


Global $auto_parry = IniRead("config.ini", "options", "autoparry", "1")
Global $forward_dodge = IniRead("config.ini", "options", "forwarddodge", "1")
Global $auto_block = IniRead("config.ini", "options", "autoblock", "0")
Global $block_check = IniRead("config.ini", "options", "blockcheck", "1")
Global $auto_gb = IniRead("config.ini", "options", "autogb", "1")
Global $random_guard = IniRead("config.ini", "options", "randomguard", "0")
Global $special_combo = IniRead("config.ini", "options", "special1", "0")

Global $enemy_box_left = IniRead("config.ini", "block", "left", "582")
Global $enemy_box_top = IniRead("config.ini", "block", "top", "296")
Global $enemy_box_right = IniRead("config.ini", "block", "right", "921")
Global $enemy_box_bottom = IniRead("config.ini", "block", "bottom", "741")

Global $enemy_box_width = $enemy_box_right - $enemy_box_left;
Global $enemy_box_height = $enemy_box_bottom - $enemy_box_top;

Global $aClientSize = WinGetClientSize("[CLASS:FoxGame]")


Global $player_left = 0
Global $player_top = 0
Global $player_right = 0
Global $player_bottom = 0

Global $target_left = 0
Global $target_top = 0
Global $target_right = 0
Global $target_bottom = 0

Global $lastBlockFound[2] = [0, 0]

Global $blockInputTime = 0;

Global $guardModeTime = 0;

Global $hasTargetTime = 0;
Global $lastRan = 0;
Global $gotPressedR = false;

Global $guardTime = 0;
Global $lastGuardSide

CalculateEnemyBox()
CalculateGuardBreakBox()
CalculatePlayerBox()
CalculateTargetBox()

;MsgBox(0,"", $gb_left1);
Main();

Func ToggleBox()
	$drawBox = Not $drawBox
	If $drawBox Then
		DrawBox()
	Else
		GUIDelete($hRectangle_GUI)
	EndIf
EndFunc

Func DrawBox()
	;$hRectangle_GUI = GUICreate("", $player_right - $player_left, $player_bottom - $player_top, $player_left, $player_top, BitOR($WS_POPUP,$WS_BORDER),$WS_EX_TOPMOST)
    $hRectangle_GUI = GUICreate("", $enemy_box_width, $enemy_box_height, $enemy_box_left, $enemy_box_top, BitOR($WS_POPUP,$WS_BORDER),$WS_EX_TOPMOST)
	;$hRectangle_GUI = GUICreate("", $target_right - $target_left, $target_bottom - $target_top, $target_left, $target_top, BitOR($WS_POPUP,$WS_BORDER),$WS_EX_TOPMOST)
	GUISetBkColor(0xffffff)
	WinSetTrans($hRectangle_GUI, "", 30)
	GUISetState(@SW_SHOW)
EndFunc

Func RandomGuardChange()
   Local $mousePos = MouseGetPos();
   Local $ran = Random(0, 2, 1);
   If $ran = 0 Then
	  ;MouseMove(0, $mousePos[1], 0);
	  Send("{j down}");
	  Sleep(50);
	  Send("{j up}");
   ElseIf $ran = 1 Then
	 ;MouseMove(1200, $mousePos[1], 0);
	  Send("{k down}");
	  Sleep(50);
	  Send("{k up}");
   Else
	  ;MouseMove($mousePos[0], 0, 0);
	  Send("{l down}");
	  Sleep(50);
	  Send("{l up}");
   EndIf
   $lastRan = $ran;
EndFunc

Func CalculateEnemyBox()
	Local $center_point[2] = [0, 0]
	$center_point[0] = $aClientSize[0] / 2
	$center_point[1] = $aClientSize[1] / 2
	$enemy_box_left = ($aClientSize[0] / 2.7)
	$enemy_box_top = ($aClientSize[1] / 3)
	$enemy_box_right = $aClientSize[0] - ($aClientSize[0] / 2.7)
	$enemy_box_bottom =  $aClientSize[1] - ($aClientSize[1] / 3)

	$enemy_box_width = $enemy_box_right - $enemy_box_left;
	$enemy_box_height = $enemy_box_bottom - $enemy_box_top;
EndFunc

Func CalculatePlayerBox()
	$player_left = ($aClientSize[0] / 4.3)
	$player_top = ($aClientSize[1] / 1.9)
	$player_right = $aClientSize[0] - ($aClientSize[0] / 1.7)
	$player_bottom =  $aClientSize[1] - ($aClientSize[1] / 5.5)
EndFunc

Func CalculateTargetBox()
	$target_left = $enemy_box_left + ($enemy_box_left / 4)
	$target_top = $enemy_box_top - ($enemy_box_top / 2)
	$target_right = $enemy_box_right
	$target_bottom =  $enemy_box_top
EndFunc


Func CalculateGuardBreakBox()
	$gb_left1 = IniRead("config.ini", "guardbreak", "left1", "0")
	$gb_top1 = IniRead("config.ini", "guardbreak", "top1", "0")
	$gb_right1 = IniRead("config.ini", "guardbreak", "right1", "0")
	$gb_bottom1 = IniRead("config.ini", "guardbreak", "bottom1", "0")
EndFunc

Func Main()

    ; Initialize a Local variable.
   While 1
	   ;ToolTip("center", $enemy_box_right, $enemy_box_bottom);
	  $hasRed = False;
	PausePulse()
	;guard

	If $block_check = "1" Then
		BlockPulse()
	EndIf

	If $auto_gb = "1" Then
		AutoGBPulseNew()
	EndIf

	If $blockInputTime > 0 Then
		$blockInputTime -= $frames
	EndIf

	If $guardModeTime > 0 Then
		$guardModeTime -= $frames
	EndIf

	If $hasTargetTime > 0 Then
		$hasTargetTime -= $frames
	EndIf


	InputPulse()
	GuardModeCheckPulse()
	HasTargetCheckPulse()
	;ToolTip($hasTargetTime, 0, 0)
	;EndIf
	Sleep($frames)
   WEnd
EndFunc   ;==>Example


Func GuardModeActive()
	If $guardModeTime > 0 Then
		Return True
	EndIf
EndFunc

Func HasTarget()
	If $hasTargetTime > 0 Then
		Return True
	EndIf
EndFunc

Func InputPulse()

	If _isPressed("04") Then
		$blockInputTime = 300
	EndIf

	If $random_guard = "1" Then
		If _isPressed("01") Then
			RandomGuardChange()
		EndIf
	EndIf

	If $special_combo = "1" Then
		If _isPressed("52") Then
			SendAllMoveKeysUp()
			Sleep(5)
			Send("{s down}");
			Send("{space down}");
			Sleep(50)
			MouseDown("middle" );
			$gotPressedR = true;
			Sleep(50);
		EndIf

		If $gotPressedR And Not _IsPressed("52") Then
			 $gotPressedR = false;
			 Send("{s up}");
			 Send("{space up}");
			 MouseUp("middle");
			 Sleep(50);
			 RandomGuardChange()
		EndIf

		If _isPressed("51") Then
			Dodge("left")
			RandomGuardChange();
		EndIf

		If _isPressed("45") Then
			Dodge("right")
			RandomGuardChange();
		EndIf

		If _isPressed("06") Then
			SendAllMoveKeysUp();
			Dodge("forward")
			Sleep(220)
			ExecuteGuardBreak()
			Sleep(100)
		EndIf


		If _isPressed("06") Then
			;MouseClick("middle" );
			;Sleep(5);
		EndIf

	EndIf
EndFunc

Func AutoParryPulse()
	;ToolTip("asd", $lastBlockFound[0], $lastBlockFound[1])
	;$aCoord = PixelSearch($lastBlockFound[0] - 5, $lastBlockFound[1] - 5, $lastBlockFound[0] + 5, $lastBlockFound[1] + 5, 0xff9f8e, 10)
	$aCoord = PixelSearch($lastBlockFound[0] - 5, $lastBlockFound[1] - 5, $lastBlockFound[0] + 5, $lastBlockFound[1] + 5, 0xff9f8e, 5)
	If Not   @Error Then
		If $forward_dodge = "1" And $lastGuardSide = "top" Then
			Dodge("forward")
		EndIf
		Attack("right")
		Attack("left")
	EndIf
EndFunc

Func Attack($mouse)
	ToolTip("AUTOPARRY", 0, 0)
	MouseClick($mouse)
	MouseClick($mouse)
EndFunc

Func BlockPulse()
	$aCoord = PixelSearch($enemy_box_left, $enemy_box_top, $enemy_box_right, $enemy_box_bottom, 0x970c05, 10)
	If Not   @Error Then
		$x_relation = $enemy_box_width - ($enemy_box_right - $aCoord[0])
		$y_relation = $enemy_box_height - ($enemy_box_bottom - $aCoord[1])

		$center_dist = Abs((($enemy_box_width / 2) - $x_relation));

		If $y_relation < ($enemy_box_height / 3.2) And $center_dist < 30 Then
			$lastGuardSide = "top"
		ElseIf $y_relation > ($enemy_box_height / 1.8) And  $x_relation < ($enemy_box_width / 2) + 10 Then
			$lastGuardSide = "left"
		ElseIf $y_relation > ($enemy_box_height / 1.8) And $x_relation > $x_relation < ($enemy_box_width / 2) - 10 Then
			$lastGuardSide = "right"
		EndIf
		$lastBlockFound = $aCoord;
		$guardTime = 80;
	EndIf
	If $guardTime > 0 Then
		If $auto_block = "1" Then
			Guard($lastGuardSide)
		EndIf
		If $auto_parry = "1" Then
			AutoParryPulse()
		EndIf

		$guardTime -= $frames;
		ToolTip($guardTime, 0, 0)
	EndIf
EndFunc

Func Guard($side)
	 If $side = "top" Then
		ToolTip("Guard top", 0, 0);
		Send("{k down}");
		Sleep($frames);
		Send("{k up}");
	 ElseIf $side = "right" Then
		ToolTip("Guard right", 0, 0);
		Send("{l down}");
		Sleep($frames);
		Send("{l up}");
	ElseIf $side = "left" Then
		ToolTip("Guard left", 0, 0);
		Send("{j down}");
		Sleep($frames);
		Send("{j up}");
	EndIf
EndFunc

Func AutoBlockPulse()
	;top

	 $aCoord = PixelSearch(708, 139, 743, 394, 0xD30607, 5)
	 If Not   @Error Then
		Guard("top");
	  EndIf
	  ;right
	 $aCoord = PixelSearch(718, 424, 860, 584, 0xD30607, 5)
	 If Not   @Error Then
		Guard("right");
	 EndIf
	 ;left
	 $aCoord = PixelSearch(479, 414, 700, 602, 0xD30607, 5)
	If Not   @Error Then
		Guard("left");
	EndIf
EndFunc

Func SendAllMoveKeysUp()
	Send("{d up}");
	Send("{a up}");
	Send("{s up}");
	Send("{w up}");
EndFunc

Func Dodge($side)
	SendAllMoveKeysUp()
	Sleep(10)
	If $side = "left" Then
		Send("{a down}");
	ElseIf $side = "right" Then
		Send("{d down}");
	ElseIf $side = "forward" Then
		Send("{w down}");
	ElseIf $side = "backwards" Then
		Send("{s down}");
	EndIf
	Send("{space down}");
	Sleep(50);
	Send("{d up}");
	Send("{a up}");
	Send("{s up}");
	Send("{w up}");
	Send("{space up}");
	Sleep(20);
EndFunc

Func AutoGBPulseNew()
	If $blockInputTime > 0 Or Not HasTarget() Then
		Return
	EndIf
	$found1 = False
	$aCoord = PixelSearch($enemy_box_left, $enemy_box_top, $enemy_box_right, $enemy_box_bottom, 0x6FB5DC, 4)
	If Not   @Error Then
		$found1 = True
	EndIf
	If $found1 Then
		ExecuteGuardBreak()
		;ToolTip("guard", $aCoord[0], $aCoord[1])
	EndIf
EndFunc


Func GuardModeCheckPulse()
	$aCoord = PixelSearch($player_left, $player_top, $player_right, $player_bottom, 0xfffff0, 5)
	If Not   @Error Then
		$guardModeTime = 300
	EndIf
EndFunc

Func HasTargetCheckPulse()
	$aCoord = PixelSearch($target_left, $target_top, $target_right, $target_bottom, 0x00cc65, 5)
	If Not   @Error Then
		$hasTargetTime = 300
	Else
		If $hasTargetTime > 100 Then
			$aCoord = PixelSearch($target_left, $target_top, $target_right, $target_bottom, 0xfffff0, 0)
			If Not   @Error Then
				$hasTargetTime = 300
			EndIf
		EndIf
	EndIf
EndFunc


Func ExecuteGuardBreak()
	MouseClick("middle")
	MouseClick("middle")
	MouseClick("middle")
	MouseClick("middle")
	Sleep(100)
EndFunc

Func PausePulse()
	If _isPressed($pause_btn) Then
		$paused = Not $paused
		sleep(100)
	EndIf

	If $paused Then
		ToolTip("Paused", 0, 0)
	;Else
		;ToolTip("Active", 0, 0)
	EndIf

	  ;If _IsPressed("56", $hDLL) Then
	While $paused Or Not WinActive("[CLASS:FoxGame]")
		Sleep(100);
		If _isPressed($pause_btn) Then
			$paused = Not $paused
			Sleep(100)
			ToolTip("Active", 0, 0)
		EndIf
	WEnd
EndFunc

Func _Terminate()
    Exit
 EndFunc   ;==>_Terminate

 DllClose($hDLL);
 GUIDelete($hRectangle_GUI)