use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfTransfusion method onZap.
@Override
protected void onZap(Ballistica beam) {
for (int c : beam.subPath(0, beam.dist)) CellEmitter.center(c).burst(BloodParticle.BURST, 1);
int cell = beam.collisionPos;
Char ch = Actor.findChar(cell);
Heap heap = Dungeon.level.heaps.get(cell);
// if we find a character..
if (ch != null && ch instanceof Mob) {
processSoulMark(ch, chargesPerCast());
// heals an ally, or a charmed enemy
if (ch.alignment == Char.Alignment.ALLY || ch.buff(Charm.class) != null) {
int missingHP = ch.HT - ch.HP;
// heals 30%+3%*lvl missing HP.
int healing = (int) Math.ceil((missingHP * (0.30f + (0.03f * level()))));
ch.HP += healing;
ch.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1 + level() / 2);
ch.sprite.showStatus(CharSprite.POSITIVE, "+%dHP", healing);
// harms the undead
} else if (ch.properties().contains(Char.Property.UNDEAD)) {
// deals 30%+5%*lvl total HP.
int damage = (int) Math.ceil(ch.HT * (0.3f + (0.05f * level())));
ch.damage(damage, this);
ch.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10 + level());
Sample.INSTANCE.play(Assets.SND_BURNING);
// charms an enemy
} else {
float duration = 5 + level();
Buff.affect(ch, Charm.class, duration).object = curUser.id();
duration *= Random.Float(0.75f, 1f);
Buff.affect(curUser, Charm.class, duration).object = ch.id();
ch.sprite.centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);
curUser.sprite.centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);
}
// if we find an item...
} else if (heap != null && heap.type == Heap.Type.HEAP) {
Item item = heap.peek();
// 30% + 10%*lvl chance to uncurse the item and reset it to base level if degraded.
if (item != null && Random.Float() <= 0.3f + level() * 0.1f) {
if (item.cursed) {
item.cursed = false;
CellEmitter.get(cell).start(ShadowParticle.UP, 0.05f, 10);
Sample.INSTANCE.play(Assets.SND_BURNING);
}
int lvldiffFromBase = item.level() - (item instanceof Ring ? 1 : 0);
if (lvldiffFromBase < 0) {
item.upgrade(-lvldiffFromBase);
CellEmitter.get(cell).start(Speck.factory(Speck.UP), 0.2f, 3);
Sample.INSTANCE.play(Assets.SND_BURNING);
}
}
// if we find some trampled grass...
} else if (Dungeon.level.map[cell] == Terrain.GRASS) {
// regrow one grass tile, suuuuuper useful...
Dungeon.level.set(cell, Terrain.HIGH_GRASS);
GameScene.updateMap(cell);
CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 4);
// If we find embers...
} else if (Dungeon.level.map[cell] == Terrain.EMBERS) {
// 30% + 3%*lvl chance to grow a random plant, or just regrow grass.
if (Random.Float() <= 0.3f + level() * 0.03f) {
Dungeon.level.plant((Plant.Seed) Generator.random(Generator.Category.SEED), cell);
CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 8);
GameScene.updateMap(cell);
} else {
Dungeon.level.set(cell, Terrain.HIGH_GRASS);
GameScene.updateMap(cell);
CellEmitter.get(cell).burst(LeafParticle.LEVEL_SPECIFIC, 4);
}
} else
// don't damage the hero if we can't find a target;
return;
if (!freeCharge) {
damageHero();
} else {
freeCharge = false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class ScrollOfRemoveCurse method empoweredRead.
@Override
public void empoweredRead() {
for (Item item : curUser.belongings) {
if (item.cursed) {
item.cursedKnown = true;
}
}
Sample.INSTANCE.play(Assets.SND_READ);
Invisibility.dispel();
doRead();
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RingOfWealth method generateRareDrop.
// TODO this is a start, but i'm sure this could be made more interesting...
private static ArrayList<Item> generateRareDrop() {
float roll = Random.Float();
ArrayList<Item> items = new ArrayList<>();
if (roll < 0.6f) {
switch(Random.Int(3)) {
case 0:
items.add(new Gold().random());
break;
case 1:
items.add(Generator.random(Generator.Category.POTION));
break;
case 2:
items.add(Generator.random(Generator.Category.SCROLL));
break;
}
} else if (roll < 0.9f) {
switch(Random.Int(3)) {
case 0:
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
break;
case 1:
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
break;
case 2:
items.add(new Bomb().random());
items.add(new Honeypot());
break;
}
} else {
Gold g = new Gold();
g.random();
g.quantity(g.quantity() * 5);
items.add(g);
}
return items;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item 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.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Wandmaker method interact.
@Override
public boolean interact() {
sprite.turnTo(pos, Dungeon.hero.pos);
if (Quest.given) {
Item item;
switch(Quest.type) {
case 1:
default:
item = Dungeon.hero.belongings.getItem(CorpseDust.class);
break;
case 2:
item = Dungeon.hero.belongings.getItem(Embers.class);
break;
case 3:
item = Dungeon.hero.belongings.getItem(Rotberry.Seed.class);
break;
}
if (item != null) {
GameScene.show(new WndWandmaker(this, item));
} else {
String msg = "";
switch(Quest.type) {
case 1:
msg = Messages.get(this, "reminder_dust", Dungeon.hero.givenName());
break;
case 2:
msg = Messages.get(this, "reminder_ember", Dungeon.hero.givenName());
break;
case 3:
msg = Messages.get(this, "reminder_berry", Dungeon.hero.givenName());
break;
}
GameScene.show(new WndQuest(this, msg));
}
} else {
String msg1 = "";
String msg2 = "";
switch(Dungeon.hero.heroClass) {
case WARRIOR:
msg1 += Messages.get(this, "intro_warrior");
break;
case ROGUE:
msg1 += Messages.get(this, "intro_rogue");
break;
case MAGE:
msg1 += Messages.get(this, "intro_mage", Dungeon.hero.givenName());
break;
case HUNTRESS:
msg1 += Messages.get(this, "intro_huntress");
break;
}
msg1 += Messages.get(this, "intro_1");
switch(Quest.type) {
case 1:
msg2 += Messages.get(this, "intro_dust");
break;
case 2:
msg2 += Messages.get(this, "intro_ember");
break;
case 3:
msg2 += Messages.get(this, "intro_berry");
break;
}
msg2 += Messages.get(this, "intro_2");
final String msg2final = msg2;
final NPC wandmaker = this;
GameScene.show(new WndQuest(wandmaker, msg1) {
@Override
public void hide() {
super.hide();
GameScene.show(new WndQuest(wandmaker, msg2final));
}
});
Notes.add(Notes.Landmark.WANDMAKER);
Quest.given = true;
}
return false;
}
Aggregations