import { world, system, EquipmentSlot} from "@minecraft/server";
import { launchPlayer } from "./../../util/movements.js";
import { weaponDamageIndicator, generateUniqueId, stunDamageIndicator } from "./../../util/utils.js";
import { attackPlayerMeikyu, plunge, executer } from "./../../util/attackMethods.js";
import {JsonDatabase} from "./../../util/con-database.js";
import { attackFramerMeikyu } from "./../../util/cameraMoves.js";

let attackMoves = new JsonDatabase("attackMoves")
let AirCharges = new JsonDatabase("AirCharges")
const animations = [
    [
        /*new Map([
           ["sprint", {
                    animation: "minced.greatsword.attack_sprint",
                    knockback: [0,1.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_speed: 10,
                    hit_number: 1,
                    stun_type: "long",
                    range: 3,
                    distance: 2,
                    targetNum: 1,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    next_attack_time: 15,
                    Unbreakable: true
                }
           ],
           ["attack_0",{
                    animation: "minced.greatsword.attack",
                    knockback: [0,0.25],
                    Player_Knockback: [1,0.25],
                    type: "slash",
                    attack_speed: 13,
                    hit_number: 1,
                    stun_type: "long",
                    range: 3,
                    distance: 2,
                    targetNum: 5,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    next_attack_time: 10,
                    Unbreakable: true
                }
            ] 
        ]),*/
        {
            animation: "minced.greatsword.attack_sprint",
            knockback: [0,0],
            Player_Knockback: [2,0],
            type: "slash",
            attack_speed: 10,
            hit_number: 1,
            stun_type: "long",
            range: 3,
            distance: 2,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 15,
            Unbreakable: true
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.attack",
            ShowFrames: false,
            next_attack_time: 10,
            attackFrameNumber: 5,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,1.5],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,0.12],
                    type: "slash",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,0.12],
                    type: "slash",
                    attack_timeFrame: 11,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,0.12],
                    type: "slash",
                    attack_timeFrame: 12,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,0.12],
                    type: "slash",
                    attack_timeFrame: 13,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:-0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,0.12],
                    type: "slash",
                    attack_timeFrame: 14,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:-1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.attack2",
            ShowFrames: false,
            next_attack_time: 10,
            attackFrameNumber: 3,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,1.5],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "pierce",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:-0.25, y: 1, z: 1},
                    targetNum: 1,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "pierce",
                    attack_timeFrame: 12,
                    hit_number: 2,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 2,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "pierce",
                    attack_timeFrame: 14,
                    hit_number: 3,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 3},
                    targetNum: 5,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.attack3",
            ShowFrames: false,
            attackFrameNumber: 5,
            next_attack_time: 10,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,1.5],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 9,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:-1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:-0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 11,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 12,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 13,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.attack4",
            ShowFrames: false,
            attackFrameNumber: 3,
            next_attack_time: 10,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,1.5],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 9,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0.5, y: 1, z: -1},
                    targetNum: 14,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 16,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3,
                    distanceOffset: {x:0.25, y: 1.5, z: 0},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 18,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3,
                    distanceOffset: {x:0, y: 2, z: 2},
                    targetNum: 18,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.attack5",
            ShowFrames: false,
            attackFrameNumber: 3,
            next_attack_time: 15,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,1.5],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 12,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 2, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 14,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1.5, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0,0.5],
                    Player_Knockback: [1,2],
                    type: "slash",
                    attack_timeFrame: 16,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
    ],
    [
        {
            animation: "minced.greatsword.strenght_style.attack_sprint",
            knockback: [0,1.5],
            Player_Knockback: [1,2],
            type: "slash",
            attack_speed: 10,
            hit_number: 1,
            stun_type: "long",
            range: 3,
            distance: 2,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 15,
            Unbreakable: true
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.strenght_style.attack0",
            ShowFrames: false,
            next_attack_time: 10,
            attackFrameNumber: 5,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,0],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 11,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 12,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 13,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:-0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 14,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:-1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_particle_effect",
                    FrameMode: "normal",
                    attack_timeFrame: 13,
                    distanceOffset: {x:-1, y: 0, z: 1.5},
                    particle: "minced:tiny_pushback"
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.strenght_style.attack1",
            ShowFrames: false,
            next_attack_time: 10,
            attackFrameNumber: 3,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,0],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:0.5, y: 1, z: -1},
                    targetNum: 1,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 12,
                    hit_number: 2,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:0, y: 1, z: 1},
                    targetNum: 2,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "slash",
                    attack_timeFrame: 14,
                    hit_number: 3,
                    stun_type: "medium",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:-1, y: 1, z: -1},
                    targetNum: 5,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_particle_effect",
                    FrameMode: "normal",
                    attack_timeFrame: 15,
                    distanceOffset: {x:1.5, y: 0, z: -0.5},
                    particle: "minced:tiny_pushback"
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        },
        {
            attackTime: 20,
            animation: "minced.greatsword.strenght_style.attack2",
            ShowFrames: false,
            attackFrameNumber: 3,
            next_attack_time: 10,
            frames: [
                {
                    timeStamp: "checkParry",
                    FrameMode: "normal",
                    knockback: [0,0],
                    attack_timeFrame: 1
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "pierce",
                    attack_timeFrame: 9,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 5,
                    distanceOffset: {x:-1, y: 1, z: -0.5},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "pierce",
                    attack_timeFrame: 10,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 3.5,
                    distanceOffset: {x:-0.5, y: 1, z: 1},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "pierce",
                    attack_timeFrame: 11,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "add_frame",
                    FrameMode: "normal",
                    knockback: [0.25,0],
                    Player_Knockback: [1,0],
                    type: "pierce",
                    attack_timeFrame: 12,
                    hit_number: 1,
                    stun_type: "long",
                    knockCheck: "mp",
                    range: 2.5,
                    distanceOffset: {x:0, y: 1, z: 2},
                    targetNum: 10,
                    damage_multiplier: 1,
                    stun_damage_multiplier: 1,
                    Unbreakable: true
                },
                {
                    timeStamp: "restore_movement",
                    FrameMode: "normal",
                    attack_timeFrame: 20
                },
            ] 
        }
    ],
    [
        {
            animation: "minced.greatsword.attack",
            knockback: [0,0.25],
            Player_Knockback: [1,0.25],
            type: "slash",
            attack_speed: 10,
            hit_number: 1,
            stun_type: "long",
            range: 3,
            distance: 2,
            targetNum: 5,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 10,
            Unbreakable: true
        },
        {
            animation: "minced.greatsword.attack2",
            knockback: [2,0.25],
            Player_Knockback: [1,0.25],
            type: "pierce",
            attack_speed: 8,
            hit_number: 1,
            stun_type: "long",
            range: 3,
            distance: 2,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 14,
            Unbreakable: true
        },
        {
            animation: "minced.greatsword.attack3",
            knockback: [0,0.25],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 13,
            hit_number: 1,
            stun_type: "long",
            range: 3,
            distance: 2,
            targetNum: 5,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 12,
            Unbreakable: true
        },
        {
            animation: "minced.greatsword.attack4",
            knockback: [1,0],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 15,
            hit_number: 1,
            stun_type: "knockdown",
            range: 3,
            distance: 2,
            targetNum: 5,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 16,
            Unbreakable: true
        },
        {
            animation: "minced.greatsword.attack5",
            knockback: [0,-1],
            Player_Knockback: [1,0],
            type: "slash",
            attack_speed: 15,
            hit_number: 1,
            stun_type: "knockdown",
            range: 3,
            distance: 2,
            targetNum: 1,
            damage_multiplier: 1,
            stun_damage_multiplier: 1,
            next_attack_time: 18,
            Unbreakable: true
        }
    ]
]
const weapon = {
    name: 'greatsword',
    display_name: "Greatsword",
    dual_wield: ["greatsword","hand_cannon","sword","pistol","katana","wakizashi"],
    type: "great_sword",
    can_block: true,
    block_damage: 100,
    block_power: 70,
    block_time: 8,
    block_cooldown: 10,
    clash_power: 100,
    front_dodge: [5, 0.5],
    back_dodge:[-2, 0.25],
    left_dodge:"none",
    right_dodge:"none",
    stylePrefixes: ["minced.greatsword", "minced.greatsword.strenght_style"],
    weaponSize: "large",
    cd: 22,
    available_moves: ["front_dodge", "flying"],
    execute(player, weapon, effect, mode, burn) {
        const cd = this.cd
        const blckdmg = this.block_damage
        //let loc = coordExtractor(player, 1)
        //let local = Vector.add(loc, Vector.multiply(player.getViewDirection(), 2.5));
        let atkspd
        let lavander = weaponDamageIndicator(weapon) * 1
        let stundamage = stunDamageIndicator(weapon.getTags())
        let critChance = Math.floor(Math.random()*12)
        let critDamage = 0
        critChance == 2 ? critDamage = Math.floor(Math.random() * lavander) : critDamage = 0
        lavander = JSON.parse(lavander) + critDamage
        let Style = player.getProperty("fighting:style")
        let animChecker
        for(let i = (animations[Style].length - 1); i > 0; i--) {
            if(player.getDynamicProperty("combo") % i == 0) {
                animChecker = i
                break;
            }
        }
        let attackEffect = []
        attackEffect.push(effect)
        mode == "front_dodge" && Style != 0 ? mode = "default" : mode = mode
        switch(mode) {
            case "front_dodge":{
                let propCheck = {
                    animation: "minced.greatsword.attack_forward",
                    knockback: [0,0],
                    Player_Knockback: [3,0.5],
                    type: "slash",
                    attack_speed: 9,
                    hit_number: 1,
                    stun_type: "knockdown",
                    range: 7,
                    distance: 0,
                    targetNum: 10,
                    damage_multiplier: 1.5,
                    stun_damage_multiplier: 6,
                    next_attack_time: 5
                }
                let knockback = propCheck.knockback
                player.playAnimation(`animation.${propCheck.animation}`)
                atkspd = propCheck.attack_speed
                let Pknockback = propCheck.Player_Knockback 
                let effects = propCheck.type
                let stun = propCheck.stun_type
                let ranger = propCheck.range
                let distil = propCheck.distance
                let tgtnm = propCheck.targetNum
                let NAT = propCheck.next_attack_time
                let stunD = stundamage * propCheck.stun_damage_multiplier
                let breakable = propCheck.Unbreakable
                let hitCount = propCheck.hit_number
                system.runTimeout(()=>{
                    launchPlayer(player, Pknockback[0], Pknockback[1])
                },(atkspd - 1))
                system.runTimeout(()=>{
                    launchPlayer(player, 1, -0.5)
                    player.runCommand(`execute as @s run camerashake add @s 0.5 0.3`)
                },(atkspd))
                player.addEffect("slow_falling", 16, { amplifier: 3, showParticles: false })
                
                attackPlayerMeikyu(player, ranger, (lavander * propCheck.damage_multiplier), blckdmg, cd, atkspd, distil, tgtnm, "line_target", attackEffect, knockback, stun, "", effects, "", stunD, NAT,breakable, "normal",weapon, hitCount, true)
            }
                
            break;
            case "sprint":{
                let propCheck = animations[0][0]
                let knockback = propCheck.knockback
                player.playAnimation(`animation.${propCheck.animation}`)
                atkspd = propCheck.attack_speed
                let Pknockback = propCheck.Player_Knockback
                let effects = propCheck.type
                let stun = propCheck.stun_type
                let ranger = propCheck.range
                let distil = propCheck.distance
                let stunD = stundamage * propCheck.stun_damage_multiplier
                let lavander = weaponDamageIndicator(weapon)
                let hitCount = propCheck.hit_number
                if(AirCharges.get(player.id) > 0) {
                    player.playAnimation(`animation.minced.greatsword.attack_sprint_air_charged`)
                    atkspd = animations[0][0].attack_speed 
                    knockback = [0.1,1.5]
                    AirCharges.set(player.id,(AirCharges.get(player.id) - 1))
                    console.warn("aget Attack")
                    attackPlayerMeikyu(player, ranger, lavander, blckdmg, cd, atkspd, distil, 100, "line_target", attackEffect, knockback, stun, "after_attack", effects, 5, stunD, 20, true, "normal",weapon, hitCount, true)
                } else {
                    player.playAnimation(`animation.${animations[0][0].animation}`)
                    atkspd = 10 
                    knockback = [3,0.2]
                    let launcher = system.runInterval(() => {
                        launchPlayer(player, knockback[0], knockback[1])
                        system.clearRun(launcher)
                    },(atkspd - 2))
                    attackPlayerMeikyu(player, ranger, lavander, blckdmg, cd, atkspd, distil, 100, "line_target", attackEffect, knockback, stun, "", effects, "", stundamage, 20, true, "normal",weapon, hitCount, true)
                }
            } break;
            case "jump": {
                if(world.scoreboard.getObjective("exhaust").getScore(player) < 20) {
                    player.setDynamicProperty("attacking",0)
                    world.scoreboard.getObjective("combatCooldown").setScore(player, 10)
                    world.scoreboard.getObjective("combatCheck").setScore(player, 0)
                    player.runCommandAsync("tag @s remove attack")
                    return;
                }
                let propCheck = {
                    animation: "minced.greatsword.attack_jump",
                    knockback: [1,0.75],
                    Player_Knockback: [0,0],
                    type: "pierce",
                    attack_speed: 8,
                    hit_number: 1,
                    stun_type: "knockdown",
                    range: 3,
                    distance: 1,
                    targetNum: 1,
                    damage_multiplier: 1.5,
                    stun_damage_multiplier: 2,
                    next_attack_time: 16,
                    Unbreakable: false
                }
                let knockback = propCheck.knockback
                player.playAnimation(`animation.${propCheck.animation}`)
                atkspd = propCheck.attack_speed
                let Pknockback = propCheck.Player_Knockback 
                let effects = propCheck.type
                let stun = propCheck.stun_type
                let ranger = propCheck.range
                let distil = propCheck.distance
                let tgtnm = propCheck.targetNum
                let NAT = propCheck.next_attack_time
                let stunD = stundamage * propCheck.stun_damage_multiplier
                let breakable = propCheck.Unbreakable
                let hitCount = propCheck.hit_number
                system.runTimeout(()=>{
                    launchPlayer(player, Pknockback[0], Pknockback[1])
                },atkspd-5)
                player.addEffect("slow_falling", 16, { amplifier: 3, showParticles: false })
                attackPlayerMeikyu(player, ranger, (lavander * propCheck.damage_multiplier), blckdmg, cd, atkspd, distil, tgtnm, "line_target", attackEffect, knockback, stun, "", effects, (animations[Style].length - 1), stunD, NAT, breakable, "no cooldown",weapon, hitCount, true)
            } break;
            case "on_air": {
                let lavander = weaponDamageIndicator(weapon)
                atkspd = 10
                player.playAnimation(`animation.minced.greatsword.attack_on_air`,{
                    blendOutTime: 0.1,
                    stopExpression: "query.is_on_ground",
                    nextState: `animation.minced.greatsword.combat_stance`
                })
                let knockback
                burn != "" ? knockback = [0,-1] : knockback = [0,0]
                plunge(player, 5, lavander, cd, atkspd, 2, 3, -1, this.name)
            } break;
            case "execute": {
                executer(player, burn, (lavander * 200), this.name, 44)
            } break;
            default: {
                let propCheck = animations[Style][animChecker]
                player.playAnimation(`animation.${propCheck.animation}`)
                atkspd = propCheck.attack_speed
                let Pknockback = propCheck.Player_Knockback 
                let NAT = propCheck.next_attack_time
                if(animChecker == 3) {
                    player.addEffect("slow_falling", 16, { amplifier: 3, showParticles: false })
                }
                attackFramerMeikyu(player, propCheck, lavander, blckdmg, cd, attackEffect, (animations[Style].length - 1), stundamage, NAT, weapon, true)
            }
            break;
        }
    },
    setCore(player, item, storage) {
        let Abilities = [
            {
              Id: "S1",
            },
            {
              Id: "P3",
            },
            {
              Id: "O0",
            },
            {
              Id: "B3",
            },
            {
              Id: "D1",
            }
          ]
          item.setDynamicProperty("abilities", JSON.stringify(Abilities))
          item.setDynamicProperty("fightStyle", 0)
        player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
    },
    getCurrentAtkspd(player, combo) {
        let animChecker
        for(let i = (animations[0].length - 1); i > 0; i--) {
            if(player.getDynamicProperty("combo") % i == 0) {
                animChecker = i
                break;
            }
        }
        return animations[0][animChecker].attack_speed
    } 
}

export default weapon


