AttackTimes+

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
807
First Language
English
Primarily Uses
RMMV
So I'm using LecodeTBS v0.77.2b and noticed that AttackTimes+ is not utilized at all. This is a critical feature in my game, so I really must resolve this. Is there a way for me to get LTBS to handle AttackTimes+?

This is what I found in rpg_objects.js:
JavaScript:
Game_Action.prototype.numRepeats = function() {
    var repeats = this.item().repeats;
    if (this.isAttack() || this.isPhysical()) {
        repeats += this.subject().attackTimesAdd();
    }
    return Math.floor(repeats);
};
(I added "|| this.isPhysical()" so that it also affects physical skills)

Also, I think these parts are relevant as well:
JavaScript:
Game_Action.prototype.repeatTargets = function(targets) {
    var repeatedTargets = [];
    var repeats = this.numRepeats();
    for (var i = 0; i < targets.length; i++) {
        var target = targets[i];
        if (target) {
            for (var j = 0; j < repeats; j++) {
                repeatedTargets.push(target);
            }
        }
    }
    return repeatedTargets;
};
And this:
JavaScript:
Game_Action.prototype.evaluate = function() {
    var value = 0;
    this.itemTargetCandidates().forEach(function(target) {
        var targetValue = this.evaluateWithTarget(target);
        if (this.isForAll()) {
            value += targetValue;
        } else if (targetValue > value) {
            value = targetValue;
            this._targetIndex = target.index();
        }
    }, this);
    value *= this.numRepeats();
    if (value > 0) {
        value += Math.random();
    }
    return value;
};
Anyways, there's no reference to AttackTimes anywhere in the LTBS plugin. I'm hoping this addition won't be too difficult. Thx in advance!
 
Last edited:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,607
Reaction score
662
First Language
Chinese
Primarily Uses
N/A
You may want to place this right after LeTBS(or just edit the function in LeTBS.js directly):
JavaScript:
TBSSequenceManager.prototype.readTargets = function (data, deepRead) {
    if (deepRead == null) deepRead = true;
    if (data instanceof Array) return data;
    if (deepRead) {
        var cells = this.readCellTargets(data, false);
        if (cells.length > 0) {
            return BattleManagerTBS.getEntitiesInScope(cells);
        }
    }

    var targets = [];
    var cursorCell = this.baseCursorCell();
    var aoe = [];
    if (data.match(/\{(.+)\}/i)) {
        var aoeKey = RegExp.$1;
        if (aoeKey === "aoe") {
            aoe = this.baseAoE();
        } else if (aoeKey === "cursor") {
            aoe = [cursorCell];
        } else {
            var param = {
                user: this.getUser(),
                dir: this.getUser().getDirectionTo(cursorCell),
                need_check_los: false,
                exclude_center: false,
                line_of_sight: false
            };
            aoe = BattleManagerTBS.getScopeFromData(aoeKey, cursorCell, param);
        }
    }
    var aoeTargets = BattleManagerTBS.getEntitiesInScope(aoe);
    var aoeAllyTargets = aoeTargets.filter(function (entity) {
        return this.isAlly(entity.battler());
    }.bind(this));
    var aoeEnemyTargets = aoeTargets.filter(function (entity) {
        return this.isEnemy(entity.battler());
    }.bind(this));
    var aoeDeadTargets = aoeTargets.filter(function (entity) {
        return entity.battler().isDead();
    });
    var aoeDeadAllyTargets = aoeAllyTargets.filter(function (entity) {
        return entity.battler().isDead();
    });
    var aoeDeadEnemyTargets = aoeEnemyTargets.filter(function (entity) {
        return entity.battler().isDead();
    });
    var cursorTarget = [cursorCell.getEntity()];
    var cursorAllyTarget = (cursorTarget[0] && this.isAlly(cursorTarget[0].battler())) ? cursorTarget : [];
    var cursorEnemyTarget = (cursorTarget[0] && this.isEnemy(cursorTarget[0].battler())) ? cursorTarget : [];
    var cursorDeadTarget = (cursorTarget[0] && cursorTarget[0].battler().isDead()) ? cursorTarget : [];
    var cursorDeadAllyTarget = (cursorAllyTarget[0] > 0 && cursorAllyTarget[0].battler().isDead()) ? cursorAllyTarget : [];
    var cursorDeadEnemyTarget = (cursorEnemyTarget[0] > 0 && cursorEnemyTarget[0].battler().isDead()) ? cursorEnemyTarget : [];

    if (data.match(/^user$/i)) {    //user
        targets = [this.getUser()];
    } else if (data.match(/^all$/i)) {  //all
        BattleManagerTBS.allEntities().forEach(function (entity) {
            targets.push(entity);
        });
    } else if (data.match(/^allies$/i)) {   //allies
        BattleManagerTBS.allEntities().forEach(function (entity) {
            if (this.isAlly(entity.battler()))
                targets.push(entity);
        }.bind(this));
    } else if (data.match(/^enemies$/i)) {  //enemies
        BattleManagerTBS.allEntities().forEach(function (entity) {
            if (this.isEnemy(entity.battler()))
                targets.push(entity);
        }.bind(this));
    } else if (data.match(/^active_entity$/i)) { //active_entity
        targets = [BattleManagerTBS.activeEntity()];
    } else if (data.match(/^cursor_battler$/i)) { //cursor_battler
        targets = cursorTarget;
    } else if (data.match(/^cursor_ally$/i)) { //cursor_ally
        targets = cursorAllyTarget;
    } else if (data.match(/^cursor_enemy$/i)) { //cursor_enemy
        targets = cursorEnemyTarget;
    } else if (data.match(/^saved\((.+)\)$/i) && this._savedEntities[RegExp.$1]) { //saved(x)
        targets = this._savedEntities[RegExp.$1];
    } else if (data.match(/^\{.+\}_battlers$/i)) { //{x}_battlers
        targets = aoeTargets;
    } else if (data.match(/^\{.+\}_allies$/i)) {
        targets = aoeAllyTargets;
    } else if (data.match(/^\{.+\}_enemies$/i)) {
        targets = aoeEnemyTargets;
    } else if (data.match(/^(\d+)_battlers_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeTargets, Number(RegExp.$1));
    } else if (data.match(/^(\d+)_allies_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeAllyTargets, Number(RegExp.$1));
    } else if (data.match(/^(\d+)_enemies_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeEnemyTargets, Number(RegExp.$1));
    } else if (data.match(/^\{.+\}_dead_battlers$/i)) {
        targets = aoeDeadTargets;
    } else if (data.match(/^\{.+\}_dead_allies$/i)) {
        targets = aoeDeadAllyTargets;
    } else if (data.match(/^\{.+\}_dead_enemies$/i)) {
        targets = aoeDeadEnemyTargets;
    } else if (data.match(/^(\d+)_dead_battlers_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeDeadTargets, Number(RegExp.$1));
    } else if (data.match(/^(\d+)_dead_allies_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeDeadAllyTargets, Number(RegExp.$1));
    } else if (data.match(/^(\d+)_dead_enemies_in_\{.+\}$/i)) {
        targets = LeUtilities.getXRandomValuesInArray(aoeDeadEnemyTargets, Number(RegExp.$1));
    } else if (data.match(/^cursor_dead_battler/i)) {
        targets = cursorDeadTarget;
    } else if (data.match(/^cursor_dead_ally$/i)) {
        targets = cursorDeadAllyTarget;
    } else if (data.match(/^cursor_dead_enemy$/i)) {
        targets = cursorDeadEnemyTarget;
    } else if (data.match(/^battler_toward_user$/i)) {
        var cell = this.getUser().getForwardCell();
        if (cell) {
            var target = cell.getEntity();
            if (target)
                targets = [target];
        }
    }

    // Edited to support skill/item repeats and Attack Times+ as well
    // return targets;
    var repeatedTargets = [];
    var repeats = 1;
    if (BattleManagerTBS._activeAction.item()) {
        repeats = BattleManagerTBS._activeAction.item().repeats;
    }
    if (BattleManagerTBS._activeAction.isAttack()) {
        repeats += this.getUser().battler().attackTimesAdd();
    }
    repeats = Math.floor(repeats);
    for (var i = 0; i < targets.length; i++) {
        var target = targets[i];
        if (target) {
            for (var j = 0; j < repeats; j++) {
                repeatedTargets.push(target);
            }
        }
    }
    return repeatedTargets;
    //
};
While I've tested that it works with Attack Times+, it doesn't work with skill/item repeats due to the following in Yanfly Engine Plugins - Battle Engine Core:
JavaScript:
DataManager.addActionEffects = function(obj, array) {
    for (;;) {
      array[array.length] = ['ACTION EFFECT'];
      array[array.length] = ['DEATH BREAK'];
      obj.repeats -= 1;
      if (obj.repeats <= 0) break;
      array[array.length] = ['WAIT', [8]];
    }
    obj.repeats = 1;
};
If you want to have repeats as well, simply remove the last line (obj.repeats = 1; ) :)
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
807
First Language
English
Primarily Uses
RMMV
OMG Thank you!! I don't utilize skill/item repeats anyways, so this is perfect.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Yanfly told me the new earth all animations in MZ look a bit like summoning potatoes and now I can't unsee it. halp
Despite time and all the other things I am working on, I decided that I am going to start a Fire Emblem-like project. Follow your dreams! I'll just have to balance hours efficiently. I'm also not making this as complex as my Might and Magic inspired project, so it will be a much easier project to work on.
So I've taken to doing a test of the game, and making a list of everything I think of during the test to add/fix. Over the course of the night I check them off as I do them, and by the end of the night I always feel like I've accomplished something. :LZSexcite:
Eventz MZ? Events MZ!
My laptop has been restarting for around ten minutes. Not updating. I am concerned.

Forum statistics

Threads
100,586
Messages
977,521
Members
132,180
Latest member
Reich
Top