julianxhokaxhiu / FFNx

Next generation modding platform for Final Fantasy VII and Final Fantasy VIII ( with native Steam 2013 release support! )
GNU General Public License v3.0
371 stars 49 forks source link

[ FF7 ] Add auto-battle mode that repeats previous commands from memory #708

Open JordanLongstaff opened 5 months ago

JordanLongstaff commented 5 months ago

Summary

There is currently an auto-attack cheat, but all it does is attack. I would like to see it reworked to repeat the last command each character did last, if possible. If the last command was Steal, do it again on the previous target. If the target was removed (e.g. KO'd), choose a different target. If it was Cure on all targets, cast Cure on all targets again. If All has run out, cast it on a single target. If it was a Limit, and the Limit is ready, use the same Limit again (or the next one if the Limit level was changed); otherwise, Attack.

Basic example

The implementation details are given in pseudocode and may be incomplete.

CommandData getAutoBattleCommandData() {
    CommandData commandData;

    CommandData* lastCommandData = currentCharacter->lastCommandData;
    if (!isCommandAvailable(lastCommandData->commandId)) {
        // If the battle menu doesn't contain the command (e.g. if its materia was removed), default to attacking
        return CommandData::getAttackCommandData();
    } else if (!isCommandUsable(lastCommandData->commandId)) {
        // If the command is in the menu but is not usable at the moment (e.g. not enough MP, or Silenced), default to attacking
        return CommandData::getAttackCommandData();
    } else if (lastCommandData->targetMode == ALL && !canTargetAll(lastCommandData)) {
        // If the command was an All-cast spell and the Alls have run out, repeat the spell but target only one entity
        commandData.commandId = lastCommandData->commandId;
        commandData.targetMode = SINGLE;
        commandData.targetIndex = 0;
        // ...
    } else if (lastCommandData->commandId == LIMIT && !currentCharacter->isLimitReady()) {
        // If the command was Limit but Limit isn't ready, default to attacking
        return CommandData::getAttackCommandData();
    } else if (lastCommandData->commandId == LIMIT && lastCommandData->limitLevel != currentCharacter->limitLevel) {
        // If the command was Limit and the Limit level was changed, use the first Limit on the current level
        commandData.commandId = LIMIT;
        commandData.limitLevel = currentCharacter->limitLevel;
        commandData.limitIndex = 0;
        // ...
    } else {
        // If there are no problems, re-use the last command
        commandData = *lastCommandData;
    }

    return commandData;
}

Motivation

The Pixel Remasters have an auto-battle feature that remembers the last thing each character did in battle (for 1-3, you can even see the command's name next to character stats). The idea here is to emulate that same feature in FF7 also, instead of just repeating the Attack command. Attacking repeatedly is not only boring, but poor strategy. It is far more advantageous to manually set up the commands that exploit enemy weaknesses, and then repeat them.

KuraudoXS commented 3 months ago

"The Pixel Remasters have an auto-battle feature that remembers the last thing each character did in battle"

If I may add, always in battle when one use Phoenix Down it does not select automatically the dead ally. I dunno if that is doable too?