Changing attack behavior

Hello Community!


I am quite new to RPG Maker and I am struggling with default attacks.


Now whats my problem.


I would like to change default attack behavior (when player attacks). Giving him (for example) some yes/no question and adjust damage according to the answer. 


Whats the best approach to this problem? I dont think that writting own battleSystem is required to make this change.


My idea was to replace script that is executed right after player selects command and before the damage is calculated. Add some branching and then continue executing original code with altered damage calculation. But I didnt found this piece of code in the project. 


Do you know where should I look for this piece of code? Am I even taking the right approach?


Thanks in advance,


Nate.
You could probably do something by triggering a common event in the skill effects. I mean, is the battle formula going to be a constant between the two options? If so, create two attack skills one is just plain old "Attack" with the low hitting battle damage for an incorrectly answered question and the other is like "Attack+" for a correctly answered question. So the common event would ask a question based on a conditional branch through a random number roll set variable <blank> to and theres an option for range between 0 and whatever or 1 and whatever.

🙂  So you could potentially have an almost limitless amount of questions. You could even force some questions to unlock after certain parts of the story or something too! Anyway I digress, within the event after the question is answered and whether or not the answer is correct you could force action either "Attack" or "Attack+." 

Ok, tested it out and it sort of works! The Attack skill in slot number one should be left as is since enemies will be using it as well or their attack skill will also activate the common event. So, you've got Attack, Attack+ and Attack(actor's skill that will proc the question).

Here's a picture of the common event I tested with.


Test_Battle_Questions.png


The only caveats here are that when I chose to force action, I had to choose a specific actor to do it with. If you don't have a lot of characters then you could have a separate attack skill to proc the action with that player and a replica of the common event for each one and also the initial attack action must do at least one damage or strike the enemy in some way or the common event won't proc(although there might be some other way to get it to work I.E. a script 😉 ). It's doable but the drawback is the sheer complexity of it all once you have a lot of questions. You could most definitely do this with a script of some kind but I lack the knowledge of RPG Maker's core system to provide you with any remnant of an idea for that one. XD 


EDIT: Also I wanted to apologize. I realize this is the Javascript section and you weren't looking for this answer; however, I wanted to try and offer some alternative in case you don't have the know-how to accomplish it through JS.


RE-EDIT: Although, looking through the js files, it looks as though you might be able to create a function within the battle manager that could execute said common event or you might even be able to execute all of it from within a script as well but I'm not sure of all RPG Maker MV's available JS functions. If I had to guess, you'd get it to work by creating a copy of Scene_Battle.prototype.onSkillOk by matching the skill id against the skill you want to execute it. Probably creating another function to call in the scene_battle.prototype.onSkillOk function(or whatever function it is that actually causes the action to execute in battle) that will activate your common event questions. 

Original thread: https://forums.rpgmakerweb.com/threads/changing-attack-behavior.61756/