Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Save battle actor ID in a variable

I'm trying to develop a system where the Characters learn skills through the use of basick attack with a weapon.

I already figured out a workaround using a specific Skill, but I can't do it with the "standard attack". I tried to place an event like this:

- IF Variable Actor ID = 1
-- IF Actor 1 Dagger is Equipped
-- Add +1 to Variable "Dagger Use"
--- IF Variable Dagger Use = 3
--- Learn Skill "Double Dagger".

Se setting this common event to the basic attack would trigger only if I i could store the ID of the attacker in a variable. So even if other characters use the attack it will add the +1 only if the Actor 1 has attacked.

As I said before I already found a workaround, but If I could do it with the basic attack it would be better.
 
JavaScript:
var LB_StoreActor = 0; //What var you want to store the ID

BattleManager.startAction = function() {
    var subject = this._subject;
    var action = subject.currentAction();
    var targets = action.makeTargets();
    this._phase = 'action';
    this._action = action;
    this._targets = targets;
    //    VARS:
    //    $gameParty._actors[action._targetIndex] - The Target of the action
    //    subject._actorId - The actor doing the action
    if(action._item._dataClass == skill){ $gameVariables.setValue(LB_StoreActor, subject._actorId); }
    subject.useItem(action.item()); //You'll want to do ^ before <
    this._action.applyGlobal();
    this.refreshStatus();
    this._logWindow.startAction(subject, action, targets);
};
There, just change the top var to the RPG Maker Var you want it to be in and simply stick that code in a js, into plugins and enable it.
 
Sorry for the late answer but I had some issues in rl and could not concentrate in making.

I just tried your script Lord Bones (and I thank you very much for it), but it seems I'm missing something:

- I copied your script in a Notepad++ page.
- Edited the variable part (LB_StoreActor = 1) since the variable I'm using for the check is n.1
- Saved the script as .js
- Moved it into plugins / js folder on the project
- Activated via plugin manager inside RpgmakerMV
- Set up the common event that checks the variable and makes you learn a test skill.
- Nothing happened
 
Top