====== Armor Buff - Code References ====== ===== Java Classes ===== * [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/plants/Earthroot.java|Earthroot.java]] (contains Armor as inner class) ===== JSON Configuration ===== This entity is implemented in Java, no JSON configuration exists ===== String Resources ===== Armor ===== Lua Scripts ===== This entity is implemented in Java, no Lua script exists ===== Buff Properties (from Earthroot.Armor) ===== * ''extends Buff'' - Inherits from base Buff class * ''level'' - Stores the damage absorption amount (set to character's HT when applied) * ''pos'' - Stores the position where the buff was applied * ''absorb(damage)'' - Method that reduces incoming damage and detaches when depleted ===== Buff Implementation ===== public static class Armor extends Buff { private static final float STEP = 1f; @Packable public int pos; @Packable public int level; @Override public boolean attachTo(@NotNull Char target) { pos = target.getPos(); return super.attachTo(target); } @Override public boolean act() { if (target.getPos() != pos) { detach(); } spend(STEP); return true; } public int absorb(int damage) { if (damage >= level) { detach(); return damage - level; } else { level -= damage; return 0; } } } ===== Buff Behavior ===== * Applied when a character steps on an [[mr:earthroot_plant|Earthroot]] plant * Level is set to the character's HT (hit points) when applied * Absorbs incoming damage up to the level amount * Detaches if the character moves from the position where it was applied * Detaches after absorbing damage equal to or greater than its level ===== Related mr Entities ===== * [[mr:earthroot_plant|Earthroot (Plant)]] * [[mr:barkskin_buff|Barkskin (Buff)]]