/** * Gets the chance a unit can hit its target * * @param a The attacking Unit * @param b The defending Unit * @param m The map it takes place on. * @return The hit chance. */ public static int hitChance(Unit a, Unit b, Map m) { // Determine Hit Rate, Evasion, and Weapon Advantage. int hitRate = a.getTotalSkill() * 2 + a.getTotalLuck() + a.getEquppedWeapon().getHit(); int evade = b.getTotalSpd() * 2 + b.getTotalLuck() + m.getTerrainAtPoint(b.getCoord()).getEvade(); int weaponAdvantage = weaponAdvantageAccuracy(a.getEquppedWeapon(), b.getEquppedWeapon()); return (hitRate + weaponAdvantage - evade); }
/** Cleans up, and awards XP TODO */ public void cleanup() { // Just in case they're not back where they belong. if (!graphics) { attacker.moveInstantly(attacker.getCoord()); defender.moveInstantly(defender.getCoord()); } // Award XP if (attacker.getTeam() == 0) { int xp = 10; if (defenderDied) xp += 20; attackerXP = xpMath(attacker, defender, xp); } if (defender.getTeam() == 0) { int xp = 10; if (attackerDied) xp += 20; defenderXP = xpMath(defender, attacker, xp); } }