[RMMZ] REMOVE ATTACK (SKILL 1) FROM AN AUTOBATTLER'S LIST OF ACTIONS.

Posts

Pages: 1
Hi all!

In my current project, I have a party member who is always set to auto-battle. The way I have this set up is that the character has a customizable list of skills that the player can turn on or off, so that the character will only pick from the actions that the player had turned on for them.

However it seems that, by default, RMMZ will also add "Attack" (Skill 1) to that character's possible skill list regardless of whether or not they can actually use it. Trying to restrict the Attack command via "Seal Skill: Attack" or by making Attack cost 999 MP or something doesn't seem to work: If the character rolls Attack for that turn and cannot use it, they will skip their turn entirely.

Is there a way to remove Attack from their list of actions? It's worth noting that nothing in my game uses the Attack command, so I'm okay with it being a global change.

Thanks in advance!
Marrend
Guardian of the Description Thread
21781
So, here's what I'm suspecting is the function that occurs in MZ's auto battle algorithm with the default code.

Game_Actor.prototype.makeAutoBattleActions = function() {
    for (let i = 0; i < this.numActions(); i++) {
        const list = this.makeActionList();
        let maxValue = -Number.MAX_VALUE;
        for (const action of list) {
            const value = action.evaluate();
            if (value > maxValue) {
                maxValue = value;
                this.setAction(i, action);
            }
        }
    }
    this.setActionState("waiting");
};

What's popping out to me with this is the line that reads `const list = this.makeActionList();`. What this calls is...

Game_Actor.prototype.makeActionList = function() {
    const list = [];
    const attackAction = new Game_Action(this);
    attackAction.setAttack();
    list.push(attackAction);
    for (const skill of this.usableSkills()) {
        const skillAction = new Game_Action(this);
        skillAction.setSkill(skill.id);
        list.push(skillAction);
    }
    return list;
};

...this function. The line `attackAction.setAttack();` from that code probably calls...

Game_Action.prototype.setAttack = function() {
    this.setSkill(this.subject().attackSkillId());
};

...this method. So, my current guess is that it could be replaced with `attackAction.setSkill(skillID)`...

Game_Action.prototype.setSkill = function(skillId) {
    this._item.setObject($dataSkills[skillId]);
};

...or, somehow rework that line that it reads off of the list of possible skills that you've set up. I imagine this is done through metadata/tags?



*Edit: Or... I guess you could, theoretically, comment out the line `attackAction.setAttack();` from the `Game_Actor..makeActionList()` function entirely? Re-looking at the code, and what you want to do versus what it already does, that might be the easiest solution.
author=Marrend
So, here's what I'm suspecting is the function that occurs in MZ's auto battle algorithm with the default code.

Game_Actor.prototype.makeAutoBattleActions = function() {
    for (let i = 0; i < this.numActions(); i++) {
        const list = this.makeActionList();
        let maxValue = -Number.MAX_VALUE;
        for (const action of list) {
            const value = action.evaluate();
            if (value > maxValue) {
                maxValue = value;
                this.setAction(i, action);
            }
        }
    }
    this.setActionState("waiting");
};


What's popping out to me with this is the line that reads `const list = this.makeActionList();`. What this calls is...

Game_Actor.prototype.makeActionList = function() {
    const list = [];
    const attackAction = new Game_Action(this);
    attackAction.setAttack();
    list.push(attackAction);
    for (const skill of this.usableSkills()) {
        const skillAction = new Game_Action(this);
        skillAction.setSkill(skill.id);
        list.push(skillAction);
    }
    return list;
};


...this function. The line `attackAction.setAttack();` from that code probably calls...

Game_Action.prototype.setAttack = function() {
    this.setSkill(this.subject().attackSkillId());
};


...this method. So, my current guess is that it could be replaced with `attackAction.setSkill(skillID)`...

Game_Action.prototype.setSkill = function(skillId) {
    this._item.setObject($dataSkills[skillId]);
};


...or, somehow rework that line that it reads off of the list of possible skills that you've set up. I imagine this is done through metadata/tags?


wordle
*Edit: Or... I guess you could, theoretically, comment out the line `attackAction.setAttack();` from the `Game_Actor..makeActionList()` function entirely? Re-looking at the code, and what you want to do versus what it already does, that might be the easiest solution.

Thx Marrend...all clear for me
Sorry to bump this thread after many weeks, and doubly sorry for not responding to you sooner, Marrend. Thank you for the suggestion!

Thankfully, it turns out the solution was much easier than I had realized: RPG Maker MZ has a function called "Attack Skill" that can be applied to an actor, class, or state. This allows the Attack command to be substituted with any other skill.



So with some tinkering, I set it up so that the Attack Skill matches whichever skill the AI character rolled for that turn, thus ensuring that it will always use that skill and not have to pick between Attack (skill 1) and the Skill that it rolled.
unity
You're magical to me.
12540
Ooooh, super cool solution, I'm glad that worked! :D
Pages: 1