I have no idea where the code that you posted code came from.
it looks like an independent mod that was added after initial release.
What I have is the roseZA source from just before it was released as dev rev 4.
If anything got updated after that then i don't have it. I have not been keeping up with mods to the source.
Looks to me like statmodifier is a local variable. it should be defined nearer to the top of the NormalAttack function
The code as will calculate the hitchance of both monster and player.
for monster it is
hitchance = (Stats->Accuracy/10) / statmodifier;for player it is
hitchance = Stats->Accuracy / statmodifier;Note the conditional uses a NOT operand
if(!IsMonster( )) so the logic is reversed from what it might look like initially
It seems this was done to reduce monster accuracy by a factor of 10 across the board. You could change the 10 to whatever you like to penalize the monsters
Dodgechance appears to be the same for monsters and players
float dodgechance = Enemy->Stats->Dodge / statmodifier; //enemys dodge chance up to 75% at level 220 when same levelNote that Enemy can be either player or monster. It is whatever the currently selected character (player or monster) is fighting.
Then it is capped at a maximum of 75
Next it generates a random number between 0 and 100 and stores it in local variable
serverrandom.
then it gets a bit strange.
First it calculates if the hit was dodged by non-summon monsters
- if(IsMonster( ) && !IsSummon()) //monsters have a static 19% dodge level when at the same level
- {
- if(serverrandom < (19-hitchance)) //19 was chosen as at level 1 with default accuracy its 5% chance to dodge
- dodge=true; // dodged
- }
The reason I say it gets strange is that we need
serverrandom to be less than the condition
(19 - hitchance) for a successful dodge.
It appears that as the attacker's hitchance goes up (i.e. he has greater accuracy) the condition is going to go down (get more negative). So it should but I'm not so sure about the logic here.
with
hitchance = 5 then
serverrandom needs to be lower than (19 - 5 =
14) for a successful dodge. 14%
with
hitchance = 75 (maximum) then
serverrandom needs to be less than (19 - 75 =
-56) It's clearly impossible for a value in the range of 0 - 100 to be less than -56 so something is seriously wrong with this formula
What it means is that for any monster attack against a player of summon if its accuracy is greater than 19 then it
cannot ever be dodgedIt scales wrong.
No negative values should ever come from a formula like this. The concept is fine but I think it needs to be overhauled and re-balanced. Usually the use of any Addition or subtraction should be avoided in this type of formula. Better to use division and multiplication. That way it can be kept in the right range.
now the other cases
-
- else
- {
- if(dodgechance > 75) dodgechance = 75;
-
- if(serverrandom < (dodgechance - hitchance)) //enemys dodge chance - your hit chance
- dodge=true; // dodged
- }
at least now we use the
dodgechance value for something. it wasn't used at all in the monster attack formula.
So anyway the ELSE clause means this applies to anything that is not a monster
Basically for any case where the Enemy's
dodgechance is greater than the attacker's
hitchance there is ZERO chance of scoring a hit.
There should always be a small chance of a successful hit even if the
dodgechance is greater than the
hitchanceGood luck fighting above your level with a formula like that. You are never going to hit anything.
try dividing
dodgechance by
hitchance and multiplying by 50
when the two are equal the division will result in 1. Multiply by 50 to get a 50% chance which seems fair
If
dodgechance is 75 (max) and
hitchance is only 50 then D/H*50 = 33%
My example may be scaled a little wrong but you get the idea right? Keep your actual chance of scoring a hit positive
You could use
(dodgechance / (hitchance * 2) * 50) or whatever that would give 25% when the two are the same and 16% for the two examples above.
It will NEVER go negative though