====== mr:wand_of_lightning_item ====== Machine-readable reference page for Wand of Lightning item in Remixed Dungeon. ==== Java Implementation ==== **Class File:** * File: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/wands/WandOfLightning.java|WandOfLightning.java]] * Package: com.watabou.pixeldungeon.items.wands * Extends: SimpleWand * Entity Kind: WandOfLightning **Item Properties:** * Type: Wand (ranged magical weapon) * Image: From items/wands.png sprite sheet * Rarity: Uncommon * Charges: Starts with 3 charges, maximum of 8 * Price: 50 gold when identified ==== Code Implementation ==== package com.watabou.pixeldungeon.items.wands; import com.nyrds.pixeldungeon.ml.R; import com.nyrds.platform.util.StringsManager; import com.watabou.noosa.Camera; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.ResultDescriptions; import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.effects.CellEmitter; import com.watabou.pixeldungeon.effects.Lightning; import com.watabou.pixeldungeon.effects.particles.SparkParticle; import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.levels.traps.LightningTrap; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.pixeldungeon.utils.GLog; import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Callback; import com.watabou.utils.Random; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; public class WandOfLightning extends SimpleWand { private final ArrayList affected = new ArrayList<>(); private final int[] points = new int[20]; private int nPoints; @Override protected void onZap( int cell, Char ch ) { if ((getOwner() == Dungeon.hero) && !getOwner().isAlive()) { Dungeon.fail( Utils.format( ResultDescriptions.getDescription(ResultDescriptions.Reason.WAND), name, Dungeon.depth ) ); GLog.n(StringsManager.getVar(R.string.WandOfLightning_Info1)); } } private void hit( Char ch, int damage ) { if (damage < 1) { return; } if (ch == Dungeon.hero) { Camera.main.shake( 2, 0.3f ); } affected.add( ch ); ch.damage( Dungeon.level.water[ch.getPos()] && !ch.isFlying() ? damage * 2 : damage, LightningTrap.LIGHTNING ); ch.getSprite().centerEmitter().burst( SparkParticle.FACTORY, 3 ); ch.getSprite().flash(); points[nPoints++] = ch.getPos(); HashSet ns = new HashSet<>(); for (int i=0; i < Level.NEIGHBOURS8.length; i++) { Char n = Actor.findChar( ch.getPos() + Level.NEIGHBOURS8[i] ); if (n != null && !affected.contains( n )) { ns.add( n ); } } if (!ns.isEmpty()) { hit( Random.element( ns ), Random.Int( damage / 2, damage ) ); } } @Override protected void fx( int cell, Callback callback ) { nPoints = 0; points[nPoints++] = getOwner().getPos(); Char ch = Actor.findChar( cell ); if (ch != null) { affected.clear(); int lvl = effectiveLevel(); hit( ch, Random.Int( 5 + lvl / 2, 10 + lvl ) ); } else { points[nPoints++] = cell; CellEmitter.center( cell ).burst( SparkParticle.FACTORY, 3 ); } GameScene.addToMobLayer(new Lightning(Arrays.copyOfRange(points, 0, nPoints), callback)); } @Override public String desc() { return StringsManager.getVar(R.string.WandOfLightning_Info); } } ==== Key Properties from Code ==== **Damage Calculation:** * Base damage: Random.Int(5 + lvl/2, 10 + lvl) where lvl is effective wand level * Chain damage: Random.Int(damage/2, damage) for each subsequent target * Water bonus: Damage doubled if target is in water and not flying **Chain Lightning Mechanics:** * Hits primary target, then chains to adjacent enemies * Uses recursive hit() method to find next target * Tracks affected characters to avoid hitting same target twice * Maximum chain range: 8 neighboring cells (Level.NEIGHBOURS8) * Maximum lightning points tracked: 20 **Visual Effects:** * Lightning effect rendered via GameScene.addToMobLayer() * Spark particles emitted on hit (3 particles per target) * Camera shake effect when hero is hit (2 intensity, 0.3f duration) * Target sprite flashes on hit ==== String Resources ==== **English (values/strings_all.xml):** * WandOfLightning_Name - "Wand of Lightning" * WandOfLightning_Info - "This wand conjures forth deadly arcs of electricity, which will deal damage to several creatures standing close to each other." * WandOfLightning_Info1 - "You zapped yourself with your own Wand of Lightning..." * WandOfLightning_Gender - "feminine" **Russian (values-ru/strings_all.xml):** * WandOfLightning_Name - Russian item name * WandOfLightning_Info - Russian description * WandOfLightning_Info1 - Russian self-zap message * WandOfLightning_Gender - Russian gender ==== Acquisition ==== **Primary Source:** * Found in dungeon chests * Available in shops * Dropped by certain enemies ==== Mechanics ==== **Charge-Based:** * Uses charges for each zap (typically 1 charge per use) * Gradually regains charges over time **Multi-Target Damage:** * Excellent against groups of enemies due to chain effect * Good for clearing rooms filled with weak enemies * Effective against enemies positioned in clusters **Self-Damage Risk:** * Can damage the user if targeting fails * Death from own wand triggers failure message **Water Interaction:** * Deals double damage to targets in water * Does not affect flying targets ==== Strategy ==== * Excellent against groups of enemies due to chain effect * Good for clearing rooms filled with weak enemies * Effective against enemies positioned in clusters * Conserve charges for critical group situations * Use in water-filled areas for maximum damage ==== Related Entities ==== **Related Items:** * [[mr:wand_item|mr:wand_item]] - Base wand class * [[mr:wands|mr:wands]] - General wand mechanics * [[mr:charges|mr:charges]] - Information about magical charges **Related Traps:** * [[mr:lightning_trap|mr:lightning_trap]] - Uses same LIGHTNING damage type ==== Wiki Pages ==== **English:** * [[en:rpd:wand_of_lightning_item|Wand of Lightning]] - Main wiki page **Russian:** * [[ru:rpd:wand_of_lightning_item|Жезл молний]] - Russian wiki page ==== Code References ==== * Item implementation: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/wands/WandOfLightning.java|WandOfLightning.java]] * Parent class: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/wands/SimpleWand.java|SimpleWand.java]] * Registration: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/items/common/ItemFactory.java|ItemFactory.java]] * String resources: [[https://github.com/NYRDS/remixed-dungeon/blob/master/RemixedDungeon/src/main/res/values/strings_all.xml|strings_all.xml]] {{tag> mr items wands lightning magic chain_lightning reference machine-readable}}