User Tools

Site Tools


en:rpd:attack_skill_mechanic

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:

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:

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

en/rpd/attack_skill_mechanic.txt · Last modified: by 127.0.0.1