Untitled

 avatar
unknown
javascript
5 months ago
48 kB
2
Indexable
var button;
var storedData;

var skillTree = {
    Knight: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 11, name: "ХП", x: 200, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: true, next: [13] },
                            { id: 13, name: "УРОН", x: 180, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 52, offsetY: 0, unlocked: false, next: [15] },
                            { id: 15, name: "УРОН", x: 160, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 52, offsetY: 0, unlocked: false, next: [18] },
                            { id: 18, name: "ХП", x: 140, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 12, name: "БРОНЯ", x: 200, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 26, offsetY: 0, unlocked: true, next: [14] },
                            { id: 14, name: "ХП", x: 180, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [16] },
                            { id: 16, name: "ХП", x: 160, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [17] },
                            { id: 17, name: "БРОНЯ", x: 140, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 26, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",
                
                type: "unique",
                skill: { id: 100, name: "Уникальный навык", x: 100, y: 208, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 30, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 110, name: "Навык 1", x: 85, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0,unlocked: false, next: [111] },
                            { id: 111, name: "Навык 2", x: 65, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [112] },
                            { id: 112, name: "Навык 2", x: 45, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0,unlocked: false, next: [113] },
                            { id: 113, name: "Навык 2", x: 25, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 114, name: "Навык 1", x: 85, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [115] },
                            { id: 115, name: "Навык 2", x: 65, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0, unlocked: false, next: [116] },
                            { id: 116, name: "Навык 2", x: 45, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0, unlocked: false, next: [117] },
                            { id: 117, name: "Навык 2", x: 25, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 52, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 101, name: "Финальный уникальный навык", x: -15, y: 208, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 75, offsetY: 30, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 118, name: "Навык 1", x: -35, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 52, offsetY: 0, unlocked: false, next: [118] },
                            { id: 120, name: "Навык 2", x: -55, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 119, name: "Навык 1", x: -35, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [121] },
                            { id: 121, name: "Навык 2", x: -55, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
    Thief: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 21, name: "Скорость", x: 215, y: 250, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [23] },
                            { id: 23, name: "Контрудар", x: 203, y: 260, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0, unlocked: false, next: [24] },
                            { id: 24, name: "Вампиризм", x: 190, y: 270, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 130, offsetY: 0, unlocked: false, next: [25] },
                            { id: 25, name: "ХП", x: 190, y: 285, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 22, name: "БРОНЯ", x: 230, y: 260, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [26] },
                            { id: 26, name: "ХП", x: 230, y: 275, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [27] },
                            { id: 27, name: "ХП", x: 230, y: 290, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [28] },
                            { id: 28, name: "БРОНЯ", x: 215, y: 300, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",
                
                type: "unique",
                skill: { id: 200, name: "Ловкость пальцев", x: 178, y: 300, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 148, offsetY: 30, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 29, name: "Навык 1", x: 165, y: 325, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [211] },
                            { id: 211, name: "Навык 2", x: 152, y: 335, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0,unlocked: false, next: [212] },
                            { id: 212, name: "Навык 2", x: 138, y: 345, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0,unlocked: false, next: [213] },
                            { id: 213, name: "Навык 2", x: 138, y: 360, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 210, name: "Навык 1", x: 190, y: 340, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [214] },
                            { id: 214, name: "Навык 2", x: 190, y: 355, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [215] },
                            { id: 215, name: "Навык 2", x: 190, y: 370, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 130, offsetY: 0, unlocked: false, next: [216] },
                            { id: 216, name: "Навык 2", x: 175, y: 380, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 201, name: "Безмерное богатство", x: 135, y: 375, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 104, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 217, name: "Навык 1", x: 122, y: 400, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 130, offsetY: 0, unlocked: false, next: [218] },
                            { id: 218, name: "Навык 2", x: 108, y: 412, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 219, name: "Навык 1", x: 147, y: 415, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [220] },
                            { id: 220, name: "Навык 2", x: 147, y: 430, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
    Barbarian: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 31, name: "Скорость", x: 280, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: true, next: [33] },
                            { id: 33, name: "Контрудар", x: 300, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 156, offsetY: 0, unlocked: false, next: [35] },
                            { id: 35, name: "Вампиризм", x: 320, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [37] },
                            { id: 37, name: "ХП", x: 340, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 156, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 32, name: "БРОНЯ", x: 280, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: true, next: [34] },
                            { id: 34, name: "ХП", x: 300, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 232, offsetY: 0, unlocked: false, next: [36] },
                            { id: 36, name: "ХП", x: 320, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [38] },
                            { id: 38, name: "БРОНЯ", x: 340, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 232, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",
                
                type: "unique",
                skill: { id: 300, name: "Прилив крови", x: 355, y: 208, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 148, offsetY: 104, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 39, name: "Навык 1", x: 395, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [316] },
                            { id: 316, name: "Навык 2", x: 415, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0,unlocked: false, next: [310] },
                            { id: 310, name: "Навык 2", x: 435, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 232, offsetY: 0,unlocked: false, next: [311] },
                            { id: 311, name: "Навык 2", x: 455, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 232, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 312, name: "Навык 1", x: 395, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [313] },
                            { id: 313, name: "Навык 2", x: 415, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [314] },
                            { id: 314, name: "Навык 2", x: 435, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 156, offsetY: 0, unlocked: false, next: [315] },
                            { id: 315, name: "Навык 2", x: 455, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 156, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 301, name: "Кровожадный молот", x: 470, y: 208, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 75, offsetY: 104, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 317, name: "Навык 1", x: 510, y: 210, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 156, offsetY: 0, unlocked: false, next: [318] },
                            { id: 318, name: "Навык 2", x: 530, y: 200, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 319, name: "Навык 1", x: 510, y: 230, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 232, offsetY: 0, unlocked: false, next: [320] },
                            { id: 320, name: "Навык 2", x: 530, y: 240, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
    Hunter: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 41, name: "Скорость", x: 230, y: 180, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [42] },
                            { id: 42, name: "Контрудар", x: 230, y: 165, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [43] },
                            { id: 43, name: "Вампиризм", x: 230, y: 150, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [44] },
                            { id: 44, name: "ХП", x: 215, y: 140, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 45, name: "БРОНЯ", x: 215, y: 192, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: true, next: [46] },
                            { id: 46, name: "ХП", x: 203, y: 182, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [47] },
                            { id: 47, name: "ХП", x: 190, y: 172, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [48] },
                            { id: 48, name: "БРОНЯ", x: 190, y: 158, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",  
                type: "unique",
                skill: { id: 400, name: "Зоопарк", x: 178, y: 120, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives2.png", offsetX: 148, offsetY: 0, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 49, name: "Навык 1", x: 190, y: 105, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0,unlocked: false, next: [410] },
                            { id: 410, name: "Навык 2", x: 190, y: 90, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0,unlocked: false, next: [411] },
                            { id: 411, name: "Навык 2", x: 190, y: 75, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0,unlocked: false, next: [412] },
                            { id: 412, name: "Навык 2", x: 175, y: 65, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 413, name: "Навык 1", x: 165, y: 120, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [414] },
                            { id: 414, name: "Навык 2", x: 152, y: 110, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [415] },
                            { id: 415, name: "Навык 2", x: 138, y: 100, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [416] },
                            { id: 416, name: "Навык 2", x: 138, y: 85, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 401, name: "Точный выстрел", x: 135, y: 47, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives2.png", offsetX: 0, offsetY: 74, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 417, name: "Навык 1", x: 147, y: 30, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [418] },
                            { id: 418, name: "Навык 2", x: 147, y: 15, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 419, name: "Навык 1", x: 122, y: 47, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [420] },
                            { id: 420, name: "Навык 2", x: 108, y: 37, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
    Assasin: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 55, name: "Скорость", x: 265, y: 250, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [56] },
                            { id: 56, name: "Контрудар", x: 277, y: 260, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [57] },
                            { id: 57, name: "Вампиризм", x: 290, y: 270, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [58] },
                            { id: 58, name: "ХП", x: 290, y: 285, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 51, name: "БРОНЯ", x: 250, y: 260, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [52] },
                            { id: 52, name: "ХП", x: 250, y: 275, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0, unlocked: false, next: [53] },
                            { id: 53, name: "ХП", x: 250, y: 290, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 130, offsetY: 0, unlocked: false, next: [54] },
                            { id: 54, name: "БРОНЯ", x: 265, y: 300, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",  
                type: "unique",
                skill: { id: 500, name: "Подлый удар", x: 278, y: 300, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 178, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 513, name: "Навык 1", x: 315, y: 325, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0,unlocked: false, next: [514] },
                            { id: 514, name: "Навык 2", x: 328, y: 335, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0,unlocked: false, next: [515] },
                            { id: 515, name: "Навык 2", x: 341, y: 345, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 104, offsetY: 0,unlocked: false, next: [516] },
                            { id: 516, name: "Навык 2", x: 341, y: 360, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 59, name: "Навык 1", x: 290, y: 340, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [510] },
                            { id: 510, name: "Навык 2", x: 290, y: 355, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [511] },
                            { id: 511, name: "Навык 2", x: 290, y: 370, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [512] },
                            { id: 512, name: "Навык 2", x: 305, y: 380, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 501, name: "Тёмный убийца", x: 320, y: 375, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 74, offsetY: 178, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 519, name: "Навык 1", x: 357, y: 400, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [520] },
                            { id: 520, name: "Навык 2", x: 371, y: 412, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 517, name: "Навык 1", x: 333, y: 415, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 130, offsetY: 0, unlocked: false, next: [518] },
                            { id: 518, name: "Навык 2", x: 333, y: 430, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
    Ranger: {
        branches: [
            {
                id: 1,
                name: "Начальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 11,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 61, name: "Скорость", x: 250, y: 180, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [62] },
                            { id: 62, name: "Контрудар", x: 250, y: 165, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [63] },
                            { id: 63, name: "Вампиризм", x: 250, y: 150, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [64] },
                            { id: 64, name: "ХП", x: 265, y: 140, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 12,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 65, name: "БРОНЯ", x: 265, y: 192, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: true, next: [66] },
                            { id: 66, name: "ХП", x: 277, y: 182, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [67] },
                            { id: 67, name: "ХП", x: 290, y: 172, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [68] },
                            { id: 68, name: "БРОНЯ", x: 290, y: 158, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 2,
                name: "Уникальный навык",  
                type: "unique",
                skill: { id: 600, name: "Слабое место", x: 278, y: 120, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives2.png", offsetX: 0, offsetY: 0, unlocked: false, next: [3] },
            },
            {
                id: 3,
                name: "Новые ветки",
                type: "choice",
                branches: [
                    {
                        id: 31,
                        name: "Верхняя",
                        skills: [
                            { id: 69, name: "Навык 1", x: 290, y: 105, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0,unlocked: false, next: [610] },
                            { id: 610, name: "Навык 2", x: 290, y: 90, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0,unlocked: false, next: [611] },
                            { id: 611, name: "Навык 2", x: 290, y: 75, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0,unlocked: false, next: [612] },
                            { id: 612, name: "Навык 2", x: 305, y: 65, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0,unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 32,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 613, name: "Навык 1", x: 315, y: 120, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [614] },
                            { id: 614, name: "Навык 2", x: 328, y: 110, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 0, offsetY: 0, unlocked: false, next: [615] },
                            { id: 615, name: "Навык 2", x: 341, y: 100, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [616] },
                            { id: 616, name: "Навык 2", x: 341, y: 85, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                ],
            },
            {
                id: 4,
                name: "Финальный уникальный навык",
                type: "unique",
                skill: { id: 601, name: "Отравленные стрелы", x: 320, y: 47, width: 36, height: 36, nameTexture: "minecraft:textures/gui/passives2.png", offsetX: 74, offsetY: 0, unlocked: false, next: [5] },
            },
            {
                id: 5,
                name: "Финальные ветки",
                type: "choice",
                branches: [
                    {
                        id: 51,
                        name: "Верхняя ветка",
                        skills: [
                            { id: 617, name: "Навык 1", x: 333, y: 30, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 78, offsetY: 0, unlocked: false, next: [618] },
                            { id: 618, name: "Навык 2", x: 333, y: 15, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                    },
                    {
                        id: 52,
                        name: "Нижняя ветка",
                        skills: [
                            { id: 619, name: "Навык 1", x: 357, y: 47, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 182, offsetY: 0, unlocked: false, next: [620] },
                            { id: 620, name: "Навык 2", x: 371, y: 37, width: 12, height: 12, nameTexture: "minecraft:textures/gui/passives.png", offsetX: 208, offsetY: 0, unlocked: false, next: [] },
                        ],
                        // gui.addTexturedButton(119,"",-35,230,12,12,"minecraft:textures/gui/passives.png",0,0); //хп
                    },
                ],
            },
        ],
    },
};

function drawing(event, player, storedData, selectClass, skillTree) {
    var gui = event.API.createCustomGui(0, 500, 500, false);        
    gui.addButton(10, "Очистить", 400, 400);

    // Выбор классов
    if(selectClass >= 1 && selectClass <= 6) {
        var classNames = ["Воин", "Варвар", "Вор", "Ассасин", "Охотник", "Рейнджер"];
        var classCoordinates = [220, 260, 230, 250, 230, 250];
        var classOffsets = [220, 220, 240, 240, 200, 200];
        var classIcons = [0, 78, 26, 52, 104, 130];

        for(var i = 0; i < 6; i++) {
            if(selectClass != (i + 1)) {
                gui.addTexturedRect(i + 1, "minecraft:textures/gui/classes.png", classCoordinates[i], classOffsets[i], 12, 12, classIcons[i], 0);
            } else {
                gui.addTexturedButton(i + 1, "", classCoordinates[i], classOffsets[i], 12, 12, "minecraft:textures/gui/classes.png", classIcons[i] + 12, 0);
            }
            gui.getComponent(i + 1).setHoverText("§a" + classNames[i]);
        }
    } else {
        var classNames = ["Воин", "Варвар", "Вор", "Ассасин", "Охотник", "Рейнджер"];
        var classCoordinates = [220, 260, 230, 250, 230, 250];
        var classOffsets = [220, 220, 240, 240, 200, 200];
        var classIcons = [0, 78, 26, 52, 104, 130];
    
        for(var i = 0; i < 6; i++) {
            gui.addTexturedButton(i + 1, "", classCoordinates[i], classOffsets[i], 12, 12, "minecraft:textures/gui/classes.png", classIcons[i], 0);
            gui.getComponent(i + 1).setHoverText("§a" + classNames[i]);
        }
    }    

    // Отрисовка дерева навыков
    drawSkillTree(skillTree, event, gui);    
    player.showCustomGui(gui);
}

function drawSkillTree(skillTree, event, gui) {
    if (!skillTree) {
        event.player.message("Дерево навыков undefined");
        return;
    }

    // Обрабатываем дерево навыков для каждого класса
    var classes = ['Knight', 'Thief', 'Barbarian', 'Hunter', 'Assasin', 'Ranger'];
    
    classes.forEach(function(className) {
        if (skillTree[className]) {
            for (var i = 0; i < skillTree[className].branches.length; i++) {
                var branch = skillTree[className].branches[i];
        
                if (branch.type === "choice") {
                    for (var j = 0; j < branch.branches.length; j++) {
                        var subBranch = branch.branches[j];
                        for (var k = 0; k < subBranch.skills.length; k++) {
                            var skill = subBranch.skills[k];
                            if (skill.unlocked) {
                                // Добавляем доступные кнопки
                                gui.addTexturedButton(skill.id, "", skill.x, skill.y, skill.width, skill.height, skill.nameTexture, skill.offsetX, skill.offsetY);
                            } else {
                                // Добавляем заблокированные кнопки как текстуры
                                gui.addTexturedRect(skill.id, skill.nameTexture, skill.x, skill.y, skill.width, skill.height, skill.offsetX, skill.offsetY);
                            }

                            if (skill.next && skill.next.length > 0) {
                                for (var l = 0; l < skill.next.length; l++) {
                                    var nextSkillId = skill.next[l];
                                    var nextSkill = getSkillById(nextSkillId, skillTree, className);
                                    if (nextSkill && nextSkill.unlocked) {
                                        // Если следующий навык доступен, показываем кнопку
                                        gui.addTexturedButton(nextSkill.id, "", nextSkill.x, nextSkill.y, nextSkill.width, nextSkill.height, nextSkill.nameTexture, nextSkill.offsetX, nextSkill.offsetY);
                                    }
                                }
                            }
                        }
                    }
                }

                if (branch.type === "unique" && branch.skill) {
                    var skill = branch.skill;
                    if (skill.unlocked) {
                        gui.addTexturedButton(skill.id, "", skill.x, skill.y, skill.width, skill.height, skill.nameTexture, skill.offsetX, skill.offsetY);
                    } else {
                        gui.addTexturedRect(skill.id, skill.nameTexture, skill.x, skill.y, skill.width, skill.height, skill.offsetX, skill.offsetY);
                    }
                }
            }
        }
    });
}

function getSkillById(skillId, skillTree, className) {
    if (!skillTree[className]) return null;

    for (var i = 0; i < skillTree[className].branches.length; i++) {
        var branch = skillTree[className].branches[i];
        if (branch.type === "choice") {
            for (var j = 0; j < branch.branches.length; j++) {
                var subBranch = branch.branches[j];
                for (var k = 0; k < subBranch.skills.length; k++) {
                    var skill = subBranch.skills[k];
                    if (skill.id === skillId) return skill;
                }
            }
        }
        if (branch.type === "unique" && branch.skill.id === skillId) {
            return branch.skill;
        }
    }
    return null;
}

function keyPressed(event) {
    var player = event.player;   
    var gui = event.gui; 
    var key = event.key;
    var storedData = event.player.getStoreddata();    
    var selectClass = storedData.get("button");
    if(key == "80") {
        drawing(event, player, storedData, selectClass, skillTree);
    }    
}

function customGuiButton(event) {
    var player = event.player;    
    var gui = event.gui;
    var button = gui.getComponent(event.buttonId).getID();    
    var storedData = player.getStoreddata();    
    storedData.put("button", button);
    var selectClass = storedData.get("button");

    switch(button) {        
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            drawing(event, player, storedData, selectClass, skillTree);
            break;
        case 10:
            drawing(event, player, storedData, selectClass, skillTree);    
    }
    
    event.player.message(selectClass);
    gui.update(player);
}

function init(event) {
    var storedData = event.player.getStoreddata();    
    var selectClass = storedData.get("button");
    event.player.message(selectClass);
}
Editor is loading...
Leave a Comment