import { system, Player, Entity, BlockPermutation, world, System } from "@minecraft/server";
import { rushAttack, convertRotYtoPosXZ, getEntitiesInFront, fillCommand, shiftLocation, shootProjectile, removeProjectileInBLock, getDistance, damageByEffectStrength, caret, caretZ, rangedAttackForward, shootProjectilePropH, fillCommandDestroy, getEntitiesInRange, applyVarious, getEntitiesDistance, applySelfKnockback, cancelKnockback, isPlayer, spawnExplosion, clearAllSkill, clearFormSkill } from "./function";
import { getScoreUtility, setScoreUtility } from "./scoreboard";

//Gon//
/**
 * @param {Player} player 
 */
export function gon_charge(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.nen_charged",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.nen_charged",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function rock(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.rock_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.rock_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rock_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rock_attack2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.1});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",110);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[8,8],
            distance:8,
            damage:{amount:damageByEffectStrength(player,28,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:4,verticalStrength:0.55}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function rock2(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.rock_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.rock_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rock_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rock_attack2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rock_attack3",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1});
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:3,pitch:2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.1});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",105);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[8.5,8.5],
            distance:8.5,
            damage:{amount:damageByEffectStrength(player,40,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:4.25,verticalStrength:0.65}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function rock_smash_charge(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.smash_charge",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.smash_charge",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function rock_smash(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.mob.smash_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.mob.smash_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:rock_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:rock_attack2",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:rock_attack3",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:meruem_tail_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    const crack_loc = shiftLocation(player.location,0,-0.6,0);
    player.dimension.spawnParticle("hxc:crack",crack_loc);
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:3,pitch:1.5});
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:2,pitch:1.2});
    player.dimension.playSound("bigbang_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:2,pitch:1.2});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",105);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.runCommand("camerashake add @a[r=12] 0.5 0.6");
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        const loc = player.location;
        for(const targetEntity of getEntitiesInRange(player,shiftLocation(loc,-8.5,-6,-8.5),{x:17,y:11,z:17})){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:damageByEffectStrength(player,40,1.3),cause:"entityAttack"},
                knockback:{type:"sphere",horizontalStrength:4.6,verticalStrength:1}
            });
        }
        if(world.gameRules.mobGriefing==true){
            spawnExplosion(player,loc,1,false);
        }
    },2);
}
/**
 * @param {Player} player 
 */
export function scissor(player){
    const startLocation = player.location;
    const cos0 = Math.cos(player.getRotation().x * (Math.PI/180));
    const sin0 = Math.sin(player.getRotation().x * (Math.PI/180));
    const horizontalStrength = player.getRotation().x < 0 ? 35 * cos0 : 35;
    const verticalStrength = Math.max(0,-3 * sin0);
    applySelfKnockback(player,horizontalStrength,verticalStrength);
    player.dimension.playSound("sword.rush",player.location);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",105);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.scissor_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.scissor_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        cancelKnockback(player);
    },2);
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    system.runTimeout(()=>{
        if(!player.isOnGround){
            cancelKnockback(player);
            cancelKnockback(player);
            cancelKnockback(player);
        }
        const stopLocation = player.location;
        rushAttack({
            damaging:player,
            startLocation,
            stopLocation,
            volume:{x:4,y:4,z:4},
            damage:{amount:damageByEffectStrength(player,26,1.3),cause:"entityAttack",swordDamage:true},
            particle:{trailParticleId:"hxc:scissor_attack"}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function scissor2(player){
    const startLocation = player.location;
    const cos0 = Math.cos(player.getRotation().x * (Math.PI/180));
    const sin0 = Math.sin(player.getRotation().x * (Math.PI/180));
    const horizontalStrength = player.getRotation().x < 0 ? 35 * cos0 : 35;
    const verticalStrength = Math.max(0,-3 * sin0);
    applySelfKnockback(player,horizontalStrength,verticalStrength);
    player.dimension.playSound("sword.rush",player.location);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",100);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.scissor_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.scissor_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        cancelKnockback(player);
    },2);
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    system.runTimeout(()=>{
        if(!player.isOnGround){
            cancelKnockback(player);
            cancelKnockback(player);
            cancelKnockback(player);
        }
        const stopLocation = player.location;
        rushAttack({
            damaging:player,
            startLocation,
            stopLocation,
            volume:{x:4,y:4,z:4},
            damage:{amount:damageByEffectStrength(player,35,1.3),cause:"entityAttack",swordDamage:true},
            particle:{trailParticleId:"hxc:scissor_attack"}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function paper(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.rock_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.rock_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    const knockbackTargets = getEntitiesInFront(player,[3,3],3);
    for(const targetEntity of knockbackTargets){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:damageByEffectStrength(player,23,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:5,verticalStrength:1}
        });
    }
    shootProjectile(player,"hxc:paper_p",1);
    player.dimension.playSound("punch",player.location);
    player.dimension.playSound("random.explode",player.location);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",105);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Player} player 
 */
export function paper2(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.rock_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.gon.rock_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:rage_blast_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rage_blast_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    const knockbackTargets = getEntitiesInFront(player,[3.5,3.5],3.5);
    for(const targetEntity of knockbackTargets){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:damageByEffectStrength(player,32,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:5,verticalStrength:1}
        });
    }
    shootProjectile(player,"hxc:paper2_p",1);
    player.dimension.playSound("punch",player.location);
    player.dimension.playSound("rush_attack",player.location);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",100);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function paper_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-1.5,-1.5,-1.5),{x:3,y:3,z:3});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:gon3"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,27,1.3),cause:"entityAttack"}
            });
        }else if(owner.typeId == "hxc:gon2"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,25,1.3),cause:"entityAttack"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,23,1.3),cause:"entityAttack"}
            });
        }
    }
}
/**
 * @param {Entity} entity 
 */
export function paper2_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-1.75,-1.75,-1.75),{x:3.5,y:3.5,z:3.5});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:gon3"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,38,1.3),cause:"entityAttack"}
            });
        }else if(owner.typeId == "hxc:gon2"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,35,1.3),cause:"entityAttack"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,32,1.3),cause:"entityAttack"}
            });
        }
    }
}
/**
 * @param {Player} player 
 */
export function gon_adult_start(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.gon.adult_start",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
        player.dimension.spawnParticle("hxc:gon_adult_eye",caret(player.getHeadLocation(),player.getRotation(),[0.25,0.25,0]));
        player.dimension.spawnParticle("hxc:gon_adult_eye",caret(player.getHeadLocation(),player.getRotation(),[-0.25,0.25,0]));
    }else{
        player.playAnimation("animation.gon.adult_start",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
        player.dimension.spawnParticle("hxc:gon_adult_eye",caret(player.getHeadLocation(),player.getRotation(),[0.25,1,0]));
        player.dimension.spawnParticle("hxc:gon_adult_eye",caret(player.getHeadLocation(),player.getRotation(),[-0.25,1,0]));
    }
    player.setProperty("hxc:damage_sensor","invincible");
}
/**
 * @param {Player} player 
 */
export function gon_adult(player){
    player.dimension.playSound("random.totem",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:2,pitch:1.1});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:2,pitch:1.1});
    player.dimension.spawnParticle("hxc:gon_adult_particle1",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.runCommand("scoreboard players operation @s nen = @s nen_max");
    player.setProperty("hxc:form","gon_adult");
    player.setProperty("hxc:damage_sensor","default");
    player.triggerEvent("no_nen");
    clearFormSkill(player);
    system.runTimeout(()=>{
        player.addEffect("instant_health",10,{amplifier:99,showParticles:false});
    },2);
}
/**
 * @param {Player} player 
 */
export function gon_adult_end(player){
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:1.1});
    player.dimension.spawnParticle("hxc:gon_adult_particle2",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.startItemCooldown("hatsu3",2000);
    player.startItemCooldown("hatsu2",800);
    player.startItemCooldown("hatsu",700);
    player.setProperty("hxc:form","default");
    player.triggerEvent("no_nen");
    clearAllSkill(player);
    player.removeTag("nen_control");
    player.setProperty("hxc:level",1);
    player.setProperty("hxc:exp",0);
    system.runTimeout(()=>{
        player.runCommand("kill @s");
    },2);
}

//Killua//
/**
 * @param {Player} player 
 */
export function killua_charge(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.killua.nen_charged",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.killua.nen_charged",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function lightning_punch(player){
    player.runCommand("function punch_side_count");
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_attack",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1});
    player.dimension.playSound("thunder",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.25});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",100);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[4.5,4.5],
            distance:4.5,
            damage:{amount:damageByEffectStrength(player,35,1.25),cause:"lightning"},
            knockback:{type:"front",horizontalStrength:3.5,verticalStrength:0.5}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function lightning_palm(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.killua.lightning_palm",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.killua.lightning_palm",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:killua_lightning_attack",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("kick",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1});
    player.dimension.playSound("thunder",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.25});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",110);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[6,6],
            distance:6,
            damage:{amount:damageByEffectStrength(player,38,1.25),cause:"lightning"},
            knockback:{type:"front",horizontalStrength:2.0,verticalStrength:0.3}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function lightning_bolt(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.killua.lightning_palm",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.killua.lightning_palm",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:killua_lightning_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:killua_lightning_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    const knockbackTargets = getEntitiesInFront(player,[4,4],4);
    for(const targetEntity of knockbackTargets){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:damageByEffectStrength(player,30,1.25),cause:"lightning"},
            knockback:{type:"front",horizontalStrength:3.0,verticalStrength:0.3}
        });
    }
    shootProjectile(player,"hxc:lightning_bolt_p",1);
    player.dimension.playSound("thunder",player.location);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",100);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function lightning_bolt_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-2,-2,-2),{x:4,y:4,z:4});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:killua3"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,34,1.25),cause:"lightning"}
            });
        }else if(owner.typeId == "hxc:killua2"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,32,1.25),cause:"lightning"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,30,1.25),cause:"lightning"}
            });
        }
    }
}
/**
 * @param {Player} player 
 */
export function lightning_speed(player){
    const startLocation = player.location;
    const cos0 = Math.cos(player.getRotation().x * (Math.PI/180));
    const sin0 = Math.sin(player.getRotation().x * (Math.PI/180));
    const horizontalStrength = player.getRotation().x < 0 ? 36 * cos0 : 36;
    const verticalStrength = Math.max(0,-3 * sin0);
    applySelfKnockback(player,horizontalStrength,verticalStrength);
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:3,pitch:1.1});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,-0.25]),{volume:3,pitch:1.5});
    player.dimension.playSound("rush_attack",caret(player.getHeadLocation(),player.getRotation(),[0,1,0]),{volume:1.5,pitch:1.15});
    player.dimension.playSound("thunder",caret(player.getHeadLocation(),player.getRotation(),[0,1,0]),{volume:2,pitch:1.1});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",120);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.rush_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.rush_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        cancelKnockback(player);
    },2);
    system.runTimeout(()=>{
        if(!player.isOnGround){
            cancelKnockback(player);
            cancelKnockback(player);
            cancelKnockback(player);
        }
        const stopLocation = player.location;
        rushAttack({
            damaging:player,
            startLocation,
            stopLocation,
            volume:{x:5,y:5,z:5},
            damage:{amount:damageByEffectStrength(player,40,1.25),cause:"entityAttack"},
            particle:{trailParticleId:"hxc:lightning_speed_particle"}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function killua_godspeed_start(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.killua.godspeed_start",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.killua.godspeed_start",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.setProperty("hxc:damage_sensor","invincible");
}
/**
 * @param {Player} player 
 */
export function killua_godspeed(player){
    player.dimension.playSound("thunder",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:3,pitch:0.85});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:3,pitch:1.1});
    player.dimension.spawnParticle("hxc:killua_godspeed_e1",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.dimension.spawnParticle("hxc:lightning_strike1",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.setProperty("hxc:form","killua_godspeed");
    player.setProperty("hxc:damage_sensor","default");
    for(const targetEntity of getEntitiesInRange(player,shiftLocation(player.location,-8,-6,-8),{x:16,y:12,z:16})){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:36,cause:"lightning"},
            knockback:{type:"sphere",horizontalStrength:2,verticalStrength:0.35}
        });
    }
    player.triggerEvent("no_nen");
}
/**
 * @param {Player} player 
 */
export function killua_godspeed_end(player){
    player.dimension.playSound("thunder",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:1.25});
    player.dimension.spawnParticle("hxc:killua_godspeed_e2",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.startItemCooldown("hatsu3",1000);
    player.startItemCooldown("hatsu2",600);
    player.startItemCooldown("hatsu",500);
    player.setProperty("hxc:form","default");
    player.triggerEvent("no_nen");
    clearAllSkill(player);
}

//Uvogin//
/**
 * @param {Player} player 
 */
export function uvogin_charge(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.uvogin.nen_charged",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.uvogin.nen_charged",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function bigbang_impact(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.uvogin.bigbang_impact",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.uvogin.bigbang_impact",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:bigbang_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:bigbang_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:bigbang_impact3",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.2});
    player.dimension.playSound("bigbang_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:3,pitch:1});
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:3,pitch:2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:2,pitch:1.1});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",135);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[10,10],
            distance:10,
            damage:{amount:damageByEffectStrength(player,38,1.2),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:4.35,verticalStrength:0.75}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function bigbang_impact2(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.uvogin.bigbang_impact",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.uvogin.bigbang_impact",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    const knockbackTargets = getEntitiesInFront(player,[5,5],5);
    for(const targetEntity of knockbackTargets){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:damageByEffectStrength(player,28,1.2),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:5,verticalStrength:1}
        });
    }
    shootProjectile(player,"hxc:bigbang_impact_p",1);
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:1.2});
    player.dimension.playSound("bigbang_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:3,pitch:1});
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:3,pitch:2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:1.1});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",140);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function bigbang_impact_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-4,-4,-4),{x:8,y:8,z:8});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:uvogin"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,20,1.2),cause:"entityAttack"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,16,1.2),cause:"entityAttack"}
            });
        }
    }
}
/**
 * @param {Player} player 
 */
export function bigbang_impact3_charge(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.uvogin.smash_charge",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.uvogin.smash_charge",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function bigbang_impact3(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.mob.smash_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.mob.smash_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:bigbang_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:bigbang_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:bigbang_impact3",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    player.dimension.spawnParticle("hxc:meruem_tail_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]));
    const crack_loc = shiftLocation(player.location,0,-0.6,0);
    player.dimension.spawnParticle("hxc:crack",crack_loc);
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:3,pitch:1.5});
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:2,pitch:1.2});
    player.dimension.playSound("bigbang_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:2,pitch:1.2});
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:3,pitch:2});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",110);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.runCommand("camerashake add @a[r=12] 0.55 0.6");
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        const loc = player.location;
        for(const targetEntity of getEntitiesInRange(player,shiftLocation(loc,-8.5,-6,-8.5),{x:17,y:11,z:17})){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:damageByEffectStrength(player,40,1.2),cause:"entityAttack"},
                knockback:{type:"sphere",horizontalStrength:4.7,verticalStrength:1}
            });
        }
        if(world.gameRules.mobGriefing==true){
            spawnExplosion(player,loc,1.5,false);
        }
    },2);
}

//Meruem//
/**
 * @param {Player} player 
 */
export function meruem_charge1(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.nen_charged1",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.nen_charged1",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function meruem_charge2(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.nen_charged2",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.nen_charged2",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function tail_attack(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.tail_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.tail_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]));
    player.dimension.spawnParticle("hxc:meruem_tail_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]));
    player.dimension.spawnParticle("hxc:meruem_tail_attack2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:1.75,pitch:1.2});
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:2,pitch:1.2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:2,pitch:1.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",85);
    }else{
        player.triggerEvent("hxc:cooldown");
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[6.5,6.5],
            distance:6.5,
            damage:{amount:damageByEffectStrength(player,25,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:4,verticalStrength:0.65}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function rush_attack(player){
    const startLocation = player.location;
    const cos0 = Math.cos(player.getRotation().x * (Math.PI/180));
    const sin0 = Math.sin(player.getRotation().x * (Math.PI/180));
    const horizontalStrength = player.getRotation().x < 0 ? 36 * cos0 : 36;
    const verticalStrength = Math.max(0,-3 * sin0);
    applySelfKnockback(player,horizontalStrength,verticalStrength);
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:3,pitch:1.1});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,-0.25]),{volume:3,pitch:1.5});
    player.dimension.playSound("rush_attack",caret(player.getHeadLocation(),player.getRotation(),[0,1,0]),{volume:1.5,pitch:1.15});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",125);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.addTag("can_parry");
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },3);
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.rush_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.rush_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        cancelKnockback(player);
    },2);
    system.runTimeout(()=>{
        if(!player.isOnGround){
            cancelKnockback(player);
            cancelKnockback(player);
            cancelKnockback(player);
        }
        const stopLocation = player.location;
        rushAttack({
            damaging:player,
            startLocation,
            stopLocation,
            volume:{x:4.5,y:4.5,z:4.5},
            damage:{amount:damageByEffectStrength(player,38,1.3),cause:"entityAttack"},
            particle:{trailParticleId:"hxc:meruem_rush_attack"}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function rage_blast(player){
    player.dimension.spawnParticle("hxc:rage_blast_impact1",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.spawnParticle("hxc:rage_blast_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("rage_blast",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]),{volume:3,pitch:1.1});
    const knockbackTargets = getEntitiesInFront(player,[6,6],6);
    for(const targetEntity of knockbackTargets){
        applyVarious({
            target:targetEntity,
            damaging:player,
            damage:{amount:damageByEffectStrength(player,30,1.25),cause:"entityExplosion"},
            knockback:{type:"front",horizontalStrength:3.75,verticalStrength:0.75}
        });
    }
    shootProjectile(player,"hxc:rage_blast_p",1);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",150);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function rage_blast_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-5,-5,-5),{x:10,y:10,z:10});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:meruem"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,36,1.25),cause:"entityExplosion"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,30,1.25),cause:"entityExplosion"}
            });
        }
    }
    if(world.gameRules.mobGriefing==true){
        spawnExplosion(owner,entity.location,1.5,false);
    }
}
/**
 * @param {Player} player 
 */
export function rush_wing(player){
    player.startItemCooldown("hatsu",150);
    let targetDist = 12;
    let delay = 4;
    const entityRay = player.getEntitiesFromViewDirection({maxDistance:64});
    if(entityRay.length){
        targetDist = entityRay[0].distance;
        delay = Math.min(6,Math.floor(targetDist/4));
    }else{
        const blockRay = player.getBlockFromViewDirection({maxDistance:128,includePassableBlocks:false});
        if(blockRay!=undefined){
            targetDist = getDistance(player.location,blockRay.block.location);
            delay = Math.min(6,Math.floor(targetDist/4));
        }
    }
    if(delay<2){
        system.runTimeout(()=>{
            const horizontalStrength = (targetDist * Math.cos(player.getRotation().x * (Math.PI/180)));
            const verticalStrength = -5 * Math.sin(player.getRotation().x * (Math.PI/180));
            applySelfKnockback(player,horizontalStrength,verticalStrength);
            rush_wing_exe(player);
        },2);
    }
    else if(true){
        applySelfKnockback(player,0,2.15);
        system.runTimeout(()=>{
            const horizontalStrength = ((targetDist/2) * Math.cos(player.getRotation().x * (Math.PI/180)));
            const verticalStrength = -5 * Math.sin(player.getRotation().x * (Math.PI/180));
            applySelfKnockback(player,horizontalStrength,verticalStrength);
            system.runTimeout(()=>{
                rush_wing_exe(player);
            },delay);
        },1);
    }
}
/**
 * @param {Player} player 
 */
function rush_wing_exe(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.rush_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.rush_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.playSound("rush_attack",caret(player.getHeadLocation(),player.getRotation(),[0,1,0]),{volume:3,pitch:1.1});
    player.addEffect("slow_falling",40,{showParticles:false});
    system.runTimeout(()=>{
        cancelKnockback(player);
        rush_wing_attack(player,caretZ(shiftLocation(player.location,0,1,0),player.getRotation(),[0,0,2]));
    },1);
}
/**
 * @param {Entity} entity 
 * @returns 
 */
export function meruem_rush_wing(entity){
    applySelfKnockback(entity,0,3.15);
    if(entity.typeId == "minecraft:player"){
        entity.playAnimation("animation.meruem.rush_attack",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        entity.playAnimation("animation.meruem.rush_attack",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    entity.dimension.playSound("rush_attack",caret(entity.getHeadLocation(),entity.getRotation(),[0,1,0]),{volume:3,pitch:1.1});
    const entityRaycastHit = entity.getEntitiesFromViewDirection({excludeFamilies:["damage","inanimate"],excludeTypes:["item","xp_orb"]})[0];
    if(entityRaycastHit==undefined) return;
    const target = entityRaycastHit.entity;
    const targetLocation = target.location;
    const targetLocationX = targetLocation.x;
    const targetLocationY = targetLocation.y;
    const targetLocationZ = targetLocation.z;
    const entityLocation = entity.location;
    const entityLocationX = entityLocation.x;
    const entityLocationY = entityLocation.y;
    const entityLocationZ = entityLocation.z;
    const targetDistXZ = Math.sqrt(Math.pow((targetLocationX - entityLocationX),2) + Math.pow((targetLocationZ - entityLocationZ),2));
    const targetDistY = targetLocationY - entityLocationY;
    const targetDist = Math.sqrt(Math.pow(targetDistXZ,2) + Math.pow(targetDistY,2));
    const horizontalStrength = targetDistXZ / (2 + targetDistXZ*0.02);
    const headRotation = entity.getRotation().x;
    const verticalStrength = targetDistY/7;
    const damgeDelay = 10 + Math.round(targetDist/10);
    /**@param {Number} n  */
    function runTimeout(n){
        system.runTimeout(()=>{
            applySelfKnockback(entity,horizontalStrength,verticalStrength);
            if(n != 0){
                runTimeout(n-1);
            }
        },1);
    }
    const count = Math.abs(headRotation) >= 60 ? 0 : Math.abs(headRotation) >= 30 ? 1 : targetDist >= 60 ? 4 : targetDist >= 40 ? 3 : targetDist >= 10 ? 2 : targetDist >= 5 ? 1 : 0;
    runTimeout(count);
    system.runTimeout(()=>{
        entity.triggerEvent("hxc:cooldown2");
        rush_wing_attack(entity,entity.location);
    },damgeDelay);
}
/**
 * @param {Entity} entity 
 * @param {import("@minecraft/server").Vector3} location 
 */
export function rush_wing_attack(entity,location){
    entity.dimension.playSound("sword.swing",caret(entity.getHeadLocation(),entity.getRotation(),[0,0,3.5]),{volume:3,pitch:1.1});
    entity.dimension.playSound("random.explode",caret(entity.getHeadLocation(),entity.getRotation(),[0,0,-0.25]),{volume:3,pitch:1.5});
    entity.dimension.spawnParticle("hxc:rush_wing_attack",location);
    for(const targetEntity of getEntitiesInRange(entity,shiftLocation(location,-7.5,-7.5,-7.5),{x:15,y:15,z:15})){
        applyVarious({
            target:targetEntity,
            damaging:entity,
            damage:{amount:damageByEffectStrength(entity,46,1.3),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:4,verticalStrength:0.5}
        });
    }
}
/**
 * @param {Player} player 
 */
export function release(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.meruem.release",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.meruem.release",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:meruem_release1",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.spawnParticle("hxc:meruem_release2",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.spawnParticle("hxc:meruem_release3",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:3,pitch:1.5});
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:2,pitch:1.2});
    player.dimension.playSound("bigbang_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:3,pitch:1.25});
    system.runTimeout(()=>{
        player.dimension.spawnParticle("hxc:meruem_release4",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
        const crack_loc = shiftLocation(player.location,0,-0.6,0);
        player.dimension.spawnParticle("hxc:crack",crack_loc);
        player.runCommand("camerashake add @a[r=60] 0.4 0.3");
    },1);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",135);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    player.setProperty("hxc:form","meruem_release");
    system.runTimeout(()=>{
        for(const targetEntity of getEntitiesInRange(player,shiftLocation(player.location,-10,-6,-10),{x:20,y:14,z:20})){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:damageByEffectStrength(player,34,1.25),cause:"entityAttack"},
                knockback:{type:"sphere",horizontalStrength:4.85,verticalStrength:1}
            });
        }
    },2);
}
/**
 * @param {Player} player 
 */
export function release_end(player){
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:1.25});
    player.dimension.spawnParticle("hxc:meruem_release4",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.startItemCooldown("hatsu3",950);
    player.startItemCooldown("hatsu2",500);
    player.startItemCooldown("hatsu",400);
    player.setProperty("hxc:form","default");
    player.triggerEvent("no_nen");
}

//Feitan
/**
 * @param {Player} player 
 */
export function feitan_angry_start(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.feitan.angry_start",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.feitan.angry_start",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.setProperty("hxc:damage_sensor","invincible");
}
/**
 * @param {Player} player 
 */
export function feitan_angry(player){
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:3,pitch:0.85});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:3,pitch:1.1});
    player.dimension.spawnParticle("minecraft:huge_explosion_emitter",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.setProperty("hxc:form","feitan_angry");
    player.setProperty("hxc:damage_sensor","default");
    player.triggerEvent("feitan_angry");
    for(const targetEntity of getEntitiesInRange(player,shiftLocation(loc,-4,-3,-4),{x:8,y:8,z:8})){
        if(targetEntity != player){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:15,cause:"entityExplosion"},
                knockback:{type:"sphere",horizontalStrength:2.85,verticalStrength:0.35}
            });
        }
    }
    player.triggerEvent("no_nen");
}
/**
 * @param {Player} player 
 */
export function feitan_angry_end(player){
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:2.5});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]),{volume:1,pitch:2.25});
    player.dimension.spawnParticle("hxc:tail_attack",caret(player.getHeadLocation(),player.getRotation(),[0,0.5,0]));
    player.startItemCooldown("hatsu3",1000);
    player.startItemCooldown("hatsu2",600);
    player.startItemCooldown("hatsu",500);
    player.setProperty("hxc:form","default");
    player.triggerEvent("no_nen");
    player.triggerEvent("all_damage");
    clearAllSkill(player);
}
/**
 * @param {Player} player 
 */
export function rising_sun(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.feitan.rising_sun",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.feitan.rising_sun",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.runCommand("summon hxc:rising_sun_p ^^0.25^0.5 ~~ hxc:levitation");
    player.runCommand("scoreboard players remove @s pain_score 100");
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:2.5});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:2.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu2",600);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function rising_sun_p(entity){
    const targets = getEntitiesInRange(entity,shiftLocation(entity.location,-50,-50,-50),{x:100,y:100,z:100});
    entity.runCommand("camerashake add @a[r=60] 0.3 0.5");
    for(const targetEntity of targets){
        applyVarious({
            target:targetEntity,
            damaging:entity,
            damage:{amount:32,cause:"fire"}
        });
    }
}
/**
 * @param {Player} player 
 */
export function rising_moon(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.feitan.rising_sun",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.feitan.rising_sun",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.runCommand("summon hxc:rising_moon_p ^^0.25^0.5 ~~ hxc:levitation");
    player.runCommand("scoreboard players remove @s pain_score 100");
    player.dimension.playSound("ren",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:2.5});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,0.5]),{volume:2,pitch:2.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu2",600);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function rising_moon_p(entity){
    const targets = getEntitiesInRange(entity,shiftLocation(entity.location,-52,-52,-52),{x:105,y:105,z:105});
    entity.runCommand("camerashake add @a[r=60] 0.05 0.5");
    for(const targetEntity of targets){
        applyVarious({
            target:targetEntity,
            damaging:entity,
            damage:{amount:30,cause:"freezing"}
        });
        targetEntity.runCommand(`execute unless entity @s[has_property={hxc:form="feitan_angry"}] as @s run effect @s slowness 2 3 true`);
    }
}

//Nobunaga
/**
 * @param {Player} player 
 */
export function en_slash(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.player.rush_slash_charge",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.player.rush_slash_charge",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:en_slash1",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.spawnParticle("hxc:en_slash2",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.spawnParticle("hxc:en_slash3",caret(player.getHeadLocation(),player.getRotation(),[0,0.2,0]));
    player.dimension.playSound("sword.slash1",caret(player.getHeadLocation(),player.getRotation(),[0,0.1,0]),{volume:0.8,pitch:2.25});
    player.runCommand("camerashake add @a[r=10] 0.45 0.2");
    player.runCommand("kill @e[family=projectile,r=10]");
    player.runCommand("kill @e[type=arrow,r=10]");
    player.runCommand("kill @e[type=snowball,r=10]");
    player.runCommand("kill @e[type=egg,r=10]");
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        const loc = player.location;
        for(const targetEntity of getEntitiesInRange(player,shiftLocation(loc,-10,-8,-10),{x:20,y:16,z:20})){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:4,cause:"override",swordDamage:true},
                knockback:{type:"sphere",horizontalStrength:0,verticalStrength:0}
            });
        }
    },1);
}
/**
 * @param {Player} player 
 */
export function en_slash_end(player){
    player.runCommand("scoreboard players set @s score_test 0");
    player.removeTag("can_parry");
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("sword",120);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}

//Netero
/**
 * @param {Entity} entity 
 */
export function rose_bomb(entity){
    const loc = entity.location;
    entity.runCommand("camerashake add @a[r=64] 0.45 0.35");
    system.runTimeout(()=>{
        for(const targetEntity of getEntitiesInRange(entity,shiftLocation(loc,-46,-46,-46),{x:92,y:92,z:92})){
            targetEntity.addEffect("wither",3000,{amplifier:11,showParticles:true});
            targetEntity.runCommand("damage @s 3 override entity @e[type=hxc:rose_bomb,c=1]");
            cancelKnockback(targetEntity);
        }
    },1);
    const randomX = Math.floor(-44 + Math.random()*44*2);
    const randomZ = Math.floor(-44 + Math.random()*44*2);
    const exeLoc = {
        x:loc.x + randomX,
        y:loc.y,
        z:loc.z + randomZ
    }
    const targetBlock = entity.dimension.getTopmostBlock({x:exeLoc.x,z:exeLoc.z},exeLoc.y);
    const targetBLockLoc = targetBlock.location;
    system.runTimeout(()=>{
        spawnExplosion(targetBlock,shiftLocation(targetBLockLoc,0,-0.1,0),1,false);
        spawnExplosion(targetBlock,shiftLocation(targetBLockLoc,0,-0.1,0),2,false);
        spawnExplosion(targetBlock,shiftLocation(targetBLockLoc,0,-0.1,0),3,false);
    },1);
}
/**
 * @param {Player} player 
 */
export function first_hand(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.hyakushiki_kannon.first_hand",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.hyakushiki_kannon.first_hand",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.spawnParticle("hxc:rock_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.spawnParticle("hxc:rock_attack3",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:2,pitch:1.2});
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:2.5,pitch:1.2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.25]),{volume:3,pitch:1.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",105);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[11,11],
            distance:11,
            damage:{amount:damageByEffectStrength(player,36,1.15),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:7,verticalStrength:0.85}
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function second_hand(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.hyakushiki_kannon.second_hand",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.hyakushiki_kannon.second_hand",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    
    system.runTimeout(()=>{
        const knockbackTargets = getEntitiesInFront(player,[4,4],4);
        for(const targetEntity of knockbackTargets){
            applyVarious({
                target:targetEntity,
                damaging:player,
                damage:{amount:damageByEffectStrength(player,32,1.15),cause:"entityAttack"},
                knockback:{type:"front",horizontalStrength:7.5,verticalStrength:1}
            });
        }
        player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,3,-3]),{volume:4,pitch:0.98});
    },2);
    system.runTimeout(()=>{
        player.dimension.playSound("rush_attack",caret(player.getHeadLocation(),player.getRotation(),[0,3,-3]),{volume:5,pitch:0.98});
        shootProjectile(player,"hxc:second_hand_p",1,[0,3,-3]);
    },4);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",115);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function second_hand_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-5.5,-5.5,-5.5),{x:11,y:11,z:11});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:netero"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,38,1.15),cause:"entityAttack"}
            });
        }else if(owner.typeId == "hxc:netero2"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,35,1.15),cause:"entityAttack"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,32,1.15),cause:"entityAttack"}
            });
        }
    }
    if(world.gameRules.mobGriefing==true){
        spawnExplosion(owner,entity.location,2,false);
    }
}
/**
 * @param {Player} player 
 */
export function third_hand(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.hyakushiki_kannon.third_hand",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.hyakushiki_kannon.third_hand",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.spawnParticle("hxc:rock_attack1",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.spawnParticle("hxc:rock_attack3",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
    player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:2,pitch:1.2});
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:2.5,pitch:1.2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:3,pitch:1.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",120);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
    system.runTimeout(()=>{
        player.addTag("can_parry");
    },1);
    system.runTimeout(()=>{
        player.removeTag("can_parry");
    },4);
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[13,13],
            distance:13,
            damage:{amount:damageByEffectStrength(player,40,1.15),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:0.18,verticalStrength:0.15},
            effect:[
                {typeId:"blindness",duration:40,amplifier:0},
                {typeId:"slowness",duration:60,amplifier:5}
            ]
        });
    },2);
}
/**
 * @param {Player} player 
 */
export function ninetyninth_hand_start(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.hyakushiki_kannon.ninetyninth_hand",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.hyakushiki_kannon.ninetyninth_hand",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
}
/**
 * @param {Player} player 
 */
export function ninetyninth_hand(player){
    player.dimension.spawnParticle("hxc:punch_impact2",caret(player.getHeadLocation(),player.getRotation(),[0,0,4.5]));
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:2.5,pitch:1.2});
    player.dimension.playSound("random.explode",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:3,pitch:1.5});
    player.addTag("can_parry");
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[16,16],
            distance:16,
            damage:{amount:damageByEffectStrength(player,16,1.15),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:0.55,verticalStrength:0}
        });
    },1);
}
/**
 * @param {Player} player 
 */
export function ninetyninth_hand_end(player){
    player.removeTag("can_parry");
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",160);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Player} player 
 */
export function zero_hand(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.hyakushiki_kannon.zero_hand",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.hyakushiki_kannon.zero_hand",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    system.runTimeout(()=>{
        rangedAttackForward({
            damaging:player,
            range:[14,14],
            distance:14,
            damage:{amount:damageByEffectStrength(player,5,1.15),cause:"entityAttack"},
            knockback:{type:"front",horizontalStrength:0.1,verticalStrength:0.1},
            effect:[
                {typeId:"blindness",duration:60,amplifier:0},
                {typeId:"slowness",duration:125,amplifier:5}
            ]
        });
        player.dimension.spawnParticle("hxc:punch_impact",caret(player.getHeadLocation(),player.getRotation(),[0,0,4]));
        player.dimension.playSound("punch",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:1,pitch:1.2});
        player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,3.5]),{volume:1,pitch:1.2});
    },4);
    system.runTimeout(()=>{
        player.dimension.playSound("rage_blast",caret(player.getHeadLocation(),player.getRotation(),[0,5,-5]),{volume:5,pitch:0.98});
        shootProjectile(player,"hxc:zero_hand_p",1,[0,5,-5]);
    },28);
    system.runTimeout(()=>{
        shootProjectile(player,"hxc:zero_hand_p",1,[0,5,-5]);
    },30);
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("hatsu",1300);
        player.startItemCooldown("hatsu2",1300);
        player.startItemCooldown("hatsu3",1300);
        player.setProperty("hxc:zero_hand_ct",true);
        setScoreUtility(player,"nen",-400);
        system.runTimeout(()=>{
            player.setProperty("hxc:zero_hand_ct",false);
        },1300);
        player.triggerEvent("no_nen");
    }
    else if(player.typeId == "hxc:netero"){
        player.setProperty("hxc:final_move",true);
        system.runTimeout(()=>{
            player.setProperty("hxc:final_move",false);
        },3500);
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function zero_hand_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const owner = projectileComp.owner;
    const targets = getEntitiesInRange(owner,shiftLocation(entity.location,-9,-9,-9),{x:18,y:18,z:18});
    for(const targetEntity of targets){
        if(owner.typeId == "hxc:netero"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,100,1.1),cause:"entityExplosion"}
            });
        }else if(owner.typeId == "hxc:netero2"){
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,90,1.1),cause:"entityExplosion"}
            });
        }else{
            applyVarious({
                target:targetEntity,
                damaging:owner,
                damage:{amount:damageByEffectStrength(owner,80,1.1),cause:"entityExplosion"}
            });
        }
    }
    if(world.gameRules.mobGriefing==true){
        spawnExplosion(owner,entity.location,6,false);
    }
}

//God Warrior
/**
 * @param {Player} player 
 */
export function god_magic_beam(player){
    if(player.typeId == "minecraft:player"){
        player.playAnimation("animation.god_warrior.god_magic_beam",{nextState:"third_person",blendOutTime:0.25,controller:"controller.animation.player.root",stopExpression:"q.any_animation_finished"});
    }else{
        player.playAnimation("animation.god_warrior.god_magic_beam",{nextState:"default",blendOutTime:0.25,controller:"controller.animation.mob",stopExpression:"q.any_animation_finished"});
    }
    player.runCommand("summon hxc:god_magic_beam ^^10^-5");
    player.dimension.spawnParticle("hxc:god_trident_throw",caret(player.getHeadLocation(),player.getRotation(),[0,0,3]));
    player.dimension.playSound("sword.swing",caret(player.getHeadLocation(),player.getRotation(),[0,0,2]),{volume:0.8,pitch:1.5});
    if(player.typeId == "minecraft:player"){
        player.startItemCooldown("powers",100);
    }else{
        player.triggerEvent("hxc:cooldown2");
    }
}
/**
 * @param {Entity} entity 
 */
export function god_magic_beam_p(entity){
    if(removeProjectileInBLock(entity)) return;
    const projectileComp = entity.getComponent("projectile");
    if(projectileComp==undefined) return;
    const targets = entity.dimension.getEntities({excludeFamilies:["damage","god_warrior"],excludeTypes:["item","xp_orb"],location:shiftLocation(entity.location,-6,-6,-6),volume:{x:12,y:12,z:12}});
    for(const targetEntity of targets){
        targetEntity.applyDamage(42,{cause:"void",damagingEntity:entity});
    }
    if(world.gameRules.mobGriefing==true){
        spawnExplosion(entity,entity.location,2,false);
    }
}
