====== Backstab Spell - Code References ====== This page contains raw code references and configuration excerpts for the Backstab spell entity. ==== Entity Kind ==== * **Spell Type:** Rogue Affinity Spell (Lua implementation) * **Targeting:** self (targets nearest enemy within 1 tile) ==== Java Implementation ==== * No dedicated Java class for this spell * Spell is implemented entirely in Lua ==== Lua Script ==== * **Script location:** [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/assets/scripts/spells/Backstab.lua|Backstab.lua]] * **Spell library:** [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/assets/scripts/lib/spell.lua|spell.lua]] ==== Lua Script Content ==== local RPD = require "scripts/lib/commonClasses" local spell = require "scripts/lib/spell" local distracted = {} distracted["PASSIVE"] = true distracted["SLEEPING"] = true distracted["FLEEING"] = true distracted["HORRIFIED"] = true distracted["RUNNINGAMOK"] = true return spell.init{ desc = function () return { image = 2, imageFile = "spellsIcons/rogue.png", name = "Backstab_Name", info = "Backstab_Info", magicAffinity = "Rogue", targetingType = "self", level = 2, castTime = 1, spellCost = 2 } end, cast = function(self, spell, caster) local level = caster:level() local ownPos = caster:getPos() local victim = caster:getNearestEnemy() if victim == nil or level:distance(ownPos, victim:getPos()) > 1 then RPD.glogn("Backstab_TooFar") return false end if not distracted[victim:getState():getTag()] and not victim:isParalysed() then RPD.glogn("Backstab_Aware") return false end victim:showStatus(0xff2030,"backstab") local weapon = caster:getBelongings().weapon local secondaryWeapon = caster:getBelongings().leftHand local damage = math.sqrt(caster:skillLevel()) * (weapon:damageRoll(caster) + secondaryWeapon:damageRoll(caster)) victim:damage(damage, caster) RPD.Sfx.Wound:hit(victim) return true end } ==== Key Properties from Code ==== * **Magic Affinity:** Rogue * **Targeting:** self (auto-targets nearest enemy within 1 tile) * **Level:** 2 * **Mana Cost:** 2 * **Cast Time:** 1 turn * **Damage Formula:** sqrt(caster's skill level) * (main weapon damage roll + secondary weapon damage roll) * **Conditions:** Only works on distracted enemies (PASSIVE, SLEEPING, FLEEING, HORRIFIED, RUNNINGAMOK) or paralyzed targets * **Range:** 1 tile distance from caster ==== String Resources ==== Backstab Silent hit in the back. Dishonest, but extremely effective, backstab damage will grow with performer skill level.\n\nSuccessful backstab will completely ignore victim armor or special defense abilities. Victim too far for successful hit. Victim shouldn't be aware of you for a good backstab. ==== JSON Configuration ==== This entity does not use JSON configuration. ==== Code Behavior ==== * Implemented as Lua spell using the spell library * Checks if nearest enemy is within 1 tile distance * Requires target to be distracted (PASSIVE, SLEEPING, FLEEING, HORRIFIED, RUNNINGAMOK) or paralyzed * Calculates damage using both main hand and off-hand weapon damage rolls * Damage scales with square root of caster's skill level * Ignores victim's armor completely when successful * Shows visual status effect (0xff2030 "backstab") on victim * Plays Wound sound effect after attack ==== Spell Registration ==== * Registered in [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/assets/scripts/spells/CustomSpellsList.lua|CustomSpellsList.lua]] under "Rogue" affinity * Part of Rogue class spell set ==== Related Entities ==== * **Rogue Class:** [[mr:rogue_class|rogue_class]] - Class that has access to this spell * **Assassin Subclass:** [[mr:assassin_subclass|assassin_subclass]] - Subclass that might have enhanced backstab capabilities * **English Page:** [[en:rpd:backstab_spell|backstab_spell]] * **Russian Page:** [[ru:rpd:backstab_spell|backstab_spell]] (if exists) {{tag> mr rpd spells rogue lua_defined}}