====== Magic Affinities Mechanic ======
**Magic Affinities** in Remixed Dungeon determine which spells are available to a character class or hero subclass. Each class typically has a primary affinity which grants access to specific spells.
==== Affinity System Code ====
The magic affinity system is implemented in several Java files:
// In SpellHelper.java
public static final String AFFINITY_NECROMANCY = "Necromancy";
public static final String AFFINITY_ELEMENTAL = "Elemental";
public static final String AFFINITY_RAGE = "Rage";
public static final String AFFINITY_DEMONOLOGY = "Demolonogy";
public static final String AFFINITY_NATURE = "Nature";
public static final String AFFINITY_SHADOW = "Shadow";
public static final String AFFINITY_COMMON = "Common";
// In HeroClass.java
private String magicAffinity = Utils.EMPTY_STRING;
// In SpellFactory.java
static private Map> mSpellsByAffinity;
==== List of Magic Affinities ====
==== Common ====
* **Description:** Basic utility spells
* **Classes:** Available to most classes
* **Spells:** [[rpd:town_portal_spell|Town Portal]], [[rpd:healing_spell|Heal]], [[rpd:raise_dead_spell|Raise Dead]], [[rpd:cloak_spell|Cloak]], [[rpd:calm_spell|Calm]], [[rpd:charm_spell|Charm]]
* **Code Reference:** ''SpellHelper.AFFINITY_COMMON''
* **String Resource:** ''Abilities_Common'' → "Common Spells"
==== Combat ====
* **Description:** Spells focused on combat enhancement
* **Spells:** [[rpd:die_hard_spell|Die Hard]], [[rpd:dash_spell|Dash]], [[rpd:body_armor_spell|Body Armor]], [[rpd:smash_spell|Smash]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Elemental ====
* **Description:** Spells related to elemental damage and effects
* **Spells:** [[rpd:freeze_globe_spell|Freeze Globe]], [[rpd:magic_torch_spell|Magic Torch]], [[rpd:wind_gust_spell|Wind Gust]], [[rpd:ignite_spell|Ignite]], [[rpd:root_spell|Root]]
* **Code Reference:** ''SpellHelper.AFFINITY_ELEMENTAL''
* **String Resource:** ''Abilities_Elemental'' → "Elemental Spells"
==== Necromancy ====
* **Description:** Undead summoning and dark magic
* **Spells:** [[rpd:raise_dead_spell|Raise Dead]], [[rpd:exhumation_spell|Exhumation]], [[rpd:dark_sacrifice_spell|Dark Sacrifice]], [[rpd:possess_spell|Possess]]
* **Code Reference:** ''SpellHelper.AFFINITY_NECROMANCY''
* **String Resource:** ''Abilities_Necromancy'' → "Necromancy"
==== Rogue ====
* **Description:** Spells focused on stealth and utility
* **Spells:** [[rpd:cloak_spell|Cloak]], [[rpd:backstab_spell|Backstab]], [[rpd:kunai_throw_spell|Kunai Throw]], [[rpd:haste_spell|Haste]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Witchcraft ====
* **Description:** Control and manipulation spells
* **Classes:** Gnoll class
* **Spells:** [[rpd:roar_spell|Roar]], [[rpd:lightning_bolt_spell|Lightning Bolt]], [[rpd:healing_spell|Heal]], [[rpd:order_spell|Order]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Huntress ====
* **Description:** Spells related to ranged combat
* **Spells:** [[rpd:calm_spell|Calm]], [[rpd:charm_spell|Charm]], [[rpd:shoot_in_eye_spell|Shoot In Eye]], [[rpd:summon_beast_spell|Summon Beast]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Elf ====
* **Description:** Nature and control magic
* **Spells:** [[rpd:magic_arrow_spell|Magic Arrow]], [[rpd:sprout_spell|Sprout]], [[rpd:hide_in_grass_spell|Hide In Grass]], [[rpd:nature_armor_spell|Nature Armor]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Priest ====
* **Description:** Holy magic and healing
* **Classes:** Plague Doctor class
* **Spells:** [[rpd:healing_spell|Heal]], [[rpd:calm_spell|Calm]], [[rpd:charm_spell|Charm]], [[rpd:order_spell|Order]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Plague Doctor ====
* **Description:** Disease and poison-based magic
* **Classes:** Plague Doctor class
* **Spells:** [[rpd:healing_spell|Heal]], [[rpd:calm_spell|Calm]], [[rpd:charm_spell|Charm]], [[rpd:order_spell|Order]]
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Rage ====
* **Code Reference:** ''SpellHelper.AFFINITY_RAGE''
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Nature ====
* **Code Reference:** ''SpellHelper.AFFINITY_NATURE''
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Shadow ====
* **Code Reference:** ''SpellHelper.AFFINITY_SHADOW''
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Demonology ====
* **Code Reference:** ''SpellHelper.AFFINITY_DEMONOLOGY''
* **String Resource:** ''Abilities_Default'' → "Mastery"
==== Dev ====
* **Description:** Development/test spells
* **Spells:** [[rpd:test_spell|Test Spell]], [[rpd:curse_item_spell|Curse Item]]
==== Affinity Implementation ====
The affinity system is implemented using Lua scripts in ''scripts/spells/SpellsByAffinity.lua'' and ''scripts/spells/CustomSpellsList.lua'':
-- In CustomSpellsList.lua
local spells = {}
spells["Necromancy"] = {"RaiseDead","Exhumation", "DarkSacrifice","Possess"}
spells["Common"] = {"TownPortal","Heal","RaiseDead","Cloak","Calm","Charm"}
spells["Combat"] = {"DieHard","Dash","BodyArmor","Smash"}
spells["Rogue"] = {"Cloak","Backstab","KunaiThrow","Haste"}
spells["Witchcraft"] = {"Roar","LightningBolt","Heal","Order"}
spells["Huntress"] = {"Calm","Charm","ShootInEye","SummonBeast"}
spells["Elf"] = {"MagicArrow","Sprout","HideInGrass","NatureArmor"}
spells["Priest"] = {"Heal","Calm","Charm","Order"}
spells["PlagueDoctor"] = {"Heal","Calm","Charm","Order"}
spells["Dev"] = {"TestSpell", "CurseItem"}
return spells
==== Class Implementation ====
The hero class determines the magic affinity:
// In Hero.java
public boolean hasMagicAffinity() {
return !heroClass.getMagicAffinity().isEmpty();
}
// In HeroClass.java
private String magicAffinity = Utils.EMPTY_STRING;
==== Code References ====
* Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/mechanics/spells/SpellHelper.java|SpellHelper.java]]
* Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/mechanics/spells/SpellFactory.java|SpellFactory.java]]
* Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/windows/WndHeroSpells.java|WndHeroSpells.java]]
* Java: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/HeroClass.java|HeroClass.java]]
* Lua: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/assets/scripts/spells/SpellsByAffinity.lua|SpellsByAffinity.lua]]
* Lua: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/assets/scripts/spells/CustomSpellsList.lua|CustomSpellsList.lua]]
==== Related Strings ====
* ''Abilities_Default'': "Mastery"
* ''Abilities_Common'': "Common Spells"
* ''Abilities_Elemental'': "Elemental Spells"
* ''Abilities_Necromancy'': "Necromancy"
==== Mechanics ====
* **Spell availability** - Characters have primary access to spells matching their affinity
* **Cross-affinity access** - Some classes may have access to multiple affinities
* **Spell learning** - Affinity affects how spells are learned and used
* **Mastery titles** - Different affinities have different mastery titles determined by string resources
==== Strategy ====
* Choose classes based on preferred spell affinities
* Understand which spells are available to your character
* Plan spell usage around your character's affinity
* Consider class-specific affinities when building your character
==== See Also ====
* [[rpd:spells_mechanic|Spells]]
* [[rpd:spell_affinities_mechanic|Spell Affinities]]
* [[rpd:hero_classes_mechanic|Hero Classes]]
* [[rpd:healing_spell|Healing Spell]]
* [[rpd:witchcraft_affinity_mechanic|Witchcraft Affinity]]
{{tag> rpd magic affinities spells mechanics }}