Best JavaScript code snippet using wpt
YEP_AutoPassiveStates.js
Source:YEP_AutoPassiveStates.js
1//=============================================================================2// Yanfly Engine Plugins - Auto Passive States3// YEP_AutoPassiveStates.js4//=============================================================================5var Imported = Imported || {};6Imported.YEP_AutoPassiveStates = true;7var Yanfly = Yanfly || {};8Yanfly.APS = Yanfly.APS || {};9Yanfly.APS.version = 1.17;10//=============================================================================11 /*:12 * @plugindesc v1.17 This plugin allows for some states to function as13 * passives for actors, enemies, skills, and equips.14 * @author Yanfly Engine Plugins15 *16 * @param ---Basic---17 * @default18 *19 * @param Actor Passives20 * @parent ---Basic---21 * @desc These states will always appear on actors as passives.22 * Place a space in between each state ID.23 * @default 024 *25 * @param Enemy Passives26 * @parent ---Basic---27 * @desc These states will always appear on enemies as passives.28 * Place a space in between each state ID.29 * @default 030 *31 * @param Global Passives32 * @parent ---Basic---33 * @desc These states will always appear on all battlers as passives.34 * Place a space in between each state ID.35 * @default 036 *37 * @param ---List---38 * @default ...Requires RPG Maker MV 1.5.0+...39 *40 * @param Actor Passives List41 * @parent ---List---42 * @type state[]43 * @desc These states will always appear on actors as passives.44 * Use with RPG Maker MV 1.5.0+.45 * @default []46 *47 * @param Enemy Passives List48 * @parent ---List---49 * @type state[]50 * @desc These states will always appear on enemies as passives.51 * Use with RPG Maker MV 1.5.0+.52 * @default []53 *54 * @param Global Passives List55 * @parent ---List---56 * @type state[]57 * @desc These states will always appear on all battlers as passives.58 * Use with RPG Maker MV 1.5.0+.59 * @default []60 *61 * @help62 * ============================================================================63 * Introduction64 * ============================================================================65 *66 * Passive states are states that are automatically active. You can think of67 * them as an extension of traits but with more flexibility. They will always68 * be there as long as the actor or enemy has auto passive state notetags.69 *70 * ============================================================================71 * Notetags72 * ============================================================================73 *74 * For those who would like to allocate passive states to your battlers, use75 * the notetags below:76 *77 * Actor, Class, Skills, Weapon, Armor, Enemy Notetags:78 * <Passive State: x>79 * <Passive State: x, x, x>80 * This will allow the actor or enemy to have state x as a passive state.81 * If placed inside a weapon or armor notebox, the user will have that82 * passive state.83 *84 * <Passive State: x to y>85 * This will add the states x through y (in a sequence) for the actor or86 * enemy to have as a passive state. If placed inside a weapon or armor87 * notebox, the user will have that passive state.88 *89 * For those who don't want their passive states to always be on, you can use90 * the following notetags to introduce conditions for your passive states. All91 * conditions must be fulfilled in order for the passive state to appear.92 *93 * State Notetags:94 * <Passive Condition: HP Above x%>95 * <Passive Condition: HP Below x%>96 * <Passive Condition: MP Above x%>97 * <Passive Condition: MP Below x%>98 * If the user's HP or MP is above/below x% of the MaxHP or MaxMP, this99 * condition will be met for the passive state to appear.100 *101 * <Passive Condition: Stat Above x>102 * <Passive Condition: Stat Below x>103 * Replace 'stat' with 'HP', 'MP', 'TP', 'MAXHP', 'MAXMP', 'ATK', 'DEF',104 * 'MAT', 'MDF', 'AGI', 'LUK'. If the above stat is above/below x, then the105 * condition is met for the passive state to appear.106 *107 * <Passive Condition: Switch x ON>108 * <Passive Condition: Switch x OFF>109 * If switch x is either ON/OFF, then the condition is met for the passive110 * state to appear.111 *112 * <Passive Condition: Variable x Above y>113 * <Passive Condition: Variable x Below y>114 * Replace x with the variable you wish to check to see if it's above/below115 * y, then the condition is met for the passive state to appear.116 *117 * ============================================================================118 * Lunatic Mode - Conditional Passives119 * ============================================================================120 *121 * For those who understand a bit of JavaScript and would like for their122 * passive states to appear under specific conditions, you can use this notetag123 * to accomplish conditional factors.124 *125 * State Notetags:126 * <Custom Passive Condition>127 * if (user.hp / user.mhp <= 0.25) {128 * condition = true;129 * } else {130 * condition = false;131 * }132 * </Custom Passive Condition>133 * This enables you to input conditions to be met in order for the passive134 * state to appear. If the 'condition' variable returns true, the passive135 * state will appear. If the 'condition' returns false, it won't appear. If136 * condition is not defined, it will return true and the passive state will137 * appear on the battler.138 * * Note: All non-custom passive conditions must be met before this one can139 * be fulfilled and allow the custom condition to appear.140 * * Note: If you decide to use a condition that requires the actor to have a141 * particular state, it cannot be a passive state to prevent infinite loops.142 *143 * ============================================================================144 * Changelog145 * ============================================================================146 *147 * Version 1.17:148 * - Optimization update. There should be less lag spikes if there are more149 * passive conditions present on a battler.150 *151 * Version 1.16:152 * - Bypass the isDevToolsOpen() error when bad code is inserted into a script153 * call or custom Lunatic Mode code segment due to updating to MV 1.6.1.154 *155 * Version 1.15:156 * - Bug fixed that made global passives not apply to actors.157 *158 * Version 1.14:159 * - Updated for RPG Maker MV version 1.5.0.160 * - Added parameters: Actor Passives List, Enemy Passives List, and161 * Global Passives List162 *163 * Version 1.13:164 * - Lunatic Mode fail safes added.165 *166 * Version 1.12:167 * - Implemented <Custom Passive Condition> to now affect passive state ID's168 * added by Equip Battle Skills.169 *170 * Version 1.11:171 * - Added 'Global Passives' that encompass both actors and enemies.172 *173 * Version 1.10:174 * - Added compatibility functionality for Equip Battle Skills to add the175 * equipped passive states during battle test.176 *177 * Version 1.09:178 * - Added 'Actor Passives' and 'Enemy Passives' plugin parameters. This will179 * cause all actors and enemies respectively to be affected by the listed180 * states as passives.181 *182 * Version 1.08:183 * - Fixed conditional checks to make sure all states are being checked184 * properly without conflict with other conditional states.185 *186 * Version 1.07:187 * - Updated for RPG Maker MV version 1.1.0.188 *189 * Version 1.06:190 * - Added a mass member refresh whenever $gamePlayer is refreshed.191 *192 * Version 1.05a:193 * - Added Lunatic Mode - <Custom Passive Condition> notetag for states.194 * - Fixed a bug that would cause infinite loops.195 *196 * Version 1.04:197 * - Added a lot of passive condition notetags for states.198 * --- <Passive Condition: HP/MP Above/Below x%>199 * --- <Passive Condition: Stat Above/Below x>200 * --- <Passive Condition: Switch x ON/OFF>201 * --- <Passive Condition: Variable x Above/Below y>202 *203 * Version 1.03:204 * - Added refreshing whenever a new skill is learned to update passives.205 *206 * Version 1.02:207 * - Optimized passive state calculations to reduce lag.208 *209 * Version 1.01:210 * - Fixed a bug with having multiple passive states of the same ID.211 *212 * Version 1.00:213 * - Finished plugin!214 */215//=============================================================================216//=============================================================================217// Parameter Variables218//=============================================================================219Yanfly.SetupParameters = function() {220 Yanfly.Parameters = PluginManager.parameters('YEP_AutoPassiveStates');221 Yanfly.Param = Yanfly.Param || {};222 Yanfly.Param.APSActorPas = String(Yanfly.Parameters['Actor Passives']);223 Yanfly.Param.APSActorPas = Yanfly.Param.APSActorPas.split(' ');224 for (var i = 0; i < Yanfly.Param.APSActorPas.length; ++i) {225 Yanfly.Param.APSActorPas[i] = parseInt(Yanfly.Param.APSActorPas[i]);226 Yanfly.Param.APSActorPas[i] = Yanfly.Param.APSActorPas[i] || 0;227 }228 var data = JSON.parse(Yanfly.Parameters['Actor Passives List']);229 for (var i = 0; i < data.length; ++i) {230 var stateId = parseInt(data[i]);231 if (stateId <= 0) continue;232 if (Yanfly.Param.APSActorPas.contains(stateId)) continue;233 Yanfly.Param.APSActorPas.push(stateId);234 }235 Yanfly.Param.APSEnemyPas = String(Yanfly.Parameters['Enemy Passives']);236 Yanfly.Param.APSEnemyPas = Yanfly.Param.APSEnemyPas.split(' ');237 for (var i = 0; i < Yanfly.Param.APSEnemyPas.length; ++i) {238 Yanfly.Param.APSEnemyPas[i] = parseInt(Yanfly.Param.APSEnemyPas[i]);239 Yanfly.Param.APSEnemyPas[i] = Yanfly.Param.APSEnemyPas[i] || 0;240 }241 var data = JSON.parse(Yanfly.Parameters['Enemy Passives List']);242 for (var i = 0; i < data.length; ++i) {243 var stateId = parseInt(data[i]);244 if (stateId <= 0) continue;245 if (Yanfly.Param.APSEnemyPas.contains(stateId)) continue;246 Yanfly.Param.APSEnemyPas.push(stateId);247 }248 Yanfly.Param.APSGlobalPas = String(Yanfly.Parameters['Global Passives']);249 Yanfly.Param.APSGlobalPas = Yanfly.Param.APSGlobalPas.split(' ');250 for (var i = 0; i < Yanfly.Param.APSGlobalPas.length; ++i) {251 id = parseInt(Yanfly.Param.APSGlobalPas[i]);252 Yanfly.Param.APSActorPas.push(id);253 Yanfly.Param.APSEnemyPas.push(id);254 }255 var data = JSON.parse(Yanfly.Parameters['Global Passives List']);256 for (var i = 0; i < data.length; ++i) {257 var stateId = parseInt(data[i]);258 if (stateId <= 0) continue;259 if (!Yanfly.Param.APSActorPas.contains(stateId)) {260 Yanfly.Param.APSActorPas.push(stateId);261 }262 if (!Yanfly.Param.APSEnemyPas.contains(stateId)) {263 Yanfly.Param.APSEnemyPas.push(stateId);264 }265 }266};267Yanfly.SetupParameters();268//=============================================================================269// DataManager270//=============================================================================271Yanfly.APS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;272DataManager.isDatabaseLoaded = function() {273 if (!Yanfly.APS.DataManager_isDatabaseLoaded.call(this)) return false;274 if (!Yanfly._loaded_YEP_AutoPassiveStates) {275 this.processAPSNotetags1($dataActors, Yanfly.Param.APSActorPas);276 this.processAPSNotetags1($dataClasses);277 this.processAPSNotetags1($dataEnemies, Yanfly.Param.APSEnemyPas);278 this.processAPSNotetags1($dataSkills);279 this.processAPSNotetags1($dataWeapons);280 this.processAPSNotetags1($dataArmors);281 this.processAPSNotetags2($dataStates);282 Yanfly._loaded_YEP_AutoPassiveStates = true;283 }284 return true;285};286DataManager.processAPSNotetags1 = function(group, inheritArray) {287 var note1 = /<(?:PASSIVE STATE):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;288 var note2 = /<(?:PASSIVE STATE):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;289 for (var n = 1; n < group.length; n++) {290 var obj = group[n];291 var notedata = obj.note.split(/[\r\n]+/);292 obj.passiveStates = [];293 if (inheritArray) {294 obj.passiveStates = obj.passiveStates.concat(inheritArray);295 }296 for (var i = 0; i < notedata.length; i++) {297 var line = notedata[i];298 if (line.match(note1)) {299 var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');300 obj.passiveStates = obj.passiveStates.concat(array);301 } else if (line.match(note2)) {302 var range = Yanfly.Util.getRange(parseInt(RegExp.$1),303 parseInt(RegExp.$2));304 obj.passiveStates = obj.passiveStates.concat(range);305 }306 }307 }308};309DataManager.processAPSNotetags2 = function(group) {310 var note1a = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:ABOVE)[ ](\d+)([%ï¼
])>/i;311 var note1b = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:BELOW)[ ](\d+)([%ï¼
])>/i;312 var note2a = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:ABOVE)[ ](\d+)>/i;313 var note2b = /<(?:PASSIVE CONDITION):[ ](.*)[ ](?:BELOW)[ ](\d+)>/i;314 var note3a = /<(?:PASSIVE CONDITION):[ ]SWITCH[ ](\d+)[ ](.*)>/i;315 var notez1 = /<(?:CUSTOM PASSIVE CONDITION)>/i;316 var notez2 = /<\/(?:CUSTOM PASSIVE CONDITION)>/i;317 for (var n = 1; n < group.length; n++) {318 var obj = group[n];319 var notedata = obj.note.split(/[\r\n]+/);320 obj.passiveCondition = '';321 obj.passiveConditionEval = '';322 var evalMode = 'none';323 for (var i = 0; i < notedata.length; i++) {324 var line = notedata[i];325 if (line.match(note1a)) {326 var rate = parseFloat(RegExp.$2) * 0.01;327 var param = this.getPassiveConditionParamRate(String(RegExp.$1));328 var pass = 'if (' + param + ' <= ' + rate + ') condition = false;';329 obj.passiveCondition = obj.passiveCondition + pass + '\n';330 } else if (line.match(note1b)) {331 var rate = parseFloat(RegExp.$2) * 0.01;332 var param = this.getPassiveConditionParamRate(String(RegExp.$1));333 var pass = 'if (' + param + ' >= ' + rate + ') condition = false;';334 obj.passiveCondition = obj.passiveCondition + pass + '\n';335 } else if (line.match(note2a)) {336 var rate = parseInt(RegExp.$2);337 var param = this.getPassiveConditionParam(String(RegExp.$1));338 var pass = 'if (' + param + ' <= ' + rate + ') condition = false;';339 obj.passiveCondition = obj.passiveCondition + pass + '\n';340 } else if (line.match(note2b)) {341 var rate = parseInt(RegExp.$2);342 var param = this.getPassiveConditionParam(String(RegExp.$1));343 var pass = 'if (' + param + ' >= ' + rate + ') condition = false;';344 obj.passiveCondition = obj.passiveCondition + pass + '\n';345 } else if (line.match(note3a)) {346 var id = parseInt(RegExp.$1);347 var value = String(RegExp.$2).toUpperCase();348 var pass = ''349 if (['ON', 'TRUE', 'ENABLE', 'ENABLED'].contains(value)) {350 pass = 'if (!$gameSwitches.value(' + id + ')) condition = false;'351 }352 if (['OFF', 'FALSE', 'DISABLE', 'DISABLED'].contains(value)) {353 pass = 'if ($gameSwitches.value(' + id + ')) condition = false;'354 }355 if (pass === '') continue;356 obj.passiveCondition = obj.passiveCondition + pass + '\n';357 } else if (line.match(notez1)) {358 evalMode = 'custom passive condition';359 } else if (line.match(notez2)) {360 evalMode = 'none';361 } else if (evalMode === 'custom passive condition') {362 obj.passiveConditionEval = obj.passiveConditionEval + line + '\n';363 }364 }365 obj.passiveCondition = new Function('condition','a','user','subject','b',366 'target','s','v', obj.passiveCondition + '\nreturn condition;');367 obj.passiveConditionEval = new Function('condition','a','user','subject',368 'b','target','s','v', obj.passiveConditionEval + '\nreturn condition;');369 }370};371DataManager.getPassiveConditionParam = function(string) {372 string = string.toUpperCase();373 var text = 'user.';374 if (['HP'].contains(string)) text += 'hp';375 if (['MP', 'SP'].contains(string)) text += 'mp';376 if (['TP'].contains(string)) text += 'tp';377 if (['ATK'].contains(string)) text += 'param(2)';378 if (['DEF'].contains(string)) text += 'param(3)';379 if (['MAT', 'INT'].contains(string)) text += 'param(4)';380 if (['MDF', 'RES'].contains(string)) text += 'param(5)';381 if (['AGI'].contains(string)) text += 'param(6)';382 if (['LUK'].contains(string)) text += 'param(7)';383 if (['MAX HP', 'MAXHP'].contains(string)) text += 'mhp';384 if (['MAX MP', 'MAX SP', 'MAXMP', 'MAXSP'].contains(string)) text += 'mmp';385 if (string.match(/VARIABLE[ ](\d+)/i)) {386 text = '$gameVariables.value(' + parseInt(RegExp.$1) + ')';387 }388 return text;389};390DataManager.getPassiveConditionParamRate = function(string) {391 string = string.toUpperCase();392 var text = '0';393 if (['HP'].contains(string)) return 'user.hpRate()';394 if (['MP'].contains(string)) return 'user.mpRate()';395 return text;396};397//=============================================================================398// Game_BattlerBase399//=============================================================================400Yanfly.APS.Game_BattlerBase_refresh = Game_BattlerBase.prototype.refresh;401Game_BattlerBase.prototype.refresh = function() {402 this._passiveStatesRaw = undefined;403 Yanfly.APS.Game_BattlerBase_refresh.call(this);404};405Yanfly.APS.Game_BattlerBase_states = Game_BattlerBase.prototype.states;406Game_BattlerBase.prototype.states = function() {407 var array = Yanfly.APS.Game_BattlerBase_states.call(this);408 array = array.concat(this.passiveStates());409 this.sortPassiveStates(array);410 return array;411};412Yanfly.APS.Game_BattlerBase_isStateAffected =413 Game_BattlerBase.prototype.isStateAffected;414Game_BattlerBase.prototype.isStateAffected = function(stateId) {415 if (this.isPassiveStateAffected(stateId)) return true;416 return Yanfly.APS.Game_BattlerBase_isStateAffected.call(this, stateId);417};418Game_BattlerBase.prototype.passiveStates = function() {419 var array = [];420 var raw = this.passiveStatesRaw();421 for (var i = 0; i < raw.length; ++i) {422 var state = $dataStates[raw[i]];423 if (state && array.contains(state)) continue;424 array.push(state);425 }426 return array;427};428Game_BattlerBase.prototype.passiveStatesRaw = function() {429 var array = [];430 return array.filter(Yanfly.Util.onlyUnique);431};432Game_BattlerBase.prototype.getPassiveStateData = function(obj) {433 if (!obj) return [];434 if (!obj.passiveStates) return [];435 var array = [];436 for (var i = 0; i < obj.passiveStates.length; ++i) {437 var stateId = obj.passiveStates[i];438 if (!this.meetPassiveStateCondition(stateId)) continue;439 array.push(stateId);440 }441 var added = this.addEquipBattleTestSkillPassives(obj);442 if (added.length > 0) {443 for (var i = 0; i < added.length; ++i) {444 var stateId = added[i];445 if (!this.meetPassiveStateCondition(stateId)) continue;446 array.push(stateId);447 }448 }449 return array;450};451Game_BattlerBase.prototype.addEquipBattleTestSkillPassives = function(obj) {452 if (!Imported.YEP_EquipBattleSkills) return [];453 if (!DataManager.isBattleTest()) return [];454 if (!DataManager.isSkill(obj)) return [];455 return obj.equipStates;456};457Game_BattlerBase.prototype.meetPassiveStateCondition = function(stateId) {458 this._checkPassiveStateCondition = this._checkPassiveStateCondition || [];459 if (this._checkPassiveStateCondition.contains(stateId)) return false;460 var state = $dataStates[stateId];461 if (!state) return false;462 if (state.passiveCondition !== '') {463 if (!this.passiveStateConditions(state)) return false;464 }465 if (state.passiveConditionEval === '') return true;466 return this.passiveStateConditionEval(state);467};468Game_BattlerBase.prototype.passiveStateConditions = function(state) {469 this._checkPassiveStateCondition = this._checkPassiveStateCondition || [];470 this._checkPassiveStateCondition.push(state.id);471 var condition = true;472 var a = this;473 var user = this;474 var subject = this;475 var b = this;476 var target = this;477 var s = $gameSwitches._data;478 var v = $gameVariables._data;479 var code = state.passiveCondition;480 try {481 condition = state.passiveCondition.call(this, condition, a, user, subject,482 b, target, s, v);483 } catch (e) {484 Yanfly.Util.displayError(e, code, 'PASSIVE STATE CUSTOM CONDITION ERROR');485 }486 var index = this._checkPassiveStateCondition.indexOf(state.id);487 this._checkPassiveStateCondition.splice(index, 1);488 return condition;489};490Game_BattlerBase.prototype.passiveStateConditionEval = function(state) {491 this._checkPassiveStateCondition = this._checkPassiveStateCondition || [];492 this._checkPassiveStateCondition.push(state.id);493 var condition = true;494 var a = this;495 var user = this;496 var subject = this;497 var b = this;498 var target = this;499 var s = $gameSwitches._data;500 var v = $gameVariables._data;501 var code = state.passiveConditionEval;502 try {503 condition = state.passiveConditionEval.call(this, condition, a, user,504 subject, b, target, s, v);505 } catch (e) {506 Yanfly.Util.displayError(e, code, 'PASSIVE STATE CUSTOM CONDITION ERROR');507 }508 var index = this._checkPassiveStateCondition.indexOf(state.id);509 this._checkPassiveStateCondition.splice(index, 1);510 return condition;511};512Game_BattlerBase.prototype.sortPassiveStates = function(array) {513 array.sort(function(a, b) {514 var p1 = a.priority;515 var p2 = b.priority;516 if (p1 !== p2) return p2 - p1;517 return a - b;518 });519};520Game_BattlerBase.prototype.isPassiveStateAffected = function(stateId) {521 return this.passiveStatesRaw().contains(stateId);522};523//=============================================================================524// Game_Battler525//=============================================================================526Yanfly.APS.Game_Battler_isStateAddable = Game_Battler.prototype.isStateAddable;527Game_Battler.prototype.isStateAddable = function(stateId) {528 if (this.isPassiveStateAffected(stateId)) return false;529 return Yanfly.APS.Game_Battler_isStateAddable.call(this, stateId);530};531Yanfly.APS.Game_Battler_removeState = Game_Battler.prototype.removeState;532Game_Battler.prototype.removeState = function(stateId) {533 if (this.isPassiveStateAffected(stateId)) return;534 Yanfly.APS.Game_Battler_removeState.call(this, stateId);535};536//=============================================================================537// Game_Actor538//=============================================================================539Game_Actor.prototype.passiveStatesRaw = function() {540 if (this._passiveStatesRaw !== undefined) return this._passiveStatesRaw;541 var array = Game_BattlerBase.prototype.passiveStatesRaw.call(this);542 array = array.concat(this.getPassiveStateData(this.actor()));543 array = array.concat(this.getPassiveStateData(this.currentClass()));544 for (var i = 0; i < this.equips().length; ++i) {545 var equip = this.equips()[i];546 array = array.concat(this.getPassiveStateData(equip));547 }548 for (var i = 0; i < this._skills.length; ++i) {549 var skill = $dataSkills[this._skills[i]];550 array = array.concat(this.getPassiveStateData(skill));551 }552 this._passiveStatesRaw = array.filter(Yanfly.Util.onlyUnique)553 return this._passiveStatesRaw;554};555Yanfly.APS.Game_Actor_learnSkill = Game_Actor.prototype.learnSkill;556Game_Actor.prototype.learnSkill = function(skillId) {557 Yanfly.APS.Game_Actor_learnSkill.call(this, skillId);558 this._passiveStatesRaw = undefined;559};560Yanfly.APS.Game_Actor_forgetSkill = Game_Actor.prototype.forgetSkill;561Game_Actor.prototype.forgetSkill = function(skillId) {562 Yanfly.APS.Game_Actor_forgetSkill.call(this, skillId);563 this._passiveStatesRaw = undefined;564};565//=============================================================================566// Game_Enemy567//=============================================================================568Game_Enemy.prototype.passiveStatesRaw = function() {569 if (this._passiveStatesRaw !== undefined) return this._passiveStatesRaw;570 var array = Game_BattlerBase.prototype.passiveStatesRaw.call(this);571 array = array.concat(this.getPassiveStateData(this.enemy()));572 for (var i = 0; i < this.skills().length; ++i) {573 var skill = this.skills()[i];574 array = array.concat(this.getPassiveStateData(skill));575 }576 this._passiveStatesRaw = array.filter(Yanfly.Util.onlyUnique)577 return this._passiveStatesRaw;578};579if (!Game_Enemy.prototype.skills) {580 Game_Enemy.prototype.skills = function() {581 var skills = []582 for (var i = 0; i < this.enemy().actions.length; ++i) {583 var skill = $dataSkills[this.enemy().actions[i].skillId];584 if (skill) skills.push(skill);585 }586 return skills;587 }588};589//=============================================================================590// Game_Unit591//=============================================================================592Game_Unit.prototype.refreshMembers = function() {593 var group = this.allMembers();594 var length = group.length;595 for (var i = 0; i < length; ++i) {596 var member = group[i];597 if (member) member.refresh();598 }599};600Game_Unit.prototype.allMembers = function() {601 return this.members();602};603//=============================================================================604// Game_Player605//=============================================================================606Yanfly.APS.Game_Player_refresh = Game_Player.prototype.refresh;607Game_Player.prototype.refresh = function() {608 $gameParty.refreshMembers();609 Yanfly.APS.Game_Player_refresh.call(this);610};611//=============================================================================612// Utilities613//=============================================================================614Yanfly.Util = Yanfly.Util || {};615Yanfly.Util.displayError = function(e, code, message) {616 console.log(message);617 console.log(code || 'NON-EXISTENT');618 console.error(e);619 if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= "1.6.0") return;620 if (Utils.isNwjs() && Utils.isOptionValid('test')) {621 if (!require('nw.gui').Window.get().isDevToolsOpen()) {622 require('nw.gui').Window.get().showDevTools();623 }624 }625};626Yanfly.Util.getRange = function(n, m) {627 var result = [];628 for (var i = n; i <= m; ++i) result.push(i);629 return result;630};631Yanfly.Util.onlyUnique = function(value, index, self) {632 return self.indexOf(value) === index;633};634//=============================================================================635// End of File...
showingPassiveImageSkill.js
Source:showingPassiveImageSkill.js
1export default function showingPassiveImageSkill (heroClass,numberOfSkill) {2 let url;3 switch (heroClass) {4 case 'Mage':5 switch (numberOfSkill) {6 case 1:7 url = 'skills/passive/mage/1';8 break;9 case 2:10 url = 'skills/passive/mage/2';11 break;12 case 3:13 url = 'skills/passive/mage/3';14 break;15 case 4:16 url = 'skills/passive/mage/4';17 break;18 case 5:19 url = 'skills/passive/mage/5';20 break;21 case 6:22 url = 'skills/passive/mage/6';23 break;24 case 7:25 url = 'skills/passive/mage/7';26 break;27 case 8:28 url = 'skills/passive/mage/8';29 break;30 case 9:31 url = 'skills/passive/mage/9';32 break;33 case 10:34 url = 'skills/passive/mage/10';35 break;36 case 11:37 url = 'skills/passive/mage/11';38 break;39 case 12:40 url = 'skills/passive/mage/12';41 break;42 default:43 break;44 }45 break;46 case 'Priest':47 switch (numberOfSkill) {48 case 1:49 url = 'skills/passive/priest/1';50 break;51 case 2:52 url = 'skills/passive/priest/2';53 break;54 case 3:55 url = 'skills/passive/priest/3';56 break;57 case 4:58 url = 'skills/passive/priest/4';59 break;60 case 5:61 url = 'skills/passive/priest/5';62 break;63 case 6:64 url = 'skills/passive/priest/6';65 break;66 case 7:67 url = 'skills/passive/priest/7';68 break;69 case 8:70 url = 'skills/passive/priest/8';71 break;72 case 9:73 url = 'skills/passive/priest/9';74 break;75 case 10:76 url = 'skills/passive/priest/10';77 break;78 case 11:79 url = 'skills/passive/priest/11';80 break;81 case 12:82 url = 'skills/passive/priest/12';83 break;84 default:85 break;86 }87 break;88 case 'Berserk':89 switch (numberOfSkill) {90 case 1:91 url = 'skills/passive/berserk/1';92 break;93 case 2:94 url = 'skills/passive/berserk/2';95 break;96 case 3:97 url = 'skills/passive/berserk/3';98 break;99 case 4:100 url = 'skills/passive/berserk/4';101 break;102 case 5:103 url = 'skills/passive/berserk/5';104 break;105 case 6:106 url = 'skills/passive/berserk/6';107 break;108 case 7:109 url = 'skills/passive/berserk/7';110 break;111 case 8:112 url = 'skills/passive/berserk/8';113 break;114 case 9:115 url = 'skills/passive/berserk/9';116 break;117 case 10:118 url = 'skills/passive/berserk/10';119 break;120 case 11:121 url = 'skills/passive/berserk/11';122 break;123 case 12:124 url = 'skills/passive/berserk/12';125 break;126 default:127 break;128 }129 break;130 case 'Hunter':131 switch (numberOfSkill) {132 case 1:133 url = 'skills/passive/hunter/1';134 break;135 case 2:136 url = 'skills/passive/hunter/2';137 break;138 case 3:139 url = 'skills/passive/hunter/3';140 break;141 case 4:142 url = 'skills/passive/hunter/4';143 break;144 case 5:145 url = 'skills/passive/hunter/5';146 break;147 case 6:148 url = 'skills/passive/hunter/6';149 break;150 case 7:151 url = 'skills/passive/hunter/7';152 break;153 case 8:154 url = 'skills/passive/hunter/8';155 break;156 case 9:157 url = 'skills/passive/hunter/9';158 break;159 case 10:160 url = 'skills/passive/hunter/10';161 break;162 case 11:163 url = 'skills/passive/hunter/11';164 break;165 case 12:166 url = 'skills/passive/hunter/12';167 break;168 default:169 break;170 }171 break;172 case 'Warrior':173 switch (numberOfSkill) {174 case 1:175 url = 'skills/passive/warrior/1';176 break;177 case 2:178 url = 'skills/passive/warrior/2';179 break;180 case 3:181 url = 'skills/passive/warrior/3';182 break;183 case 4:184 url = 'skills/passive/warrior/4';185 break;186 case 5:187 url = 'skills/passive/warrior/5';188 break;189 case 6:190 url = 'skills/passive/warrior/6';191 break;192 case 7:193 url = 'skills/passive/warrior/7';194 break;195 case 8:196 url = 'skills/passive/warrior/8';197 break;198 case 9:199 url = 'skills/passive/warrior/9';200 break;201 case 10:202 url = 'skills/passive/warrior/10';203 break;204 case 11:205 url = 'skills/passive/warrior/11';206 break;207 case 12:208 url = 'skills/passive/warrior/12';209 break;210 default:211 break;212 }213 break;214 default:215 break;216 }217 return url;...
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest(options);5}, function(err, data) {6 if (err) return console.error(err);7 console.log('Test status: ' + data.statusText);8 console.log('View your test at: ' + data.data.userUrl);9});10var wpt = require('webpagetest');11var options = {12};13var wpt = new WebPageTest(options);14}, function(err, data) {15 if (err) return console.error(err);16 console.log('Test status: ' + data.statusText);17 console.log('View your test at: ' + data.data.userUrl);18});19var wpt = require('webpagetest');20var options = {21};22var wpt = new WebPageTest(options);23}, function(err, data) {24 if (err) return console.error(err);25 console.log('Test status: ' + data.statusText);26 console.log('View your test at: ' + data.data.userUrl);27});28var wpt = require('webpagetest
Using AI Code Generation
1var wpt = require('webpagetest')('www.webpagetest.org','A.12345678901234567890123456789012');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13});14}, function(err, data) {15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});21}, function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28}, function(err, data) {29 if (err) {30 console.log(err);31 } else {32 console.log(data);33 }34});35}, function(err, data) {36 if (err) {37 console.log(err);38 } else {39 console.log(data);40 }41});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.5e5b6c1af6f9b6f8e6e5c6f5d6e5f6e5');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status:', data.statusText);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org', 'A.5e5b6c1af6f9b6f8e6e5c6f5d6e5f6e5');9}, function(err, data) {10 if (err) return console.error(err);11 console.log('Test status:', data.statusText);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org', 'A.5e5b6c1af6f9b6f8e6e5c6f5d6e5f
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!