Advertisement
Astfgl

AstfglSCB

Aug 19th, 2018
1,699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //===================================================================================
  2. // Astfgl's Shield counter and Break
  3. // Date 19/08/2018
  4. // Free to use non commercially, commercially, repost and
  5. // edit, as long as the final product is kept under the same terms of use.
  6. // Credits required, any of Astfgl, Astgfl (Pierre MATEO), Pierre MATEO
  7. // Credits goes to yanfly for modified parts of battle engine core
  8. // v1.0 19/08: release
  9. // v1.1 21/08 modified shield display modes
  10. // v1.2 25/08 created weakness display, added parameters for shield mode, made weakness display save
  11. // v1.3 25/08 added notetags to actor enemies and states to allow not displaying shield value
  12. // v1.4 04/09 added revealRandomWeakness functions, added option for actors or enemies to not use shields,
  13. // added option to reset known weaknesses after combat.
  14. // v1.5 24/02/20 added shImpact notetag, fixed misses or evades from modifying shield count
  15. // v1.5.1 29/02/20 Fixed default state bug
  16. // Time spent : 8h35
  17. //====================================================================================
  18.  
  19. /*:
  20.  * @plugindesc OT Shield and Break System
  21.  * @author Astfgl
  22.  *
  23.  * @param globalMode
  24.  * @text Shield usage
  25.  * @type number
  26.  * @default 0
  27.  * @desc 0-> all, 1-> actors only -> 2 -> enemies only
  28.  
  29.  * @param defaultState
  30.  * @text State Id when shield = 0
  31.  * @type number
  32.  * @default 4
  33.  * @desc Which state will be applied when a battler shield reaches 0.
  34.  *
  35.  * @param defaultElemCutoff
  36.  * @text Elemental weakness cutoff
  37.  * @type number
  38.  * @default 1
  39.  * @desc Attacks must have an elemental value strictly superior to this to remove from the shield counter.
  40.  *
  41.  * @param baseIcon
  42.  * @text Base shield Icon
  43.  * @type number
  44.  * @default 16
  45.  * @desc The icon id to display shields.
  46.  *
  47.  * @param mode
  48.  * @text Shield display mode
  49.  * @type number
  50.  * @default 0
  51.  * @desc 0->number in brackets, 1 -> number in icon
  52.  *
  53.  * @param showWeaknesses
  54.  * @text Show weaknesses below enemy name
  55.  * @type number
  56.  * @default 1
  57.  * @desc 0-> don't show weaknesses, 1 -> show weaknesses
  58.  *
  59.  * @param wIArray
  60.  * @text Weakness Icon Array
  61.  * @default [0,0,0,0,0,0,0,0,0,0]
  62.  * @desc Icons for each elemental weakness, in order from your elements list in the system tab with a leading "0,".
  63.  *
  64.  * @param defautWeaknessIcon
  65.  * @text Undiscovered Weakness icon
  66.  * @type number
  67.  * @default 16
  68.  * @desc The icon id that will be used to display undiscovered weaknesses.
  69.  *
  70.  * @param saveWeakness
  71.  * @text Save weaknesses
  72.  * @type boolean
  73.  * @default true
  74.  * @desc If this parameter is set to false, discovered weaknesses will be reset at battle end.
  75.  *
  76.  *
  77.  * @help
  78.  *Allows you to set up a shield and break system similar to Octopath traveler's
  79.  *Recommended plugins:
  80.  * - Yanfly's Battle engine core
  81.  * - Yanfly's Element core
  82.  * - Yanfly's Buffs and state core
  83.  *It has not been tested without these plugins and thus may not function.
  84.  *
  85.  *==========================================
  86.  * What it does:
  87.  *==========================================
  88.  *In battle, if an attack hits an elemental weakness,
  89.  *it will decrease a shield counter, once that counter reaches 0
  90.  *a state will be applied to the battler.
  91.  *
  92.  *It will reduce the shield counter by 1 for each element of the attack
  93.  *the recipient is weak to.
  94.  *So if your attack deals fire and ice damage and the enemy is weak to both
  95.  *shields will be reduced by 2.
  96.  *
  97.  *Display of the shield amount is done via the battler name in brackets or with an icon.
  98.  *
  99.  *It also creates a weakness icon array below the monster.
  100.  *If the show weakness parameter is set to 1, it will display any element
  101.  *weakness reaching the default cutoff with the icon corresponding to the defined id
  102.  *in the weakness icon array below the battler name.
  103.  *
  104.  *==========================================
  105.  * How to use:
  106.  *==========================================
  107.  *Set max shield notetags:
  108.  *
  109.  *Order for max shield calculation:
  110.  *actor, class, equipment, passive states, states then floored
  111.  *Notetags: <mSh: >, Ex: <mSh: num += 5>
  112.  *
  113.  *Each time calculations are made with the num variable.
  114.  *Ex: num += 5 in actor, num *= 2 in class will result in a max shield of 10
  115.  *The same thing but with a state using num = 1 will result in a max shield of 1
  116.  *
  117.  *Enemies are the same except you remove class and equipment calculations
  118.  *
  119.  *If you don't set anything, battlers have a default shield value of 1.
  120.  *
  121.  *If you want it to function like octopath traveler, I recommend
  122.  *using a state with the cannot move property, set to expire in 2 turns
  123.  *and with the following notetag:
  124.  *<Custom Remove Effect>
  125.  *user._sh = user._mSh;
  126.  *</Custom Remove Effect>
  127.  *This will restore shields to maximum when the broken state expires.
  128.  *
  129.  *==========================================
  130.  * Changing break state
  131.  *==========================================
  132.  *If you want to change what state enemies are inflected with upon break use:
  133.  *<DBS: > in an enemy note box
  134.  *Else it will use what's inside plugin parameters
  135.  *
  136.  *==========================================
  137.  * Modifying enemy shields:
  138.  *==========================================
  139.  * Use the following script calls:
  140.  * (battler).modMaxSh(number)
  141.  * This will add number to max shields, after all other calculations.
  142.  * This bonus will never be reset.
  143.  * Use states for temporary modifications for actors.
  144.  *
  145.  * (battler).changeSh(number), this will withdraw number from current shields
  146.  *
  147.  *All parameters and notetags are evaled
  148.  *
  149.  *==========================================
  150.  * How to setup weakness display array:
  151.  *==========================================
  152.  *
  153.  * The parameter is an array of icon ids with a leading 0.
  154.  * For default projects it would be:
  155.  * [0,physicalIconId,fireIconId,...,darknessIconId]
  156.  *
  157.  *==========================================
  158.  * How to hide shield amount
  159.  *==========================================
  160.  * Use the following notetag in an actor enemy or state notebox:
  161.  * <shieldDisplay:false>
  162.  *
  163.  *==========================================
  164.  * How to make a specific battler not use shields
  165.  *==========================================
  166.  * Use the following notetag in an actor enemy or state notebox:
  167.  * <shieldDisplay:none>
  168.  * This battler will not display his shields and will not suffer
  169.  * from break.
  170.  *==========================================
  171.  * How to reveal weaknesses
  172.  *==========================================
  173.  * Use the following script calls:
  174.  * battler.revealRandomWeakness()
  175.  * to reveal one weakness for an enemy type.
  176.  * Replace battler accordingly with a b user or target in
  177.  * notetags or the damage formula.
  178.  *
  179.  * You can reveal one weakness at random for each enemy type
  180.  * in the troop with the following script call:
  181.  * $gameTroop.revealRandomWeakness();
  182.  *
  183.  *==========================================
  184.  * How to modify shield depletion
  185.  *==========================================
  186.  * You can change the amount from which a skill or item
  187.  * impacts the shield counter using the following notetag:
  188.  * <shImpact: X>
  189.  * This notetag is evaled and is executed in the Game_Action context.
  190.  *
  191.  * ex: <shImpact: 3> will remove 3 points from the shield gauge if striking a weakness
  192.  * ex: <shImpact: -1> will add 1 point to the shield gauge if striking a weakness
  193.  * ex: <shImpact: if (target.result().critical) {3} else {1}>
  194.  * this will substract 3 on a critical strike and 1 on a regular strike
  195.  *
  196. */
  197. var Astfgl = Astfgl || {};
  198. Astfgl.enemies = Astfgl.enemies || {};
  199. Astfgl.enemies.disWeak = [];
  200.  
  201. (function(){
  202. //get parameters value
  203. var defaultState = eval(PluginManager.parameters("AstfglSCB").defaultState);
  204. var defaultElemCutoff = eval(PluginManager.parameters("AstfglSCB").defaultElemCutoff);
  205. var mode = eval(PluginManager.parameters("AstfglSCB").mode)
  206. var shieldIcon = eval(PluginManager.parameters("AstfglSCB").baseIcon)
  207. var showWeaknesses = eval(PluginManager.parameters("AstfglSCB").showWeaknesses)
  208. var wIArray =  eval(PluginManager.parameters("AstfglSCB").wIArray)
  209. var defautWeaknessIcon = eval(PluginManager.parameters("AstfglSCB").defautWeaknessIcon)
  210. var globalMode = eval(PluginManager.parameters("AstfglSCB").globalMode)
  211. var saveWeakness = eval(PluginManager.parameters("AstfglSCB").saveWeakness)
  212.  
  213. //Weakness setup
  214. var _aliasGAI = Game_Actor.prototype.initialize
  215. Game_Actor.prototype.initialize = function(actorId) {
  216.     _aliasGAI.call(this,actorId);
  217.     if (this._actorId === 0) {return}
  218.     if (globalMode !== 2) {
  219.     this._mShB = 0;
  220.     this._mSh = this.getMaxSh();
  221.     this._sh = this._mSh
  222.     }
  223. };
  224.  
  225. //get max shield value from notetags
  226. Game_Actor.prototype.getMaxSh = function() {
  227.     var num = 0;
  228.     var a = this;
  229.     var user = this;
  230.     var id = this.actorId();
  231.     if ($dataActors[id].meta.mSh) {
  232.         num = eval($dataActors[id].meta.mSh)
  233.     }
  234.     if ($dataClasses[this._classId].meta.mSh) {
  235.         num = eval($dataActors[id].meta.mSh)
  236.     }
  237.     for (let i = 0; i < this._equips.length; i++) {
  238.         var it = this._equips[i];
  239.         if (it._dataClass === "weapon" && it._itemId !== 0) {
  240.             if ($dataWeapons[it._itemId].meta.mSh) {
  241.                 num = eval($dataWeapons[it._itemId].meta.mSh)
  242.             }
  243.  
  244.         }
  245.         if (it._dataClass === "armor" && it._itemId !== 0) {
  246.             if ($dataArmors[it._itemId].meta.mSh) {
  247.                 num = eval($dataArmors[it._itemId].meta.mSh)
  248.             }
  249.  
  250.         }
  251.     }
  252.     if (this._passiveStatesRaw) {
  253.         for (let i = 0; i < this._passiveStatesRaw.length; i ++) {
  254.             if ($dataStates[this._passiveStatesRaw[i]].meta.mSh) {
  255.                 num = eval($dataStates[this._passiveStatesRaw[i]].meta.mSh)
  256.             }
  257.         }
  258.     }
  259.     for (let i = 0; i < this._states.length; i ++) {
  260.         if ($dataStates[this._states[i]].meta.mSh) {
  261.             num = eval($dataStates[this._states[i]].meta.mSh)
  262.         }
  263.     }
  264.     num +=  this._mShB
  265.     num = Math.floor(num)
  266.     if (num === 0 || isNaN(num)) {num = 1}
  267.     return num
  268. }
  269.  
  270. //setup enemies shield
  271. var _aliasGEI = Game_Enemy.prototype.initialize
  272. Game_Enemy.prototype.initialize = function(enemyId, x, y) {
  273.     _aliasGEI.call(this,enemyId, x, y);
  274.     if (this._enemyId === 0) {return};
  275.     if (globalMode !== 1) {
  276.         this._mShB = 0;
  277.         this._mSh = this.getMaxSh()
  278.         this._sh = this._mSh;
  279.     }
  280.     //create known weakness array the first time an enemy is initialized
  281.     if (Astfgl.enemies.disWeak.length === 0) {
  282.         for (let i = 0; i < $dataEnemies.length; i++) {
  283.             var _WI = [];
  284.             for (let i = 0; i < $dataSystem.elements.length; i ++) {
  285.                 _WI.push(0);
  286.             }
  287.         Astfgl.enemies.disWeak.push(_WI)
  288.         }
  289.     }
  290.  
  291. };
  292.  
  293. //get max enemy shield value from enemy and state notetags
  294. Game_Enemy.prototype.getMaxSh = function() {
  295.     var num = 0;
  296.     var a = this;
  297.     var user = this;
  298.     var id = this._enemyId;
  299.     if ($dataEnemies[id].meta.mSh) {
  300.         num = eval($dataEnemies[id].meta.mSh)
  301.     }
  302.     if (this._passiveStatesRaw) {
  303.         for (let i = 0; i < this._passiveStatesRaw.length; i ++) {
  304.             if ($dataStates[this._passiveStatesRaw[i]].meta.mSh) {
  305.                 num = eval($dataStates[this._passiveStatesRaw[i]].meta.mSh)
  306.             }
  307.         }
  308.     }
  309.     for (let i = 0; i < this._states.length; i ++) {
  310.         if ($dataStates[this._states[i]].meta.mSh) {
  311.             num = eval($dataStates[this._states[i]].meta.mSh)
  312.         }
  313.     }
  314.     num += this._mShB;
  315.     num = Math.floor(num)
  316.     if (num === 0 || isNaN(num)) {num = 1}
  317.     return num
  318. }
  319.  
  320. //check for shield display amount
  321. Game_Battler.prototype.checkShieldDisplay = function() {
  322.     var value = true;
  323.     var data;
  324.     if (this.isEnemy()) {data = $dataEnemies[this._enemyId]}
  325.     if (this.isActor()) {data = $dataActors[this.actorId()]}
  326.     if (data.meta.shieldDisplay) {
  327.         if (data.meta.shieldDisplay === "none") {return "none"}
  328.         value = eval(data.meta.shieldDisplay);
  329.     }
  330.     if (!value) {return value}
  331.     if (this._passiveStatesRaw) {
  332.         for (let i = 0; i < this._passiveStatesRaw.length; i ++) {
  333.             if ($dataStates[this._passiveStatesRaw[i]].meta.shieldDisplay) {
  334.                 value = eval($dataStates[this._passiveStatesRaw[i]].meta.shieldDisplay)
  335.                 if (!value) {return value}
  336.             }
  337.         }
  338.     }
  339.     for (let i = 0; i < this._states.length; i ++) {
  340.         if ($dataStates[this._states[i]].meta.shieldDisplay) {
  341.             value = eval($dataStates[this._states[i]].meta.shieldDisplay)
  342.             if (!value) {return value}
  343.         }
  344.     }
  345.     return value
  346. }
  347.  
  348. //store known weaknesses in global array
  349. Game_Enemy.prototype.checkWeaknessDisplay = function (num) {
  350.     if (Astfgl.enemies.disWeak[this._enemyId][num] === 0) {
  351.         Astfgl.enemies.disWeak[this._enemyId][num] = 1
  352.     }
  353. }
  354.  
  355. //Action modifying
  356. var _aliasGAA = Game_Action.prototype.apply
  357. Game_Action.prototype.apply = function(target) {
  358.     _aliasGAA.call(this,target)
  359.     //don't substract if miss or evade
  360.     if (target.result().missed || target.result().evaded) {return}
  361.     //check the amount to modify shield by
  362.     var a = 1;
  363.     var id = this._item._itemId
  364.     if (this._item._dataClass === "skill") {
  365.         if ($dataSkills[id].meta.shImpact) {
  366.             a = eval($dataSkills[id].meta.shImpact)
  367.         }
  368.     } else if (this._item._dataClass === "item") {
  369.         if ($dataItems[id].meta.shImpact) {
  370.             a = eval($dataItems[id].meta.shImpact)
  371.         }
  372.     }
  373.     var mod = 0;
  374.     var elements = this.getItemElements();
  375.     for (let i = 0; i < elements.length; i++) {
  376.         if (target.elementRate(elements[i]) > defaultElemCutoff) {
  377.             mod += a;
  378.             if (!target.isActor()) {
  379.                 target.checkWeaknessDisplay(elements[i])
  380.             }
  381.         }
  382.     }
  383.     target.changeSh(mod);
  384. }
  385.  
  386. Game_Battler.prototype.changeSh = function(num) {
  387.     if (this._sh === 0) {return}
  388.     if (globalMode === 2 && this.isActor()) {return}
  389.     if (globalMode === 1 && this.isEnemy()) {return}
  390.     if (this.checkShieldDisplay() === "none") {return}
  391.     this._sh -= num;
  392.     this._sh = this._sh.clamp(0,this._mSh);
  393.     var st = defaultState;
  394.     if (this._sh === 0) {
  395.         if (this.isActor()) {if ($dataActors[this.actorId()].meta.DBS) {st = eval($dataActors[this.actorId()].meta.DBS)}}
  396.         else {if ($dataEnemies[this._enemyId].meta.DBS) {st = eval($dataEnemies[this._enemyId].meta.DBS)}}
  397.         this.addState(st)
  398.     };
  399. }
  400.  
  401. /*
  402. //Modify name function to display shield amount
  403. var _aliasGEN = Game_Enemy.prototype.name
  404. Game_Enemy.prototype.name = function() {
  405.     if ( mode === 0 ) {return _aliasGEN.call(this); }
  406.     return "[" + this._sh + "]" + this.originalName() + (this._plural ? this._letter : '');
  407. }*/
  408.  
  409. //Modify battle window draw name function to display shield amount
  410. var _aliasWBSDAN = Window_BattleStatus.prototype.drawActorName
  411. Window_BattleStatus.prototype.drawActorName = function(actor, x, y, width) {
  412.     if (globalMode === 2 || actor.checkShieldDisplay() === "none") {_aliasWBSDAN.call(this,actor,x,y,width); return}
  413.     width = width || 168;
  414.     this.changeTextColor(this.hpColor(actor));
  415.     if (mode === 1) {
  416.         var fs = this.contents.fontSize
  417.         this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  418.         this.drawIcon(shieldIcon,x,y+3)
  419.         if (actor.checkShieldDisplay()) {
  420.             var wd = this.textWidth(String(actor._sh));
  421.             this.drawText(actor._sh, x + 16 - wd/2, y, 40);
  422.         } else {
  423.             var wd = this.textWidth("?");
  424.             this.drawText("?", x + 16 - wd/2, y, 40);
  425.         }
  426.         this.contents.fontSize = fs
  427.         this.drawText(actor.name(), x + 40, y, width - 48);
  428.     } else {
  429.         if (actor.checkShieldDisplay()) {
  430.             this.drawText("["+ actor._sh + "]" + actor.name(), x, y, width);
  431.         } else {
  432.             this.drawText("[?]" + actor.name(), x, y, width);
  433.         }
  434.     }
  435. }
  436.  
  437. //Modify enemy name display
  438. var _aliasWEVSR = Window_EnemyVisualSelect.prototype.refresh
  439. Window_EnemyVisualSelect.prototype.refresh = function() {
  440.     this.contents.clear();
  441.     if (!this._battler) return;
  442.     if (!this._showEnemyName) return;
  443.     if (this._battler.isHidden()) return;
  444.     this._requestRefresh = false;
  445.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  446.     var text = this._battler.name();
  447.     var wy = this.contents.height - this.lineHeight() * 2;
  448.     if (globalMode !== 1 && this._battler.checkShieldDisplay() !== "none") {
  449.         if (mode === 1) {
  450.                 this.drawIcon(shieldIcon,0,wy+3)
  451.                 if (this._battler.checkShieldDisplay()) {
  452.                     var wd = this.textWidth(String(this._battler._sh));
  453.                     this.drawText(this._battler._sh, 16 - wd/2, wy, 40);
  454.                 } else {
  455.                     var wd = this.textWidth("?");
  456.                     this.drawText("?", 16 - wd/2, wy, 40);
  457.                 }
  458.                 this.drawText(text, 40, wy, this.contents.width, 'left');
  459.         } else {
  460.                 if (this._battler.checkShieldDisplay()) {
  461.                     this.drawText("[" + this._battler._sh + "]" + text, 0, wy, this.contents.width, 'center');
  462.                 } else {
  463.                     this.drawText("[?]" + text, 0, wy, this.contents.width, 'center');
  464.                 }
  465.         }
  466.     } else {
  467.         this.drawText(text, 0, wy, this.contents.width, 'center');
  468.     }
  469.    
  470.     if (showWeaknesses === 1) {
  471.         var elemWeak = [];
  472.         for (let i = 1; i < $dataSystem.elements.length; i++) {
  473.             if (this._battler.elementRate(i) > defaultElemCutoff) {
  474.                 elemWeak.push(i)
  475.             }
  476.         }
  477.         wy = wy + this.lineHeight();
  478.         if (this.width < 32 * elemWeak.length) {
  479.             this.width = 32 * elemWeak.length
  480.             this.contents.width = 32 * elemWeak.length
  481.         }
  482.         var x = 0;
  483.         for (let i = 0; i < elemWeak.length; i++) {
  484.             var iconId = defautWeaknessIcon;
  485.             if (Astfgl.enemies.disWeak[this._battler._enemyId][elemWeak[i]] === 1) {
  486.                 iconId = wIArray[elemWeak[i]];
  487.             }
  488.             this.drawIcon(iconId,x,wy)
  489.             x += 32;
  490.         }
  491.     }
  492.  
  493. };
  494.  
  495. //change window size to display the right width for weaknesses icons
  496. Window_EnemyVisualSelect.prototype.updateWindowSize = function() {
  497.     if (showWeaknesses === 1) {
  498.         var elemWeak = [];
  499.         for (let i = 1; i < $dataSystem.elements.length; i++) {
  500.             if (this._battler.elementRate(i) > defaultElemCutoff) {
  501.                 elemWeak.push(i)
  502.             }
  503.         }
  504.         var num = elemWeak.length * 32;
  505.     } else {
  506.         num = 0;
  507.     }
  508.     var spriteWidth = this._battler.spriteWidth();
  509.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  510.     if (this._nameTextWidth === undefined) {
  511.       this._nameTextWidth = this.textWidth(this._battler.name());
  512.     }
  513.     var textWidth = this._nameTextWidth;
  514.     textWidth += this.textPadding() * 2;
  515.     var width = Math.max(spriteWidth, textWidth, num) + this.standardPadding() * 2;
  516.     width = Math.ceil(width);
  517.     var height = this._battler.spriteHeight() + this.standardPadding() * 2;
  518.     height = Math.ceil(height);
  519.     height = Math.max(height, this.lineHeight() + this.standardPadding() * 2);
  520.     if (width === this.width && height === this.height) return;
  521.     this.width = width;
  522.     this.height = height;
  523.     this.createContents();
  524.     this._requestRefresh = true;
  525.     this.makeWindowBoundaries();
  526. };
  527.  
  528. // Accessory functions
  529. Game_Battler.prototype.modMaxSh = function (num) {
  530.     if (globalMode === 2 && this.isActor()) {return}
  531.     if (globalMode === 1 && this.isEnemy()) {return}
  532.     this._mShB += num;
  533.     this._mSh = this.getMaxSh();
  534.     this._sh.clamp(0,this._mSh);
  535. }
  536.  
  537. //save and load weakness array
  538. var _aliasDMMSC = DataManager.makeSaveContents
  539. DataManager.makeSaveContents = function() {
  540.     var contents = _aliasDMMSC.call(this)
  541.     contents.astfgl = Astfgl
  542.     return contents
  543. }
  544.  
  545. var _aliasDMESC = DataManager.extractSaveContents
  546. DataManager.extractSaveContents = function(contents) {
  547.     _aliasDMESC.call(this,contents);
  548.     Astfgl = contents.astfgl
  549. }
  550.  
  551. //Reset discovered weakness on battle end
  552. if (saveWeakness) {
  553.     var _aliasBMEB = BattleManager.endBattle
  554.     BattleManager.endBattle = function(result) {
  555.         _aliasBMEB.call(this,result);
  556.         $gameTroop.members().forEach(function(member){
  557.             for (let i=0; i < Astfgl.enemies.disWeak[member._enemyId].length; i++) {
  558.                 Astfgl.enemies.disWeak[member._enemyId][i] = 0
  559.             }
  560.         })
  561.     };
  562. }
  563.  
  564. Game_Enemy.prototype.revealRandomWeakness = function() {
  565.     var member = this;
  566.     var eId = member._enemyId
  567.     var dis = [];
  568.     for (let i = 1; i < $dataSystem.elements.length; i ++){
  569.         if (Astfgl.enemies.disWeak[eId][i] === 0 && member.elementRate(i) > defaultElemCutoff) {dis.push(i)}
  570.     }
  571.     if (dis.length!==0) {
  572.         var num = Math.floor(Math.random() * Math.floor(dis.length));
  573.         Astfgl.enemies.disWeak[eId][dis[num]] = 1;
  574.     }
  575. }
  576.  
  577. Game_Troop.prototype.revealRandomWeakness = function() {
  578.     var ids = []
  579.     this.members().forEach(function(member){
  580.     var eId = member._enemyId
  581.     if (!ids.contains(eId)) {
  582.         var dis = [];
  583.         for (let i = 1; i < $dataSystem.elements.length; i ++){
  584.             if (Astfgl.enemies.disWeak[eId][i] === 0 && member.elementRate(i) > defaultElemCutoff) {dis.push(i)}
  585.         }
  586.         ids.push(eId)
  587.         if (dis.length!==0) {
  588.             var num = Math.floor(Math.random() * Math.floor(dis.length));
  589.             Astfgl.enemies.disWeak[eId][dis[num]] = 1;
  590.         }
  591.     }
  592.     })
  593. }
  594.  
  595.  
  596. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement