I'm pretty new to RPG Maker so I was wondering what the veterans had to say about the following scenario. Basically, I'm implementing a system where when Character A does their normal attack, some special action will happen. My initial stab at it was the following:
To me, that seems like the right way to do it since it puts the logic in less places and is less complex (also, my understanding of common events is that they should be common ie. used in multiple places. This one is just for the one scenario), but not sure if there are any risks modifying the core scripts like that.
- Modify Game_Actor.prototype.performAction to set a game variable to the subject name in the action.isAttack() clause.
- Create a common event and have it run whenever the Attack skill is invoked.
- The script in the common event will check the game variable set in #1 to see if it is Character A.
- If it is Character A, then run the special action.
To me, that seems like the right way to do it since it puts the logic in less places and is less complex (also, my understanding of common events is that they should be common ie. used in multiple places. This one is just for the one scenario), but not sure if there are any risks modifying the core scripts like that.
JavaScript:
$.aliasPerformAction = Game_Actor.prototype.performAction;
Game_Actor.prototype.performAction = function (action) {
$.aliasPerformAction.call(this, action);
if (action.isAttack()) {
//setting battleAttacker to whoever is attacking
$gameVariables.setValue(161, BattleManager._subject._name);
console.log('person attacking: ' + BattleManager._subject._name);
//**** Put common event script here instead of in common event?
}