====== Attack Skill Mechanic ====== Attack Skill is a core combat mechanic in Remixed Dungeon that determines the chance of successfully hitting an enemy with attacks. ==== Attack Skill Formula ==== The attack skill is calculated in the ''Char.java'' file as part of the ''attackSkill'' method: public int attackSkill(Char target) { int[] bf = {0}; forEachBuff(b -> bf[0] += b.attackSkillBonus(this)); int bonus = bf[0]; float accuracy = (float) Math.pow(1.4, bonus); if (target == null) { // Mainly to mask bug in Remixed RPG target = CharsList.DUMMY; } if (rangedWeapon.valid() && level().distance(getPos(), target.getPos()) == 1) { accuracy *= 0.5f; } float mainAccuracyFactor = getActiveWeapon().accuracyFactor(this); float secondaryAccuracyFactor = getSecondaryWeapon().accuracyFactor(this); float skillFactor = Utils.min(20f, mainAccuracyFactor, secondaryAccuracyFactor); int aSkill = (int) ((baseAttackSkill + lvl()) * accuracy * skillFactor); GLog.debug("%s attacking %s with factor %2.2f, resulting skill %d", getEntityKind(), target.getEntityKind(), skillFactor, aSkill); return aSkill; } ==== Attack Skill Components ==== ==== Base Attack Skill ==== * **Definition**: The character's base attack skill value * **Storage**: ''baseAttackSkill'' field in Char class * **Examples**: * Rat: 8 * Warrior: 10 (in Hero class) * Thief: 12 * Goo: 11 * King: 32 * Yog's Heart: 26 * **Function**: Provides the foundational attack value before modifiers ==== Level Bonus ==== * **Formula**: ''baseAttackSkill + lvl()'' * **Effect**: Each level increases attack skill by 1 point * **Implementation**: ''baseAttackSkill + lvl()'' in the calculation ==== Buff Bonuses ==== * **Mechanism**: Each buff with ''attackSkillBonus'' increases the skill * **Formula**: Bonuses are summed and applied as exponential modifier to accuracy: ''Math.pow(1.4, bonus)'' * **Examples**: * [[rpd:ring_of_accuracy_item|Ring of Accuracy]] increases attack skill bonus equal to its level * [[rpd:blessed_buff|Blessed buff]] provides attack skill bonus * [[rpd:hero_subclass|Hero subclasses]] may provide attack skill bonuses ==== Accuracy Factors ==== * **Weapon Accuracy**: ''getActiveWeapon().accuracyFactor(this)'' and ''getSecondaryWeapon().accuracyFactor(this)'' * **Calculation**: The minimum of both weapon accuracy factors is used, capped at 20.0 * **Examples**: * **[[rpd:ring_of_accuracy_item|Ring of Accuracy]]**: Provides accuracy bonus * **[[rpd:weightstone_item|Weightstone]]**: Can imbue weapons with accuracy * **[[rpd:compound_bow_item|Compound Bow]]**: Has improved accuracy over wooden bow ==== Ranged Penalty ==== * **Condition**: When using a ranged weapon at melee distance (distance = 1) * **Effect**: Accuracy is halved (0.5f multiplier) * **Purpose**: Discourages using ranged weapons at close range ==== Defense Comparison ==== * **Usage**: Attack skill is compared to the target's defense skill to determine hit probability * **Implementation**: In ''CharUtils.java'', ''Random.Float(attacker.attackSkill(defender)) > Random.Float(defender.defenseSkill(attacker))'' ==== Hero Attack Skill Enhancement ==== The Hero class has a special attack skill calculation that can be enhanced by subclass: // In Hero.java public int attackSkill(Char target) { float attackSkillFactor = 1; if (getSubClass() == HeroSubClass.GLADIATOR) { attackSkillFactor *= 1.2; } return (int) (super.attackSkill(target) * attackSkillFactor); } ==== Attack Skill in Combat ==== * **Hit Chance**: The attacker's attack skill is compared against the defender's defense skill * **Calculation**: ''Random.Float(attacker.attackSkill(defender)) > Random.Float(defender.defenseSkill(attacker))'' * **Result**: If true, the attack hits; if false, the attack misses ==== Code References ==== * Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/Char.java|Char.java]] * Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/Hero.java|Hero.java]] * Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/CharUtils.java|CharUtils.java]] * Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/buffs/Blessed.java|Blessed.java]] ==== Related ==== * [[rpd:defense_mechanic|Defense Mechanic]] * [[rpd:accuracy_mechanic|Accuracy Mechanic]] * [[rpd:combat_mechanic|Combat Mechanic]] * [[rpd:evasion_mechanic|Evasion Mechanic]] * [[rpd:ring_of_accuracy_item|Ring of Accuracy]] {{tag> rpd mechanics combat attack skill }}