I'm trying to make a custom accuracy formula, but I'm having some problems.
For the damage formula I used formulas from commercial games like Disgaea 4 as a reference, but the only thing I can find about accuracy is unhelpful things like "hit chance = 1.2 * (HIT/SPD)" I don't know how to put that into my game at all.
Also, I'm confused as to why, in the code, there needs to be a first and second hit detection.
Everything seems to work fine when I only use the first one, which comes before the damage formula
The first hit detection looks like this:
hit_result = (rand(100) < attacker.hit)
which i think means, take a random number between 0 and 100. if it is greater than the attacker's hit, then hit_result = true.
and then there's this silly thing, which comes after the damage formula:
# Second hit detection
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
What are the colons and question marks for?
I don't get it >.<
For critical hits it's easy since I just keep the LUK stat between 0 and 100, but the HIT and SPD stats can be from 1 to 255
Maybe I should use an evasion stat so battlers can attack often, but be easy to hit...
I'm trying to make a custom accuracy formula, but I'm having some problems.
For the damage formula I used formulas from commercial games like Disgaea 4 as a reference, but the only thing I can find about accuracy is unhelpful things like "hit chance = 1.2 * (HIT/SPD)" I don't know how to put that into my game at all.
Also, I'm confused as to why, in the code, there needs to be a first and second hit detection.
Everything seems to work fine when I only use the first one, which comes before the damage formula
The first hit detection looks like this:
hit_result = (rand(100) < attacker.hit)
which i think means, take a random number between 0 and 100. if it is greater than the attacker's hit, then hit_result = true.
and then there's this silly thing, which comes after the damage formula:
What are the colons and question marks for?
I don't get it >.<
For critical hits it's easy since I just keep the LUK stat between 0 and 100, but the HIT and SPD stats can be from 1 to 255
Maybe I should use an evasion stat so battlers can attack often, but be easy to hit...
Edited by Bob423Share this post
Link to post
Share on other sites