------------------------------------------

									--------------------------------------------------------------------------------
									--									CUSTOM OPTIONS						 	  --
									--------------------------------------------------------------------------------
									
------------------------------------------
-- Modo de deflexao
-- Deflection Mode
-- 0 = Default - Time: 0.2s, 0.1, 0.085, Cooldown 0.5s
-- 1 = Easy - Time: 0.3s, 0.2, 0.1, Cooldown 0.5s
-- 2 = Hard - Time: 0.1s, 0.075, 0.050, Cooldown 0.5s

CUSTOM_DEFLECTION_MODE = 1

------------------------------------------
-- Habilita o Power Stance MODE
-- Enable Power Stance MODE
-- 1 = ON
-- 0 = OFF

CUSTOM_POWERSTANCE_MODE = 1

------------------------------------------									
-- Qualquer arma pode defletir
-- Any weapon can deflect
-- 1 = ON
-- 0 = OFF

CUSTOM_ANY_WEAPON_CAN_DEFLECT_MODE = 1

------------------------------------------
-- Escudos podem defletir
-- Shields can deflect
-- 1 = ON
-- 0 = OFF

CUSTOM_SHIELD_CAN_DEFLECT_MODE = 0

------------------------------------------ 
-- Pode defletir se segurar L1
-- Can deflect if holding L1
-- 1 = ON
-- 0 = OFF

CUSTOM_CAN_DEFLECT_HOLDING_MODE = 0

------------------------------------------    
-- Habilita a deflexao com uma mao
-- Enable One Hand Deflection
-- 1 = ON
-- 0 = OFF

CUSTOM_ONEHAND_CAN_DEFLECT = 0

------------------------------------------ 
-- Habilita o sistema de postura
-- Enable posture system
-- 1 = ON
-- 0 = OFF

CUSTOM_POSTURESYSTEM_MODE = 0

------------------------------------------
-- Habilita Contra-taques de Sekiro
-- Enable Sekiro Counter Attacks
-- 1 = ON
-- 0 = OFF

CUSTOM_SEKIRO_ATKCOUNTER = 0

------------------------------------------
-- W.I.P

CUSTOM_DEBUG_MODE = 0
------------------------------------------

------------------------------------------
-- Needed for SetParamField
PARAM_AtkParam_Npc = 7
SIGNED_INT = 5

SetParamValue = 10004
------------------------------------------


									--------------------------------------------------------------------------------
									--									 SYSTEM								 	  --
									--------------------------------------------------------------------------------
									
------------------------------------------
-- Executa override nas funcôes originais
------------------------------------------
original_IsEnableGuard = IsEnableGuard
original_ExecGuard = ExecGuard
original_GetAttackRequest = GetAttackRequest
original_ExecAttack = ExecAttack
original_ExecDamage = ExecDamage
original_Update = Update
original_ExecDeath = ExecDeath
original_JumpCommonFunction = JumpCommonFunction

------------------------------------------
-- Atualiza o sistema
------------------------------------------
function VIZZO_MainUpdate()
------------------------------------------
-- Atualiza o sistema principal
------------------------------------------
	VIZZO_CheckWeaponStyle()
	VIZZO_CheckStamina()
	VIZZO_HoldingRequest()
	VIZZO_AnimJumper()
	VIZZO_IsPlayerRequest()
	
	if CUSTOM_POSTURESYSTEM_MODE == 1 then
		SKD_PoiseBreak()
		if env(HasBrokenSA) == TRUE then
			SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level)
		end
		if env(IsCOMPlayer) == TRUE and SKD_PoiseBreak() == TRUE then
			ExecEventAllBody("W_GuardBreak")
		end
	end
    ----------------------------
    -- Malenia Lifesteal
	UpdateMaleniaLifesteal()
	----------------------------
	
end
------------------------------------------
-- Verifica o estilo da empunhadura
------------------------------------------
function VIZZO_CheckWeaponStyle()
	local StyleHand = c_Style
	local HandLeftCategory = env(GetEquipWeaponCategory, HAND_LEFT)
	local HandRightCategory = env(GetEquipWeaponCategory, HAND_RIGHT)
	local IsDualWieldStyle = IsEnableDualWielding()
	
	if StyleHand == HAND_RIGHT_BOTH or StyleHand == HAND_LEFT_BOTH or CUSTOM_ONEHAND_CAN_DEFLECT == 1 then
		return HandBothStyle
	elseif HandLeftCategory == HandRightCategory then
        return DualWeaponStyle
	elseif IsDualWieldStyle ~= -1 then
		return DualWieldStyle
	end

end
------------------------------------------
-- Verifica e define o modo de deflexao
------------------------------------------
function VIZZO_CheckCanDeflect()
    local AnyWeaponCanDeflect = CUSTOM_ANY_WEAPON_CAN_DEFLECT_MODE
    local ShieldsCanDeflect = CUSTOM_SHIELD_CAN_DEFLECT_MODE
    local HoldingL1CanDeflect = CUSTOM_CAN_DEFLECT_HOLDING_MODE
    local CheckStyle = VIZZO_CheckWeaponStyle()
    local StyleHand = c_Style

    local HandR_Weapon_List = GetEquipType(HAND_RIGHT, 
        WEAPON_CATEGORY_TORCH, WEAPON_CATEGORY_FIST, WEAPON_CATEGORY_BEAST_CLAW, 
        WEAPON_CATEGORY_CLAW, WEAPON_CATEGORY_FLAIL, WEAPON_CATEGORY_MARTIAL_ARTS, 
        WEAPON_CATEGORY_PERFUME_BOTTLE, WEAPON_CATEGORY_STAFF, WEAPON_CATEGORY_WHIP, 
        WEAPON_CATEGORY_BALISTA, WEAPON_CATEGORY_BALLISTA, WEAPON_CATEGORY_SMALL_ARROW, 
        WEAPON_CATEGORY_ARROW, WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW)
		
    local HandL_Weapon_List = GetEquipType(HAND_LEFT, 
        WEAPON_CATEGORY_TORCH, WEAPON_CATEGORY_FIST, WEAPON_CATEGORY_BEAST_CLAW, 
        WEAPON_CATEGORY_CLAW, WEAPON_CATEGORY_FLAIL, WEAPON_CATEGORY_MARTIAL_ARTS, 
        WEAPON_CATEGORY_PERFUME_BOTTLE, WEAPON_CATEGORY_STAFF, WEAPON_CATEGORY_WHIP, 
        WEAPON_CATEGORY_BALISTA, WEAPON_CATEGORY_BALLISTA, WEAPON_CATEGORY_SMALL_ARROW, 
        WEAPON_CATEGORY_ARROW, WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW)

    local HandR_Shield_List = GetEquipType(HAND_RIGHT, 
        WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD, 
        WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_DUELING_SHIELD)
		
    local HandL_Shield_List = GetEquipType(HAND_LEFT, 
        WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD, 
        WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_DUELING_SHIELD)

    local invalidDefaultConditions = HandR_Weapon_List == TRUE or HandL_Weapon_List == TRUE
    local invalidShieldsConditions = HandR_Weapon_List == TRUE or HandL_Weapon_List == TRUE

--    if invalidConditions[StyleHand] == TRUE then return FALSE end
    if HandL_Shield_List == TRUE and HandR_Shield_List == TRUE then return FALSE end

    if AnyWeaponCanDeflect == 0 and ShieldsCanDeflect == 0 and HoldingL1CanDeflect == 0 then
	if invalidDefaultConditions or HandL_Shield_List == TRUE and StyleHand ~= HAND_RIGHT_BOTH then return FALSE 
	elseif HandR_Shield_List == TRUE and StyleHand == HAND_RIGHT_BOTH then return FALSE end
		return CanDeflectDefault
	else
		if AnyWeaponCanDeflect == 1 then
			if HoldingL1CanDeflect == 1 then
				return CanDeflectHolding
			else
				return CanDeflectDefault
			end
		elseif ShieldsCanDeflect == 1 then
			if invalidShieldsConditions and (StyleHand == HAND_RIGHT_BOTH or StyleHand == HAND_LEFT_BOTH) then return FALSE end
			if HoldingL1CanDeflect == 1 then
				return CanDeflectHolding
			else
				return CanDeflectDefault
			end
		elseif HoldingL1CanDeflect == 1 and ShieldsCanDeflect == 0 and AnyWeaponCanDeflect == 0 then
		if invalidDefaultConditions or HandL_Shield_List == TRUE and StyleHand ~= HAND_RIGHT_BOTH then return FALSE 
		elseif HandR_Shield_List == TRUE and StyleHand == HAND_RIGHT_BOTH then return FALSE end
			return CanDeflectHolding
		end
	end

    return FALSE
end

------------------------------------------
-- Gerencia a Stamina
------------------------------------------
function VIZZO_CheckStamina()
	
    local currentStamina = env(GetStamina)
    local maxStamina = env(GetMaxStamina)
    local minStamina = maxStamina * 0.26 -- 10% da stamina total
    local staminaToRecover = minStamina - currentStamina

    -- Verifica se a stamina atual está abaixo do mínimo e se deve recuperar stamina
    if currentStamina < minStamina then
        if SKD_IsDuringDeflect() == TRUE then
            -- Calcula e aplica a quantidade de stamina a ser recuperada
            if staminaToRecover > 0 then
                act(ChangeStamina, staminaToRecover)
            end
        end
    end
end
------------------------------------------
-- Gerencia o sistema de postura
------------------------------------------
function SKD_PoiseBreak()
    local CurrentPoise = env(GetPoise) -- Obtém o valor atual do poise do jogador
    local IsDuringDeflect = env(GetSpEffectID, 150240) == TRUE -- Verifica se está em uma deflexão
    local PoiseBreakRecover = env(GetSpEffectID, 150242) -- Verifica se o efeito de recuperação de poise foi aplicado

    -- Verifica todos os efeitos de deflexão
    local CheckDeflectionStatus = SKD_IsDuringDeflect() == FALSE

    if CUSTOM_POSTURESYSTEM_MODE == 1 then
		if CurrentPoise > 20 and IsDuringDeflect then
			act(AddSpEffect, 150239)
	elseif CurrentPoise > 20 and env(IsCOMPlayer) == TRUE and env(HasReceivedAnyDamage) == TRUE then
			act(AddSpEffect, 150239)
	elseif CurrentPoise <= 20 and env(HasReceivedAnyDamage) == TRUE and SKD_IsDuringDeflect() == FALSE then
			return TRUE
		end
	end

    return FALSE
end

------------------------------------------ 	
-- Verifica se L1 esta sendo pressionado
------------------------------------------
function VIZZO_HoldingRequest()
	-- Se foi pressionado
    local IsRequestL1 = env(ActionDuration, ACTION_ARM_L1)
	
	-- Se L1 esta sendo segurado
	if env(ActionDuration, ACTION_ARM_L1) > 100 then
		if CUSTOM_CAN_DEFLECT_HOLDING_MODE == 1 and VIZZO_CheckCanDeflect() == CanDeflectHolding then
			act(AddSpEffect, 150238)
			return IsHoldingL1
		end
		
		return IsHoldingL1
	end

end

------------------------------------------
-- Animation Jumper (W.I.P)
------------------------------------------

    -- Animation Jumpers:
    -- 8000000: [JUMPER] ANIM CANCEL
    -- 8000100: [JUMPER] CANCEL RESET
	-- 8000543: [JUMPER] Deflect S1/S3 R1/R2
	-- 8000545: [JUMPER] Deflect S2/M1/L1 R1/R2
	-- 8000547: [JUMPER] Deflect M2/L2 R1/R2
	-- 8000548: [JUMPER] Deflect M3/L3 R1/R2

function VIZZO_AnimJumper()

	if (env(1116, 8000000) == TRUE) then -- Anim Cancel
		ExecEventAllBody("W_Idle")
		act(AddSpEffect, 8000100)
	end
	
end

------------------------------------------

									--------------------------------------------------------------------------------
									--									FUNCTIONS							 	  --
									--------------------------------------------------------------------------------
									
------------------------------------------
-- Verifica se é o jogador
------------------------------------------
function VIZZO_IsPlayerRequest()
	local DebugMode = CUSTOM_DEBUG_MODE
	if env(IsCOMPlayer) == FALSE then
		if DebugMode == 1 then
			act(ChangeHP, 1000)
			act(ChangeStamina, 1000)
			return TRUE -- É o jogador
		end
		return TRUE -- É o jogador
	end
	
	return FALSE -- É um NPC
end
------------------------------------------
-- Verifica se o modo Power Stance esta habilitado
------------------------------------------
function VIZZO_CheckPowerStanceMode()
	
	if CUSTOM_POWERSTANCE_MODE == 1 then
		return TRUE
	end
	
	return FALSE
end

-- Set ATK NPC Field
function SetParamField(ParamID, field, value, type, bitOffset)
    return act(SetParamValue, PARAM_AtkParam_Npc, ParamID, field, type or SIGNED_INT, value, bitOffset or 0)
end

------------------------------------------
------------------------------------
-- Malenia Lifesteal
function UpdateMaleniaLifesteal()

    -- Lista de IDs de Malenia
    local MaleniaIDs = {
        [1] = {2120100, 2120110, 2120120, 2120130, 2120140, 2120150, 2120170, 2120180, 2120190, 2120200, 2120201, 2120202, 2120203, 2120204, 2120205, 2120300, 2120310, 2120340, 2120370, 2120380, 2120390, 2120400, 2120401, 2120402, 2120403, 2120404, 2120410, 2120450, 2120460, 2120480, 2120481, 2120482, 2120483, 2120484, 2120485, 2120486, 2120487, 2120488, 2120490, 2120491 },  -- 18412
        [2] = {2120141, 2120160, 2120161, 2120210, 2120220, 2120260, 2120270, 2120500, 2120510, 2120520, 2120530 }, -- 18413
        [3] = {2120209, 2120489, 2120800, 2120801, 2120810, 2120811},  -- 18410
        [4] = {2120230, 2120231, 2120240, 2120241}, -- 18415
        [5] = {2120271, 2120321, 2120470, 2120471, 2120501, 2120502, 2120531, 2120532}, -- 18417
        [6] = {2120290, 2120292, 2120293} -- 18414
    }

    local effectValues = {
        [1] = 18412,
        [2] = 18413,
        [3] = 18410,
        [4] = 18415,
        [5] = 18417,
        [6] = 18414
    }

    -- Executar SetParamField para cada ID nas listas de MaleniaIDs
    for index, maleniaIDsList in pairs(MaleniaIDs) do
        for _, maleniaID in ipairs(maleniaIDsList) do
            if SKD_IsDuringDeflect() == TRUE then
                SetParamField(maleniaID, 0x18, -1, SIGNED_INT)
            else
                local effectValue = effectValues[index]
                SetParamField(maleniaID, 0x18, effectValue, SIGNED_INT)
            end
        end
    end
end

--
------------------------------------------

									--------------------------------------------------------------------------------
									--									DEFLECT CORE						 	  --
									--------------------------------------------------------------------------------
									
------------------------------------------
-- Define o modo de deflexao
------------------------------------------
function SKD_CheckDeflectMode()
	local ChoiceDeflectMode = VIZZO_CheckCanDeflect()
	
		if ChoiceDeflectMode == CanDeflectDefault then
			return DefaultMode
		elseif ChoiceDeflectMode == CanDeflectHolding then
			return HoldingMode
		end
	
	return FALSE
end
------------------------------------------
-- Define o Status para a deflexao
------------------------------------------
function SKD_SetDeflectStatus()
    local DeflectDefaultMode = SKD_CheckDeflectMode()
    local modeEffects = {
        [0] = {150247, 150248, 150249},  -- Default Mode
        [1] = {150244, 150245, 150246},  -- Easy Mode
        [2] = {150230, 150232, 150234}   -- Hard Mode
    }

    local effectIds = modeEffects[CUSTOM_DEFLECTION_MODE]
    
    if DeflectDefaultMode == DefaultMode then
        local effectId1 = effectIds[1]
        local effectId2 = effectIds[2]
        local effectId3 = effectIds[3]

        if env(GetSpEffectID, effectId3) == TRUE or env(GetSpEffectID, 150235) == TRUE then
            act(AddSpEffect, 150235)
        elseif env(GetSpEffectID, effectId2) == TRUE or env(GetSpEffectID, 150233) == TRUE then
            act(AddSpEffect, effectId3)
        elseif env(GetSpEffectID, effectId1) == TRUE or env(GetSpEffectID, 150231) == TRUE then
            act(AddSpEffect, effectId2)
        else
            act(AddSpEffect, effectId1)
        end
    end
end

------------------------------------------
-- Verifica se está no meio de uma deflexão
------------------------------------------
function SKD_IsDuringDeflect()
	local DefaultModeStatus = env(GetSpEffectID, 150230) == TRUE or env(GetSpEffectID, 150232) == TRUE or env(GetSpEffectID, 150234) == TRUE
	local HardModeStatus = env(GetSpEffectID, 150244) == TRUE or env(GetSpEffectID, 150245) == TRUE or env(GetSpEffectID, 150246) == TRUE
	local EasyModeStatus = env(GetSpEffectID, 150247) == TRUE or env(GetSpEffectID, 150248) == TRUE or env(GetSpEffectID, 150249) == TRUE
	
    if  DefaultModeStatus or HardModeStatus or EasyModeStatus or
		env(GetSpEffectID, 150237) == TRUE or
		env(GetSpEffectID, 150238) == TRUE then
        return TRUE
    end
	
    return FALSE
end
------------------------------------------
-- Atualiza a lógica de deflexão e verifica se "L1" está sendo pressionado
------------------------------------------
function SKD_DeflectCommonUpdate()
	local DeflectionDefaultMode = CUSTOM_DEFLECTION_MODE == 0
	local DeflectionEasyMode = CUSTOM_DEFLECTION_MODE == 1
	local DeflectionHardMode = CUSTOM_DEFLECTION_MODE == 2
	local IsPressedL1 = env(ActionRequest, ACTION_ARM_L1) == TRUE
	local AttackDuringGuard = (env(GetSpEffectID, 173) == TRUE or env(GetSpEffectID, 174) == TRUE) and env(ActionRequest, ACTION_ARM_R1) == TRUE
	
    if IsPressedL1 then
        SetVariable("GuardStartType", 0)
        SetVariable("IndexGuardStyle", GUARD_STYLE_DEFAULT)
		ExecEventHalfBlend(Event_GuardStart, ALLBODY)
	-- Se "L1" estiver sendo pressionado, executa animacao de guarda
    elseif AttackDuringGuard then
        ExecEventAllBody("W_AttackBothLight1")
	end
    if DamageCommonFunction(TO_GUARDON, FALSE, ESTEP_NONE, FALL_TYPE_DEFAULT) == TRUE then
    end
	--
end
------------------------------------------
-- Atualiza a lógica de bloqueio
------------------------------------------
function SKD_BlockCommonUpdate()
	local IsHoldingL1 = VIZZO_HoldingRequest() == IsHoldingL1
	
	if IsHoldingL1 then
		act(SetStaminaRecoveryDisabled)
	end
    if DamageCommonFunction(TO_GUARDON, FALSE, ESTEP_NONE, FALL_TYPE_DEFAULT) == TRUE then
    end
	--
end
------------------------------------------
-- Define qual animação será executada e reinicia o tempo de cooldown 
------------------------------------------
function SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level)
    local anim
    local ShieldCanDeflect = CUSTOM_SHIELD_CAN_DEFLECT_MODE == 1
    local CheckStyleHand = c_Style
    local CheckIsDualStyle = VIZZO_CheckWeaponStyle() == DualWeaponStyle or VIZZO_CheckWeaponStyle() == DualWieldStyle
    local CheckCanDeflect = SKD_CheckDeflectMode()
    local DuringDeflection = SKD_IsDuringDeflect() == TRUE
    local DeflectHoldingL1Status = env(GetSpEffectID, 150238) == TRUE
	local CheckDeflectionStatus = SKD_IsDuringDeflect() == FALSE

    -- Define animações para deflexão e bloqueio
    local deflectAnims = {
        [1] = { RIGHT = "W_DeflectS3", LEFT = "W_DeflectS2", DEFAULT = "W_DeflectS1" },
        [3] = { RIGHT = "W_DeflectL3", LEFT = "W_DeflectL2", DEFAULT = "W_DeflectL1" },
        [4] = "W_DeflectLL",
        [5] = { RIGHT = "W_DeflectM3", LEFT = "W_DeflectM2", DEFAULT = "W_DeflectM1" }
    }

    local blockAnims = {
        [1] = { RIGHT = "W_BlockS3", LEFT = "W_BlockS2", DEFAULT = "W_BlockS1" },
        [3] = { RIGHT = "W_BlockL3", LEFT = "W_BlockL2", DEFAULT = "W_BlockL1" },
        [4] = "W_BlockLL",
        [5] = { RIGHT = "W_BlockM3", LEFT = "W_BlockM2", DEFAULT = "W_BlockM1" }
    }

    local dualDeflectAnims = {
        [1] = { RIGHT = "W_DualDeflectS2", LEFT = "W_DualDeflectS1", RANDOM = { "W_DualDeflectS1", "W_DualDeflectS2" } },
        [3] = { RIGHT = "W_DualDeflectL2", LEFT = "W_DualDeflectL1", RANDOM = { "W_DualDeflectL1", "W_DualDeflectL2" } },
        [4] = { RETURN_FALSE = TRUE },
        [5] = { RIGHT = "W_DualDeflectM2", LEFT = "W_DualDeflectM1", RANDOM = { "W_DualDeflectM1", "W_DualDeflectM2" } }
    }

    local dualBlockAnims = {
        [1] = { RIGHT = "W_DualBlockS2", LEFT = "W_DualBlockS1", RANDOM = { "W_DualBlockS1", "W_DualBlockS2" } },
        [3] = { RIGHT = "W_DualBlockL2", LEFT = "W_DualBlockL1", RANDOM = { "W_DualBlockL1", "W_DualBlockL2" } },
        [4] = { RETURN_FALSE = TRUE },
        [5] = { RIGHT = "W_DualBlockM2", LEFT = "W_DualBlockM1", RANDOM = { "W_DualBlockM1", "W_DualBlockM2" } }
    }

    local shieldDeflectAnims = {
        [1] = { RIGHT = "W_ShieldDeflectS2", LEFT = "W_ShieldDeflectS1", RANDOM = { "W_ShieldDeflectS1", "W_ShieldDeflectS2" } },
        [3] = { RIGHT = "W_ShieldDeflectL2", LEFT = "W_ShieldDeflectL1", RANDOM = { "W_ShieldDeflectL1", "W_ShieldDeflectL2" } },
        [4] = { RETURN_FALSE = TRUE },
        [5] = { RIGHT = "W_ShieldDeflectM2", LEFT = "W_ShieldDeflectM1", RANDOM = { "W_ShieldDeflectM1", "W_ShieldDeflectM2" } }
    } -- W.I.P

    local function getAnim(animTable, level, dir)
        local levelAnims = animTable[level]
        if type(levelAnims) == "table" then
            if levelAnims.RETURN_FALSE then
                SetVariable("IndexGuard", 1)
                return FALSE
            elseif levelAnims.RANDOM then
                return levelAnims.RANDOM[math.random(1, #levelAnims.RANDOM)]
            else
                return dir == ATTACK_DIR_RIGHT and levelAnims.RIGHT
                       or (dir == ATTACK_DIR_LEFT and levelAnims.LEFT
                           or levelAnims.DEFAULT)
            end
        else
            return levelAnims
        end
    end
	
    -- Processa deflexão ou bloqueio se não houver quebra de postura
	if SKD_PoiseBreak() == FALSE then
        if CheckStyleHand == HAND_RIGHT_BOTH or CheckStyleHand == HAND_LEFT_BOTH or CUSTOM_ONEHAND_CAN_DEFLECT == 1 then
            if DuringDeflection or DeflectHoldingL1Status then
                act(AddSpEffect, 150237) -- Aplica Deflect Grace
                act(AddSpEffect, 150240) -- Impede a quebra de postura
                anim = getAnim(deflectAnims, guard_damage_level, attack_dir)
            else
                act(AddSpEffect, 150240) -- Impede a quebra de postura
                anim = getAnim(blockAnims, guard_damage_level, attack_dir)
            end
            ExecEventAllBody(anim)
            return TRUE
        elseif CUSTOM_POWERSTANCE_MODE == 1 and CheckIsDualStyle then
            if DuringDeflection or DeflectHoldingL1Status then
                act(AddSpEffect, 150237) -- Aplica Deflect Grace
                act(AddSpEffect, 150240) -- Impede a quebra de postura
                anim = getAnim(dualDeflectAnims, guard_damage_level, attack_dir)
                if anim == FALSE then
                    return FALSE
                end
            else
                act(AddSpEffect, 150240) -- Impede a quebra de postura
                anim = getAnim(dualBlockAnims, guard_damage_level, attack_dir)
                if anim == FALSE then
                    return FALSE
                end
            end
            if anim then
                ExecEventAllBody(anim)
                return TRUE
            end
        elseif ShieldCanDeflect and CheckCanDeflect == HoldingMode then
            if DuringDeflection or DeflectHoldingL1Status then
                anim = getAnim(dualDeflectAnims, guard_damage_level, attack_dir) --------------- NAO ESQUECE DE MUDAR ISSO !!!!!!!!!
                if anim == FALSE then
                    return FALSE
                end
            end
            if anim then
                ExecEventAllBody(anim)
                return TRUE
            end
        end
	end

		if SKD_PoiseBreak() == TRUE then
            if attack_dir == ATTACK_DIR_RIGHT then
                anim = "W_PoiseBreakR"
        elseif attack_dir == ATTACK_DIR_LEFT then
                anim = "W_PoiseBreakL"
            else
		local AnimVariation = guard_damage_level > 1
				if AnimVariation then
					anim = "W_PoiseBreak2"
				else
					anim = "W_PoiseBreak1"
				end
			end

            ExecEventAllBody(anim)
            return TRUE
		end

    return FALSE
end

------------------------------------------
-- Atualiza a logica de deflexao
------------------------------------------

local function createUpdateFunction(updateFunc)
    return function()
        updateFunc()
    end
end

local updateTypes = {
    Block = SKD_BlockCommonUpdate,
    Deflect = SKD_DeflectCommonUpdate
}

local sizes = {"S", "M", "L"}
local versions = {1, 2, 3}

-- Criar funções para Block e Deflect
for _, size in ipairs(sizes) do
    for _, version in ipairs(versions) do
        _G["Block" .. size .. version .. "_onUpdate"] = createUpdateFunction(updateTypes.Block)
        _G["Deflect" .. size .. version .. "_onUpdate"] = createUpdateFunction(updateTypes.Deflect)
    end
end

-- Criar funções para DualBlock e DualDeflect
for _, size in ipairs(sizes) do
    for i = 1, 2 do
        _G["DualBlock" .. size .. i .. "_onUpdate"] = createUpdateFunction(updateTypes.Block)
        _G["DualDeflect" .. size .. i .. "_onUpdate"] = createUpdateFunction(updateTypes.Deflect)
    end
end

------------------------------------------

									--------------------------------------------------------------------------------
									--								CORE FUNCTIONS OVERRIDE					 	  --
									--------------------------------------------------------------------------------
									
------------------------------------------

function IsEnableGuard()
    local style = c_Style
    local hand = HAND_LEFT

    if style == HAND_RIGHT_BOTH then
        hand = HAND_RIGHT
    end
	
	------------------------------------------
	-- VIZZO - Habilita a guarda
	------------------------------------------
	local NotIsValidWeapon = GetEquipType(hand, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW, WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW, WEAPON_CATEGORY_BALLISTA, WEAPON_CATEGORY_STAFF)
	
	if VIZZO_IsPlayerRequest() == TRUE then
		if VIZZO_CheckPowerStanceMode() == TRUE then
			if VIZZO_CheckWeaponStyle() == DualWeaponStyle or VIZZO_CheckWeaponStyle() ==  DualWieldStyle and NotIsValidWeapon == TRUE then
				if (FALSE == NotIsValidWeapon) then
					return TRUE
				end
			end
		end
		if CUSTOM_ONEHAND_CAN_DEFLECT == 1 and style == HAND_RIGHT or style == HAND_LEFT and NotIsValidWeapon == TRUE then
			if (FALSE == NotIsValidWeapon) then
				return TRUE
			end
		end
	end
	------------------------------------------

    local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, hand)

    if style == HAND_RIGHT and GetEquipType(hand, WEAPON_CATEGORY_STAFF) == TRUE then
        return FALSE
    end
    if sp_kind == 249 and (style == HAND_LEFT_BOTH or style == HAND_RIGHT_BOTH) then
        return FALSE
    end
    if IsWeaponCanGuard() == FALSE then
        return FALSE
    end
    if IsEnableDualWielding() ~= -1 then
        return FALSE
    end
	
	-- Chama o codigo Original
	original_IsEnableGuard()
    return TRUE
end

function ExecGuard(event, blend_type)
    if env(ActionDuration, ACTION_ARM_ACTION) > 0 then
        return FALSE
    end
    if c_IsStealth == TRUE then
        blend_type = ALLBODY
    end
    if env(ActionRequest, ACTION_ARM_L1) == TRUE or env(ActionDuration, ACTION_ARM_L1) > 0 then
        if env(GetStamina) <= 0 then
            return FALSE
        end
        if IsEnableGuard() == TRUE then
            local style = c_Style
            local hand = HAND_LEFT

            if style == HAND_RIGHT_BOTH then
                hand = HAND_RIGHT
            end

            local kind = env(GetEquipWeaponCategory, hand)
            local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, hand)
            local guardindex = env(GetGuardMotionCategory, hand)

            if kind == WEAPON_CATEGORY_DUELING_SHIELD then
                guardindex = GUARD_STYLE_DUELINGSHIELD
            end

            -- Set Torch Color
            if kind == WEAPON_CATEGORY_TORCH and style == HAND_RIGHT then
                guardindex = GUARD_STYLE_TORCH

                if sp_kind == 291 then
                    SetVariable("IndexTorchColor", 1) -- Ghostflame Torch
                elseif sp_kind == 292 then
                    SetVariable("IndexTorchColor", 2) -- St. Trina's Torch
                elseif sp_kind == 288 then
                    SetVariable("IndexTorchColor", 3) -- Nanaya's Torch
                else
                    SetVariable("IndexTorchColor", 0) -- Torch
                end
            elseif sp_kind == 240 and style == HAND_RIGHT then
                guardindex = GUARD_STYLE_TORCH
            elseif style == HAND_RIGHT_BOTH or style == HAND_LEFT_BOTH then
                if env(GetStayAnimCategory) ~= 15 and env(GetStayAnimCategory) ~= 0 and env(GetStayAnimCategory) ~= 2
                    and env(GetStayAnimCategory) ~= 3 then
                    guardindex = GUARD_STYLE_DEFAULT
                end
                if kind == WEAPON_CATEGORY_DUELING_SHIELD then
                    guardindex = GUARD_STYLE_DUELINGSHIELD
                end
            end

            if env(GetSpEffectID, 172) == TRUE then
                SetVariable("GuardStartType", 1)
            else
                SetVariable("GuardStartType", 0)
            end
			
            ------------------------------------------
            -- VIZZO -  One Hand Guard
			------------------------------------------
			if CUSTOM_ONEHAND_CAN_DEFLECT == 1 and VIZZO_IsPlayerRequest() == TRUE then
				if style == HAND_RIGHT or style == HAND_LEFT then
					guardindex = GUARD_STYLE_DEFAULT
					guardindex = 1
				end
			end
			------------------------------------------

            SetVariable("IndexGuardStyle", guardindex)

            if blend_type == ALLBODY and MoveStart(LOWER, Event_MoveLong, FALSE) == TRUE then
                blend_type = UPPER
            end

            ------------------------------------------
            -- VIZZO -  SKD Define o Status de Deflexão
			------------------------------------------
			local CheckHolding = VIZZO_HoldingRequest() == IsHoldingL1
			
			if CheckHolding then
			else
				SKD_SetDeflectStatus()
			end
				
            ------------------------------------------

            if env(GetSpEffectID, 102000) == TRUE and event ~= Event_GuardOn then
                local is_after_additive_just_guard = FALSE
                if env(GetSpEffectID, 102020) == TRUE or env(GetSpEffectID, 102022) == TRUE then
                    is_after_additive_just_guard = TRUE
                end
                if env(GetSpEffectID, 102002) == TRUE and is_after_additive_just_guard == FALSE then
                    event = Event_GuardStart_JustGuard2
                elseif env(GetSpEffectID, 102003) == TRUE and is_after_additive_just_guard == FALSE then
                    event = Event_GuardStart_JustGuard3
                elseif env(GetSpEffectID, 102004) == TRUE and is_after_additive_just_guard == FALSE then
                    if IsNodeActive("GuardStart_JustGuard4_Upper Selector") == TRUE then
                        event = Event_GuardStart_JustGuard4_SelfTrans
                    else
                        event = Event_GuardStart_JustGuard4
                    end
                elseif event ~= Event_GuardStart then
                elseif IsNodeActive("GuardStart_JustGuard_Upper Selector") == TRUE then
                    event = Event_GuardStart_JustGuard_SelfTrans
                else
                    event = Event_GuardStart_JustGuard
                end
            end

            act(AddSpEffect, 102021)
            ExecEventHalfBlend(event, blend_type)

            return TRUE
        end
    end
	
	-- Chama o codigo Original
	original_ExecGuard()
    return FALSE
end

function GetAttackRequest(is_guard)
    local style = c_Style
    local is_both = FALSE
    local is_both_right = FALSE

    if style >= HAND_LEFT_BOTH then
        is_both = TRUE
    end

    if style == HAND_RIGHT_BOTH then
        is_both_right = TRUE
    end

    local hand = HAND_RIGHT
    if style == HAND_LEFT_BOTH then
        hand = HAND_LEFT
    end

    local is_arrow = GetEquipType(hand, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW, WEAPON_CATEGORY_LARGE_ARROW)
    local is_crossbow = GetEquipType(hand, WEAPON_CATEGORY_CROSSBOW)
    local is_ballista = GetEquipType(hand, WEAPON_CATEGORY_BALLISTA)
    local is_staff = GetEquipType(hand, WEAPON_CATEGORY_STAFF)
    local request_r1 = env(ActionRequest, ACTION_ARM_R1)
    local request_r2 = env(ActionRequest, ACTION_ARM_R2)
    local request_l1 = env(ActionRequest, ACTION_ARM_L1)
    local request_l2 = env(ActionRequest, ACTION_ARM_L2)

    if env(ActionDuration, ACTION_ARM_ACTION) > 0 then
        request_r1 = FALSE
        request_r2 = FALSE
        request_l1 = FALSE
        request_l2 = FALSE
    end

    -- R1
    if request_r1 == TRUE and is_staff == FALSE or request_r2 == TRUE and is_staff == TRUE then
        if is_both == TRUE then
            if is_arrow == TRUE then
                g_ArrowSlot = 0
                act(ChooseBowAndArrowSlot, 0)

                if style == HAND_LEFT_BOTH then
                    return ATTACK_REQUEST_ARROW_FIRE_LEFT
                else
                    return ATTACK_REQUEST_ARROW_FIRE_RIGHT
                end
            elseif is_crossbow == TRUE or is_ballista == TRUE then
                g_ArrowSlot = 0
                act(ChooseBowAndArrowSlot, 0)

                return ATTACK_REQUEST_BOTHRIGHT_CROSSBOW
            else
                return ATTACK_REQUEST_BOTH_LIGHT
            end
        elseif is_guard == TRUE then
            local is_spear = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_SPEAR)
            local is_rapier = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_RAPIER)
            local is_large_spear = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_LARGE_SPEAR)
            local is_large_rapier = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_LARGE_RAPIER)

            -- Shield Poke
            if is_spear == TRUE or is_rapier == TRUE or is_large_spear == TRUE or is_large_rapier == TRUE then
                if env(ActionDuration, ACTION_ARM_L1) > 0 then
                    return ATTACK_REQUEST_ATTACK_WHILE_GUARD
                else
                    return ATTACK_REQUEST_RIGHT_LIGHT
                end
            else
                if is_arrow == TRUE or is_ballista == TRUE then
                    return ATTACK_REQUEST_ARROW_BOTH_RIGHT
                end

                if is_crossbow == TRUE then
                    g_ArrowSlot = 0
                    act(ChooseBowAndArrowSlot, 0)
                    return ATTACK_REQUEST_RIGHT_CROSSBOW
                end
                return ATTACK_REQUEST_RIGHT_LIGHT
            end
        else
            if is_arrow == TRUE or is_ballista == TRUE then
                return ATTACK_REQUEST_ARROW_BOTH_RIGHT
            end

            if is_crossbow == TRUE then
                g_ArrowSlot = 0
                act(ChooseBowAndArrowSlot, 0)

                return ATTACK_REQUEST_RIGHT_CROSSBOW
            end
            return ATTACK_REQUEST_RIGHT_LIGHT
        end
    end
    -- R2
    if request_r2 == TRUE then
        -- Bow / Greatbow
        if is_arrow == TRUE then
            if is_both == TRUE then
                g_ArrowSlot = 1
                act(ChooseBowAndArrowSlot, 1)
                if style == HAND_LEFT_BOTH then
                    return ATTACK_REQUEST_ARROW_FIRE_LEFT2
                else
                    return ATTACK_REQUEST_ARROW_FIRE_RIGHT2
                end
            else
                return ATTACK_REQUEST_ARROW_BOTH_RIGHT
            end
            -- Crossbow
        elseif is_crossbow == TRUE then
            if is_both == TRUE then
                g_ArrowSlot = 1
                act(ChooseBowAndArrowSlot, 1)
                return ATTACK_REQUEST_BOTHRIGHT_CROSSBOW2
            else
                g_ArrowSlot = 1
                act(ChooseBowAndArrowSlot, 1)

                return ATTACK_REQUEST_RIGHT_CROSSBOW2
            end
            -- Ballista
        elseif is_ballista == TRUE then
            if is_both == TRUE then
                g_ArrowSlot = 1
                act(ChooseBowAndArrowSlot, 1)

                return ATTACK_REQUEST_BOTHRIGHT_CROSSBOW2
            else
                return ATTACK_REQUEST_ARROW_BOTH_RIGHT
            end
            -- 2H Heavy
        else
            local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, hand)
            if IsWeaponCatalyst(sp_kind) == TRUE then
                return ATTACK_REQUEST_INVALID
            end
            if is_both == TRUE then
                return ATTACK_REQUEST_BOTH_HEAVY
                -- R1 Heavy
            else
                return ATTACK_REQUEST_RIGHT_HEAVY
            end
        end
    end
    -- L1
    if request_l1 == TRUE then
        if env(IsPrecisionShoot) == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        local is_shield_left = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD,
            WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_TORCH)
        local is_shield_right = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD,
            WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_TORCH)
        local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, hand)
        if is_both == TRUE and sp_kind == 249 then
            return ATTACK_REQUEST_BOTH_LEFT
        end
        if is_shield_left == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        if is_shield_right == TRUE and is_both_right == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        is_arrow = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
            WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_BALLISTA)
        is_crossbow = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_CROSSBOW)
        if is_arrow == TRUE then
            if is_both == FALSE then
                return ATTACK_REQUEST_ARROW_BOTH_LEFT
            else
                return ATTACK_REQUEST_INVALID
            end
        elseif is_crossbow == TRUE then
            if is_both == FALSE then
                g_ArrowSlot = 0
                act(ChooseBowAndArrowSlot, 0)
                return ATTACK_REQUEST_LEFT_CROSSBOW
            else
                return ATTACK_REQUEST_INVALID
            end
        end
        is_staff = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_STAFF)
        if is_staff == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        is_arrow = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
            WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW, WEAPON_CATEGORY_BALLISTA)
        if is_arrow == TRUE and is_both == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        is_crossbow = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_CROSSBOW)
        if is_crossbow == TRUE and is_both == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        local isEnableDualWielding = IsEnableDualWielding()
		------------------------------------------
		-- VIZZO - PowerStanceMode
		------------------------------------------
		if VIZZO_IsPlayerRequest() == TRUE and VIZZO_CheckPowerStanceMode() == TRUE then
		local CheckDualStyle = IsEnableDualWielding() ~= -1
            if CheckDualStyle then
                return ATTACK_REQUEST_INVALID
            end
		end
		------------------------------------------
        -- VIZZO -  One Hand Guard
		------------------------------------------
		if CUSTOM_ONEHAND_CAN_DEFLECT == 1 and VIZZO_IsPlayerRequest() == TRUE then
			if style == HAND_RIGHT or style == HAND_LEFT then
				return ATTACK_REQUEST_INVALID
			end 
		end
		------------------------------------------
        if isEnableDualWielding == HAND_RIGHT then
            return ATTACK_REQUEST_DUAL_RIGHT
        elseif isEnableDualWielding == HAND_LEFT then
            return ATTACK_REQUEST_DUAL_LEFT
        end
        if IsWeaponCanGuard() == TRUE then
            return ATTACK_REQUEST_INVALID
        end
        return ATTACK_REQUEST_LEFT_HEAVY
    end
    -- L2
    if request_l2 == TRUE then
        act(DebugLogOutput, "action request ACTION_ARM_L2")
        if is_both == FALSE then
            is_arrow = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
                WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_BALLISTA)
            is_crossbow = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_CROSSBOW)
            if is_arrow == TRUE then
                return ATTACK_REQUEST_ARROW_BOTH_LEFT
            elseif is_crossbow == TRUE then
                g_ArrowSlot = 1
                act(ChooseBowAndArrowSlot, 1)
                return ATTACK_REQUEST_LEFT_CROSSBOW2
            end
            local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, HAND_LEFT)
            if IsWeaponCatalyst(sp_kind) == TRUE then
                return ATTACK_REQUEST_INVALID
            end
        end
        if c_SwordArtsID == 399 then
            if is_both == FALSE then
                return ATTACK_REQUEST_LEFT_HEAVY
            else
                return ATTACK_REQUEST_BOTH_LIGHT
            end
        end
        if c_IsEnableSwordArts == TRUE then
            local swordartrequest = GetSwordArtsRequestNew()
            local is_arrowright = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
                WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_BALLISTA)
            if swordartrequest == SWORDARTS_REQUEST_RIGHT_STANCE and is_arrowright == TRUE then
                if style ~= HAND_RIGHT_BOTH then
                    return ATTACK_REQUEST_ARROW_BOTH_RIGHT
                else
                    return swordartrequest
                end
            else
                return swordartrequest
            end
        elseif is_both == TRUE then
            if GetEquipType(hand, WEAPON_CATEGORY_STAFF) == TRUE then
                return ATTACK_REQUEST_BOTH_LIGHT
            else
                return ATTACK_REQUEST_BOTH_HEAVY
            end
        else
            return ATTACK_REQUEST_LEFT_HEAVY
        end
    end
	
	-- Chama o codigo Original
	original_GetAttackRequest()
    return ATTACK_REQUEST_INVALID
end

function ExecAttack(r1, r2, l1, l2, b1, b2, is_guard, blend_type, artsr1, artsr2, is_stealth_rolling)
    local cur_stamina = env(GetStamina)

	------------------------------------------
	-- VIZZO -- Check WeaponSpecial
	------------------------------------------
	
	-- Lista de IDs de armas especiais
	local SpecialWeaponIDs = {
	270 	-- Kazekage
	}

	-- Verificação se a arma equipada é uma das especiais
	local EquippedWeaponID = env(GetEquipWeaponSpecialCategoryNumber, HAND_RIGHT)
	
	local IsSpecialWeapon = false
	for _, id in ipairs(SpecialWeaponIDs) do
		if EquippedWeaponID == id then
			IsSpecialWeapon = true
			break
		end
	end
	
	------------------------------------------

    if cur_stamina <= 0 and GetVariable("StaminaComboResetTest") == 1 then
        g_ComboReset = TRUE
    end

    local request = GetAttackRequest(is_guard)

    if request == ATTACK_REQUEST_INVALID then
        return FALSE
    end

    act(DebugLogOutput, "ExecAttack request=" .. request)

    local style = c_Style
    local swordartpoint_hand = HAND_RIGHT
    local atk_hand = HAND_RIGHT
    local guard_hand = HAND_RIGHT
    local is_find_atk = TRUE

    if cur_stamina <= 0 then
        ResetRequest()
        return FALSE
    end

    local is_Dual = FALSE
    g_ComboReset = FALSE

    if c_Style == HAND_LEFT_BOTH then
        swordartpoint_hand = HAND_LEFT
    end
	------------------------------------------
	-- VIZZO - PowerStanceMode
	------------------------------------------
	if VIZZO_IsPlayerRequest() == TRUE and VIZZO_CheckPowerStanceMode() == TRUE then
	local CheckDualStyle = IsEnableDualWielding() ~= -1
	 
		if request == ATTACK_REQUEST_RIGHT_LIGHT and CheckDualStyle and artsr1 == FALSE then
			if env(ActionDuration, ACTION_ARM_L2) > 100 then
				request = ATTACK_REQUEST_BOTH_LIGHT
			end
		end
    end
	------------------------------------------

    act(SetDamageMotionBlendRatio, 0)

    if env(IsSpecialTransitionPossible) == TRUE then
        r1 = "W_AttackRightLight1"
        l1 = "W_AttackLeftLight1"
        b1 = "W_AttackBothLight1"

        -- 132 "[HKS] Recovery Window: Heavy Attack"
        -- Applied in TAE
        if env(GetSpEffectID, 132) == FALSE then
            r2 = "W_AttackRightHeavy1Start"
            l2 = "W_AttackLeftHeavy1"
            b2 = "W_AttackBothHeavy1Start"
        end
    end

	------------------------------------------
	-- VIZZO - My Weapons Compatible
	------------------------------------------
	
	------------------------------------------
	-- Kazekage
	------------------------------------------
	if IsSpecialWeapon then
	------------------------------------------
		if (env(GetSpEffectID, 8000500) == TRUE) then
			b2 = "W_AttackBothHeavySpecial1Start" -- R1(3) - R2
		end
		if (env(GetSpEffectID, 134) == TRUE) then
			b2 = "W_AttackRightHeavySpecial2Start" -- R1(1) - R2
		end
		if (env(GetSpEffectID, 133) == TRUE) then
			b2 = "W_AttackBothHeavySpecial2Start" -- SprintATK - R2
		end
		if (env(GetSpEffectID, 132) == TRUE) then
			r2 = "W_AttackRightHeavySpecial1Start" -- Martial SprintATK - R2
		end
	------------------------------------------
	end
	------------------------------------------

    -- 133 "[HKS] Switch Heavy to Heavy Sub"
    -- Applied in TAE
    if env(GetSpEffectID, 133) == TRUE then
        if r2 == "W_AttackRightHeavy1Start" then
            r2 = "W_AttackRightHeavy1SubStart"
        end

        if b2 == "W_AttackBothHeavy1Start" then
            b2 = "W_AttackBothHeavy1SubStart"
        end
        -- 134 "[HKS] Switch Heavy Sub to Heavy"
        -- Applied in TAE
    elseif env(GetSpEffectID, 134) == TRUE then
        if r2 == "W_AttackRightHeavy1SubStart" then
            r2 = "W_AttackRightHeavy1Start"
        end

        if b2 == "W_AttackBothHeavy1SubStart" then
            b2 = "W_AttackBothHeavy1Start"
        end
    end

    local isAfterAdditiveJustGuard = FALSE
    if IsNodeActive("Guard_Upper LayerGenerator") == TRUE and env(GetSpEffectID, 102020) == TRUE then
        isAfterAdditiveJustGuard = TRUE
    end

    -- 173 "[HKS] Guard Counter: End"
    -- 174 "[HKS] Guard Counter: Window"
    if env(GetSpEffectID, 173) == TRUE or env(GetSpEffectID, 174) == TRUE or isAfterAdditiveJustGuard == TRUE then
        if c_Style == HAND_RIGHT_BOTH then
            atk_hand = HAND_RIGHT
            guard_hand = HAND_RIGHT
        elseif c_Style == HAND_LEFT_BOTH then
            atk_hand = HAND_LEFT
            guard_hand = HAND_LEFT
        end

        -- Guard Counter Window
        -- If the player is holding a valid weapon, and has pressed R2, play Guard Counter anim

	------------------------------------------
	-- VIZZO - Sekiro CounterAttack Override
	------------------------------------------
	local IsEnableSekiroCounter = CUSTOM_SEKIRO_ATKCOUNTER
	local CheckIsBothHand = c_Style == HAND_RIGHT_BOTH or c_Style == HAND_LEFT_BOTH
	local CheckDualWield = env(GetEquipWeaponCategory, HAND_LEFT) == env(GetEquipWeaponCategory, HAND_RIGHT)
	
	local HandR_Shield_List = GetEquipType(HAND_RIGHT, 
        WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD, 
        WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_DUELING_SHIELD)
		
    local HandL_Shield_List = GetEquipType(HAND_LEFT, 
        WEAPON_CATEGORY_SMALL_SHIELD, WEAPON_CATEGORY_MIDDLE_SHIELD, 
        WEAPON_CATEGORY_LARGE_SHIELD, WEAPON_CATEGORY_DUELING_SHIELD)
	
	local StaffL_List = GetEquipType(HAND_LEFT, WEAPON_CATEGORY_STAFF)
	local StaffR_List = GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_STAFF)

	if IsEnableSekiroCounter == 1 or IsSpecialWeapon and (HandR_Shield_List == FALSE and HandL_Shield_List == FALSE and StaffL_List == FALSE and StaffR_List == FALSE) then

    local DeflectActions = {
        { effectID = 8000543, deflectR2 = "W_DeflectS1_R2", dualDeflectR2 = "W_DualDeflectS1_R2", deflectR1 = "W_DeflectS1_R1" },
        { effectID = 8000545, deflectR2 = "W_DeflectS2_R2", dualDeflectR2 = "W_DualDeflectS2_R2", deflectR1 = "W_DeflectS2_R1" },
        { effectID = 8000547, deflectR2 = "W_DeflectM3_R2", dualDeflectR2 = "W_DualDeflectM1_R2", deflectR1 = "W_DeflectM3_R1" },
        { effectID = 8000548, deflectR2 = "W_DeflectM2_R2", dualDeflectR2 = "W_DualDeflectM2_R2", deflectR1 = "W_DeflectM2_R1" }
    }

		for _, action in ipairs(DeflectActions) do
			if env(GetSpEffectID, action.effectID) == TRUE then
			-- R2
				if env(ActionRequest, ACTION_ARM_R2) == TRUE then
					if CheckIsBothHand then
						ExecEventAllBody(action.deflectR2) -- Deflect Action R2
						return TRUE
					end
					if CheckDualWield then
						ExecEventAllBody(action.dualDeflectR2) -- DualDeflect Action R2
						return TRUE
					end
				end
			-- R1
				if env(ActionRequest, ACTION_ARM_R1) == TRUE then
					if CheckIsBothHand then
						ExecEventAllBody(action.deflectR1) -- Deflect Action R1
						return TRUE
					end
				end
			end
		end
	end

	-- Executa o codigo Vanilla
	if IsEnableSekiroCounter == 0 or HandR_Shield_List == TRUE or HandL_Shield_List == TRUE or StaffL_List == TRUE or StaffR_List == TRUE then
        if GetEquipType(atk_hand, WEAPON_CATEGORY_STAFF, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
            WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW, WEAPON_CATEGORY_BALLISTA) == FALSE
            and env(ActionRequest, ACTION_ARM_R2) == TRUE then
            if c_Style == HAND_RIGHT_BOTH or c_Style == HAND_LEFT_BOTH then
                ExecEventAllBody("W_AttackBothHeavyCounter")
            else
                ExecEventAllBody("W_AttackRightHeavyCounter")
            end

            return TRUE
        end
	end

	------------------------------------------

        -- Otherwise, if in Guard Counter Window, mulch the request
        if env(GetSpEffectID, 174) == TRUE then
            return FALSE
        end
    end

    -- 100630 "[HKS] Throw related"
    if env(GetSpEffectID, 100630) == TRUE and ExecFallAttack() == TRUE then
        return TRUE
    end
    if request == ATTACK_REQUEST_RIGHT_LIGHT then
        if artsr1 == TRUE then
            SetSwordArtsPointInfo(ACTION_ARM_R1, TRUE, r1)

            if r1 == "W_DrawStanceRightAttackLight" then
                SetSwordArtsWepCategory_DrawStanceRightAttackLight()
            end
        end

        if c_SwordArtsID == 318 then
            if r1 == "W_SwordArtsOneShotComboEnd_MesmerSowrdArts" then
                SetSwordArtsPointInfo(ACTION_ARM_R1, TRUE)
            elseif r1 == "W_SwordArtsOneShotComboEnd_2" then
                SetSwordArtsPointInfo(ACTION_ARM_R1, TRUE)
                local val = GetVariable("IsEnoughArtPointsR1")
                SetVariable("IsEnoughArtPointsR2", val)
            end
        end

        --- 135 "[HKS] Light Sub Start Type 0"
        --- 136 "[HKS] Light Sub Start Type 1"
        --- 137 "[HKS] Light Sub Start Type 2"
        --- 138 "[HKS] Light Sub Start Type 3"
        if r1 == "W_AttackRightLightSubStart" then
            if env(GetSpEffectID, 135) == TRUE then
                SetVariable("AttackLightSubStartType", 0)
            elseif env(GetSpEffectID, 136) == TRUE then
                SetVariable("AttackLightSubStartType", 1)
            elseif env(GetSpEffectID, 137) == TRUE then
                SetVariable("AttackLightSubStartType", 2)
            elseif env(GetSpEffectID, 138) == TRUE then
                SetVariable("AttackLightSubStartType", 3)
            else
                r1 = "W_AttackRightLight2"
            end
        end

        if r1 == "W_AttackRightLightStealth" and IsUseStealthAttack(FALSE) == FALSE then
            r1 = "W_AttackRightLightStep"
        end

        if GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_STAFF) == TRUE and r1 ~= "W_AttackRightLight2" and r1
            ~= "W_AttackRightLight3" then
            r1 = "W_AttackRightLight1"
        end

        if env(GetSpEffectID, 19903) == TRUE then
            r1 = "W_AttackRightLight3"
        elseif env(GetSpEffectID, 19904) == TRUE then
            r1 = "W_AttackRightLight4"
        end
        if env(GetSpEffectID, 19915) == TRUE then
            r1 = "W_AttackRightLight2"
        end
		
		------------------------------------------
		-- VIZZO - PowerStanceMode
		------------------------------------------
		if VIZZO_IsPlayerRequest() == TRUE and VIZZO_CheckPowerStanceMode() == TRUE then
		local CheckStyle = VIZZO_CheckWeaponStyle()
		local CheckDualStyle = CheckStyle == DualWeaponStyle or CheckStyle == DualWieldStyle
		
			if IsEnableGuard() == TRUE and artsr1 == FALSE and CheckDualStyle then
			is_Dual = TRUE

				if r1 == "W_AttackRightLightDash" then
					r1 = "W_AttackDualDash"
				elseif r1 == "W_AttackRightLightStep" then
					r1 = "W_AttackDualRolling"
				elseif r1 == "W_AttackRightBackstep" then
					r1 = "W_AttackDualBackStep"
				elseif r1 == "W_AttackRightLightStealth" then
					if IsUseStealthAttack(TRUE) == FALSE then
						r1 = "W_AttackDualRolling"
					else
						r1 = "W_AttackDualStealth"
					end
				elseif l1 == "W_AttackLeftLight1" then
					r1 = "W_AttackDualLight1"
				elseif l1 == "W_AttackLeftLight2" then
					r1 = "W_AttackDualLight2"
				elseif l1 == "W_AttackLeftLight3" then
					r1 = "W_AttackDualLight3"
				elseif l1 == "W_AttackLeftLight4" then
					r1 = "W_AttackDualLight4"
				elseif l1 == "W_AttackLeftLight5" then
					r1 = "W_AttackDualLight5"
				elseif l1 == "W_AttackLeftLight6" then
					r1 = "W_AttackDualLight6"
				else
					r1 = "W_AttackDualLight1"
				end
			end
			
			if env(GetSpEffectID, 19903) == TRUE then
				r1 = "W_AttackDualLight3"
			elseif env(GetSpEffectID, 19904) == TRUE then
				r1 = "W_AttackDualLight4"
			end

			if r1 == "W_AttackDualLightSubStart" then
				if env(GetSpEffectID, 135) == TRUE then
					SetVariable("AttackLightSubStartType", 0)
				else
					r1 = "W_AttackDualLight2"
				end
			end
		end
		------------------------------------------
        ExecEventAllBody(r1)

    elseif request == ATTACK_REQUEST_RIGHT_HEAVY then
        if (c_SwordArtsID == 313 or c_SwordArtsID == 273)
            and (r2 == "W_SwordArtsOneShotComboEnd" or r2 == "W_SwordArtsOneShotComboEnd_2") then
            artsr2 = TRUE
            SetVariable("SwordArtsOneShotComboCategory", 0)
        end

        if artsr2 == TRUE then
            SetSwordArtsPointInfo(ACTION_ARM_R2, TRUE, r2)
        end

        local IsEnableSpecialAttack = FALSE

        -- Barbaric Roar: Heavy Special
        if env(GetSpEffectID, 1681) == TRUE or env(GetSpEffectID, 1686) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        -- War Cry: Heavy Special
        if env(GetSpEffectID, 1811) == TRUE or env(GetSpEffectID, 1816) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 1)
        end

        -- Unknown: Heavy Special
        if env(GetSpEffectID, 1716) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        -- Unknown: Heavy Special
        if env(GetSpEffectID, 1721) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        -- Unknown (DLC): Heavy Special
        if env(GetSpEffectID, 102101) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        if IsEnableSpecialAttack == TRUE then
            if r2 == "W_AttackRightHeavy1Start" then
                r2 = "W_AttackRightHeavySpecial1Start"
            elseif r2 == "W_AttackRightHeavy1SubStart" then
                r2 = "W_AttackRightHeavySpecial1SubStart"
            elseif r2 == "W_AttackRightHeavy2Start" then
                r2 = "W_AttackRightHeavySpecial2Start"
            end
        end

        if env(GetSpEffectID, 1681) == FALSE and env(GetSpEffectID, 1686) == FALSE and env(GetSpEffectID, 1811) == FALSE
            and env(GetSpEffectID, 1816) == FALSE and env(GetSpEffectID, 19912) == TRUE then
            r2 = "W_AttackRightHeavy2Start"
        end

        ExecEventAllBody(r2)
    elseif request == ATTACK_REQUEST_LEFT_LIGHT then
        atk_hand = HAND_LEFT
        guard_hand = HAND_LEFT
        ExecEventAllBody(l1)
    elseif request == ATTACK_REQUEST_LEFT_HEAVY then
        atk_hand = HAND_LEFT
        guard_hand = HAND_LEFT
        ExecEventAllBody(l2)
    elseif request == ATTACK_REQUEST_BOTH_LIGHT then
        if c_SwordArtsID == 318 and r1 == "W_SwordArtsOneShotComboEnd_MesmerSowrdArts" then
            artsr1 = TRUE
        end
        if artsr1 == TRUE then
            SetSwordArtsPointInfo(ACTION_ARM_R1, TRUE, b1)
            if b1 == "W_DrawStanceRightAttackLight" then
                SetSwordArtsWepCategory_DrawStanceRightAttackLight()
            end
        end

        --- 135 "[HKS] Light Sub Start Type 0"
        --- 136 "[HKS] Light Sub Start Type 1"
        --- 137 "[HKS] Light Sub Start Type 2"
        --- 138 "[HKS] Light Sub Start Type 3"
        if b1 == "W_AttackBothLightSubStart" then
            if env(GetSpEffectID, 135) == TRUE then
                SetVariable("AttackLightSubStartType", 0)
            elseif env(GetSpEffectID, 136) == TRUE then
                SetVariable("AttackLightSubStartType", 1)
            elseif env(GetSpEffectID, 137) == TRUE then
                SetVariable("AttackLightSubStartType", 2)
            elseif env(GetSpEffectID, 138) == TRUE then
                SetVariable("AttackLightSubStartType", 3)
            else
                b1 = "W_AttackBothLight2"
            end
        end

        if b1 == "W_AttackBothLightStealth" and IsUseStealthAttack(FALSE) == FALSE then
            b1 = "W_AttackBothLightStep"
        end

        local staff_hand = HAND_RIGHT

        if c_Style == HAND_LEFT_BOTH then
            staff_hand = HAND_LEFT
        end

        if GetEquipType(staff_hand, WEAPON_CATEGORY_STAFF) == TRUE and b1 ~= "W_AttackBothLight2" and b1
            ~= "W_AttackBothLight3" then
            b1 = "W_AttackBothLight1"
        end

        if env(GetSpEffectID, 19903) == TRUE then
            b1 = "W_AttackBothLight3"
        elseif env(GetSpEffectID, 19904) == TRUE then
            b1 = "W_AttackBothLight4"
        end

        if env(GetSpEffectID, 19915) == TRUE then
            b1 = "W_AttackBothLight2"
        end

        if style == HAND_RIGHT_BOTH then
            atk_hand = HAND_RIGHT
        elseif style == HAND_LEFT_BOTH then
            atk_hand = HAND_LEFT
        end

        if env(GetEquipWeaponCategory, atk_hand) == WEAPON_CATEGORY_DUELING_SHIELD then
            guard_hand = atk_hand
            if is_guard == TRUE and env(ActionDuration, ACTION_ARM_L1) > 0 then
                b1 = "W_AttackBothLightGuard"
            end
        end

        ExecEventAllBody(b1)
    elseif request == ATTACK_REQUEST_BOTH_LEFT then
        if l1 ~= "W_AttackBothLeftSpecial2" and l1 ~= "W_AttackBothLeftSpecial3" and l1 ~= "W_AttackBothLeftSpecial4"
            and l1 ~= "W_AttackBothLeftSpecial5" then
            l1 = "W_AttackBothLeftSpecial1"
        end

        ExecEventAllBody(l1)
    elseif request == ATTACK_REQUEST_BOTH_HEAVY then
        -- DLC 1.13.1: Dynastic Sickleplay, Raging Beast
        if (c_SwordArtsID == 313 or c_SwordArtsID == 273) and (r2 == "W_SwordArtsOneShotComboEnd" or r2 == "W_SwordArtsOneShotComboEnd_2") then
            artsr2 = TRUE
            SetVariable("SwordArtsOneShotComboCategory", 0)
        end

        if artsr2 == TRUE then
            SetSwordArtsPointInfo(ACTION_ARM_R2, TRUE, b2)
        end

        local IsEnableSpecialAttack = FALSE

        -- Barbaric Roar: Heavy Special
        if c_Style == HAND_RIGHT_BOTH then
            if env(GetSpEffectID, 1681) == TRUE or env(GetSpEffectID, 1686) == TRUE then
                IsEnableSpecialAttack = TRUE
                SetVariable("AttackRightHeavySpecialType", 0)
            end
        elseif c_Style == HAND_LEFT_BOTH and (env(GetSpEffectID, 1683) == TRUE or env(GetSpEffectID, 1688) == TRUE) then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        -- War Cry: Heavy Special
        if c_Style == HAND_RIGHT_BOTH then
            if env(GetSpEffectID, 1811) == TRUE or env(GetSpEffectID, 1816) == TRUE or env(GetSpEffectID, 1861) == TRUE then
                IsEnableSpecialAttack = TRUE
                SetVariable("AttackRightHeavySpecialType", 1)
            end
        elseif c_Style == HAND_LEFT_BOTH
            and (env(GetSpEffectID, 1813) == TRUE or env(GetSpEffectID, 1818) == TRUE or env(GetSpEffectID, 1863) == TRUE) then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 1)
        end

        -- Unknown: Heavy Special
        if c_Style == HAND_RIGHT_BOTH then
            if env(GetSpEffectID, 1716) == TRUE then
                IsEnableSpecialAttack = TRUE
                SetVariable("AttackRightHeavySpecialType", 0)
            end
        elseif c_Style == HAND_LEFT_BOTH and env(GetSpEffectID, 1718) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        -- Unknown: Heavy Special
        if c_Style == HAND_RIGHT_BOTH then
            if env(GetSpEffectID, 1721) == TRUE then
                IsEnableSpecialAttack = TRUE
                SetVariable("AttackRightHeavySpecialType", 0)
            end
        elseif c_Style == HAND_LEFT_BOTH and env(GetSpEffectID, 1723) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        if c_Style == HAND_RIGHT_BOTH then
            if env(GetSpEffectID, 102101) == TRUE then
                IsEnableSpecialAttack = TRUE
                SetVariable("AttackRightHeavySpecialType", 0)
            end
        elseif c_Style == HAND_LEFT_BOTH and env(GetSpEffectID, 102106) == TRUE then
            IsEnableSpecialAttack = TRUE
            SetVariable("AttackRightHeavySpecialType", 0)
        end

        if IsEnableSpecialAttack == TRUE then
            if b2 == "W_AttackBothHeavy1Start" then
                b2 = "W_AttackBothHeavySpecial1Start"
            elseif b2 == "W_AttackBothHeavy1SubStart" then
                b2 = "W_AttackBothHeavySpecial1SubStart"
            elseif b2 == "W_AttackBothHeavy2Start" then
                b2 = "W_AttackBothHeavySpecial2Start"
            end
        end

        if env(GetSpEffectID, 1681) == FALSE and env(GetSpEffectID, 1686) == FALSE and env(GetSpEffectID, 1811) == FALSE
            and env(GetSpEffectID, 1816) == FALSE and env(GetSpEffectID, 19912) == TRUE then
            b2 = "W_AttackBothHeavy2Start"
        end
        if style == HAND_RIGHT_BOTH then
            atk_hand = HAND_RIGHT
        elseif style == HAND_LEFT_BOTH then
            atk_hand = HAND_LEFT
        end
        if env(GetEquipWeaponCategory, atk_hand) == WEAPON_CATEGORY_DUELING_SHIELD then
            guard_hand = atk_hand
        end

        ExecEventAllBody(b2)
    elseif request == ATTACK_REQUEST_DUAL_RIGHT then
        if r1 == "W_AttackRightLightDash" then
            l1 = "W_AttackDualDash"
        elseif r1 == "W_AttackRightLightStep" then
            l1 = "W_AttackDualRolling"
        elseif r1 == "W_AttackRightBackstep" then
            l1 = "W_AttackDualBackStep"
        elseif r1 == "W_AttackRightLightStealth" then
            if IsUseStealthAttack(TRUE) == FALSE then
                l1 = "W_AttackDualRolling"
            else
                l1 = "W_AttackDualStealth"
            end
        elseif l1 == "W_AttackLeftLight1" then
            l1 = "W_AttackDualLight1"
        elseif l1 == "W_AttackLeftLight2" then
            l1 = "W_AttackDualLight2"
        elseif l1 == "W_AttackLeftLight3" then
            l1 = "W_AttackDualLight3"
        elseif l1 == "W_AttackLeftLight4" then
            l1 = "W_AttackDualLight4"
        elseif l1 == "W_AttackLeftLight5" then
            l1 = "W_AttackDualLight5"
        elseif l1 == "W_AttackLeftLight6" then
            l1 = "W_AttackDualLight6"
        elseif l1 == "W_AttackDualLightSubStart" then
            l1 = "W_AttackDualLightSubStart"
        else
            l1 = "W_AttackDualLight1"
        end

        if env(GetSpEffectID, 19903) == TRUE then
            l1 = "W_AttackDualLight3"
        elseif env(GetSpEffectID, 19904) == TRUE then
            l1 = "W_AttackDualLight4"
        end

        if l1 == "W_AttackDualLightSubStart" then
            if env(GetSpEffectID, 135) == TRUE then
                SetVariable("AttackLightSubStartType", 0)
            else
                l1 = "W_AttackDualLight2"
            end
        end

        is_Dual = TRUE
        ExecEventAllBody(l1)
    elseif request == ATTACK_REQUEST_ARROW_BOTH_RIGHT then
        if c_Style ~= HAND_RIGHT_BOTH and c_Style ~= HAND_LEFT_BOTH and ExecHandChange(HAND_RIGHT, TRUE, blend_type)
            == TRUE then
            return TRUE
        end
        return FALSE
    elseif request == ATTACK_REQUEST_ARROW_BOTH_LEFT then
        if c_Style ~= HAND_RIGHT_BOTH and c_Style ~= HAND_LEFT_BOTH and ExecHandChange(HAND_LEFT, TRUE, blend_type)
            == TRUE then
            return TRUE
        end
        return FALSE
    elseif request == ATTACK_REQUEST_LEFT_REVERSAL then
        ExecEventAllBody("W_AttackLeftReversal")
    elseif request == SWORDARTS_REQUEST_LEFT_NORMAL then
        SetSwordArtsPointInfo(ACTION_ARM_L2, TRUE)
        atk_hand = HAND_LEFT
        guard_hand = HAND_LEFT

        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        local idle_cat = env(GetStayAnimCategory)
        local wep_cat = env(GetEquipWeaponCategory, c_SwordArtsHand)
        local arts_cat = GetSwordArtsDiffCategory(c_SwordArtsID, idle_cat, wep_cat)
        local arts_idx = 0

        if arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON then
            arts_idx = 1
        elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM then
            arts_idx = 2
        elseif arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON_SMALL_SHIELD then
            arts_idx = 3
        elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM_SMALL_SHIELD then
            arts_idx = 4
        elseif arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON_LARGE_SHIELD then
            arts_idx = 5
        elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM_LARGE_SHIELD then
            arts_idx = 6
        elseif arts_cat == WEAPON_CATEGORY_SHORT_SWORD then
            arts_idx = 7
        elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD then
            arts_idx = 8
        elseif arts_cat == WEAPON_CATEGORY_LARGE_SHIELD then
            arts_idx = 9
        elseif arts_cat == WEAPON_CATEGORY_SMALL_SHIELD then
            arts_idx = 10
        elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
            arts_idx = 11
        end

        SetVariable("SwordArtsOneShotShieldCategory", arts_idx)

        -- Torch Attack
        if c_SwordArtsID == 17 then
            SetVariable("SwordArtsOneShotComboCategory", 0)
        end

        if IsHalfBlendArts(c_SwordArtsID) == TRUE then
            ExecEventHalfBlend(Event_SwordArtsHalfOneShotShieldLeft, blend_type)
        else
            ExecEventAllBody("W_SwordArtsOneShotShieldLeft")
        end
    elseif request == SWORDARTS_REQUEST_BOTH_NORMAL then
        SetSwordArtsPointInfo(ACTION_ARM_L2, TRUE)

        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        local idle_cat = env(GetStayAnimCategory)
        local wep_cat = env(GetEquipWeaponCategory, c_SwordArtsHand)
        local arts_cat = GetSwordArtsDiffCategory(c_SwordArtsID, idle_cat, wep_cat)

        if IsHalfBlendArts(c_SwordArtsID) == TRUE and c_SwordArtsID ~= 334 and c_SwordArtsID ~= 354 and c_SwordArtsID
            ~= 355 then
            if c_SwordArtsHand == HAND_LEFT then
                local arts_idx = 0

                if arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON then
                    arts_idx = 1
                elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM then
                    arts_idx = 2
                elseif arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON_SMALL_SHIELD then
                    arts_idx = 3
                elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM_SMALL_SHIELD then
                    arts_idx = 4
                elseif arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON_LARGE_SHIELD then
                    arts_idx = 5
                elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM_LARGE_SHIELD then
                    arts_idx = 6
                elseif arts_cat == WEAPON_CATEGORY_SHORT_SWORD then
                    arts_idx = 7
                elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD then
                    arts_idx = 8
                elseif arts_cat == WEAPON_CATEGORY_LARGE_SHIELD then
                    arts_idx = 9
                elseif arts_cat == WEAPON_CATEGORY_SMALL_SHIELD then
                    arts_idx = 10
                elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
                    arts_idx = 11
                end

                SetVariable("SwordArtsOneShotShieldCategory", arts_idx)
                ExecEventHalfBlend(Event_SwordArtsHalfOneShotShieldLeft, blend_type)
            else
                local arts_idx = 0

                if arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON then
                    arts_idx = 1
                elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM then
                    arts_idx = 2
                elseif arts_cat == WEAPON_CATEGORY_SHORT_SWORD or arts_cat == WEAPON_CATEGORY_THROW_DAGGER then
                    arts_idx = 3
                elseif arts_cat == WEAPON_CATEGORY_TWINBLADE then
                    arts_idx = 4
                elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD then
                    arts_idx = 5
                elseif arts_cat == WEAPON_CATEGORY_FIST or arts_cat == WEAPON_CATEGORY_MARTIAL_ARTS or arts_cat
                    == WEAPON_CATEGORY_PERFUME_BOTTLE or arts_cat == WEAPON_CATEGORY_BEAST_CLAW then
                    arts_idx = 6
                elseif arts_cat == WEAPON_CATEGORY_LARGE_SHIELD then
                    arts_idx = 7
                elseif arts_cat == WEAPON_CATEGORY_SMALL_SHIELD then
                    arts_idx = 8
                elseif arts_cat == WEAPON_CATEGORY_BACKHAND_SWORD then
                    arts_idx = 9
                elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
                    arts_idx = 10
                end

                SetVariable("SwordArtsOneShotCategory", arts_idx)
                ExecEventHalfBlend(Event_SwordArtsHalfOneShot, blend_type)
            end
        else
            local arts_idx = 0

            if arts_cat == WEAPON_CATEGORY_SHORT_SWORD then
                arts_idx = 1
            elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD then
                arts_idx = 2
            elseif arts_cat == WEAPON_CATEGORY_LARGE_SHIELD then
                arts_idx = 3
            elseif arts_cat == WEAPON_CATEGORY_SMALL_SHIELD then
                arts_idx = 4
            elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
                arts_idx = 5
            end

            SetVariable("SwordArtsOneShotShieldCategory", arts_idx)
            if IsHalfBlendArts(c_SwordArtsID) == TRUE then
                ExecEventHalfBlend(Event_SwordArtsHalfOneShotShieldBoth, blend_type)
            else
                ExecEventAllBody("W_SwordArtsOneShotShieldBoth")
            end
        end
    elseif request == SWORDARTS_REQUEST_RIGHT_NORMAL then
        SetSwordArtsPointInfo(ACTION_ARM_L2, TRUE)

        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        local idle_cat = env(GetStayAnimCategory)
        local wep_cat = env(GetEquipWeaponCategory, c_SwordArtsHand)
        local arts_cat = GetSwordArtsDiffCategory(c_SwordArtsID, idle_cat, wep_cat)
        local arts_idx = 0

        if arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON or arts_cat == WEAPON_CATEGORY_LARGE_KATANA then
            arts_idx = 1
        elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM then
            arts_idx = 2
        elseif arts_cat == WEAPON_CATEGORY_SHORT_SWORD or arts_cat == WEAPON_CATEGORY_THROW_DAGGER then
            arts_idx = 3
        elseif arts_cat == WEAPON_CATEGORY_TWINBLADE then
            arts_idx = 4
        elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD then
            arts_idx = 5
        elseif arts_cat == WEAPON_CATEGORY_FIST or arts_cat == WEAPON_CATEGORY_MARTIAL_ARTS or arts_cat
            == WEAPON_CATEGORY_PERFUME_BOTTLE or arts_cat == WEAPON_CATEGORY_BEAST_CLAW then
            arts_idx = 6
        elseif arts_cat == WEAPON_CATEGORY_LARGE_SHIELD then
            arts_idx = 7
        elseif arts_cat == WEAPON_CATEGORY_SMALL_SHIELD then
            arts_idx = 8
        elseif arts_cat == WEAPON_CATEGORY_BACKHAND_SWORD then
            arts_idx = 9
        elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
            arts_idx = 10
        elseif c_SwordArtsID == 328 and env(GetSpEffectID, 19875) == TRUE and GetVariable("IsEnoughArtPointsL2") == 0 then
            arts_idx = 12
        elseif c_SwordArtsID == 328 and env(GetSpEffectID, 19874) == TRUE and GetVariable("IsEnoughArtPointsL2") == 0 then
            arts_idx = 11
        end

        SetVariable("SwordArtsOneShotCategory", arts_idx)
        local combo_idx = 0

        if arts_cat == SWORD_ART_DIFF_CAT_LARGE_WEAPON then
            combo_idx = 1
        elseif arts_cat == SWORD_ART_DIFF_CAT_POLEARM then
            combo_idx = 2
        elseif arts_cat == WEAPON_CATEGORY_TWINBLADE then
            combo_idx = 3
        elseif arts_cat == WEAPON_CATEGORY_CURVEDSWORD or arts_cat == WEAPON_CATEGORY_MARTIAL_ARTS or arts_cat
            == WEAPON_CATEGORY_BEAST_CLAW then
            combo_idx = 4
        elseif arts_cat == WEAPON_CATEGORY_BACKHAND_SWORD then
            combo_idx = 5
        elseif arts_cat == WEAPON_CATEGORY_DUELING_SHIELD then
            combo_idx = 6
        end

        SetVariable("SwordArtsOneShotComboCategory", combo_idx)
        SetVariable("SwordArtsSubCategory", 0)

        if c_SwordArtsID == 261 then
            if env(GetSpEffectID, 102355) == TRUE then
                SetVariable("SwordArtsSubCategory", 0)
                ExecEventAllBody("W_SwordArtsOneShot_Sub")
            elseif env(GetSpEffectID, 102356) == TRUE then
                SetVariable("SwordArtsSubCategory", 1)
                ExecEventAllBody("W_SwordArtsOneShot_Sub")
            else
                ExecEventAllBody("W_SwordArtsOneShot")
            end
        elseif IsHalfBlendArts(c_SwordArtsID) == TRUE then
            ExecEventHalfBlend(Event_SwordArtsHalfOneShot, blend_type)
        else
            ExecEventAllBody("W_SwordArtsOneShot")
        end
    elseif request == SWORDARTS_REQUEST_RIGHT_STEP then
        act(DebugLogOutput, "SwordArtsRolling request" .. request)

        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        local rollingAngle = c_ArtsRollingAngle

        if GetVariable("MoveSpeedLevel") > 0.20000000298023224 then
            rollingAngle = GetVariable("MoveAngle")
        end

        local turn_target_angle = 0
        local rollingDirection = 0
        local turn_angle_real = 200
        local is_self_trans = FALSE
        local is_self_trans_2 = FALSE
        local arts_id = c_SwordArtsID
        if IsNodeActive("SwordArtsRolling Selector MP") == TRUE
            or IsNodeActive("SwordArtsRolling Selector MP_SelfTrans2") == TRUE then
            is_self_trans = TRUE
        elseif (arts_id == 155 or arts_id == 156)
            and (IsNodeActive("SwordArtsRolling Selector MP_SelfTrans") == TRUE or env(GetSpEffectID, 100710) == TRUE) then
            is_self_trans_2 = TRUE
        end

        if GetVariable("IsLockon") == false and env(IsPrecisionShoot) == FALSE and env(IsCOMPlayer) == FALSE
            or env(GetSpEffectID, 100002) == TRUE then
            rollingDirection = 0
        else
            if rollingAngle <= GetVariable("RollingAngleThresholdRightFrontTest") and rollingAngle
                >= GetVariable("RollingAngleThresholdLeftFrontTest") then
                rollingDirection = 0
                turn_target_angle = rollingAngle
            elseif rollingAngle > GetVariable("RollingAngleThresholdRightFrontTest") and rollingAngle
                < GetVariable("RollingAngleThresholdRightBackTest") then
                rollingDirection = 3
                turn_target_angle = rollingAngle - 90
            elseif rollingAngle < GetVariable("RollingAngleThresholdLeftFrontTest") and rollingAngle
                > GetVariable("RollingAngleThresholdLeftBackTest") then
                rollingDirection = 2
                turn_target_angle = rollingAngle + 90
            else
                rollingDirection = 1
                turn_target_angle = rollingAngle - 180
            end

            if arts_id == 276 then
                if rollingAngle <= 0 and rollingAngle >= -180 then
                    rollingDirection = 2
                    turn_target_angle = rollingAngle + 90
                elseif rollingAngle > 0 and rollingAngle < 180 then
                    rollingDirection = 3
                    turn_target_angle = rollingAngle - 90
                else
                    rollingDirection = 2
                    turn_target_angle = rollingAngle + 90
                end
            end

            if arts_id == 313 then
                if GetVariable("MoveSpeedLevel") < 0.20000000298023224 then
                    rollingDirection = 0
                    turn_target_angle = rollingAngle
                elseif rollingAngle <= 0 and rollingAngle >= -120 then
                    rollingDirection = 2
                    turn_target_angle = rollingAngle + 90
                elseif rollingAngle > 0 and rollingAngle < 120 then
                    rollingDirection = 3
                    turn_target_angle = rollingAngle - 90
                else
                    rollingDirection = 1
                    turn_target_angle = rollingAngle - 180
                end
            end

            turn_angle_real = math.abs(GetVariable("TurnAngle") - rollingAngle)

            if turn_angle_real > 180 then
                turn_angle_real = 360 - turn_angle_real
            end

            if arts_id ~= 276 then
                if GetVariable("IsLockon") == true then
                    act(TurnToLockonTargetImmediately, turn_target_angle)
                else
                    act(FaceDirection, turn_target_angle)
                end
            end
        end

        if is_self_trans == TRUE then
            if arts_id == 155 or arts_id == 156 then
                SetVariable("SwordArtsRollingArtsCategory", 0)
            else
                SetVariable("SwordArtsRollingArtsCategory", 1)
            end
            SetVariable("SwordArtsRollingDirection_SelfTrans", rollingDirection)
            SetVariable("RollingAngleRealSelftrans", rollingAngle)
        elseif is_self_trans_2 == TRUE then
            SetVariable("SwordArtsRollingDirection_SelfTrans2", rollingDirection)
            SetVariable("RollingAngleReal", rollingAngle)
        else
            SetVariable("SwordArtsRollingDirection", rollingDirection)
            SetVariable("RollingAngleReal", rollingAngle)
        end

        SetVariable("TurnAngleReal", turn_angle_real)
        SetSwordArtsPointInfo(ACTION_ARM_L2, TRUE)

        if env(GetSpEffectID, 102360) == FALSE and arts_id ~= 313 then
            if GetVariable("IsEnoughArtPointsL2") == 1 then
                AddStamina(STAMINA_REDUCE_ARTS_QUICKSTEP * STAMINA_CONSUMERATE_LOWSTATUS)
            else
                AddStamina(STAMINA_REDUCE_ARTS_QUICKSTEP)
            end
        end
        local arts_idx = 0
        if arts_id == 155 or arts_id == 156 then
            SetWeightIndex()
            if GetVariable("EvasionWeightIndex") == MOVE_WEIGHT_LIGHT then
                arts_idx = 1
            end
        end
        SetVariable("SwordArtsRollingWeightCategory", arts_idx)
        act(AddSpEffect, 100710)
        if is_self_trans == TRUE then
            ExecEventAllBody("W_SwordArtsRolling_SelfTrans")
        elseif is_self_trans_2 == TRUE then
            ExecEventAllBody("W_SwordArtsRolling_SelfTrans2")
        elseif (arts_id == 276 or arts_id == 313) and GetVariable("IsLockon") == true and env(GetSpEffectID, 100002)
            == TRUE then
            ExecEventAllBody("W_SwordArtsRolling_Sub")
        else
            ExecEventAllBody("W_SwordArtsRolling")
        end
    elseif request == SWORDARTS_REQUEST_RIGHT_COMBO_1 then
        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        SetSwordArtsPointInfo(ACTION_ARM_R2, TRUE)

        if IsHalfBlendArts(c_SwordArtsID) == TRUE then
            ExecEventHalfBlend(Event_SwordArtsHalfOneShotCombo1, blend_type)
        else
            ExecEventAllBody("W_SwordArtsOneShotComboEnd")
        end
    elseif request == SWORDARTS_REQUEST_RIGHT_COMBO_2 then
        if IsAttackSwordArts(c_SwordArtsID) == FALSE then
            is_find_atk = FALSE
        end

        SetSwordArtsPointInfo(ACTION_ARM_R2, TRUE, "W_SwordArtsOneShotComboEnd_2")

        if IsHalfBlendArts(c_SwordArtsID) == TRUE then
            ExecEventHalfBlend(Event_SwordArtsHalfOneShotCombo2, blend_type)
        else
            ExecEventAllBody("W_SwordArtsOneShotComboEnd_2")
        end
    elseif request == ATTACK_REQUEST_ARROW_FIRE_RIGHT or request == ATTACK_REQUEST_ARROW_FIRE_RIGHT2 then
        is_find_atk = FALSE

        if env(IsOutOfAmmo, 1) == TRUE then
            ExecEventAllBody("W_NoArrow")
        elseif env(GetEquipWeaponCategory, HAND_RIGHT) == WEAPON_CATEGORY_LARGE_ARROW then
            ExecEventHalfBlend(Event_AttackArrowRightStart, ALLBODY)
        elseif GetEquipType(HAND_RIGHT, WEAPON_CATEGORY_SMALL_ARROW) == TRUE
            and (c_IsStealth == FALSE and r1 == "W_AttackRightLightStep" or is_stealth_rolling == TRUE or r1
                == "W_AttackRightLightDash" or r1 == "W_AttackRightBackstep") then
            ExecEventAllBody("W_AttackArrowRightFireStep")
        elseif c_IsStealth == TRUE then
            ExecEventHalfBlend(Event_StealthAttackArrowStart, ALLBODY)
        else
            ExecEventHalfBlend(Event_AttackArrowRightStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_ARROW_FIRE_LEFT or request == ATTACK_REQUEST_ARROW_FIRE_LEFT2 then
        is_find_atk = FALSE

        if env(IsOutOfAmmo, 0) == TRUE then
            ExecEventAllBody("W_NoArrow")
        elseif env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_LARGE_ARROW then
            ExecEventHalfBlend(Event_AttackArrowLeftStart, ALLBODY)
        elseif GetEquipType(HAND_LEFT, WEAPON_CATEGORY_SMALL_ARROW) == TRUE
            and (c_IsStealth == FALSE and r1 == "W_AttackRightLightStep" or is_stealth_rolling == TRUE or r1
                == "W_AttackRightLightDash" or r1 == "W_AttackRightBackstep") then
            ExecEventAllBody("W_AttackArrowLeftFireStep")
        elseif c_IsStealth == TRUE then
            ExecEventHalfBlend(Event_StealthAttackArrowStart, ALLBODY)
        else
            ExecEventHalfBlend(Event_AttackArrowLeftStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_RIGHT_CROSSBOW or request == ATTACK_REQUEST_RIGHT_CROSSBOW2 then
        is_find_atk = FALSE

        if blend_type == ALLBODY then
            local move_event = Event_Move

            if c_IsStealth == TRUE then
                move_event = Event_Stealth_Move
            end

            if MoveStart(LOWER, move_event, FALSE) == TRUE then
                blend_type = UPPER
            end
        end

        local crossbowHand = HAND_RIGHT

        if c_Style == HAND_LEFT_BOTH then
            crossbowHand = HAND_LEFT
        end

        if env(IsOutOfAmmo, 1) == TRUE then
            if c_IsStealth == TRUE and GetEquipType(crossbowHand, WEAPON_CATEGORY_BALLISTA) == FALSE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowRightEmpty, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowRightEmpty, blend_type)
            end
        elseif env(GetBoltLoadingState, 1) == FALSE and GetEquipType(crossbowHand, WEAPON_CATEGORY_BALLISTA) == FALSE then
            if c_IsStealth == TRUE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowRightReload, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowRightReload, blend_type)
            end
        elseif c_IsStealth == TRUE and GetEquipType(crossbowHand, WEAPON_CATEGORY_BALLISTA) == FALSE then
            ExecEventHalfBlend(Event_StealthAttackCrossbowRightStart, blend_type)
        else
            ExecEventHalfBlend(Event_AttackCrossbowRightStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_LEFT_CROSSBOW or request == ATTACK_REQUEST_LEFT_CROSSBOW2 then
        is_find_atk = FALSE
        atk_hand = HAND_LEFT
        guard_hand = HAND_LEFT

        if blend_type == ALLBODY then
            local move_event = Event_Move

            if c_IsStealth == TRUE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
                move_event = Event_Stealth_Move
            end

            if MoveStart(LOWER, move_event, FALSE) == TRUE then
                blend_type = UPPER
            end
        end

        if env(IsOutOfAmmo, 0) == TRUE then
            if c_IsStealth == TRUE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowLeftEmpty, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowLeftEmpty, blend_type)
            end
        elseif env(GetBoltLoadingState, 0) == FALSE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
            if c_IsStealth == TRUE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowLeftReload, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowLeftReload, blend_type)
            end
        elseif c_IsStealth == TRUE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
            ExecEventHalfBlend(Event_StealthAttackCrossbowLeftStart, blend_type)
        else
            ExecEventHalfBlend(Event_AttackCrossbowLeftStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_BOTHRIGHT_CROSSBOW or request == ATTACK_REQUEST_BOTHRIGHT_CROSSBOW2 then
        is_find_atk = FALSE

        if blend_type == ALLBODY then
            local move_event = Event_Move

            if c_IsStealth == TRUE then
                move_event = Event_Stealth_Move
            end

            if MoveStart(LOWER, move_event, FALSE) == TRUE then
                blend_type = UPPER
            end
        end

        local arrowHand = 0

        if c_Style == HAND_RIGHT_BOTH then
            arrowHand = 1
        end

        if env(IsOutOfAmmo, arrowHand) == TRUE then
            if c_IsStealth == TRUE and GetEquipType(arrowHand, WEAPON_CATEGORY_BALLISTA) == FALSE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowBothRightEmpty, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowBothRightEmpty, blend_type)
            end
        elseif env(GetBoltLoadingState, arrowHand) == FALSE and GetEquipType(arrowHand, WEAPON_CATEGORY_BALLISTA)
            == FALSE then
            local reloadEvent = Event_AttackCrossbowBothRightReload

            if c_IsStealth == TRUE then
                if c_Style == HAND_LEFT_BOTH then
                    reloadEvent = Event_StealthAttackCrossbowBothLeftReload
                else
                    reloadEvent = Event_StealthAttackCrossbowBothRightReload
                end
            elseif c_Style == HAND_LEFT_BOTH then
                reloadEvent = Event_AttackCrossbowBothLeftReload
            else
                reloadEvent = Event_AttackCrossbowBothRightReload
            end
            ExecEventHalfBlend(reloadEvent, blend_type)
        elseif c_IsStealth == TRUE and GetEquipType(arrowHand, WEAPON_CATEGORY_BALLISTA) == FALSE then
            ExecEventHalfBlend(Event_StealthAttackCrossbowBothRightStart, blend_type)
        else
            ExecEventHalfBlend(Event_AttackCrossbowBothRightStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_BOTHLEFT_CROSSBOW or request == ATTACK_REQUEST_BOTHLEFT_CROSSBOW2 then
        is_find_atk = FALSE

        if blend_type == ALLBODY then
            local move_event = Event_Move

            if c_IsStealth == TRUE then
                move_event = Event_Stealth_Move
            end

            if MoveStart(LOWER, move_event, FALSE) == TRUE then
                blend_type = UPPER
            end
        end

        if env(IsOutOfAmmo, 0) == TRUE then
            if c_IsStealth == TRUE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
                ExecEventHalfBlend(Event_StealthAttackCrossbowBothLeftEmpty, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowBothLeftEmpty, blend_type)
            end
        elseif env(GetBoltLoadingState, 0) == FALSE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
            if c_IsStealth == TRUE then
                ExecEventHalfBlend(Event_AttackCrossbowBothLeftReload, blend_type)
            else
                ExecEventHalfBlend(Event_AttackCrossbowBothLeftReload, blend_type)
            end
        elseif c_IsStealth == TRUE and GetEquipType(HAND_LEFT, WEAPON_CATEGORY_BALLISTA) == FALSE then
            ExecEventHalfBlend(Event_StealthAttackCrossbowBothLeftStart, blend_type)
        else
            ExecEventHalfBlend(Event_AttackCrossbowBothLeftStart, blend_type)
        end
    elseif request == ATTACK_REQUEST_ATTACK_WHILE_GUARD then
        guard_hand = HAND_LEFT
        local index = env(GetGuardMotionCategory, HAND_LEFT)

        if env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_DUELING_SHIELD then
            index = 3
        end

        if GetEquipType(HAND_LEFT, WEAPON_CATEGORY_TORCH) == TRUE then
            index = 2
            SetVariable("IsAttackWhileTorchGuard", TRUE)
        else
            SetVariable("IsAttackWhileTorchGuard", FALSE)
        end

        SetVariable("IndexAttackWhileGuard", index)
        ExecEventAllBody("W_AttackRightWhileGuard")
    else
        return FALSE
    end

    if is_find_atk == TRUE then
        SetInterruptType(INTERRUPT_FINDATTACK)
    end

    if style == HAND_RIGHT_BOTH then
        atk_hand = HAND_RIGHT
    elseif style == HAND_LEFT_BOTH then
        atk_hand = HAND_LEFT
    end

    SetAttackHand(atk_hand)
    SetGuardHand(guard_hand)

    if is_Dual == TRUE then
        act(SetThrowPossibilityState_Defender, 400000)
    end

    act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
    SetAIActionState()

    return TRUE
end

function ExecDeath()
	-----------------------------
	-- VIZZO - Debug Mode
	-----------------------------
	if CUSTOM_DEBUG_MODE == 1 and VIZZO_IsPlayerRequest() == TRUE then
		return FALSE
	end
	-----------------------------
	original_ExecDeath()
end

function ExecDamage(is_parry, is_attackwhileguard)
    local damage_level = env(GetDamageLevel)
    local damage_type = env(GetReceivedDamageType)
    local is_damaged = env(HasReceivedAnyDamage)
    if env(GetSpEffectType, 32) == TRUE and env(GetSpEffectID, 19925) == FALSE then
        act(SetDamageAnimType, DAMAGE_FLAG_SMALL)
        ResetRequest()
        ExecEventAllBody("W_DamageBind")
        Replanning()

        return TRUE
    end
    if env(GetDamageSpecialAttribute, 5) == TRUE then
        ExecEventAllBody("W_DamageSleepResist")
        return TRUE
    end
    if env(GetDamageSpecialAttribute, 6) == TRUE then
        ExecEventAllBody("W_DamageMad")
        return TRUE
    end
    if env(GetDamageSpecialAttribute, 2) == TRUE or env(GetDamageSpecialAttribute, 4) == TRUE then
        if damage_level == DAMAGE_LEVEL_NONE then
            if IsNodeActive("SwordArtsOneShot Selector") == TRUE and c_SwordArtsID == 136 then
            elseif env(GetSpEffectID, 6340) == TRUE or env(GetSpEffectID, 1650) == TRUE or env(GetSpEffectID, 1851)
                == TRUE then
            else
                damage_level = DAMAGE_LEVEL_SMALL
            end
        elseif damage_level ~= DAMAGE_LEVEL_SMALL and damage_level ~= DAMAGE_LEVEL_MIDDLE and damage_level
            == DAMAGE_LEVEL_MINIMUM then
        end
    end

    if damage_level <= DAMAGE_LEVEL_NONE and (is_damaged == FALSE or env(IsPartDamageAdditiveBlendInvalid) == TRUE)
        and (damage_type == DAMAGE_TYPE_INVALID or damage_type == DAMAGE_TYPE_WEAK_POINT or damage_type
            == DAMAGE_LEVEL_MINIMUM) then
        return FALSE
    end
    if env(GetBehaviorID, 1) == TRUE then
        return FALSE
    end
    -- Raptors of the Mist Dodge
    if env(GetSpEffectID, 100500) == TRUE then
        ExecEventAllBody("W_SwordArtsStandDodge")
        act(AddSpEffect, 5635)
        ResetDamageCount()

        return TRUE
    end

    local attack_dir = env(GetAtkDirection)
    local damage_angle = env(GetReceivedDamageDirection)
    local style = c_Style

    if damage_type == DAMAGE_TYPE_PARRY then
        ExecEventAllBody("W_DamageParry")
        return TRUE
    end

    if damage_type >= DAMAGE_TYPE_GUARDED and damage_type <= DAMAGE_TYPE_WALL_LEFT then
        DebugPrint(1, damage_type)
        Replanning()

        if damage_type == DAMAGE_TYPE_GUARDED or damage_type == DAMAGE_TYPE_GUARDED_LEFT then
            if damage_type == DAMAGE_TYPE_GUARDED_LEFT then
                SetVariable("GuardDamageIndex", 2)
            elseif style == HAND_RIGHT then
                SetVariable("GuardDamageIndex", 0)
            elseif style == HAND_LEFT or style == HAND_RIGHT_BOTH then
                SetVariable("GuardDamageIndex", 1)
            else
                SetVariable("GuardDamageIndex", 0)
            end

            if damage_level == DAMAGE_LEVEL_NONE or damage_level == DAMAGE_LEVEL_MINIMUM then
                act(SetDamageAnimType, DAMAGE_FLAG_SMALL)
                ExecEventAllBody("W_Repelled_Small")
            elseif damage_level == DAMAGE_LEVEL_SMALL then
                act(SetDamageAnimType, DAMAGE_FLAG_SMALL)
                ExecEventAllBody("W_Repelled_Small")
            elseif damage_level == DAMAGE_LEVEL_MIDDLE or damage_level == DAMAGE_LEVEL_LARGE or damage_level
                == DAMAGE_LEVEL_EXLARGE or damage_level == DAMAGE_LEVEL_PUSH or damage_level == DAMAGE_LEVEL_FLING
                or damage_level == DAMAGE_LEVEL_SMALL_BLOW or damage_level == DAMAGE_LEVEL_UPPER or damage_level
                == DAMAGE_LEVEL_EX_BLAST or damage_level == DAMAGE_LEVEL_BREATH then
                act(SetDamageAnimType, DAMAGE_FLAG_LARGE)
                ExecEventAllBody("W_Repelled_Large")
            else
                act(SetDamageAnimType, DAMAGE_FLAG_SMALL)
                ExecEventAllBody("W_Repelled_Small")
            end

            return TRUE
        elseif damage_type == DAMAGE_TYPE_GUARDBREAK then
			----------------------------------------------------------
            -- VIZZO - SKD Previne a Quebra de Postura ao Defletir
			----------------------------------------------------------
			
            if SKD_IsDuringDeflect() == TRUE then
                local guard_damage_level = env(GetGuardLevelAction)

                if env(GetSpEffectID, 171) == TRUE and guard_damage_level < 3 then
                    guard_damage_level = 3
                end
        
                if guard_damage_level > 0 then
                    if guard_damage_level == 1 then
                        act(SetDamageAnimType, DAMAGE_FLAG_GUARD_SMALL)
                        if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
                            ExecEventAllBody("W_GuardDamageSmall")
                        end
				Block(0)
			------------------------------------------
                    elseif guard_damage_level == 3 then
                        act(SetDamageAnimType, DAMAGE_FLAG_GUARD_LARGE)
                        if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
                            ExecEventAllBody("W_GuardDamageMiddle")
                        end
                Block(1)
			------------------------------------------
                    elseif guard_damage_level == 4 then
                        act(SetDamageAnimType, DAMAGE_FLAG_GUARD_EXLARGE)
                        if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
                            ExecEventAllBody("W_GuardDamageLarge")
                        end
                Block(2)
			------------------------------------------
                    else
                        act(SetDamageAnimType, DAMAGE_FLAG_GUARD_LARGE)
                        if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
                            ExecEventAllBody("W_GuardDamageMiddle")
                        end
                Block(1)
            end
			------------------------------------------
                    return TRUE
                else
                    ExecAddDamage(damage_angle, attack_dir, damage_level, TRUE, is_damaged)
					
                    return FALSE
                end
            end
            ------------------------------------------
            if is_parry == TRUE then
                return FALSE
            end
            if env(GetSpEffectID, 175) == TRUE then
                return FALSE
            end

            local guardindex = GUARD_STYLE_DEFAULT

            if style == HAND_RIGHT then
                guardindex = env(GetGuardMotionCategory, HAND_LEFT)

                if GetEquipType(HAND_LEFT, WEAPON_CATEGORY_TORCH) == TRUE then
                    SetVariable("IsTorchGuard", TRUE)
                else
                    SetVariable("IsTorchGuard", FALSE)
                end

                if env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_DUELING_SHIELD then
                    guardindex = 3
                end

                if env(GetEquipWeaponCategory, HAND_RIGHT) == WEAPON_CATEGORY_DUELING_SHIELD then
                    guardindex = 3
                    if env(GetSpEffectID, 176) == TRUE then
                        SetVariable("GuardBreakDuelingShieldState", 1)
                    end
                end
            elseif style == HAND_LEFT_BOTH then
                SetVariable("IsTorchGuard", FALSE)

                if env(GetStayAnimCategory) == 15 then
                    guardindex = env(GetGuardMotionCategory, HAND_LEFT)
                end

                if env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_DUELING_SHIELD then
                    guardindex = 3
                end
            elseif style == HAND_RIGHT_BOTH then
                SetVariable("IsTorchGuard", FALSE)

                if env(GetStayAnimCategory) == 15 then
                    guardindex = env(GetGuardMotionCategory, HAND_RIGHT)
                end

                if env(GetEquipWeaponCategory, HAND_RIGHT) == WEAPON_CATEGORY_DUELING_SHIELD then
                    guardindex = 3
                end
            end

            SetVariable("IndexGuard", guardindex)
            act(SetDamageAnimType, DAMAGE_FLAG_GUARD_BREAK)

			------------------------------------------
			-- VIZZO - PostureSystem
			------------------------------------------
			if CUSTOM_POSTURESYSTEM_MODE == 0 then
				if c_SwordArtsID == 202 and style == HAND_RIGHT and c_SwordArtsHand == HAND_RIGHT then
					ExecEventAllBody("W_GuardBreakRight")
				else
					ExecEventAllBody("W_GuardBreak")
				end
			end
			------------------------------------------
            return TRUE
        elseif damage_type == DAMAGE_TYPE_WALL_RIGHT then
            if style == HAND_RIGHT_BOTH or style == HAND_LEFT_BOTH then
                SetVariable("GuardDamageIndex", 1)
            else
                SetVariable("GuardDamageIndex", 0)
            end

            act(SetDamageAnimType, DAMAGE_FLAG_GUARD_BREAK)
            ExecEventAllBody("W_Repelled_Wall")

            return TRUE
        elseif damage_type == DAMAGE_TYPE_WALL_LEFT then
            if style == HAND_LEFT_BOTH then
                SetVariable("GuardDamageIndex", 1)
            else
                SetVariable("GuardDamageIndex", 2)
            end

            act(SetDamageAnimType, DAMAGE_FLAG_GUARD_BREAK)
            ExecEventAllBody("W_Repelled_Wall")

            return TRUE
        elseif damage_type == DAMAGE_TYPE_GUARDBREAK_BLAST then
            act(SetDamageAnimType, DAMAGE_FLAG_SMALL_BLOW)
            ExecEventAllBody("W_DamageLv7_SmallBlow")

            return TRUE
        elseif damage_type == DAMAGE_TYPE_GUARDBREAK_FLING then
            act(SetDamageAnimType, DAMAGE_FLAG_FLING)
            ExecEventAllBody("W_DamageLv6_Fling")

            return TRUE
        end
    elseif damage_type == DAMAGE_TYPE_GUARD then
        if is_parry == TRUE or is_attackwhileguard == TRUE then
            return FALSE
        end
        if env(GetSpEffectID, 175) == TRUE then
            return FALSE
        end
        if env(GetSpEffectID, 176) == TRUE then
            return FALSE
        end

        local guardindex = GUARD_STYLE_DEFAULT

        if style == HAND_RIGHT then
            guardindex = env(GetGuardMotionCategory, HAND_LEFT)

            if GetEquipType(HAND_LEFT, WEAPON_CATEGORY_TORCH) == TRUE then
                SetVariable("IsTorchGuard", TRUE)
            else
                SetVariable("IsTorchGuard", FALSE)
            end

            if env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_DUELING_SHIELD then
                guardindex = 3
            end
        elseif style == HAND_LEFT_BOTH then
            SetVariable("IsTorchGuard", FALSE)

            if env(GetStayAnimCategory) == 15 then
                guardindex = env(GetGuardMotionCategory, HAND_LEFT)
            end

            if env(GetEquipWeaponCategory, HAND_LEFT) == WEAPON_CATEGORY_DUELING_SHIELD then
                guardindex = 3
            end
        elseif style == HAND_RIGHT_BOTH then
            SetVariable("IsTorchGuard", FALSE)

            if env(GetStayAnimCategory) == 15 then
                guardindex = env(GetGuardMotionCategory, HAND_RIGHT)
            end

            if env(GetEquipWeaponCategory, HAND_RIGHT) == WEAPON_CATEGORY_DUELING_SHIELD then
                guardindex = 3
            end
        end

        SetVariable("IndexGuard", guardindex)

        local guard_damage_level = env(GetGuardLevelAction)

        if env(GetSpEffectID, 171) == TRUE and guard_damage_level < 3 then
            guard_damage_level = 3
        end

        if guard_damage_level > 0 then
         ------------------------------------------
         -- VIZZO - SKD Executa animação de desvio
		 ------------------------------------------
		 
            if guard_damage_level == 1 then
                act(SetDamageAnimType, DAMAGE_FLAG_GUARD_SMALL)
                if env(GetSpEffectID, 102001) == TRUE or env(GetSpEffectID, 102011) == TRUE or env(GetSpEffectID, 102013)
                    == TRUE or env(GetSpEffectID, 102015) == TRUE then
                    SetJustGuardSucceedEffect(1)
                    ExecEventAllBody("W_GuardDamageSmall_JustGuard")
                else
					if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
						ExecEventAllBody("W_GuardDamageSmall")
					end
                end
			Block(0)
			------------------------------------------
            elseif guard_damage_level == 3 then
                act(SetDamageAnimType, DAMAGE_FLAG_GUARD_LARGE)
                if env(GetSpEffectID, 102001) == TRUE or env(GetSpEffectID, 102011) == TRUE or env(GetSpEffectID, 102013)
                    == TRUE or env(GetSpEffectID, 102015) == TRUE then
                    SetJustGuardSucceedEffect(2)
                    ExecEventAllBody("W_GuardDamageMiddle_JustGuard")
                else
					if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
						ExecEventAllBody("W_GuardDamageMiddle")
					end
                end
			Block(1)
			------------------------------------------
            elseif guard_damage_level == 4 then
                act(SetDamageAnimType, DAMAGE_FLAG_GUARD_EXLARGE)
                if env(GetSpEffectID, 102001) == TRUE or env(GetSpEffectID, 102011) == TRUE or env(GetSpEffectID, 102013)
                    == TRUE or env(GetSpEffectID, 102015) == TRUE then
                    SetJustGuardSucceedEffect(2)
                    ExecEventAllBody("W_GuardDamageLarge_JustGuard")
                else
					if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
						ExecEventAllBody("W_GuardDamageLarge")
					end
                end
			Block(2)
			------------------------------------------
            else
                act(SetDamageAnimType, DAMAGE_FLAG_GUARD_LARGE)
                if env(GetSpEffectID, 102001) == TRUE or env(GetSpEffectID, 102011) == TRUE or env(GetSpEffectID, 102013)
                    == TRUE or env(GetSpEffectID, 102015) == TRUE then
                    SetJustGuardSucceedEffect(2)
                    ExecEventAllBody("W_GuardDamageMiddle_JustGuard")
                else
					if SKD_ExecDeflectAnimation(damage_angle, attack_dir, guard_damage_level) == FALSE then
						ExecEventAllBody("W_GuardDamageMiddle")
					end
                end
			Block(1)
            end
			------------------------------------------


            return TRUE
        else
            if env(GetSpEffectID, 102001) == TRUE or env(GetSpEffectID, 102011) == TRUE or env(GetSpEffectID, 102013)
                == TRUE or env(GetSpEffectID, 102015) == TRUE then
                SetJustGuardSucceedEffect(1)
                ExecAddDamage(damage_angle, attack_dir, damage_level, TRUE, is_damaged, TRUE)
            else
                ExecAddDamage(damage_angle, attack_dir, damage_level, TRUE, is_damaged, FALSE)
            end
            return FALSE
        end
    end

    if env(GetKnockbackDistance) < 0 then
        if damage_angle == DAMAGE_DIR_LEFT then
            damage_angle = DAMAGE_DIR_RIGHT
        elseif damage_angle == DAMAGE_DIR_RIGHT then
            damage_angle = DAMAGE_DIR_LEFT
        elseif damage_angle == DAMAGE_DIR_FRONT then
            damage_angle = DAMAGE_DIR_BACK
        elseif damage_angle == DAMAGE_DIR_BACK then
            damage_angle = DAMAGE_DIR_FRONT
        end
    end

    if env(GetSpEffectID, 89) == TRUE or env(GetSpEffectID, 100640) == TRUE then
        if damage_level == DAMAGE_LEVEL_EXLARGE then
            act(RequestAIJumpInterupt)
        elseif damage_level == DAMAGE_LEVEL_LARGE or damage_level == DAMAGE_LEVEL_PUSH or damage_level
            == DAMAGE_LEVEL_FLING or damage_level == DAMAGE_LEVEL_SMALL_BLOW or damage_level == DAMAGE_LEVEL_UPPER
            or damage_level == DAMAGE_LEVEL_EX_BLAST or damage_level == DAMAGE_LEVEL_BREATH or env(GetIsWeakPoint)
            == TRUE then
            act(RequestAIJumpInterupt)
            damage_level = DAMAGE_LEVEL_SMALL_BLOW
        elseif damage_level == DAMAGE_LEVEL_MIDDLE or damage_level == DAMAGE_LEVEL_SMALL then
            CalcDamageCount()
            act(RequestAIJumpInterupt)
            hkbFireEvent("W_JumpDamage_Start")
            SetVariable("Int16Variable04", 0)
            act(SetDamageAnimType, 3)
            ResetRequest()
            return TRUE
        else
            damage_level = DAMAGE_LEVEL_NONE
        end
    end
    local height = env(GetFallHeight) / 100
    if env(IsFalling) == TRUE and env(GetBehaviorID, 10) == TRUE and height >= 10 then
        damage_level = DAMAGE_LEVEL_NONE
    end
    if env(GetIsWeakPoint) == TRUE and env(GetBehaviorID, 15) == FALSE then
        CalcDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_WEAK)
        ExecEventAllBody("W_DamageWeak")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_NONE then
        ExecAddDamage(damage_angle, attack_dir, damage_level, FALSE, is_damaged, FALSE)

        return FALSE
    elseif damage_level == DAMAGE_LEVEL_SMALL then
        CalcDamageCount()
        SetVariable("DamageDirection", damage_angle)
        SetVariable("IndexDamageLv1_Small_AttackDirection", attack_dir)
        act(SetDamageAnimType, DAMAGE_FLAG_SMALL)
        ExecEventAllBody("W_DamageLv1_Small")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_MIDDLE then
        CalcDamageCount()
        SetVariable("DamageDirection", damage_angle)
        SetVariable("IndexDamageLv2_Middle_AttackDirection", attack_dir)
        act(SetDamageAnimType, DAMAGE_FLAG_MEDIUM)
        ExecEventAllBody("W_DamageLv2_Middle")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_LARGE then
        CalcDamageCount()
        SetVariable("DamageDirection", damage_angle)
        SetVariable("IndexDamageLv3_Large_AttackDirection", attack_dir)
        act(SetDamageAnimType, DAMAGE_FLAG_LARGE)
        Replanning()

        if env(GetBehaviorID, 3) == TRUE then
            ExecEventAllBody("W_DamageLarge2")
            return TRUE
        else
            ExecEventAllBody("W_DamageLv3_Large")
            return TRUE
        end
    elseif damage_level == DAMAGE_LEVEL_EXLARGE then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_LARGE_BLOW)
        ExecEventAllBody("W_DamageLv4_ExLarge")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_EX_BLAST then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_LARGE_BLOW)
        ExecEventAllBody("W_DamageLV10_ExBlast")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_PUSH then
        if env(GetBehaviorID, 14) == TRUE then
            act(AddSpEffect, 19865)
        end
        CalcDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_PUSH)
        ExecEventAllBody("W_DamageLv5_Push")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_SMALL_BLOW then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_SMALL_BLOW)
        ExecEventAllBody("W_DamageLv7_SmallBlow")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_UPPER then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_LARGE_BLOW)
        if env(GetBehaviorID, 10) == TRUE then
            SetVariable("DamageLv9_Behavior", 1)
        elseif env(GetBehaviorID, 13) == TRUE then
            SetVariable("DamageLv9_Behavior", 2)
        else
            SetVariable("DamageLv9_Behavior", 0)
        end
        ExecEventAllBody("W_DamageLv9_Upper")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_MINIMUM then
        CalcDamageCount()

        local pre_index = GetVariable("IndexDamageLv8_Minimum_Random")
        local index = (pre_index + math.random(1, 2)) % 3

        SetVariable("IndexDamageLv8_Minimum_Random", index)
        act(SetDamageAnimType, DAMAGE_FLAG_MINIMUM)
        ExecEventAllBody("W_DamageLv8_Minimum")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_FLING then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_FLING)
        ExecEventAllBody("W_DamageLv6_Fling")
        Replanning()

        return TRUE
    elseif damage_level == DAMAGE_LEVEL_BREATH then
        ResetDamageCount()
        SetVariable("DamageDirection", damage_angle)
        act(SetDamageAnimType, DAMAGE_FLAG_BREATH)
        ExecEventAllBody("W_DamageLv11_Breath")
        Replanning()

        return TRUE
    end
	
	-- Chama o codigo Original
	original_ExecDamage()
    return FALSE
end

function Update()
	-------------------------------
	-- VIZZO - Main Update System
	-------------------------------
		VIZZO_MainUpdate()
		
	-- Chama o codigo Original
	original_ExecAttack()
	original_Update()
	-------------------------------
end

function JumpCommonFunction(jump_type)
    local CheckIsDualStyle = VIZZO_CheckWeaponStyle() == DualWeaponStyle or VIZZO_CheckWeaponStyle() == DualWieldStyle
    act(AIJumpState)

    if GetVariable("JumpAttackForm") == 0 then
        act(NotifyAIOfBehaviourState, IDX_AINOTE_STATETYPE, IDX_AINOTE_STATETYPE_JUMP_NONATTACK)
    elseif env(GetSpEffectID, 102050) == TRUE then
        act(LockonFixedAngleCancel)
    end

    act(DisallowAdditiveTurning, TRUE)
    local height = env(GetFallHeight) / 100
    local equip_arm_no = 1

    if c_Style == HAND_LEFT_BOTH then
        equip_arm_no = 0
    end

    -- Jump
    if Act_Jump() == TRUE then
        return TRUE
    end
    -- Jump Fall
    if env(GetSpEffectID, 145) == FALSE and GetVariable("JumpAttack_Land") == 0 then
        hkbFireEvent("W_Jump_Loop")
        return TRUE
    end

    local arrowHand = HAND_RIGHT

    if c_Style == HAND_LEFT_BOTH then
        arrowHand = HAND_LEFT
    end

    local is_arrow = GetEquipType(arrowHand, WEAPON_CATEGORY_SMALL_ARROW, WEAPON_CATEGORY_ARROW,
        WEAPON_CATEGORY_LARGE_ARROW, WEAPON_CATEGORY_CROSSBOW, WEAPON_CATEGORY_BALLISTA)

    if GetVariable("JumpAttackForm") == 0 and is_arrow == TRUE then
        if env(ActionRequest, ACTION_ARM_R1) == TRUE then
            act(ChooseBowAndArrowSlot, 0)
            g_ArrowSlot = 0
        elseif env(ActionRequest, ACTION_ARM_R2) == TRUE then
            act(ChooseBowAndArrowSlot, 1)
            g_ArrowSlot = 1
        end
    end

    local is_staff = GetEquipType(equip_arm_no, WEAPON_CATEGORY_STAFF)
    local wep_hand = HAND_RIGHT

    if c_Style == HAND_LEFT_BOTH then
        wep_hand = HAND_LEFT
    end

    local isWeaponStaff = FALSE
    local sp_kind = env(GetEquipWeaponSpecialCategoryNumber, wep_hand)

    if IsWeaponCatalyst(sp_kind) == TRUE then
        isWeaponStaff = TRUE
    end

    -- Magic
    if ExecJumpMagic(jump_type) == TRUE then
        -- Catalyst: R1
    elseif is_staff == TRUE and env(ActionRequest, ACTION_ARM_R1) == TRUE then
        -- Weapon Catalyst: R2
    elseif isWeaponStaff == TRUE and env(ActionRequest, ACTION_ARM_R2) == TRUE then
        -- Bow
    elseif is_arrow == TRUE and (c_Style == HAND_RIGHT_BOTH or c_Style == HAND_LEFT_BOTH) and env(IsOutOfAmmo, arrowHand)
        == TRUE then
        -- Crossbow
    elseif GetEquipType(arrowHand, WEAPON_CATEGORY_CROSSBOW) == TRUE
        and (env(GetBoltLoadingState, arrowHand) == FALSE or env(IsOutOfAmmo, arrowHand) == TRUE) then
        -- Jump Attack
    elseif env(GetSpEffectID, 140) == TRUE and GetVariable("JumpAttackForm") == 0 then
        if env(ActionRequest, ACTION_ARM_R1) == TRUE or is_arrow == TRUE and env(ActionRequest, ACTION_ARM_R2) == TRUE then
            ExecEventSync("Event_JumpNormalAttack_Add")
			------------------------------------------
			-- VIZZO - PowerStanceMode
			------------------------------------------
			if VIZZO_IsPlayerRequest() == TRUE and VIZZO_CheckPowerStanceMode() == TRUE and IsEnableDualWielding() == TRUE then
				SetVariable("JumpAttackFormRequest", 2)
				SetVariable("JumpAttackForm", 3)
			else
				SetVariable("JumpAttackFormRequest", 0)
				SetVariable("JumpAttackForm", 1)
			end
			------------------------------------------
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()

            return TRUE
        elseif env(ActionRequest, ACTION_ARM_R2) == TRUE then
            ExecEventSync("Event_JumpNormalAttack_Add")
            SetVariable("JumpAttackFormRequest", 1)
            SetVariable("JumpAttackForm", 2)
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()

            return TRUE
        elseif env(ActionRequest, ACTION_ARM_L1) == TRUE and IsEnableDualWielding() == HAND_RIGHT then
            ExecEventSync("Event_JumpNormalAttack_Add")
            SetVariable("JumpAttackFormRequest", 2)
            SetVariable("JumpAttackForm", 3)
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()

            return TRUE
        end
        if env(GetSpEffectID, 98) == TRUE and env(IsTruelyLanding) == TRUE and env(GetSpEffectID, 140) == FALSE then
            if jump_type == 0 then
                SetVariable("JumpAttack_Land", 1)
                SetVariable("JumpMotion_Override", 0)
                if GetVariable("JumpMotion_Override") < 0.009999999776482582 then
                    SetVariable("JumpUseMotion_Bool", 1)
                end
            elseif jump_type >= 1 then
                ExecEventAllBody("W_Jump_Attack_Land_F")
            end

            return TRUE
        end
    elseif env(GetSpEffectID, 140) == FALSE and GetVariable("JumpAttack_Land") == 0 and GetVariable("JumpAttackForm")
        == 0 then
        SetVariable("JumpAttack_Land", 0)

        if env(ActionRequest, ACTION_ARM_R1) == TRUE or is_arrow == TRUE and env(ActionRequest, ACTION_ARM_R2) == TRUE then
			------------------------------------------
			-- VIZZO - PowerStanceMode
			------------------------------------------
			if VIZZO_IsPlayerRequest() == TRUE and VIZZO_CheckPowerStanceMode() == TRUE and IsEnableDualWielding() == TRUE then
				SetVariable("JumpAttackFormRequest", 2)
			else
				SetVariable("JumpAttackFormRequest", 0)
			end
			------------------------------------------
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()

            if jump_type == 0 then
                ExecEventNoReset("W_JumpAttack_Start_Falling")
            elseif jump_type == 1 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_F")
            elseif jump_type == 2 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_D")
            end

            return TRUE
        elseif env(ActionRequest, ACTION_ARM_R2) == TRUE then
            SetVariable("JumpAttackFormRequest", 1)
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()
            if jump_type == 0 then
                ExecEventNoReset("W_JumpAttack_Start_Falling")
            elseif jump_type == 1 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_F")
            elseif jump_type == 2 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_D")
            end

            return TRUE
        elseif env(ActionRequest, ACTION_ARM_L1) == TRUE and IsEnableDualWielding() == HAND_RIGHT then
            SetInterruptType(INTERRUPT_FINDATTACK)
            act(SetNpcAIAttackRequestIDAfterBlend, env(GetNpcAIAttackRequestID))
            SetAIActionState()
            SetVariable("JumpAttackFormRequest", 2)
            if jump_type == 0 then
                ExecEventNoReset("W_JumpAttack_Start_Falling")
            elseif jump_type == 1 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_F")
            elseif jump_type == 2 then
                ExecEventNoReset("W_JumpAttack_Start_Falling_D")
            end

            return TRUE
        end
    end
    -- Landing
    if env(GetSpEffectID, 98) == TRUE and env(IsTruelyLanding) == TRUE and env(GetSpEffectID, 140) == FALSE
        and env(IsAIJumping) == FALSE then
        local landIndex = GetLandIndex(height, FALSE)
        SetVariable("LandIndex", landIndex)

        if GetVariable("JumpAttackForm") == 0 then
            local JumpMoveLevel = 0

            if GetVariable("MoveSpeedLevel") > 1.100000023841858 then
                JumpMoveLevel = 2
            elseif GetVariable("MoveSpeedLevel") > 0.6000000238418579 then
                JumpMoveLevel = 1
            end

            -- Ironjar Aromatic
            if TRUE == env(GetSpEffectID, 503520) then
                JumpMoveLevel = 0
                -- Unknown
            elseif TRUE == env(GetSpEffectID, 5520) then
                JumpMoveLevel = 0
                -- Slug: Slow
            elseif TRUE == env(GetSpEffectID, 425) then
                JumpMoveLevel = 0
                -- Sanguine Noble: Slow
            elseif TRUE == env(GetSpEffectID, 4101) then
                JumpMoveLevel = 0
                -- Sanguine Noble: Slow
            elseif TRUE == env(GetSpEffectID, 4100) then
                JumpMoveLevel = 0
            elseif env(GetSpEffectID, 19670) == TRUE then
                JumpMoveLevel = 0
            end

            if JumpMoveLevel == 2 then
                hkbFireEvent("W_Jump_Land_To_Dash")
            elseif JumpMoveLevel == 1 then
                SetVariable("JumpLandMoveDirection", GetVariable("MoveDirection"))
                hkbFireEvent("W_Jump_Land_To_Run")
            elseif jump_type == 0 then
                ExecEventNoReset("W_Jump_Land_N")
            elseif jump_type == 1 then
                ExecEventNoReset("W_Jump_Land_F")
            elseif jump_type == 2 then
                ExecEventNoReset("W_Jump_Land_D")
            end

            return TRUE
        else
            if jump_type == 0 then
                SetVariable("JumpAttack_Land", 1)
                SetVariable("JumpMotion_Override", 0)

                if GetVariable("JumpMotion_Override") < 0.009999999776482582 then
                    SetVariable("JumpUseMotion_Bool", 1)
                end
            elseif jump_type >= 1 then
                ExecEventAllBody("W_Jump_Attack_Land_F")
            end
            return TRUE
        end
        -- 146 "[HKS] Swing Window"
    elseif env(GetSpEffectID, 146) == TRUE and GetVariable("JumpAttackForm") ~= 0 then
        SetVariable("SwingPose", 4)

        if jump_type == 0 then
            ExecEventNoReset("W_Jump_Land_N")
        elseif jump_type == 1 then
            ExecEventNoReset("W_Jump_Land_F")
        elseif jump_type == 2 then
            ExecEventNoReset("W_Jump_Land_D")
        end

        return TRUE
    elseif env(GetEventEzStateFlag, 0) == TRUE and GetVariable("JumpAttackForm") ~= 0 and ExecArrowBothJumpLandAttack()
        == TRUE then
        return TRUE
    end
	-- Chama o codigo Original
	original_JumpCommonFunction()
    return FALSE
end
