
local utils = loadCelesteAsset("Assets/CC/HollowKnight/Bosses/HollowKnight/Attacks/utils") --[[@as HKUtils]]
local moveXtowardsFacing = utils.moveXtowardsFacing

--- Move back 0.5 hitboxes, hitbox grows head is gone
--- Move forward 1.5 hitboxes, hitbox shrinks head still gone (also slash only in front)
--- Move forward 0.5 hitboxes, slash
--- Move forward 0.5 hitboxes, slash
--- Regain head hitbox for some reason idk
function onBegin()
    --log("TRIPLE SLASH")
    setFlag("hk_change_to_no_head", true)
    playPuppetAnim("slash")
    moveXtowardsFacing(-17/2, 0.4)
    wait(0.45)
    moveXtowardsFacing(17*1.5, 0.2)
    local attack

	playSound("event:/CC/CC_HollowKnight/SFX/Boss SFX/SwordRandomized",puppet.Center)
    if puppet.Facing > 0 then -- left
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-62, 0), getHitbox(25, 10))
    else
        attack = getNewBasicAttackEntity(puppet.Position + vector2(5, 2), getHitbox(25, 10))
    end
    attack:Add(getEntityTimer(0.1))
    addEntity(attack)
    addComponentToBoss(getEntityChain(attack))
    wait(0.1)

    if puppet.Facing > 0 then -- left
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-55, 6), getHitbox(110, 25))
    else 
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-60, 5), getHitbox(110, 25))
    end
    attack:Add(getEntityTimer(0.1))
    addEntity(attack)
    addComponentToBoss(getEntityChain(attack))
    wait(0.18)

	playSound("event:/CC/CC_HollowKnight/SFX/Boss SFX/SwordRandomized",puppet.Center)
    moveXtowardsFacing(17, 0.2)
    if puppet.Facing > 0 then -- left
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-72, 14), getHitbox(80, 16))
        attack:Add(getEntityTimer(0.1))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-57, 3), getHitbox(84, 12))
        attack:Add(getEntityTimer(0.1))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-42, -14), getHitbox(88, 16))
        attack:Add(getEntityTimer(0.2))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
    else 
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-10, 14), getHitbox(80, 16))
        attack:Add(getEntityTimer(0.1))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-27, 3), getHitbox(84, 12))
        attack:Add(getEntityTimer(0.1))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-47, -14), getHitbox(88, 16))
        attack:Add(getEntityTimer(0.2))
        addEntity(attack)
        addComponentToBoss(getEntityChain(attack))
    end
    wait(0.3)
	
	playSound("event:/CC/CC_HollowKnight/SFX/Boss SFX/SwordRandomized",puppet.Center)
    moveXtowardsFacing(17/2, 0.2)
    if puppet.Facing > 0 then -- left
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-65, -14), getHitbox(83, 40))
    else
        attack = getNewBasicAttackEntity(puppet.Position + vector2(-16, -15), getHitbox(83, 40))
    end
    
    attack:Add(getEntityTimer(0.1))
    addEntity(attack)
    addComponentToBoss(getEntityChain(attack))

    wait(0.18)
    setFlag("hk_change_to_main", true)
    wait(0.2)
end