Help with combat

Hi, I am new this whole type of thing but have some ideas and am currently experimenting with a 20 day trial of MV. I have figured out the basics of what i want to do but am struggling with the combat. I can't seem to find the information to correctly implement what i would like from the system. Hopefully one of you guys can help me.


I would like the amount of damage a basic attack does to be fixed, regardless of who is using it, and it will not change throughout the whole game. However, i want whether the attack hits or not to be determined by a formula.


This would be like the attacker has a random number between 2 and 12 added to his attack stat. The defender then has a random number between 2 and 12 added to his defence stat.


If the attacker's score is higher then he hits successfully and inflicts 2 HP damage. If the attacker's score is equal to or lower than the defender's then the attack is unsuccessful and zero damage is done.


I have tried to piece together bits of information i've found but all i have is battles where every attack does 0 damage. Any help with what to put down and where would be greatly appreciated, even if its a no so i can rethink what i'm doing.


Thanks in advance!
You need a plugin to change the way how the hit is calculated - the damage is determined by the damage formula of the skill, and attack is the first skill.


By default, each battler rolls a percent value for hit or miss, and it needs to be lower than the current (and usually fixed) HIT% parameter.


There are some plugins that let you change the formulae for HIT%, but using plugins is a bit difficult within the trial period unless you have previous knowledge on how to use scripts/plugins etc.


However, changing the HIT% value will not change the calculation process, which does not contain any comparison between values but only %-rolls. For that change, you'll need a new plugin
This would be like the attacker has a random number between 2 and 12 added to his attack stat. The defender then has a random number between 2 and 12 added to his defence stat.

Here you're talking about defense and attack.

If the attacker's score is higher then he hits successfully and inflicts 2 HP damage. If the attacker's score is equal to or lower than the defender's then the attack is unsuccessful and zero damage is done.

And here you're talking about score. Is the score the defense/attack plus the random number?


If it is, then your attack formula should go like this... I think...

Code:
if(Math.randomInt(10)+2+a.atk > Math.randomInt(10)+2+b.def) 2;
if(Math.randomInt(10)+2+a.atk > Math.randomInt(10)+2+b.def) 2;



I tried this and my hero actually hit the orc for 2 dmg, yay! But then the screen dimmed and came up with the following message when it was the orcs turn to attack:


TypeError


Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite


I get what the formula you gave is doing which is great but i may have changed something somewhere that is causing the error. Any clues as to what it might be??
That's one error I didn't expect.


Did you try using an else? lilke this:


I tested it and it does weird stuff without it.


if(Math.randomInt(10)+2+a.atk > Math.randomInt(10)+2+b.def) {2} else {0}


Also, does your error happens ONLY when you use this attack?


Did you modified the formula? If so, how?
if(Math.randomInt(10)+2+a.atk > Math.randomInt(10)+2+b.def) {2} else {0}



This worked perfectly, thank you so much. Just needed the little change at the end. My hero just killed his first orc (and in the manner i wanted him to)! And i actually understand the formula, should be very useful info going forward.


Thanks again!!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-combat.63610/