I'm not sure how you're calculating battle at the moment, but here's the battle engine I wrote for the RSRPGE incase you wanna use it:
'--- Preset variables.
baseHitChance = 50
maxHitChance = 95
minHitChance = 5
baseDamage = 16
baseRandomDamage = 7
maxDamage = 999
minDamage = 5
'--- Determine the chance of the attack hitting.
hitWindow = baseHitChance
hitWindow = hitWindow + attackerAccuracy
hitWindow = hitWindow - defenderEvasion
IF hitWindow > maxHitChance THEN hitWindow = maxHitChance
IF hitWindow < minHitChance THEN hitWindow = minHitChance
hitRoll = RANDOM 100
'--- If the attack hits, deal damage.
IF hitRoll =< hitWindow THEN
 results$ = results$ + "AttackHit "
 damageRoll = RANDOM baseRandomDamage
 damageRoll = damageRoll + baseDamage
 damageRoll = damageRoll + attackerAttack
 damageRoll = damageRoll - defenderDefense
 IF damageRoll < minDamage THEN damageRoll = minDamage
 IF damageRoll > maxDamage THEN damageRoll = maxDamage
 defenderHP = defenderHP - damageRoll
ELSE
 results$ = results$ + "AttackMiss "
END IF
IF defenderHP < 1 THEN results$ = results$ + "DefenderDied "
IF results$ CONTAINS "DefenderDied" THEN
 defenderAlive = 0
 '--- Calculate the amount of EXP to award.
 lvlDifference = defenderLvl - attackerLvl
 expAwardAdjustment = 50 * lvlDifference
 baseExpAward = 100
 expAward = baseExpAward + expAwardAdjustment
 IF expAward < 5 THEN expAward = 5
 '--- Award EXP.
 attackerExp = attackerExp + expAward
 IF attackerExp > attackerMaxExp THEN attackerExp = attackerMaxExp
 '--- Determine whether or not the attacker has enough EXP to LVL up.
 IF attackerExp => expNeededToLvlUp THEN
  IF attackerLvl < maxLvl THEN
   attackerLvl = attackerLvl + 1
   attackerAttributePoints = attackerAttributePoints + 20
   IF attackerAttributePoints > maxAttributePoints THEN attackerAttributePoints = maxAttributePoints
  END IF
 END IF
END IF