Search in sources :

Example 1 with Weapon

use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CursingTrap method curse.

public static void curse(Hero hero) {
    // items the trap wants to curse because it will create a more negative effect
    ArrayList<Item> priorityCurse = new ArrayList<>();
    // items the trap can curse if nothing else is available.
    ArrayList<Item> canCurse = new ArrayList<>();
    KindOfWeapon weapon = hero.belongings.weapon;
    if (weapon instanceof Weapon && !weapon.cursed && !(weapon instanceof Boomerang)) {
        if (((Weapon) weapon).enchantment == null)
            priorityCurse.add(weapon);
        else
            canCurse.add(weapon);
    }
    Armor armor = hero.belongings.armor;
    if (armor != null && !armor.cursed) {
        if (armor.glyph == null)
            priorityCurse.add(armor);
        else
            canCurse.add(armor);
    }
    KindofMisc misc1 = hero.belongings.misc1;
    if (misc1 != null) {
        canCurse.add(misc1);
    }
    KindofMisc misc2 = hero.belongings.misc2;
    if (misc2 != null) {
        canCurse.add(misc2);
    }
    Collections.shuffle(priorityCurse);
    Collections.shuffle(canCurse);
    int numCurses = Random.Int(2) == 0 ? 1 : 2;
    for (int i = 0; i < numCurses; i++) {
        if (!priorityCurse.isEmpty()) {
            curse(priorityCurse.remove(0));
        } else if (!canCurse.isEmpty()) {
            curse(canCurse.remove(0));
        }
    }
    EquipableItem.equipCursed(hero);
    GLog.n(Messages.get(CursingTrap.class, "curse"));
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor) KindofMisc(com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc) ArrayList(java.util.ArrayList) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Boomerang(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)

Example 2 with Weapon

use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WaterOfTransmutation method changeWeapon.

private Weapon changeWeapon(MeleeWeapon w) {
    Weapon n;
    Category c = Generator.wepTiers[w.tier - 1];
    do {
        try {
            n = (MeleeWeapon) c.classes[Random.chances(c.probs)].newInstance();
        } catch (Exception e) {
            ShatteredPixelDungeon.reportException(e);
            return null;
        }
    } while (Challenges.isItemBlocked(n) || n.getClass() == w.getClass());
    int level = w.level();
    if (level > 0) {
        n.upgrade(level);
    } else if (level < 0) {
        n.degrade(-level);
    }
    n.enchantment = w.enchantment;
    n.levelKnown = w.levelKnown;
    n.cursedKnown = w.cursedKnown;
    n.cursed = w.cursed;
    n.imbue = w.imbue;
    return n;
}
Also used : Category(com.shatteredpixel.shatteredpixeldungeon.items.Generator.Category) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon) MeleeWeapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon)

Example 3 with Weapon

use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class ScrollOfRemoveCurse method uncurse.

public static boolean uncurse(Hero hero, Item... items) {
    boolean procced = false;
    for (Item item : items) {
        if (item != null && item.cursed) {
            item.cursed = false;
            procced = true;
        }
        if (item instanceof Weapon) {
            Weapon w = (Weapon) item;
            if (w.hasCurseEnchant()) {
                w.enchant(null);
                w.cursed = false;
                procced = true;
            }
        }
        if (item instanceof Armor) {
            Armor a = (Armor) item;
            if (a.hasCurseGlyph()) {
                a.inscribe(null);
                a.cursed = false;
                procced = true;
            }
        }
        if (item instanceof Bag) {
            for (Item bagItem : ((Bag) item).items) {
                if (bagItem != null && bagItem.cursed) {
                    bagItem.cursed = false;
                    procced = true;
                }
            }
        }
    }
    if (procced) {
        hero.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
        // for ring of might
        hero.updateHT(false);
    }
    return procced;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor) WndBag(com.shatteredpixel.shatteredpixeldungeon.windows.WndBag) Bag(com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)

Example 4 with Weapon

use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon in project shattered-pixel-dungeon-gdx by 00-Evan.

the class ScrollOfUpgrade method onItemSelected.

@Override
protected void onItemSelected(Item item) {
    upgrade(curUser);
    // ...yes this is rather messy
    if (item instanceof Weapon) {
        Weapon w = (Weapon) item;
        boolean wasCursed = w.cursed;
        boolean hadCursedEnchant = w.hasCurseEnchant();
        boolean hadGoodEnchant = w.hasGoodEnchant();
        w.upgrade();
        if (hadCursedEnchant && !w.hasCurseEnchant()) {
            removeCurse(Dungeon.hero);
        } else if (wasCursed && !w.cursed) {
            weakenCurse(Dungeon.hero);
        }
        if (hadGoodEnchant && !w.hasGoodEnchant()) {
            GLog.w(Messages.get(Weapon.class, "incompatible"));
        }
    } else if (item instanceof Armor) {
        Armor a = (Armor) item;
        boolean wasCursed = a.cursed;
        boolean hadCursedGlyph = a.hasCurseGlyph();
        boolean hadGoodGlyph = a.hasGoodGlyph();
        a.upgrade();
        if (hadCursedGlyph && !a.hasCurseGlyph()) {
            removeCurse(Dungeon.hero);
        } else if (wasCursed && !a.cursed) {
            weakenCurse(Dungeon.hero);
        }
        if (hadGoodGlyph && !a.hasGoodGlyph()) {
            GLog.w(Messages.get(Armor.class, "incompatible"));
        }
    } else if (item instanceof Wand || item instanceof Ring) {
        boolean wasCursed = item.cursed;
        item.upgrade();
        if (wasCursed && !item.cursed) {
            removeCurse(Dungeon.hero);
        }
    } else {
        item.upgrade();
    }
    Badges.validateItemLevelAquired(item);
}
Also used : Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor) Ring(com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring) Wand(com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)

Aggregations

Weapon (com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)4 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)3 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)2 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)1 Category (com.shatteredpixel.shatteredpixeldungeon.items.Generator.Category)1 KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)1 KindofMisc (com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc)1 Bag (com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag)1 Ring (com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring)1 Wand (com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand)1 MeleeWeapon (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon)1 Boomerang (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang)1 WndBag (com.shatteredpixel.shatteredpixeldungeon.windows.WndBag)1 ArrayList (java.util.ArrayList)1