import { world, system } from "@minecraft/server";

// Namespace
export const namespace = "bunnystudios_rpg";
//----------------------------------------------------------------------------------------------------
//  CUBE
//  Cube Attack 1
export const CubeAttack1Damage = 5;
export const CubeAttack1Range = 5;
export const CubeAttack1KnockbackStrength = 1;
//  Cube Attack 2
export const CubeAttack2Damage = 5;
export const CubeAttack2KnockbackStrength = 1;
//  Cube Attack 3
export const CubeAttack3Damage = 5;
export const CubeAttack3Range = 3;
export const CubeAttack3KnockbackStrength = 1;
//  Cube Attack 4
export const CubeAttack4Damage = 2;
export const CubeAttack4Range = 3;
//----------------------------------------------------------------------------------------------------
//  BLOOM
//  Bloom Attack 1
export const BloomAttack1Damage = 6;
//  Bloom Attack 2
export const BloomAttack2FirstDamage = 8;
export const BloomAttack2SecondDamage = 10;
export const BloomAttack2ThirdDamage = 12;
//  Bloom Attack 3
export const BloomAttack3Damage = 6;
export const BloomAttack3KnockbackStrength = 1;
export const BloomAttack3Range = 5.5;
//  Bloom Attack 4
export const BloomAttack4Damage = 8;
export const BloomAttack4KnockbackStrength = 0.3;
export const BloomAttack4Range = 5.5;
//  Bloom Attack 5
export const BloomAttack5Damage = 6;
//  Bloom Attack 7
export const BloomAttack7Damage = 6;
//  Bloom Attack 8
export const BloomAttack8Damage = 6;
export const BloomAttack8KnockbackStrength = 0.5;
export const BloomAttack8Range = 5.5;
//----------------------------------------------------------------------------------------------------
//  BOULDRAX
//  Bouldrax Attack 1
export const BouldraxAttack1Damage = 6;
//  Bouldrax Attack 2
export const BouldraxAttack2Damage = 1;
export const BouldraxAttack2KnockbackStrength = 1;
//  Bouldrax Attack 3
export const BouldraxAttack3Damage = 1;
export const BouldraxAttack3Range = 16;
export const BouldraxAttack3KnockbackStrength = 1;
//----------------------------------------------------------------------------------------------------
//  TWONWOLF
//  TwinWolf Attack 1
export const TwinWolfAttack1Damage = 8;
//  TwinWolf Attack 2
export const TwinWolfAttack2Damage = 6;
export const TwinWolfAttack2KnockbackStrength = 1;
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
// FUNCTİONS
// damageBetweenPoints
export function bloomDamageBetweenPoints(entity, start, end, damage, step = 0.5) {
    const dx = end.x - start.x;
    const dy = end.y - start.y;
    const dz = end.z - start.z;

    const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
    const steps = Math.ceil(distance / step);

    for (let i = 0; i <= steps; i++) {
        const t = i / steps;

        const x = start.x + dx * t;
        const y = start.y + dy * t;
        const z = start.z + dz * t;

        entity.runCommandAsync(`execute positioned ${x} ${y} ${z} run damage @e[type=!${namespace}:bloom, family=!inanimate, r=${step}] ${damage} entity_attack entity @s`)
    }
}