//----------------------------------------------------------------------------- // OcRam plugins - OcRam_Core.js (will be embedded in all of my plugins) //============================================================================= /* DO NOT COPY, RESELL OR CLAIM ANY PIECE OF THIS SOFTWARE AS YOUR OWN! * * Copyright(c) 2020, Marko Paakkunainen // mmp_81 (at) hotmail.com */ "use strict"; var ShaderTilemap = ShaderTilemap || false; var Imported = Imported || {}; var Yanfly = Yanfly || {}; // In case there's no Yanfly plugins in use if (!Imported.OcRam_Core) { // OcRam_Core has only the functionality which are used widely in all OcRam plugins... Game_Interpreter.prototype.event = function () { /* Get Game_Event in event editor like: this.event(); */ return ($gameMap) ? $gameMap.event(this._eventId) : null; }; Game_Map.prototype.getEventsByName = function (event_name) { /* Get Game_Map events by name */ return this._events.filter(function (ev) { return ev.event().name == event_name; }); }; Game_Event.prototype.getComments = function () { /* Returns all comments + commandIndex from Game_Event as Array */ if (this._erased || this._pageIndex < 0) return []; var comments = []; var i = 0; this.list().forEach(function (p) { if (p.code == 108) { p.commandIndex = i; comments.push(p); } i++; }); return comments; }; Game_Event.prototype.getStringComments = function () { /* Returns all comments from Game_Event as String Array */ if (this._erased || this._pageIndex < 0) return []; var comments = []; this.list().filter(function (c) { return c.code == 108; }).forEach(function (p) { p.parameters.forEach(function (s) { comments.push(s); }); }); return comments; }; ImageManager.loadOcRamBitmap = function (filename, hue) { /* Load bitmap from ./img/ocram folder */ return this.loadBitmap('img/ocram/', filename, hue, false); }; Imported.OcRam_Core = true; var OcRam_Core = OcRam_Core || function () { /* OcRam core class */ this.initialize.apply(this, arguments); }; OcRam_Core.prototype.initialize = function () { /* Initialize OcRam core */ this.name = "OcRam_Core"; this.version = "1.05"; this.twh = [48, 48]; this.twh50 = [24, 24]; this.radian = Math.PI / 180; this._isIndoors = false; this._screenTWidth = Graphics.width / 48; this._screenTHeight = Graphics.height / 48; this.plugins = []; this._menuCalled = false; this.Scene_Map_callMenu = Scene_Map.prototype.callMenu; this.Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded; }; OcRam_Core.prototype.debug = function () { /* Debug core? console.log("OcRam_Core", arguments); */ }; OcRam_Core.prototype.getBoolean = function (s) { /* Get 'safe' boolean */ if (!s) return false; s = s.toString().toLowerCase(); return (s == "true" && s != "0") ? true : false; }; OcRam_Core.prototype.getArray = function (a, b) { /* Get plugin param array */ return a ? eval(a) : b || []; }; OcRam_Core.prototype.getFloat = function (n) { /* Get float */ return isNaN(n - parseFloat(n)) ? 0 : parseFloat(n); }; OcRam_Core.prototype.regulateRGBG = function (obj) { /* Regulate RGBG value (used in tints) */ obj.Red = parseInt(obj.Red).clamp(-255, 255); obj.Green = parseInt(obj.Green).clamp(-255, 255); obj.Blue = parseInt(obj.Blue).clamp(-255, 255); obj.Gray = parseInt(obj.Gray).clamp(-255, 255); return obj; }; OcRam_Core.prototype.regulateHexRGBA = function (p) { /* Regulate HEX RGBA value */ if (p.substr(0, 1) !== "#") p = "#" + p; if (p.length == 7) p = p + "ff"; return /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(p)[0] || "#ffffffff"; } OcRam_Core.prototype.getJSON = function (s) { /* Get 'safe' JSON */ try { return JSON.parse(s); } catch (ex) { return null; } }; OcRam_Core.prototype.getJSONArray = function (a) { /* Get 'safe' JSON Array */ var tmp = []; if (a) { OcRam.getArray(a, []).forEach(function (s) { tmp.push(OcRam.getJSON(s)); }); } return tmp; }; OcRam_Core.prototype.followers = function () { /* Only a shortcut to $gamePlayer._followers.visibleFollowers(); */ return $gamePlayer ? $gamePlayer._followers.visibleFollowers() : []; }; OcRam_Core.prototype.setIndoorsFlag = function () { /* Set indoors flag - Each plugin will call this when needed */ if (DataManager.isEventTest()) return; if ($dataMap.meta["indoors"] !== undefined) { this.debug("Indoors meta tag found in MAP note field!", $dataMap.meta); this._isIndoors = true; } else { if ($dataTilesets[$dataMap.tilesetId].meta["indoors"] !== undefined) { this.debug("Indoors meta tag found in TILESET note field!", $dataTilesets[$dataMap.tilesetId].meta); this._isIndoors = true; } else { this.debug("Indoors meta tag was NOT found!", undefined); this._isIndoors = false; } } }; OcRam_Core.prototype.isIndoors = function () { /* Get indoors flag */ return this._isIndoors; }; OcRam_Core.prototype.runCE = function (pCE_Id) { /* Run common event */ if ($gameTemp.isCommonEventReserved()) { var tmpId = pCE_Id; var tc = this; setTimeout(function () { tc.runCE(tmpId); }, 17); } else { $gameTemp.reserveCommonEvent(pCE_Id); } }; OcRam_Core.prototype.extendMethod = function (c, b, cb) { /* Extend/override any method */ c[b] = function () { return cb.apply(this, arguments); }; }; OcRam_Core.prototype.extendProto = function (c, b, cb) { /* Extend/override any proto */ c.prototype[b] = function () { return cb.apply(this, arguments); }; }; OcRam_Core.prototype.addPlugin = function (name, version) { /* Initialize new OcRam plugin */ this[name] = {}; var new_plugin = this[name]; Imported["OcRam_" + name] = true; this.plugins.push(name); this[name]._menuCalled = false; new_plugin.name = name; new_plugin.version = version; new_plugin.parameters = PluginManager.parameters("OcRam_" + new_plugin.name); if (this.getBoolean(new_plugin.parameters["Debug mode"])) { new_plugin.debug = function () { var args = [].slice.call(arguments); args.unshift("OcRam_" + new_plugin.name + " (v" + new_plugin.version + ")", ":"); console.log.apply(console, args); }; console.log("OcRam_" + new_plugin.name + " (v" + new_plugin.version + ")", "Debug mode:", "Enabled"); console.log("OcRam_" + new_plugin.name + " (v" + new_plugin.version + ")", "Parameters:", new_plugin.parameters); } else { new_plugin.debug = function () { }; } var oc = this; new_plugin.extend = function (c, b, cb) { var cb_name = c.name + "_" + b; if (c[b]) { this[cb_name] = c[b]; oc.extendMethod(c, b, cb); } else { this[cb_name] = c.prototype[b]; oc.extendProto(c, b, cb); } }; }; var OcRam = new OcRam_Core(); // Create new OcRam_Core! (Below aliases) Scene_Map.prototype.callMenu = function () { /* Menu called? */ OcRam.Scene_Map_callMenu.call(this); OcRam.debug("Menu called:", true); OcRam._menuCalled = true; OcRam.plugins.forEach(function (p) { OcRam[p]._menuCalled = true; }); }; Scene_Map.prototype.onMapLoaded = function () { /* Set and get tile dimensions and indoors flag */ OcRam.Scene_Map_onMapLoaded.call(this); if (!OcRam._menuCalled) { OcRam.twh = [$gameMap.tileWidth(), $gameMap.tileHeight()]; OcRam.twh50 = [OcRam.twh[0] * 0.5, OcRam.twh[1] * 0.5]; OcRam._screenTWidth = Graphics.width / OcRam.twh[0]; OcRam._screenTHeight = Graphics.height / OcRam.twh[1]; OcRam.debug("Tile w/h:", OcRam.twh); OcRam.setIndoorsFlag(); OcRam.menuCalled = false; } }; CanvasRenderingContext2D.prototype.line = function (x1, y1, x2, y2) { /* Draw line to canvas context */ this.beginPath(); this.moveTo(x1, y1); this.lineTo(x2, y2); this.stroke(); }; Game_Map.prototype.adjustX_OC = function (x) { /* Optimized core adjustX */ if (this.isLoopHorizontal()) { if (x < this._displayX - (this.width() - this.screenTileX()) * 0.5) { return x - this._displayX + $dataMap.width; } else { return x - this._displayX; } } else { return x - this._displayX; } }; Game_Map.prototype.adjustY_OC = function (y) { /* Optimized core adjustY */ if (this.isLoopVertical()) { if (y < this._displayY - (this.height() - this.screenTileY()) * 0.5) { return y - this._displayY + $dataMap.height; } else { return y - this._displayY; } } else { return y - this._displayY; } }; Game_CharacterBase.prototype.screenX_OC = function () { /* Optimized core screenX */ return Math.round($gameMap.adjustX_OC(this._realX) * OcRam.twh[0] + OcRam.twh50[0]); }; Game_CharacterBase.prototype.screenY_OC = function () { /* Optimized core screenY */ return Math.round($gameMap.adjustY_OC(this._realY) * OcRam.twh[1] + OcRam.twh50[0] - this.shiftY() - this.jumpHeight()); }; } if (parseFloat(OcRam.version) < 1.05) alert("OcRam core v1.05 is required!"); //----------------------------------------------------------------------------- // OcRam plugins - OcRam_Battle_EX.js //============================================================================= "use strict"; if (!Imported || !Imported.OcRam_Core) alert('OcRam_Core.js ' + 'is required!'); OcRam.addPlugin("Battle_EX", "1.02"); /*: * @plugindesc v1.02 Create enemy troops dynamically and tweak substitute behaviour and command visibilities. PLUGIN NAME MUST BE OcRam_Battle_EX.js * @author OcRam * * @param Exclude enemies * @type text * @desc In wild card selection (*) exclude these enemy ids. Example: 7,8,9 * @default * * @param Enemy pools * @type struct[] * @desc Get enemies from named pool. (ie: init_battle 1-2 from_pool Desert) * @default ["{\"Name\":\"Forest\",\"Enemy IDs\":\"1,2,3\"}","{\"Name\":\"Desert\",\"Enemy IDs\":\"4,5,6\"}"] * * @param Enemy position variance * @type number * @desc Give enemy position variance in pixels. * @default 32 * * @param Adjust Y * @type number * @desc Adjust enemy Y axis (effects both rows). * @default 0 * * @param Show Attack * @type boolean * @desc Shows the default attack command * @default true * * @param Show Guard * @type boolean * @desc Shows the default guard command * @default true * * @param Show Skill * @type boolean * @desc Shows the default skill command * @default true * * @param Show Item * @type boolean * @desc Shows the default item command * @default true * * @param Substitute behaviour * @type text * @desc Default eval for substitute check example: this._action.isPhysical() * @default * * @param Debug mode * @parent Other parameters * @type boolean * @desc Write some events to console log (F8 or F12). * @default false * * @help * ---------------------------------------------------------------------------- * Introduction (Embedded OcRam_Core v1.5) * ============================================================================ * Ever tired to create troops for all possible enemy variations? * Or needed to form random encounter with 1-4 enemies from this enemy pool? * * If answer is yes then this is a plugin for you! * * You may also alter battle commands a bit like substitute behaviour and * command visibilities. * * You may also change ACTOR / ENEMY substitute behaviour by typing meta tag * in actors or enemys note box. Example below: * * this._action.isPhysical() && this._action.isForOne * * * NOTE: For "Dynamic Troops" maximum number of enemies is 16. * * ---------------------------------------------------------------------------- * Plugin command - Usage * ============================================================================ * Important: init_battle must be called BEFORE battle process! Else will * default standard style of troops. * * For example: EnemyID [1 = Spider, 2 = Bat and 3 = Slime] * * To have 1 slime use: init_battle 3 * To have 2 spiders and 1 bat command is: init_battle 1,1,2 * To have 1 enemy from id pool command is: init_battle 1 from_ids 1,2,3 * To have 1-4 slimes use: init_battle 1-4 from_ids 3 * To have 16 totally random enemies: init_battle 16 from_ids * * * To have 2 enemies from "Desert" pool: init_battle 2 from_pool Desert * * Force specific enemies BEFORE calling init_battle. * * To force spider and bat + 0-1 random enemies from pool "Forest": * Plugin Command : force_ids 1,2 * Plugin Command : init_battle 0-1 from_pool Forest * * To force 1 bat + 1 random enemy from id pool: * Plugin Command : force_ids 2 * Plugin Command : init_battle 1 from_ids 1,2,3,4 * * NOTE: DO NOT USE SPACES TO SEPERATE RANDOM ENEMIES OR ID POOL * WRONG: init_battle 1 - 8 from_ids * >> CORRECT: init_battle 1-8 from_ids * * WRONG: init_battle 1, 1, 2 >> CORRECT: init_battle 1,1,2 * * More plugin commands ------------------------------------------------------- * * show_attack true/false, show_guard true/false * show_skill true/false, show_item true/false * * Following command will hide skill type with id of 1: * show_skill_type 1 false * * Following command will show skill type with id of 1: * show_skill_type 1 true * * ---------------------------------------------------------------------------- * Some JScript eval examples on Substitute behaviour: * ============================================================================ * Default behaviour: * target.isDying() && !this._action.isCertainHit() * * Substitute always on 1 target physical attacks: * this._action.isPhysical() && this._action.isForOne * * Substitute always on magical attacks: * this._action.isMagical() * * ---------------------------------------------------------------------------- * Terms of Use * ============================================================================ * Edits are allowed as long as "Terms of Use" is not changed in any way. * * NON-COMMERCIAL USE: Free to use with credits to 'OcRam' * * If you gain money with your game by ANY MEANS (inc. ads, crypto-mining, * micro-transactions etc..) it's considered as COMMERCIAL use of this plugin! * * COMMERCIAL USE: (Standard license: 5 EUR, No-credits license: 40 EUR) * Payment via PayPal (https://paypal.me/MarkoPaakkunainen), please mention * PLUGIN NAME(S) you are buying / ALL plugins and your PROJECT NAME(S). * * Licenses are purchased per project and standard license requires credits. * If you want to buy several licenses: Every license purhased will give you * discount of 2 EUR for the next license purchase until minimum price of * 2 EUR / license. License discounts can be used to any of my plugins! * ALL of my plugins for 1 project = 40 EUR (standard licenses) * * https://forums.rpgmakerweb.com/index.php?threads/ocram-battle_ex.101817 * * DO NOT COPY, RESELL OR CLAIM ANY PIECE OF THIS SOFTWARE AS YOUR OWN! * Copyright (c) 2020, Marko Paakkunainen // mmp_81 (at) hotmail.com * * ---------------------------------------------------------------------------- * Version History * ============================================================================ * 2018/11/08 v1.00 - Initial release * 2018/11/11 v1.01 - Randomized troops will be temporalily saved to event * Subsitute behaviour can be actor/enemy specific * New plugin command "force_ids" (use before battle_init) * 2020/06/12 v1.02 - OcRam core v1.05 (requirement for all of my plugins) */ /* * ---------------------------------------------------------------------------- * RMMV CORE function overrides (destructive) are listed here * ============================================================================ * - */ /*~struct~Pools: * * @param Name * @desc The name of the pool that can be accessed via plugin commands. * @default * * @param Enemy IDs * @desc Enemy IDs included in this named pool. * @default 1,2,3 * */ (function () { // ------------------------------------------------------------------------------ // Plugin variables and parameters // ============================================================================== var OcRam_Utils = {}; var _this = this; var _showAttack = OcRam.getBoolean(this.parameters['Show Attack']); var _showGuard = OcRam.getBoolean(this.parameters['Show Guard']); var _showSkill = OcRam.getBoolean(this.parameters['Show Skill']); var _showItem = OcRam.getBoolean(this.parameters['Show Item']); var _substituteBehaviour = this.parameters['Substitute behaviour'] || ''; var _enemyPools = parse(this.parameters['Enemy pools']) || null; var _excludeEnemies = this.parameters['Exclude enemies'] || ''; var _enemyPosVariance = Number(this.parameters['Enemy position variance']) || 32; var _troopPosX = [0, 0, 0, 0, 0, 0, 0, 0]; var _troopPosY = [0, 0, 0, 0, 0, 0, 0, 0]; var _troopPosX12 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var _troopPosY12 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var _troopPosX16 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var _troopPosY16 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var _hideSkillType = ";"; var _troopMembers = null; var _oldStyleTroops = true; var _forceIds = ""; this.extend(Game_Interpreter, "pluginCommand", function (command, args) { switch (command.toLowerCase()) { case "show_attack": _this.debug("show_attack", args); if (OcRam.getBoolean(args[0])) { _showAttack = true; } else { _showAttack = false; } break; case "show_guard": _this.debug("show_guard", args); if (OcRam.getBoolean(args[0])) { _showGuard = true; } else { _showGuard = false; } break; case "show_skills": _this.debug("show_skills", args); if (OcRam.getBoolean(args[0])) { _showSkill = true; } else { _showSkill = false; } break; case "show_item": _this.debug("show_item", args); if (OcRam.getBoolean(args[0])) { _showItem = true; } else { _showItem = false; } break; case "show_skill_type": _this.debug("show_skill_type", args); if (OcRam.getBoolean(args[1])) { // Hide skill type with desired id _hideSkillType = _hideSkillType.replace(";" + Number(args[0]) + ";", ";"); } else { // Show skill type with desired id if (_hideSkillType.indexOf(";" + Number(args[0]) + ";") < 0) { _hideSkillType += Number(args[0]) + ";"; } } break; case "force_ids": _this.debug("force_ids", args); _forceIds = (args[0] === undefined) ? "" : args.join(""); break; case "init_battle": _this.debug("init_battle", args); var ev = null; if (this._eventId > 0) { ev = getEventById(this._eventId); if (ev.OC_lastBattleInit == args.join(" ")) { // Same init again so use previous settings... _troopMembers = ev.OC_troopMembers; _oldStyleTroops = (_troopMembers != null) ? false : true; return true; } ev.OC_lastBattleInit = args.join(" "); } if (args[0] === undefined) { // No parameters >> Use default troop _oldStyleTroops = true; _troopMembers = null; if (ev != null) ev.OC_troopMembers = _troopMembers; } else { var i = 0; _oldStyleTroops = false; var tmp_str_enemies = ''; var enemyCount = 0; if (args[args.length - 2] == "from_ids") { var tmp_enemies = []; if (args[args.length - 1] == "*") { for (i = 0; i < $dataEnemies.length; i++) { if ($dataEnemies[i] != null) { if ($dataEnemies[i].name != "") { if (("," + _excludeEnemies + ",").indexOf("," + $dataEnemies[i].id + ",") < 0) { tmp_enemies.push($dataEnemies[i].id); } else { // This enemy is excluded from wildcard pool. } } } } } else { tmp_enemies = (args[args.length - 1] + ",").split(','); } if (args[0].indexOf("-") > 0) { // Get enemy count between x-y var mm = args[0].split("-"); enemyCount = rndBetween(parseInt(mm[0]), parseInt(mm[1])); } else { // Get enemy count directly from arg enemyCount = parseInt(args[0]); } for (i = 0; i < enemyCount; i++) { tmp_str_enemies += tmp_enemies[Math.floor((tmp_enemies.length - 1) * Math.random())] + "," } tmp_str_enemies = tmp_str_enemies + _forceIds; _forceIds = ""; _troopMembers = tmp_str_enemies.split(','); if (ev != null) ev.OC_troopMembers = _troopMembers; } else if (args[args.length - 2] == "from_pool") { // Get enemies from named pool var tmp_enemies = []; var pname = ""; var enemyIDs = ""; _oldStyleTroops = true; _troopMembers = null; for (i = 0; i < _enemyPools.length; i++) { pname = _enemyPools[i].split("\",\"Enemy IDs\":")[0]; pname = pname.split("\"Name\":\"")[1]; if (pname == args[args.length - 1]) { enemyIDs = _enemyPools[i].split("\",\"Enemy IDs\":\"")[1]; enemyIDs = enemyIDs.split("\"")[0]; tmp_enemies = (enemyIDs + ",").split(','); if (args[0].indexOf("-") > 0) { // Get enemy count between x-y var mm = args[0].split("-"); enemyCount = rndBetween(parseInt(mm[0]), parseInt(mm[1])); } else { // Get enemy count directly from arg enemyCount = parseInt(args[0]); } for (i = 0; i < enemyCount; i++) { tmp_str_enemies += tmp_enemies[Math.floor((tmp_enemies.length - 1) * Math.random())] + "," } tmp_str_enemies = tmp_str_enemies + _forceIds; _forceIds = ""; _troopMembers = tmp_str_enemies.split(','); _oldStyleTroops = false; _troopMembers = (tmp_str_enemies + ",").split(","); if (ev != null) ev.OC_troopMembers = _troopMembers; return true; } } } else { // Fixed number of desired enemies like: init_battle 1,2,3 or init_battle 1 _troopMembers = (args[0] + ",").split(','); if (ev != null) ev.OC_troopMembers = _troopMembers; } } break; default: _this["Game_Interpreter_pluginCommand"].apply(this, arguments); } }); // ------------------------------------------------------------------------------ // RMMV core - Aliases // ============================================================================== this.extend(Game_Troop, "setup", function (troopId) { if (_oldStyleTroops) { // Old style members init _this["Game_Troop_setup"].apply(this, arguments); } else { setTroopPositions(_troopMembers.length); this.clear(); this._troopId = troopId; this._enemies = []; var enemyId = 0; var x = 0; var y = 0; var enemy = null; var max_variant = _enemyPosVariance; var min_variant = -(max_variant * 0.5); var troop_pos = null; if (_troopMembers.length < 12) { troop_pos = [0, 1, 2, 3, 4, 5, 6, 7]; } else { if (_troopMembers.length < 16) { troop_pos = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; } else { troop_pos = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; } } troop_pos = shuffleArray(troop_pos); var j = 0; var kk = 0; // DYNAMIC members init for (var i = 0; i < _troopMembers.length; i++) { enemyId = parseInt(_troopMembers[i]); if ($dataEnemies[enemyId]) { x = Math.floor(_troopPosX[troop_pos[j]] + ((max_variant * Math.random()) + min_variant)); y = Math.floor(_troopPosY[troop_pos[j]] + ((max_variant * Math.random()) + min_variant)); enemy = new Game_Enemy(enemyId, x, y); j++; /*if (member.hidden) { enemy.hide(); }*/ this._enemies.push(enemy); if (Imported.YEP_RowFormation) { if (x < (_troopPosX[2] + _enemyPosVariance + 1)) { $gameTroop.members()[kk].setRow(3); } else { if (x < (_troopPosX[4] + _enemyPosVariance + 1)) { $gameTroop.members()[kk].setRow(2); } else { $gameTroop.members()[kk].setRow(1); } } kk++; } } } this.makeUniqueNames(); // Reset init_battle objects _oldStyleTroops = true; _troopMembers = null; } }); this.extend(Window_ActorCommand, "makeCommandList", function () { if (_showAttack && _showGuard && _showSkill && _showItem) { // Use default cmd list _this["Window_ActorCommand_makeCommandList"].apply(this, arguments); } else { if (this._actor) { if (_showAttack != 'false') { this.addAttackCommand(); } if (_showGuard != 'false') { this.addGuardCommand(); } if (_showSkill != 'false') { this.addSkillCommands(); } if (_showItem != 'false') { this.addItemCommand(); } } } }); this.extend(Window_ActorCommand, "addSkillCommands", function () { if (_hideSkillType != "") { var skillTypes = this._actor.addedSkillTypes(); skillTypes.sort(function (a, b) { return a - b; }); skillTypes.forEach(function (stypeId) { var name = $dataSystem.skillTypes[stypeId]; if (_hideSkillType.indexOf(";" + stypeId + ";") < 0) { this.addCommand(name, 'skill', true, stypeId); } }, this); } else { _this["Window_ActorCommand_addSkillCommands"].apply(this, arguments); } }); this.extend(BattleManager, "applySubstitute", function (target) { var this_behaviour = _substituteBehaviour; var substitute = target.friendsUnit().substituteBattler(); if (substitute != undefined) { if (substitute.actor) { this_behaviour = getMetaTag(substitute.actor().note, "substitute"); if (this_behaviour == "") this_behaviour = _substituteBehaviour; } else { if (substitute.enemy) { this_behaviour = getMetaTag(substitute.enemy().note, "substitute"); if (this_behaviour == "") this_behaviour = _substituteBehaviour; } } } if (this_behaviour != "") { if (eval(this_behaviour) && substitute && target !== substitute) { _this.debug(this_behaviour); this._logWindow.displaySubstitute(substitute, target); return substitute; } return target; } else { _this["BattleManager_applySubstitute"].apply(this, arguments); } }); // Utility functions for dynamic troops function getMetaTag(note, tag) { var rex = new RegExp("\<" + tag + "\>\n?(.*?)\n?\<\/" + tag + "\>", "gi"); var ret = rex.exec(note); return (ret != null) ? ret[1] : ""; } function getEventById(eid) { if (eid == 0 || eid == null) return null; var oc_eid = eid; var tmp_event = null; while (oc_eid > -1) { tmp_event = $gameMap.events()[oc_eid]; if (tmp_event !== null && tmp_event !== undefined) { if (tmp_event._eventId == eid) return tmp_event; } oc_eid--; } return null; } function setTroopPositions(enemyCount) { var tmpPosX = null; var tmpPosY = null; var row1Y = 0; var row2Y = 0; var row3Y = 0; var row4Y = 0; var rowMinX = Graphics.width * 0.08; var rowMaxX = Graphics.width * 0.68; var rowSpace = (rowMaxX - rowMinX) / 4; var ra = rowMinX * 0.5; if (enemyCount < 12) { // 2 rows row1Y = (Graphics.height * 0.5); row2Y = (Graphics.height * 0.65); tmpPosX = [rowMinX, rowMinX + ra, rowMinX + rowSpace, rowMinX + rowSpace + ra, rowMinX + rowSpace * 2, (rowMinX + rowSpace * 2) + ra, rowMinX + rowSpace * 3, (rowMinX + rowSpace * 3) + ra]; tmpPosY = [row1Y, row2Y, row1Y, row2Y, row1Y, row2Y, row1Y, row2Y]; } else { if (enemyCount < 16) { // 3 rows row1Y = (Graphics.height * 0.48); row2Y = (Graphics.height * 0.58); row3Y = (Graphics.height * 0.68); tmpPosX = [ rowMinX, rowMinX + ra, rowMinX + ra * 2, rowMinX + rowSpace, rowMinX + rowSpace + ra, rowMinX + rowSpace + ra * 2, rowMinX + rowSpace * 2, (rowMinX + rowSpace * 2) + ra, (rowMinX + rowSpace * 2) + ra * 2, rowMinX + rowSpace * 3, (rowMinX + rowSpace * 3) + ra, (rowMinX + rowSpace * 3) + ra * 2 ]; tmpPosY = [row1Y, row2Y, row3Y, row1Y, row2Y, row3Y, row1Y, row2Y, row3Y, row1Y, row2Y, row3Y]; } else { // 4 rows row1Y = (Graphics.height * 0.4); row2Y = (Graphics.height * 0.5); row3Y = (Graphics.height * 0.6); row4Y = (Graphics.height * 0.7); tmpPosX = [ rowMinX, rowMinX + ra, rowMinX + ra * 2, rowMinX + ra * 3, rowMinX + rowSpace, rowMinX + rowSpace + ra, rowMinX + rowSpace + ra * 2, rowMinX + rowSpace + ra * 3, rowMinX + rowSpace * 2, (rowMinX + rowSpace * 2) + ra, (rowMinX + rowSpace * 2) + ra * 2, (rowMinX + rowSpace * 2) + ra * 3, rowMinX + rowSpace * 3, (rowMinX + rowSpace * 3) + ra, (rowMinX + rowSpace * 3) + ra * 2, (rowMinX + rowSpace * 3) + ra * 3 ]; tmpPosY = [row1Y, row2Y, row3Y, row4Y, row1Y, row2Y, row3Y, row4Y, row1Y, row2Y, row3Y, row4Y, row1Y, row2Y, row3Y, row4Y]; } } _troopPosX = tmpPosX; _troopPosY = tmpPosY; } function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } function rndBetween(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } function parse(string) { try { return JSON.parse(string); } catch (ex) { return null; } } }.bind(OcRam.Battle_EX)());