AttackTimes+

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,116
Reaction score
811
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,642
Reaction score
714
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
811
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

Waiting on approval on my One Map Challenge game, which I made to get a feel for RPG Maker. I was able to complete it before MZ's release, now I can focus fully on the MZ game I want to make. I'm excited, ya'll.

I have recently returned to try and developing games after I learned how to use digital drawing software.

My goal is to start simple and small. I am mostly aiming to create a game that I would play, and to tell a story that I would like to read. :smile:
RayGarden7 wrote on Geovid's profile.
Hey I'm new the RPG Maker forms as well and was having the same problem you are with needing 30 post or 30 threads we must complete. Maybe we could help each other out? Why you on the forms what is your goal?

Apparently the various VS core plugins are going to be free. :LZSexcite:
Now to go wash the stink off myself from having had to look at Twitter.
:rtear:

heroine before entering いせかい

Forum statistics

Threads
100,809
Messages
979,809
Members
132,448
Latest member
Tip2202
Top