use of com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Blacksmith method upgrade.
public static void upgrade(Item item1, Item item2) {
Item first, second;
if (item2.level() > item1.level()) {
first = item2;
second = item1;
} else {
first = item1;
second = item2;
}
Sample.INSTANCE.play(Assets.SND_EVOKE);
ScrollOfUpgrade.upgrade(Dungeon.hero);
Item.evoke(Dungeon.hero);
if (first.isEquipped(Dungeon.hero)) {
((EquipableItem) first).doUnequip(Dungeon.hero, true);
}
// prevents on-upgrade effects like enchant/glyph removal
first.level(first.level() + 1);
Dungeon.hero.spendAndNext(2f);
Badges.validateItemLevelAquired(first);
if (second.isEquipped(Dungeon.hero)) {
((EquipableItem) second).doUnequip(Dungeon.hero, false);
}
second.detachAll(Dungeon.hero.belongings.backpack);
if (second instanceof Armor) {
BrokenSeal seal = ((Armor) second).checkSeal();
if (seal != null) {
Dungeon.level.drop(seal, Dungeon.hero.pos);
}
}
Quest.reforged = true;
Notes.remove(Notes.Landmark.TROLL);
}
use of com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Guard method createLoot.
@Override
protected Item createLoot() {
// first see if we drop armor, overall chance is 1/8
if (Random.Int(2) == 0) {
Armor loot;
do {
loot = Generator.randomArmor();
// 50% chance of re-rolling tier 4 or 5 items
} while (loot.tier >= 4 && Random.Int(2) == 0);
loot.level(0);
return loot;
// otherwise, we may drop a health potion. overall chance is 1/8 * (6-potions dropped)/6
// with 0 potions dropped that simplifies to 1/8
} else {
if (Random.Float() < ((6f - Dungeon.LimitedDrops.GUARD_HP.count) / 6f)) {
Dungeon.LimitedDrops.GUARD_HP.drop();
return new PotionOfHealing();
}
}
return null;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor 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.armor.Armor in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CryptRoom method prize.
private static Item prize(Level level) {
// 1 floor set higher than normal
Armor prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
if (Challenges.isItemBlocked(prize)) {
return new Gold().random();
}
// if it isn't already cursed, give it a free upgrade
if (!prize.cursed) {
prize.upgrade();
// curse the armor, unless it has a glyph
if (!prize.hasGoodGlyph()) {
prize.cursed = prize.cursedKnown = true;
prize.inscribe(Armor.Glyph.randomCurse());
}
}
return prize;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Generator method randomArmor.
public static Armor randomArmor(int floorSet) {
floorSet = (int) GameMath.gate(0, floorSet, floorSetTierProbs.length - 1);
try {
Armor a = (Armor) Category.ARMOR.classes[Random.chances(floorSetTierProbs[floorSet])].newInstance();
a.random();
return a;
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
return null;
}
}
Aggregations