First of all, what server does that come from?
I don't recognize any of that code.
here's the bit of code that you were messing with
- attack = Stats->Attack_Power * levelmult * atkdefmult / constant;
- if(Enemy->IsPlayer());
- {
- if (attack >1400);
- {
- attack *= 0.50;
- }
- }
looks completely different when you include the whole thing doesn't it?
Anyway this is not the right place to be messing with.
This bit of code checks if enemy is a player and if it is AND your current attack is greater than 1400 it ADDs another 50% so your 1400 becomes 2100.
I don't quite see the point in this at all. Seems a bit of a weird thing to do.
look at the bit of code just before that
-
- if(Stats->MagicAttack == 1)
- {
- atkdefmult = (float) (Stats->Attack_Power) / (Enemy->Stats->Magic_Defense+Enemy->Stats->Defense);
- atkdefmult -= 3.2;
- }
- else
- {
- atkdefmult = (float) Stats->Attack_Power / (Enemy->Stats->Defense);
- }
- attack = Stats->Attack_Power * levelmult * atkdefmult / constant;
-
That's where it actually applies armor to the attack formula
As far as I can see though it is all kinds of wrong.....
for one thing it's giving magic defence PLUS ordinary defense if the attack is magic. That is utter crap. It should be ONLY magic defense
then it arbitrarily subtracts 3.2. WTF???
the line of code that calculates normal defense is this one
- atkdefmult = (float) Stats->Attack_Power / (Enemy->Stats->Defense);
so your multiplier is your attack DIVIDED by enemy defense.
Trouble is that if your attack is greater than his defense then atkdefmult becomes greater than 1 which is utter bollocks.
Example:
your attack = 100
enemy defense = 50
atkdefmult = 100/50 = 2
therefore damage done is 200. Double your attack power. Yes it will be moderated by dividing by that constant (defined as 5.5) but still...... What a shitty formula
atkdefmult needs to be returned as a percentage, not as a free running number with no limits
try replacing that chunk of code with this
- //calculate damage
- if(Stats->magicattack == 1) //magic attacks such as wands and some monsters
- {
- unsigned int totalpower = Stats->Attack_Power + Enemy->Stats->Magic_Defense;
- double hitmod = Stats->Attack_Power * 100 / totalpower + Stats->Level; //percentage of hitpower to use * 100
- hitpower = (unsigned int)floor((double)(hitmod * Stats->Attack_Power / 100));
- }
- else
- {
- unsigned int totalpower = Stats->Attack_Power + Enemy->Stats->Defense;
- double hitmod = Stats->Attack_Power * 100 / totalpower + Stats->Level; //percentage of hitpower to use * 100
- hitpower = (unsigned int)floor((double)(Stats->Attack_Power * hitmod / 100));
- //Log(MSG_DEBUG,"Normal Attack: AP %i DEF %i",Stats->Attack_Power,Enemy->Stats->Defense);
- //Log(MSG_DEBUG,"Normal Attack: hit total %i hitmod %f hit power %i",totalpower,hitmod,hitpower);
- }
- //add some randomness. + or - 5% of hitpower
- int min = (int)floor((double)(hitpower * 0.85));
- int max = (int)floor((double)(hitpower * 1.15));
- int dif = max - min;
- int mod = GServer->RandNumber( 0, dif );
- hitpower = min + mod;
That will give you a percentage formula that can never result in hitpower ending up stronger than it started.
Even better, just grab the KTRose server (that's where this snippet came from) and steal code that actually works from it then just tweak it a little to get precisely what you want.