Attack dodge calculation

12/09/2016 10:37 pintinho12#1
Ok guys, it's 7:20 am and tonight I've been working on this shit :D

Code:
public bool IsTargetDodged(IRole attacker, IRole attacked)
{
    if (attacker == null || attacked == null) return true;
    int nDodge = 0;
    if (attacked is Character || attacked is DynamicNpc || (attacked is Monster && (attacked as Monster).IsBoss))
        nDodge = 40;
    int atkHit = attacker.AttackHitRate;
    int atkdDodge = attacked.Dodge;
    int hitRate = Math.Min(100, Math.Max(40, 100 + atkHit - nDodge - atkdDodge));
    return !Calculations.ChanceCalc(hitRate);
}
Ok, there is a default dodge for characters which is 40% and it's stored in nDodge, that's simple.
atkHit will store the attacker hitrate, but how do I get this value?
The attacker hitrate is the addition of all items agility (except talismans and steed).
Example: If I'm wearing 2 level 140 beads, I'll get 202 hitrate (since each one will have +23 agility from the plus and +78 from the beads).
Sure, after that, the attacker hitrate isn't finished yet, you need to add the user Agility Points.
The attacker hit rate after all will be divided by three. So we have 125,33 hitrate points.

My tests were done with 175 Agility Points in my character (and by my experience with monks, since i've been one for years), the same I used in my full +12 monk

[Only registered and activated users can see links. Click Here To Register...]

over the years in Conquer 2.0, I should say that the calculation is 99% correct.
So after all, I've got (202 + 175)/3 which will give me around 125 hit rate points. Great!
The attacked dodge, will be the target dodge for sure. A full +12 player got 104 dodge.
But, as you can see. We add 100 points to the Attacker Hit Rate, so we get 225 points, we subtract the nDodge and the attacked dodge, so we have remaining
a 81% hitrate. Which is very precise, as far as I remember from the gold times killing fires with triple hit #16

I never really took time looking at the public sources to see how they calculate it, but I'm pretty sure that this algorithm is worth a try.
If you guys try it out, please leave a feedback. I tested this with a monk and I'll be doing more tests later. If you guys think there is something wrong or there is something that might be improved, please tell me.

Hope it's useful since I didn't find any really useful guide out there.
07/14/2017 11:29 kerohero#2
Great work, I've a small note about the last check
if (hitRate < 40)
hitRate = 40;
It's impossible :D
this will get you at least 40 Math.Max(40, 100 + atkHit - nDodge - atkdDodge)
so Math.Min(100, Math.Max(40, 100 + atkHit - nDodge - atkdDodge)); must give you more than 40 or equals 40 every time..
07/19/2017 08:11 JaniQ#3
Code:
Math.Max(40, 100 + atkHit - nDodge - atkdDodge)
Should always return 40 if "100 + atkHit - nDodge - atkdDodge" is less than 40.

thus making
Code:
 if (hitRate < 40)
        hitRate = 40;
redundant.
07/19/2017 21:59 U2_Caparzo#4
Quote:
Originally Posted by kerohero View Post
Great work, I've a small note about the last check
if (hitRate < 40)
hitRate = 40;
It's impossible :D
this will get you at least 40 Math.Max(40, 100 + atkHit - nDodge - atkdDodge)
so Math.Min(100, Math.Max(40, 100 + atkHit - nDodge - atkdDodge)); must give you more than 40 or equals 40 every time..
Quote:
Originally Posted by pitinho12
Ok guys, it's 7:20 am and tonight I've been working on this shit
:rolleyes: :rolleyes:
07/23/2017 16:48 pintinho12#5
I removed some code before posting because I was performing tests.
Good you guys know how to fix things. The calc is there and it's what matters.
The code had comments and shit, I just cleaned it a little bit, tho I didn't it perfectly, but I did.
Thanks for the feedback tho
12/12/2017 10:58 Ultimation#6
this is from the EO source and is slightly different in conquer.
12/13/2017 00:57 pintinho12#7
Yep, I adapted it on another source.
12/17/2017 19:45 Ultimation#8
But the code posted here is wrong for co..
02/24/2022 00:08 57bob57#9
Quote:
Originally Posted by Ultimation View Post
But the code posted here is wrong for co..
Do you have the calculation that tq uses? or something close
02/24/2022 00:48 Ultimation#10
Quote:
Originally Posted by 57bob57 View Post
Do you have the calculation that tq uses? or something close
as much as i appreciate you using the search feature, this thread is 5 years old, you should have just left it dead :P
02/25/2022 00:59 57bob57#11
Quote:
Originally Posted by Ultimation View Post
as much as i appreciate you using the search feature, this thread is 5 years old, you should have just left it dead :P
Hahaaa, my question was just not to open a new post, now answer me how you can help me with the atack calculations, bp .. .