/* * Copyright (c) 2023 Vladimir Skrypnikov (Pheonix KageDesu) * * * License: Creative Commons 4.0 Attribution, Share Alike, Commercial */ /*: * @plugindesc (v.1.1)[PRO] Game Difficulty * @author Pheonix KageDesu * @target MZ MV * @url https://kdworkshop.net/plugins/game-difficulty * * @help * --------------------------------------------------------------------------- * Level Difficulty coefficient for Damage Formula: dcf * Example: (a.atk * 4 - b.def * 2) * dcf * * Current level difficulty shortcut: dlv * Example $gameVariables.setValue(10, dlv) * Or you can use script call: gdGetCurrentDifficultyLevel(); * * =========================================================================== * * Script Calls: * * - Set difficulty level (LEVEL - number or NAME) * gdSetDifficulty(LEVEL_OR_NAME); * Example: gdSetDifficulty(1); * Example: gdSetDifficulty('Easy'); * * - Return current difficulty level (as number) * gdGetCurrentDifficultyLevel(); * * - Return current difficulty level (as name) * gdGetCurrentDifficultyName(); * * - Chech is current difficulty is LEVEL_OR_NAME difficulty * gdIsDifficulty(LEVEL_OR_NAME); * Example: gdIsDifficulty('Hard'); return true or false * * - Save current difficulty level (number) to variable VAR_ID * gdSaveDifficultyToVariable(VAR_ID); * Example: gdSaveDifficultyToVariable(10); * * =========================================================================== * * Special comments for Game Events Commands * * You can set game difficulty based condition shortcut for * execute certain Event Command * (not works with Show message commands, Common Event command recommended) * * Add comment (before Event Command condition for): ifdif * * You can specify next conditions for difficulty level * ifdif>X - it's mean difficulty level higher then X * ifdif#X - it's mean any difficulty level BUT NOT X * ifdif=X - it's mean difficulty level equal X * ifdif1 * ifdif#Hard * * More examples you can find in Demo project * =========================================================================== * * Enemies extra drop items: * * Depends on difficulty you can add extra drop items for enemies * * Add special condition code to enemy Note's section * (you can add more then one conditions for diffrent difficulties) * * * addDrop:TYPE:ID:AMOUNT:CHANCE * ... * * * X = difficulty level (number) * TYPE = type, one of w, i, a (weapon, item, armor) * ID = database ID, can be Extended Value * Read more here: https://github.com/KageDesu/Alpha-ABS-Z/wiki/Extended-Values * AMOUNT - number, can be Extended Value * CHANCE - chance in %, can be Extended Value * * You can specify conditions for difficulty level * * - it's mean difficulty level equal X * - it's mean difficulty level X or higher * it's mean difficulty level X or less * it's mean any difficulty level BUT NOT X * * Example: * * // if difficulty level == 2 * addDrop:w:3:1:50 // add weapon (w) with ID (3) amount (1) chance 50% * addDrop:i:[10,11,12]:[1,2]:1|V * // add item (i) with ID one of (10, 11, 12) * //amount 1 or 2, chance from variable 1 * * * * =========================================================================== * * Enemies extra actions: * * Depends on difficulty you can add extra actions (skills) for enemies * * Works in same way as Extra Drop Items (see above) * * * addSkill:SKILL_ID:RATING * ... * * * Exmaple: addSkill:20:5 // Add skill ID 20 (Bodyslam) as extra Action (witn Condition = Always, Rating = 5) addDrop:w:3:1:50 * * * More examples you can find in Demo project * * =========================================================================== * [BASIC] version of plugin have some restrictions: * - You can add only 2 difficulties to your game [Difficulties Table] * - Using in commercial projects NOT allowed * - Some plugin code is obfustaced * * [PRO] version of plugin don't have this restrictions! * * --------------------------------------------------------------------------- * If you like my Plugins, want more and offten updates, * please support me on Boosty or Patreon! * * Boosty Page: * https://boosty.to/kagedesu * Patreon Page: * https://www.patreon.com/KageDesu * YouTube Channel: * https://www.youtube.com/channel/UCA3R61ojF5vp5tGwJ1YqdgQ? * * You can use this plugin in your game thanks to all my Patrons! * * License: Creative Commons 4.0 Attribution, Share Alike, Commercial * * @param isGlobalGameDifficulty:b * @text Is Global Difficulty? * @type boolean * @on Global * @off No * @default true * @desc Global - player can change difficulty in Options menu in any time in game. * * @param difficultyOptionTitle * @parent isGlobalGameDifficulty:b * @text Option name * @default Difficulty * @desc Option title, only if difficulty is Global * * @param initialGameDifficultyLevel:int * @type number * @min 0 * @text Initial Difficulty * @default 0 * @desc Initial (default) difficulty level in game * * @param difficultyTable:structA * @text Difficulties Table * @type struct[] * @desc Difficulties levels and settings in your game. Minimum 2 difficulty levels is required. * @default ["{\"name:str\":\"Normal\",\"paramsMod:s\":\"{\\\"mhp:i\\\":\\\"100\\\",\\\"mmp:i\\\":\\\"100\\\",\\\"atk:i\\\":\\\"100\\\",\\\"def:i\\\":\\\"100\\\",\\\"mat:i\\\":\\\"100\\\",\\\"mdf:i\\\":\\\"100\\\",\\\"agi:i\\\":\\\"100\\\",\\\"luk:i\\\":\\\"100\\\"}\",\"goldMod:i\":\"100\",\"expMod:i\":\"100\",\"ignoreEnemy:intA\":\"[]\",\"enemyReplace:structA\":\"[]\",\"damageFormulaMod:i\":\"1.0\"}","{\"name:str\":\"Hard\",\"paramsMod:s\":\"{\\\"mhp:i\\\":\\\"150\\\",\\\"mmp:i\\\":\\\"150\\\",\\\"atk:i\\\":\\\"120\\\",\\\"def:i\\\":\\\"120\\\",\\\"mat:i\\\":\\\"120\\\",\\\"mdf:i\\\":\\\"120\\\",\\\"agi:i\\\":\\\"120\\\",\\\"luk:i\\\":\\\"120\\\"}\",\"goldMod:i\":\"120\",\"expMod:i\":\"120\",\"ignoreEnemy:intA\":\"[]\",\"enemyReplace:structA\":\"[]\",\"damageFormulaMod:i\":\"1.0\"}"] * * @param spacer|endHolder @text‏‏‎ ‎@desc =============================================== * * @command EMPTY_HOLDER * @text ‏ * @desc * @default */ /* * Copyright (c) 2023 Vladimir Skrypnikov (Pheonix KageDesu) * * * Лицензия: Creative Commons 4.0 Attribution, Share Alike, Commercial */ /*:ru * @plugindesc (v.1.1)[PRO] Сложность в игре * @author Pheonix KageDesu * @target MZ MV * @url https://kdworkshop.net/plugins/game-difficulty * * @help * --------------------------------------------------------------------------- * Специальный коэффициент для формул урона: dcf * Пример: (a.atk * 4 - b.def * 2) * dcf * (значение коэффициента можно настроить в параметрах * плагина для каждой сложности) * * Текущая сложность: dlv * Пример: $gameVariables.setValue(10, dlv) * Или вызов скрипта: gdGetCurrentDifficultyLevel(); * * =========================================================================== * * Вызовы скриптов: * * - Установить уровень сложности * gdSetDifficulty(номер_или_название); * Пример: gdSetDifficulty(1); * Пример: gdSetDifficulty('Легко'); * * - Возвращает текущую сложность (номер) * gdGetCurrentDifficultyLevel(); * * - Возвращает текущую сложность (название) * gdGetCurrentDifficultyName(); * * - Проверить текущая сложность соответствует данной * gdIsDifficulty(номер_или_название); * Пример: gdIsDifficulty('Высокая'); * * - Сохранить текущую сложность (номер) в переменную * gdSaveDifficultyToVariable(НОМЕР_ПЕРЕМЕННОЙ); * Пример: gdSaveDifficultyToVariable(10); * * =========================================================================== * * Специальный коммент условие для команды событий * * Вы можете задать условие выполнения команды события на основе * текущей сложности игры * (рекомендуется для команды вызов общего события) * * Добавьте комментарий (перед необходимой командой): ifdif * * Возможные варианты условий для уровня сложности (Х) * ifdif>X - больше Х * ifdif#X - любая сложность, но НЕ Х * ifdif=X - строго равно Х * ifdif1 * ifdif#Высокая * * Больше примеров условий можно найти в Демке * =========================================================================== * * Дополнительный дроп (лут) вещей из врагов: * * В зависимости от сложности можно назначить доп. вещи * которые будут даваться игроку при победе над тем или иным * монстром * * В Заметку к врагу в БД добавьте следующее условие * (можно добавлять много условий) * * * addDrop:TYPE:ID:AMOUNT:CHANCE * ... * * * X = номер сложности * TYPE = тип, один из w, i, a (w - оружие, i - предмет, a - броня) * ID = новем вещи из БД (можно исп. расширенное значение) * Подробнее тут: https://github.com/KageDesu/Alpha-ABS-Z/wiki/Extended-Values * AMOUNT - количество (число), (можно исп. расширенное значение) * CHANCE - шанс в %, (можно исп. расширенное значение) * * Возможные варианты условий для уровня сложности (Х) * * - строго равно Х * - Х или выше * Х или ниже * любая сложность, но НЕ Х * * Пример: * * // если сложность текущая == 2 * addDrop:w:3:1:50 // добавить оружие (w) с номером в БД (3) кол-во (1) шанс 50% * addDrop:i:[10,11,12]:[1,2]:1|V * // добавить вещь (i) с номером в БД -> занчение одно из (10, 11, 12) * // количество 1 или 2, шанс будет из переменной 1 * * * =========================================================================== * * Дополнительные действия для врагов: * * В зависимости от сложности можно добавить доп. действия (навыки) * для врага * * Настраивается и работает аналогично дополнительному луту (смотри выше) * * * addSkill:SKILL_ID:RATING * ... * * * Exmaple: addSkill:20:5 // Добавить навык 20 (Bodyslam) (Рейтинг = 5) addDrop:w:3:1:50 * * * Больше примеров условий можно найти в Демке * * =========================================================================== * [БАЗОВАЯ] версия плагина имеет ряд ограничений: * - Можно добавить только 2 сложности в игру * - НЕЛЬЗЯ испоьзовать в коммерческих проектах (проектах, приносящих доход) * - Часть кода обфусцированна (не читаема, не редактируема) * * [ПРО] версия НЕ имеет ограничений! * * --------------------------------------------------------------------------- * Если Вам нравятся мои плагины, поддержите меня на Boosty! * * Boosty: * https://boosty.to/kagedesu * Patreon: * https://www.patreon.com/KageDesu * YouTube: * https://www.youtube.com/channel/UCA3R61ojF5vp5tGwJ1YqdgQ? * * * Лицензия: Creative Commons 4.0 Attribution, Share Alike, Commercial * * @param isGlobalGameDifficulty:b * @text Глобальная сложность? * @type boolean * @on Глобальная * @off Локальная * @default true * @desc Глобальная - сложность на всю игру, можно менять в настройках. Локальная - хранится в файле сохранения. * * @param difficultyOptionTitle * @parent isGlobalGameDifficulty:b * @text Название опции * @default Сложность * @desc Название опции для смены сложности в меню настроек игры * * @param initialGameDifficultyLevel:int * @type number * @min 0 * @text Начальная сложность * @default 0 * @desc Начальная (стандартная) сложность в игре (индекс) * * @param difficultyTable:structA * @text Сложности * @type struct[] * @desc Все сложности в игре и их настройки. ОБЯЗАТЕЛЬНО! -> Миним 2 уровня сложности. * @default ["{\"name:str\":\"Normal\",\"paramsMod:s\":\"{\\\"mhp:i\\\":\\\"100\\\",\\\"mmp:i\\\":\\\"100\\\",\\\"atk:i\\\":\\\"100\\\",\\\"def:i\\\":\\\"100\\\",\\\"mat:i\\\":\\\"100\\\",\\\"mdf:i\\\":\\\"100\\\",\\\"agi:i\\\":\\\"100\\\",\\\"luk:i\\\":\\\"100\\\"}\",\"goldMod:i\":\"100\",\"expMod:i\":\"100\",\"ignoreEnemy:intA\":\"[]\",\"enemyReplace:structA\":\"[]\",\"damageFormulaMod:i\":\"1.0\"}","{\"name:str\":\"Hard\",\"paramsMod:s\":\"{\\\"mhp:i\\\":\\\"150\\\",\\\"mmp:i\\\":\\\"150\\\",\\\"atk:i\\\":\\\"120\\\",\\\"def:i\\\":\\\"120\\\",\\\"mat:i\\\":\\\"120\\\",\\\"mdf:i\\\":\\\"120\\\",\\\"agi:i\\\":\\\"120\\\",\\\"luk:i\\\":\\\"120\\\"}\",\"goldMod:i\":\"120\",\"expMod:i\":\"120\",\"ignoreEnemy:intA\":\"[]\",\"enemyReplace:structA\":\"[]\",\"damageFormulaMod:i\":\"1.0\"}"] * * @param spacer|endHolder @text‏‏‎ ‎@desc =============================================== * * @command EMPTY_HOLDER * @text ‏ * @desc * @default */ /*~struct~str19: @param mhp:i @text Max HP @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param mmp:i @text Max MP @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param atk:i @text Attack @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param def:i @text Defense @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param mat:i @text M.Attack @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param mdf:i @text M.Dfense @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param agi:i @text Agility @type number @min 1 @desc Value in % (100 = 100%) @default 100 @param luk:i @text Luck @type number @min 1 @desc Value in % (100 = 100%) @default 100 */ /*~struct~str19:ru @param mhp:i @text Макс. здоровье @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param mmp:i @text Макс. мана @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param atk:i @text Атака @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param def:i @text Защита @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param mat:i @text М. Атака @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param mdf:i @text М. Защита @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param agi:i @text Ловкость @type number @min 1 @desc Значение в % (100 = 100%) @default 100 @param luk:i @text Удача @type number @min 1 @desc Значение в % (100 = 100%) @default 100 */ /*~struct~str20: @param enemyReplaced:i @text Enemy Id A @type enemy @min 1 @desc Enemy Id that will be replaced @default 1 @param enemyReplaceTo:i @text Enemy Id B @type enemy @min 1 @desc New Enemy Id @default 1 */ /*~struct~str20:ru @param enemyReplaced:i @text ID Врага 1 @type enemy @min 1 @desc ID (номер) врага из базы данных, который будет ЗАМЕНЁН @default 1 @param enemyReplaceTo:i @text ID Врага 2 @type enemy @min 1 @desc ID (номер) врага из базы данных, который будет ЗАМЕСТО @default 1 */ /*~struct~str21: @param name:str @text Name @type text @desc Difficulty level name (for options menu and script calls) @default Easy @param paramsMod:s @text Parameters @type struct @desc Modificators of enemy parameters values on this difficulty @default {"mhp:i":"100","mmp:i":"100","atk:i":"100","def:i":"100","mat:i":"100","mdf:i":"100","agi:i":"100","luk:i":"100"} @param goldMod:i @text Gold modifier @type number @min 1 @desc Gold dropped from enemies. Value in % (100 = 100%) @default 100 @param expMod:i @text Exp modifier @type number @min 1 @desc Exp from enemies. Value in % (100 = 100%) @default 100 @param ignoreEnemy:intA @text Ignore List @type number[] @min 1 @desc Enemies ID's that will be ignored by parameters modificators on this difficulty @default [] @param enemyReplace:structA @text Replace List @type struct[] @desc Enemies ID's that will be replaced by another Enemies in battle on this difficulty level. @default [] @param troopReplace:structA @text Replace List (T) @type struct[] @desc Enemies troops ID's that will be replaced by another Troop in battle on this difficulty level. @default [] @param damageFormulaMod:i @text Damage Coef (dcf) @type number @decimals 1 @min 0.1 @desc Special value for using in Damage Formulas. Example: a.atk * dcf @default 1.0 */ /*~struct~str21:ru @param name:str @text Название @type text @desc Название сложности (можно использовать в вызовах скрипта) @default Easy @param paramsMod:s @text Модификаторы @type struct @desc Модификаторы базовых параметров врагов на этой сложности @default {"mhp:i":"100","mmp:i":"100","atk:i":"100","def:i":"100","mat:i":"100","mdf:i":"100","agi:i":"100","luk:i":"100"} @param goldMod:i @text Золото @type number @min 1 @desc Модификатор золота (от врагов). Значение в % (100 = 100%) @default 100 @param expMod:i @text Опыт @type number @min 1 @desc Модификатор опыта (от врагов). Значение в % (100 = 100%) @default 100 @param ignoreEnemy:intA @text Игнорировать @type number[] @min 1 @desc Список врагов (номер из БД), которые будут игнорироваться (к ним не будут применены модификаторы) @default [] @param enemyReplace:structA @text Замена @type struct[] @desc Список врагов на замену на этом уровне сложности. Один враг будет меняться другим в начале боя @default [] @param troopReplace:structA @text Замена (отряд) @type struct[] @desc Список отрядов на замену на этом уровне сложности. Отряд будет заменён другим в начале боя @default [] @param damageFormulaMod:i @text Урон @type number @decimals 1 @min 0.1 @desc Специальный модификатор (dcf) (его значение) для формулы урона. Пример: a.atk * dcf @default 1.0 */ /*~struct~TroopRelaceData: @param troopReplaced:i @text Troop Id A @type troop @min 1 @desc Troop Id that will be replaced @default 1 @param troopReplaceTo:i @text Troop Id B @type troop @min 1 @desc New Troop Id @default 1 */ // Generated by CoffeeScript 2.6.1 var PKD_GameDifficulty; window.Imported = window.Imported || {}; Imported.PKD_GameDifficulty = true; PKD_GameDifficulty = {}; PKD_GameDifficulty.version = 110; // * LITE: mod PKDGD.PP.getDifficultyTable() method PKD_GameDifficulty.isPro = function() { return true; }; // * For parameters PKD_GameDifficulty.PP = {}; // * Загрзука параметров PKD_GameDifficulty.LoadPluginSettings = function() { PKD_GameDifficulty.PP._loader = new KDParamLoaderLite_forPKDGD("PKD_GameDifficulty"); // * Применение начальной сложности if (ConfigManager.pGDLevel == null) { ConfigManager.pGDLevel = PKD_GameDifficulty.PP.initialGameDifficultyLevel(); } if (PKDGD.PP.getDifficultyTable().length < 2) { window.alert("You should add at least two difficulties levels to game!"); } }; Object.defineProperties(window, { dcf: { get: function() { return $gameSystem.pGetDifficultySettings().damageFormulaKoef(); } }, dlv: { get: function() { return window.gdGetCurrentDifficultyLevel(); } } }); PKD_GameDifficulty.getDifficultyLevelByName = function(name) { var item, table; table = PKDGD.PP.getDifficultyTable(); item = table.getByField("name", name); if (item != null) { return table.indexOf(item); } else { return -1; } }; PKD_GameDifficulty.getDifficultyNameByLevel = function(level) { var table; table = PKDGD.PP.getDifficultyTable(); if (table[level] != null) { return table[level].name; } else { return ""; } }; //@[SHORTCUT] window.PKDGD = PKD_GameDifficulty; // ------------------------------------------------------- //%[I] ИДЕИ ДЛЯ ОБНОВЛЕНИЙ // ДЛЯ ОБНОВЛЕНИЙ ::: //НАВЫКИ: тоже желательно Note условия (например поменять затраты маны) или вообще заменить скилл //ОРУЖИЕ, ВЕЩИ: Тоже Note Добвить, чтобы цену и параметры менять // Экран выбора сложности!! (на картинках основан) // Generated by CoffeeScript 2.6.1 (function() { if (window.KDCore != null) { return; } // * Ищет элемент, у которого поле FIELD (имя поля) == value Array.prototype.getByField = function(field, value) { var e; try { return this.find(function(item) { return item[field] === value; }); } catch (error) { e = error; console.warn(e); return null; } }; Array.prototype.sample = function() { var rand; if (this.length === 0) { return []; } rand = function(min, max) { return Math.round(Math.random() * (max - min)) + min; }; return this[rand(0, this.length - 1)]; }; String.prototype.isEmpty = function() { return this.length === 0 || !this.trim(); }; String.isNullOrEmpty = function(str) { if (str != null) { return str.toString().isEmpty(); } else { return true; } }; String.any = function(str) { return !String.isNullOrEmpty(str); }; })(); // Generated by CoffeeScript 2.6.1 (function() { var _; PKD_GameDifficulty.KUtils = {}; _ = PKD_GameDifficulty.KUtils; _.getItemByType = function(itemId, typeId) { var data, e; try { if ((typeId != null) && !isFinite(typeId) && String.any(typeId)) { if (typeId[0] === "w") { typeId = 1; } else if (typeId[0] === "a") { typeId = 2; } else { typeId = 0; } } data = [$dataItems, $dataWeapons, $dataArmors]; return data[typeId][itemId]; } catch (error) { e = error; console.warn(e); return null; } }; // * Преобразовать расширенное значение // * Значение может быть X -> X // * "X" -> X (цифра) // * "X,Y,Z,..." -> [X, Y, Z] // * "[X, Y, Z,...]" -> [X, Y, Z] // * "X|V" -> из переменной X // * [Y] -> случайное число из массива (рекурсивно) //@[2.8.1] since _.getEValue = function(value) { var e, items, randomValue, variableId; try { if (value == null) { return null; } if (typeof value === "string") { if (isFinite(value)) { // * Число представленно строкой return Number(value); } // * Массив представлен строкой (может быть без квадратных скобок) if (value.contains(',') || (value.contains("[") && value.contains("]"))) { value = value.replace("[", ""); value = value.replace("]", ""); // * Преобразуем в число или строку (например если extended |V) items = value.split(",").map(function(item) { var itemT; itemT = item.trim(); if (isFinite(itemT)) { return Number(itemT); } else { return itemT; } }); // * Вызываем снова эту функцию, но уже с массивом return this.getEValue(items); } if (value.contains("|V")) { variableId = parseInt(value); return $gameVariables.value(variableId); } return value; // * Просто значение в итоге } else if (Array.isArray(value)) { randomValue = value.sample(); return this.getEValue(randomValue); } else { return value; } } catch (error) { e = error; console.warn(e); return value; } }; //@[2.8.2] since _.isChanceIsGood = function(chance) { var e; try { if (chance > 1) { chance /= 100; } return chance > Math.random(); } catch (error) { e = error; console.warn(e); return false; } }; //@[2.8.2] since //KEY:w:3:1:50 , KEY:i:10:2:1|V //OUTPUT: [GameItem, COUNT] _.parseItemFromConditionStr = function(conditionLine) { var amount, e, itemChance, itemId, parts, typeId; try { if (!conditionLine.contains(":")) { return null; } parts = conditionLine.split(":"); typeId = parts[1]; itemId = this.getEValue(parts[2]); amount = this.getEValue(parts[3]); if (amount <= 0) { return null; } try { itemChance = String.any(parts[4]) ? parts[4] : 100; itemChance = this.getEValue(itemChance) / 100; } catch (error) { e = error; console.warn(e); itemChance = 0; } if (itemChance <= 0) { return null; } if (this.isChanceIsGood(itemChance)) { return [this.getItemByType(itemId, typeId), amount]; } else { return null; } } catch (error) { e = error; console.warn(e); return null; } }; })(); // Generated by CoffeeScript 2.6.1 // * Класс аналог KDCore.ParamLoader, но упрощённый, чтобы всю библиотеку не тащить var KDParamLoaderLite_forPKDGD; KDParamLoaderLite_forPKDGD = (function() { class KDParamLoaderLite_forPKDGD { constructor(pluginName) { this.pluginName = pluginName; this.paramsRaw = PluginManager.pParametersUnsafe(this.pluginName); if (!this.isLoaded()) { return; } this.params = this.parseParameters(this.paramsRaw); return; } isLoaded() { return this.paramsRaw != null; } parseParameters(paramSet) { var clearKey, key, params, typeKey, value; params = {}; for (key in paramSet) { value = paramSet[key]; clearKey = this.parseKey(key); typeKey = this.parseKeyType(key); params[clearKey] = this.parseParamItem(typeKey, value); } return params; } parseKey(keyRaw) { return keyRaw.split(":")[0]; } parseKeyType(keyRaw) { return keyRaw.split(":")[1]; } // * Имя параметра без ключа isHasParameter(paramName) { if (!this.isLoaded()) { return false; } else { return this.params[paramName] != null; } } // * Возвращает значение параметра (def - по умолчанию, если не найден) getParam(paramName, def) { var value; if (this.isHasParameter(paramName)) { value = this.params[paramName]; if (value != null) { return value; } } return def; } parseParamItem(type, item) { var e; try { if (type == null) { return item; } switch (type) { case "int": case "i": return Number(item); case "intA": return this.parseArray(item, "int"); case "bool": case "b": case "e": return eval(item); case "struct": case "s": return this.parseStruct(item); case "structA": return this.parseStructArray(item); case "str": return item; case "strA": return this.parseArray(item, "str"); case "note": return this.parseNote(item); case "css": if (window.KDCore != null) { return item.toCss(); } else { return item; } break; case "color": if (window.KDCore != null) { return KDCore.Color.FromHex(item); } else { return item; } break; default: return item; } } catch (error) { e = error; console.warn(e); return item; } } parseArray(items, type) { var e, elements, i, len, p, parsed; try { elements = []; parsed = JsonEx.parse(items); for (i = 0, len = parsed.length; i < len; i++) { p = parsed[i]; try { elements.push(this.parseParamItem(type, p)); } catch (error) { e = error; console.warn(e); } } } catch (error) { e = error; console.warn(e); } return elements; } parseStruct(item) { var e, parsed; try { parsed = JsonEx.parse(item); if (parsed != null) { return this.parseParameters(parsed); } } catch (error) { e = error; console.warn(e); } return null; } parseStructArray(items) { var e, elements, i, len, p, parsed; try { elements = []; parsed = JsonEx.parse(items); for (i = 0, len = parsed.length; i < len; i++) { p = parsed[i]; try { elements.push(this.parseStruct(p)); } catch (error) { e = error; console.warn(e); } } } catch (error) { e = error; console.warn(e); } return elements; } parseNote(item) { var e, parsed; try { parsed = JsonEx.parse(item); if (parsed != null) { return parsed; } } catch (error) { e = error; console.warn(e); } return item; } }; KDParamLoaderLite_forPKDGD.Version = 100; return KDParamLoaderLite_forPKDGD; }).call(this); (function() { //╒═════════════════════════════════════════════════════════════════════════╛ // ■ PluginManager.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- var _; //@[DEFINES] _ = PluginManager; // * Не возвращает {}, а возвращает null, чтобы можно было проверить isLoaded _.pParametersUnsafe = function(name) { return this._parameters[name.toLowerCase()]; }; })(); // ■ END PluginManager.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Scripts API.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { window.gdSetDifficulty = function(levelOrName) { var e, level; try { if (isFinite(levelOrName)) { level = parseInt(levelOrName); } else { level = PKD_GameDifficulty.getDifficultyLevelByName(levelOrName); } if (level == null) { return; } if (isNaN(level)) { return; } if (level >= 0) { return $gameSystem.pSetDifficultyLevel(level); } } catch (error) { e = error; return console.warn(e); } }; window.gdGetCurrentDifficultyLevel = function() { var e; try { return $gameSystem.pGetDifficultyLevel(); } catch (error) { e = error; console.warn(e); return 0; } }; window.gdGetCurrentDifficultyName = function() { return gdGetDifficultyBy(gdGetCurrentDifficultyLevel()); }; window.gdGetDifficultyBy = function(levelOrName) { var e; try { if (isFinite(levelOrName)) { return PKD_GameDifficulty.getDifficultyNameByLevel(levelOrName); } else { return PKD_GameDifficulty.getDifficultyLevelByName(levelOrName); } } catch (error) { e = error; console.warn(e); return 0; } }; window.gdIsDifficulty = function(levelOrName) { var currentLevel, e, level; try { currentLevel = gdGetCurrentDifficultyLevel(); if (isFinite(levelOrName)) { level = parseInt(levelOrName); } else { level = PKD_GameDifficulty.getDifficultyLevelByName(levelOrName); } return currentLevel === level; } catch (error) { e = error; console.warn(e); return false; } }; window.gdSaveDifficultyToVariable = function(variableId) { var e, level; try { level = gdGetCurrentDifficultyLevel(); if (level == null) { return; } if (isNaN(level)) { return; } return $gameVariables.setValue(variableId, level); } catch (error) { e = error; return console.warn(e); } }; })(); // ■ END Scripts API.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Parameters.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- //$[ENCODE] (function() { var _; //@[DEFINES] _ = PKD_GameDifficulty.PP; // * Если true - то общая сложность игры (на все сохранения)(есть в настройках) // * Если false - то НЕТ в настройках, для каждого сохранения _.isGlobalDifficulty = function() { return this._loader.getParam("isGlobalGameDifficulty", true); }; // * Начальная сложность _.initialGameDifficultyLevel = function() { return this._loader.getParam("initialGameDifficulty", 0); }; _.difficultyOptionName = function() { return this._loader.getParam("difficultyOptionTitle", "Difficulty"); }; //?{VERSION} _.getDifficultyTable = function() {}; _._getDefaultDifficulties = function() { return [ { name: "Normal", paramsMod: { mhp: 100, mmp: 100, atk: 100, def: 100, mat: 100, mdf: 100, agi: 100, luk: 100 }, goldMod: 100, expMod: 100, ignoreEnemy: [], enemyReplace: [], troopReplace: [], damageFormulaMod: 1 }, { name: "Hard", paramsMod: { mhp: 150, mmp: 150, atk: 120, def: 120, mat: 120, mdf: 120, agi: 120, luk: 120 }, goldMod: 120, expMod: 120, ignoreEnemy: [], enemyReplace: [], troopReplace: [], damageFormulaMod: 1 } ]; }; })(); // ■ END Parameters.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ ParseUtils.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- //$[ENCODE] (function() { var _; //%[I] Возможно эти методы стоит вынести в KDCore и использовать в других плагинах PKDGD.Utils = {}; //@[DEFINES] _ = PKDGD.Utils; _.extractMultiGroup = function(dataObject, key) { var e, eTag, endLineIndex, i, index, keyData, keyValue, len, line, meta, note, notes, param, result, sTag, startLineIndex; if (dataObject == null) { return null; } if (dataObject.meta == null) { return null; } try { meta = dataObject.meta; note = dataObject.note; if ((meta[key] != null) && (meta["/" + key] != null)) { result = []; keyValue = ""; keyData = {}; sTag = "<" + key; eTag = ""; notes = note.split(/[\r\n]+/); startLineIndex = -1; endLineIndex = -1; for (index = i = 0, len = notes.length; i < len; index = ++i) { line = notes[index]; if (line.contains(sTag)) { param = _.extractNoteParameter(line); if (param != null) { keyValue = param.value; } else { keyValue = key; } startLineIndex = index + 1; // * Себя не включает начальный таг } if (startLineIndex >= 0 && line.contains(eTag)) { endLineIndex = index; } if (startLineIndex > -1 && endLineIndex > -1) { result = notes.slice(startLineIndex, endLineIndex); keyData[keyValue] = result; startLineIndex = -1; endLineIndex = -1; } } return keyData; } else { // * KEY group not found return null; } } catch (error) { e = error; console.warn(e); return null; } }; _.extractSingleGroup = function(dataObject, key) { var e, eTag, endLineIndex, i, index, len, line, meta, note, notes, result, sTag, startLineIndex; if (dataObject == null) { return null; } if (dataObject.meta == null) { return null; } try { meta = dataObject.meta; note = dataObject.note; if ((meta[key] != null) && (meta["/" + key] != null)) { result = []; sTag = "<" + key; eTag = ""; notes = note.split(/[\r\n]+/); startLineIndex = -1; endLineIndex = -1; for (index = i = 0, len = notes.length; i < len; index = ++i) { line = notes[index]; if (line.contains(sTag)) { startLineIndex = index + 1; // * Себя не включает начальный таг } if (startLineIndex >= 0 && line.contains(eTag)) { endLineIndex = index; } } if (startLineIndex > -1 && endLineIndex > -1) { result = notes.slice(startLineIndex, endLineIndex); } return result; } else { // * KEY group not found return null; } } catch (error) { e = error; console.warn(e); return null; } }; // * Преобразовывает значение (строка или цифра) _.convertNoteParameterValue = function(paramValue) { var e; try { if (isFinite(paramValue)) { return Number(paramValue); } else { if (paramValue === "true") { return 1; } else if (paramValue === "false") { return 0; } else { return paramValue; } } } catch (error) { e = error; console.warn(e); return paramValue; } }; // * Извлекает из строки (линии) имя параметра и его значение // * Возвращает { name, value } || null _.extractNoteParameter = function(line) { var e, match, name, value; try { // * Для параметров одиночных < > if (line.match(/<.*>/i)) { match = line.match(/<(\w+)\s*:\s*(.+)>/i); // * Для параметров в группе (без < > ) } else { match = line.match(/(\w+)\s*:\s*(.+)/i); } if (match != null) { name = match[1]; value = _.convertNoteParameterValue(match[2]); return {name, value}; } else { return null; } } catch (error) { e = error; console.warn(e); return null; } }; //? addSkill:20:5 (ID:R) _.convertAddSkillParameterToAction = function(line) { var action, e, parts, rating, skillId; try { if (!line.contains("addSkill")) { return null; } parts = line.split(":"); if (parts.length < 2) { return null; } skillId = parseInt(parts[1]); rating = parseInt(parts[2] || '5'); action = { conditionParam1: 0, conditionParam2: 0, rating, skillId }; return action; } catch (error) { e = error; console.warn(e); } return null; }; })(); // ■ END ParseUtils.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 // * Класс обёртка для настроек уровня сложности var PKD_Game_DifficultySettings; PKD_Game_DifficultySettings = class PKD_Game_DifficultySettings { constructor(data1) { this.data = data1; if (this.data == null) { this.data = PKD_Game_DifficultySettings.InitEmpty(); } if (this.data.__opt == null) { this._prepareData(); } return; } // * Преобразовываю данные (для оптимизации) _prepareData() { var paramsModX; this.data.expMod = this.data.expMod / 100; this.data.goldMod = this.data.goldMod / 100; paramsModX = [this.data.paramsMod.mhp / 100, this.data.paramsMod.mmp / 100, this.data.paramsMod.atk / 100, this.data.paramsMod.def / 100, this.data.paramsMod.mat / 100, this.data.paramsMod.mdf / 100, this.data.paramsMod.agi / 100, this.data.paramsMod.luk / 100]; this.data.paramsMod = paramsModX; this.data.__opt = true; } // * Сложность кэшируется static FromLevel(level) { var data, settings; if ($gameTemp._pgdDifficultySettingsCache == null) { $gameTemp._pgdDifficultySettingsCache = []; } if ($gameTemp._pgdDifficultySettingsCache[level] == null) { data = PKDGD.PP.getDifficultyTable()[level]; settings = new PKD_Game_DifficultySettings(data); $gameTemp._pgdDifficultySettingsCache[level] = settings; } return $gameTemp._pgdDifficultySettingsCache[level]; } // * Шаблон пустого объекта static InitEmpty() { var data; data = { name: "Default", paramsMod: { mhp: 100, // 0 mmp: 100, // 1 atk: 100, // 2 def: 100, // 3 mat: 100, // 4 mdf: 100, // 5 agi: 100, // 6 luk: 100 // 7 }, goldMod: 100, expMod: 100, ignoreEnemy: [], enemyReplace: [], /*{ enemyReplaced: 0, enemyReplaceTo: 0 }*/ damageFormulaMod: 100 }; return data; } damageFormulaKoef() { return this.data.damageFormulaMod; } modParam(value, index) { return ~~(value * this.data.paramsMod[index]); } modExp(exp) { return ~~(exp * this.data.expMod); } modGold(gold) { return ~~(gold * this.data.goldMod); } // * Смена врага modEnemy(enemyId) { var e, replacePair; try { replacePair = this.data.enemyReplace.getByField('enemyReplaced', enemyId); if ((replacePair != null) && ($dataEnemies[replacePair.enemyReplaceTo] != null)) { return replacePair.enemyReplaceTo; } else { return enemyId; } } catch (error) { e = error; console.warn(e); return enemyId; } } // * Смена группы modTroop(troopId) { var e, replacePair; try { if (this.data.troopReplace == null) { return troopId; } replacePair = this.data.troopReplace.getByField('troopReplaced', troopId); if ((replacePair != null) && ($dataTroops[replacePair.troopReplaceTo] != null)) { return replacePair.troopReplaceTo; } else { return troopId; } } catch (error) { e = error; console.warn(e); return troopId; } } // * Проверка врага на игнорирование смены параметров isIgnoredEnemy(enemyId) { var e; try { return this.data.ignoreEnemy.contains(enemyId); } catch (error) { e = error; console.warn(e); return false; } } }; // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ PKD_GameDifficulty.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _, __; //@[DEFINES] _ = PKD_GameDifficulty; __ = PKD_GameDifficulty.PP; _.isMV = function() { return Utils.RPGMAKER_NAME.contains("MV"); }; _.getDifficulty = function(level) { return __.getDifficultyTable()[level]; }; })(); // ■ END PKD_GameDifficulty.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ ConfigManager.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__applyData, ALIAS__makeData, _; // * Для установки значения сложности (и получения), используется $gameSystem //@[DEFINES] _ = ConfigManager; //@[ALIAS] ALIAS__applyData = _.applyData; _.applyData = function(config) { ALIAS__applyData.call(this, config); if (config.pGDLevel == null) { this.pGDLevel = 0; } else { this.pGDLevel = config.pGDLevel; } }; //@[ALIAS] ALIAS__makeData = _.makeData; _.makeData = function() { var config; config = ALIAS__makeData.call(this); if (this.pGDLevel == null) { this.pGDLevel = 0; } config.pGDLevel = this.pGDLevel; return config; }; })(); // ■ END ConfigManager.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ DataManager.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__loadDatabase, _; //@[DEFINES] _ = DataManager; //@[ALIAS] ALIAS__loadDatabase = _.loadDatabase; _.loadDatabase = function() { ALIAS__loadDatabase.call(this); PKD_GameDifficulty.LoadPluginSettings(); }; })(); // ■ END DataManager.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_Enemy.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__exp, ALIAS__gold, ALIAS__initialize, ALIAS__makeDropItems, ALIAS__paramBase, ALIAS__selectAllActions, _; //@[DEFINES] _ = Game_Enemy.prototype; //@[ALIAS] ALIAS__initialize = _.initialize; _.initialize = function(enemyId, x, y) { var diff; diff = $gameSystem.pGetDifficultySettings(); if (diff != null) { // * Заменяем врага с учётом сложности enemyId = diff.modEnemy(enemyId); } ALIAS__initialize.call(this, enemyId, x, y); // * Модифицировать параметры данного врага мы не будем if ((diff != null) && diff.isIgnoredEnemy(enemyId)) { this.pgdIgnored = true; } }; //@[ALIAS] ALIAS__paramBase = _.paramBase; _.paramBase = function(paramId) { var diff, e, value; value = ALIAS__paramBase.call(this, ...arguments); try { if (!this.pgdIgnored) { // * Если не игнорируется diff = $gameSystem.pGetDifficultySettings(); if (diff != null) { // * Возвращаем модифицированный параметр return diff.modParam(value, paramId); } } } catch (error) { e = error; console.warn(e); } return value; }; //@[ALIAS] ALIAS__exp = _.exp; _.exp = function() { var diff, e, value; value = ALIAS__exp.call(this, ...arguments); try { if (!this.pgdIgnored) { // * Если не игнорируется diff = $gameSystem.pGetDifficultySettings(); if (diff != null) { // * Возвращаем модифицированный параметр return diff.modExp(value); } } } catch (error) { e = error; console.warn(e); } return value; }; //@[ALIAS] ALIAS__gold = _.gold; _.gold = function() { var diff, e, value; value = ALIAS__gold.call(this, ...arguments); try { if (!this.pgdIgnored) { // * Если не игнорируется diff = $gameSystem.pGetDifficultySettings(); if (diff != null) { // * Возвращаем модифицированный параметр return diff.modGold(value); } } } catch (error) { e = error; console.warn(e); } return value; }; //@[ALIAS] ALIAS__makeDropItems = _.makeDropItems; _.makeDropItems = function() { var items; items = ALIAS__makeDropItems.call(this); items = items.concat(this.pMakeDropItemsRelativeDifficulty()); return items; }; //@[ALIAS] ALIAS__selectAllActions = _.selectAllActions; _.selectAllActions = function(actionList) { actionList = this.pExpandActionListByDifficulty(actionList); //console.log actionList return ALIAS__selectAllActions.call(this, actionList); }; })(); // ■ END Game_Enemy.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_Enemy.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _; //@[DEFINES] _ = Game_Enemy.prototype; //Enemy Note's // // addDrop:w:3:1:50 // addDrop:i:10:2:1|V // //SYMBOLS: // # # # // * Возвращает дополнительные вещи, которые положенны на данной сложности _.pMakeDropItemsRelativeDifficulty = function() { var candidates, e, result; result = []; // * Уже массив вещей try { candidates = this.pGetDifficultyRelativeParameters(); //"CANDIDATES".p() //console.info candidates if (candidates.length > 0) { // * Теперь уже вычисляем предметы и вероятности по Extended Values result = this.pMakeDropItemsFromConditionsCandidates(candidates); } } catch (error) { e = error; console.warn(e); } return result; }; _.pGetDifficultyRelativeParameters = function() { var candidates, data, e, key, value; try { candidates = []; data = PKDGD.Utils.extractMultiGroup(this.enemy(), 'ifdif'); //console.info data for (key in data) { value = data[key]; //console.info value // * Раскрываем массив значений в общий массив всех предметов if (this.pIsProperItemsForCurrentDifficulty(key)) { candidates.push(...value); } } } catch (error) { e = error; console.warn(e); } return candidates; }; //%[I] В обновление, чтобы можно было также использовать слова Normal, Hard и т.д. // # # # // * Подходящий ли уровень сложности в условии _.pIsProperItemsForCurrentDifficulty = function(diff) { var currentLevel, diffLevel, e, regex, values; try { currentLevel = gdGetCurrentDifficultyLevel(); regex = /(\d+)([+\-!]*)/g; values = regex.exec(diff); if (values == null) { return false; } //console.info values diffLevel = parseInt(values[1]); if (!String.any(values[2])) { return currentLevel === diffLevel; } if (values[2] === '-') { return currentLevel <= diffLevel; } if (values[2] === '!') { return currentLevel !== diffLevel; } if (values[2] === '+') { return currentLevel >= diffLevel; } return false; } catch (error) { e = error; console.warn(e); return false; } }; //INPUT: [] -> addDrop:w:3:1:50 , addDrop:i:10:2:1|V (Extended Values) // * Возвращает массив предметов (объектов), если условия выполнены _.pMakeDropItemsFromConditionsCandidates = function(candidates) { var c, count, e, i, items, j, k, len, ref, resultItem; try { items = []; for (j = 0, len = candidates.length; j < len; j++) { c = candidates[j]; if (!this.pIsDropItemDefinition(c)) { continue; } if (window.KDCore != null) { resultItem = KDCore.Utils.parseItemFromConditionStr(c); } else { resultItem = PKD_GameDifficulty.KUtils.parseItemFromConditionStr(c); } if (resultItem != null) { count = resultItem[1]; for (i = k = 0, ref = count; (0 <= ref ? k < ref : k > ref); i = 0 <= ref ? ++k : --k) { items.push(resultItem[0]); } } } } catch (error) { e = error; console.warn(e); } return items; }; _.pIsDropItemDefinition = function(value) { var e; try { return value.contains("addDrop"); } catch (error) { e = error; console.warn(e); return false; } }; _.pExpandActionListByDifficulty = function(actionList) { var e, extraActions; try { if (this.numActions() <= 0) { return actionList; } extraActions = this._pGetExtraActionFromEnemyNote(); //console.log(actionList) if (extraActions.length > 0) { extraActions = extraActions.filter((a) => { return this.isActionValid(a); }); } return actionList.concat(extraActions); } catch (error) { e = error; console.warn(e); return actionList; } }; _._pGetExtraActionFromEnemyNote = function() { var action, c, candidates, e, j, len; try { if (this.__pExActionsForDifficulty == null) { // * Уже набор действий в правильном формате this.__pExActionsForDifficulty = []; candidates = this.pGetDifficultyRelativeParameters(); if (candidates.length > 0) { for (j = 0, len = candidates.length; j < len; j++) { c = candidates[j]; if (!this.pIsAddSkillDefinition(c)) { continue; } action = PKDGD.Utils.convertAddSkillParameterToAction(c); if ((action != null) && action.skillId > 0) { this.__pExActionsForDifficulty.push(action); } } } } return this.__pExActionsForDifficulty; } catch (error) { e = error; console.warn(e); return []; } }; _.pIsAddSkillDefinition = function(value) { var e; try { return value.contains("addSkill"); } catch (error) { e = error; console.warn(e); return false; } }; })(); // ■ END Game_Enemy.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_Interpreter.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__command108, _; //@[DEFINES] _ = Game_Interpreter.prototype; //@[ALIAS] ALIAS__command108 = _.command108; _.command108 = function(params) { if (PKD_GameDifficulty.isMV()) { this.pCheckGDComment(this._params[0]); } else { this.pCheckGDComment(params[0]); } return ALIAS__command108.call(this, params); }; })(); // ■ END Game_Interpreter.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_Interpreter.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _; //@[DEFINES] _ = Game_Interpreter.prototype; //COMMENTS //ifdif=0 | ifdif=Normal //ifdif>0, idfid<0 //ifdif#1 (не равно) // Знаки: = # > < // Сложность - цифра или Название (без пробелов только учитывается) // Ключевое слово ifdif //%[I] Обработку этих символов тоже в KDCore вынести ? Чтобы использовать в других плагинах? _.pCheckGDComment = function(comment) { var difficulty, e, regex, symbol, values; if (!comment.contains("ifdif")) { return; } try { regex = /ifdif([=><#])(.+)/g; values = regex.exec(comment); if (values == null) { return; } symbol = values[1]; difficulty = values[2]; if (symbol == null) { return; } if (difficulty == null) { return; } if (String.any(symbol) && String.any(difficulty)) { return this.pWorkWithGDCondition(symbol, difficulty); } } catch (error) { e = error; return console.warn(e); } }; _.pWorkWithGDCondition = function(symbol, difficulty) { var conditionDifficulty, conditionString, currentDifficultyLevel, e; try { currentDifficultyLevel = gdGetCurrentDifficultyLevel(); if (isFinite(difficulty)) { conditionDifficulty = parseInt(difficulty); } else { conditionDifficulty = PKD_GameDifficulty.getDifficultyLevelByName(difficulty); } if (conditionDifficulty < 0) { return; } if (symbol === "#") { // * Convert symbols symbol = "!="; } if (symbol === "=") { symbol = "=="; } // * Собираем строку с условием conditionString = "" + currentDifficultyLevel.toString() + symbol + conditionDifficulty.toString(); // * Если условие не выполняется, надо пропустить следующую строчку if (eval(conditionString) !== true) { //console.log("SKIP by " + conditionString + " == false") return this._index++; } } catch (error) { e = error; return console.warn(e); } }; })(); // ■ END Game_Interpreter.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_System.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _; //@[DEFINES] _ = Game_System.prototype; //%[Основной метод получения настроей сложности] _.pGetDifficultySettings = function() { var level; level = this.pGetDifficultyLevel(); return PKD_Game_DifficultySettings.FromLevel(level); }; //%[Основной метод получения уровня сложности текущей игры] _.pGetDifficultyLevel = function() { if (PKD_GameDifficulty.PP.isGlobalDifficulty()) { if (ConfigManager.pGDLevel == null) { ConfigManager.pGDLevel = PKD_GameDifficulty.PP.initialGameDifficultyLevel(); } return ConfigManager.pGDLevel; } else { if (this._pGameDifficultyLevel == null) { this._pGameDifficultyLevel = PKD_GameDifficulty.PP.initialGameDifficultyLevel(); } return this._pGameDifficultyLevel; } }; //%[Основной метод изменения уровня сложности текущей игры] _.pSetDifficultyLevel = function(value) { if (value < 0 || (value == null)) { value = 0; } if (PKD_GameDifficulty.PP.isGlobalDifficulty()) { return ConfigManager.pGDLevel = value; } else { return this._pGameDifficultyLevel = value; } }; })(); // ■ END Game_System.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Game_Troop.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__setup, _; //@[DEFINES] _ = Game_Troop.prototype; //@[ALIAS] ALIAS__setup = _.setup; _.setup = function(troopId) { var diff; diff = $gameSystem.pGetDifficultySettings(); if (diff != null) { // * Заменяем отряда врага с учётом сложности troopId = diff.modTroop(troopId); } return ALIAS__setup.call(this, troopId); }; })(); // ■ END Game_Troop.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Parameters.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _; //@[DEFINES] _ = PKD_GameDifficulty.PP; //?{VERSION} _.getDifficultyTable = function() { return this._loader.getParam("difficultyTable", this._getDefaultDifficulties()); }; })(); // ■ END Parameters.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Window_Options.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var _; //@[DEFINES] _ = Window_Options.prototype; _.pGetDifficultyText = function(value) { var diff; diff = PKDGD.getDifficulty(value); return diff.name; }; _.pIsDiffSymbol = function(symbol) { return symbol === "pGDLevel"; }; _.pMaxDiffIndex = function() { return PKDGD.PP.getDifficultyTable().length - 1; }; })(); // ■ END Window_Options.coffee //--------------------------------------------------------------------------- // Generated by CoffeeScript 2.6.1 //╒═════════════════════════════════════════════════════════════════════════╛ // ■ Window_Options.coffee //╒═════════════════════════════════════════════════════════════════════════╛ //--------------------------------------------------------------------------- (function() { var ALIAS__addGeneralOptions, ALIAS__cursorLeft, ALIAS__cursorRight, ALIAS__processOk, ALIAS__statusText, _; //@[DEFINES] _ = Window_Options.prototype; //@[ALIAS] ALIAS__addGeneralOptions = _.addGeneralOptions; _.addGeneralOptions = function() { this.addCommand(PKDGD.PP.difficultyOptionName(), 'pGDLevel'); ALIAS__addGeneralOptions.call(this); }; //@[ALIAS] ALIAS__statusText = _.statusText; _.statusText = function(index) { var e, symbol, value; try { symbol = this.commandSymbol(index); if (this.pIsDiffSymbol(symbol)) { value = this.getConfigValue(symbol); return this.pGetDifficultyText(value); } } catch (error) { e = error; console.warn(e); } return ALIAS__statusText.call(this, index); }; //@[ALIAS] ALIAS__processOk = _.processOk; _.processOk = function() { var index, symbol, value; index = this.index(); symbol = this.commandSymbol(index); if (this.pIsDiffSymbol(symbol)) { value = this.getConfigValue(symbol); value += 1; if (value > this.pMaxDiffIndex()) { value = 0; } value = value.clamp(0, this.pMaxDiffIndex()); return this.changeValue(symbol, value); } else { return ALIAS__processOk.call(this); } }; //@[ALIAS] ALIAS__cursorRight = _.cursorRight; _.cursorRight = function() { var index, symbol, value; index = this.index(); symbol = this.commandSymbol(index); if (this.pIsDiffSymbol(symbol)) { value = this.getConfigValue(symbol); value += 1; value = value.clamp(0, this.pMaxDiffIndex()); return this.changeValue(symbol, value); } else { return ALIAS__cursorRight.call(this); } }; //@[ALIAS] ALIAS__cursorLeft = _.cursorLeft; _.cursorLeft = function() { var index, symbol, value; index = this.index(); symbol = this.commandSymbol(index); if (this.pIsDiffSymbol(symbol)) { value = this.getConfigValue(symbol); value -= 1; value = value.clamp(0, this.pMaxDiffIndex()); return this.changeValue(symbol, value); } else { return ALIAS__cursorLeft.call(this); } }; })(); // ■ END Window_Options.coffee //--------------------------------------------------------------------------- //Plugin PKD_GameDifficulty builded by PKD PluginBuilder 2.2 - 04.10.2023