AttackTimes+

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,196
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,791
Reaction score
943
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,626
Reaction score
1,196
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 Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top