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"));
}
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;
}
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;
}
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);
}
Aggregations