en:rpd:defense_mechanic
Table of Contents
Defense Mechanic
Defense is a core combat mechanic in Remixed Dungeon that determines the chance to successfully evade incoming attacks.
Defense Skill Formula
The defense skill is calculated in the Char.java file as part of the defenseSkill method:
public int defenseSkill(Char enemy) { int defenseSkill = baseDefenseSkill + lvl(); final int[] bf = {0}; forEachBuff(b -> bf[0] += b.defenceSkillBonus(this)); int bonus = bf[0]; float evasion = (float) Math.pow(1.2, bonus); if (paralysed) { evasion /= 2; } int aEnc = getItemFromSlot(Belongings.Slot.ARMOR).requiredSTR() - effectiveSTR(); if (aEnc > 0) { return (int) (defenseSkill * evasion / Math.pow(1.5, aEnc)); } else { if (getHeroClass() == HeroClass.ROGUE) { if (getCurAction() != null && getSubClass() == HeroSubClass.FREERUNNER && !isStarving()) { evasion *= 2; } return (int) ((defenseSkill - aEnc) * evasion); } else { return (int) (defenseSkill * evasion); } } }
Defense Skill Components
Base Defense Skill
- Definition: The character's base defense skill value
- Storage:
baseDefenseSkillfield in Char class - Examples:
- Rat: 3
- Warrior: 5 (in Hero class)
- Thief: 12
- Goo: 12
- King: 25
- Yog's Heart: 40
- Function: Provides the foundational defense value before modifiers
Level Bonus
- Formula:
baseDefenseSkill + lvl() - Effect: Each level increases defense skill by 1 point
- Implementation:
baseDefenseSkill + lvl()in the calculation
Buff Bonuses
- Mechanism: Each buff with
defenceSkillBonusincreases the skill - Formula: Bonuses are summed and applied as exponential modifier to evasion:
Math.pow(1.2, bonus) - Examples: Various buffs can provide defense skill bonuses
Paralysis Penalty
- Condition: When character is paralyzed
- Effect: Evasion is halved (
evasion /= 2) - Purpose: Reduces defensive capabilities while paralyzed
Armor Encumbrance
- Calculation:
aEnc = getItemFromSlot(Belongings.Slot.ARMOR).requiredSTR() - effectiveSTR() - Effect: If
aEnc > 0(armor requires more STR than available), defense is reduced by a factor ofMath.pow(1.5, aEnc) - Impact: Wearing armor that requires more strength than available significantly reduces defense
Class-Specific Mechanics
- Hero Classes: Non-rogues use basic formula
defenseSkill * evasion - Rogues: Use modified formula
(defenseSkill - aEnc) * evasionand get additional bonuses - Freerunner Subclass: When not starving and moving, evasion is doubled (
evasion *= 2)
Combat Calculation
- 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
Hero Defense Skill Enhancement
The Hero class has a special defense skill calculation:
// In Hero.java public int defenseSkill(Char enemy) { float skillFactor = 1; if (getSubClass() == HeroSubClass.BRIGAND) { skillFactor *= 1.2; } return (int) (super.defenseSkill(enemy) * skillFactor); }
Defense in Combat
- Evasion: The primary means of avoiding damage is through the defense skill system
- Hit Calculation:
Random.Float(attacker.attackSkill(defender)) > Random.Float(defender.defenseSkill(attacker)) - Result: If the attacker's roll is higher, the hit succeeds; otherwise, the defender evades
Related String Resource
Char_StaDodged: Text displayed when a character successfully dodges an attack
Code References
- Java: Char.java
- Java: Hero.java
- Java: CharUtils.java
Data Validation
- Defense Formula (Java):
defenseSkillmethod in Char.java calculates defense with baseDefenseSkill + lvl() + buff bonuses - Evasion Multiplier:
Math.pow(1.2, bonus)where bonus comes from buffs withdefenceSkillBonusmethod - Armor Encumbrance:
aEnc = getItemFromSlot(Belongings.Slot.ARMOR).requiredSTR() - effectiveSTR() - Encumbrance Reduction Factor:
Math.pow(1.5, aEnc)when armor requires more STR than available - Paralysis Effect:
evasion /= 2when character is paralyzed - Freerunner Bonus:
evasion *= 2when not starving and moving - Combat Hit Calculation:
Random.Float(attacker.attackSkill(defender)) > Random.Float(defender.defenseSkill(attacker)) - String Resources:
Char_StaDodgedarray in strings_all.xml provides dodge text messages
Related
- Encumbrance - How armor weight affects movement and defense
- Strength - How strength affects armor requirements
- Buffs - How buffs affect defense skill
- Paralysis - Effect on defense when paralyzed
- Freerunner - Class with special defense mechanics
en/rpd/defense_mechanic.txt · Last modified: by 127.0.0.1
