use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Bones method pickItem.
private static Item pickItem(Hero hero) {
Item item = null;
if (Random.Int(3) != 0) {
switch(Random.Int(6)) {
case 0:
item = hero.belongings.weapon;
break;
case 1:
item = hero.belongings.armor;
break;
case 2:
item = hero.belongings.misc1;
break;
case 3:
item = hero.belongings.misc2;
break;
case 4:
case 5:
item = Dungeon.quickslot.randomNonePlaceholder();
break;
}
if (item == null || !item.bones) {
return pickItem(hero);
}
} else {
Iterator<Item> iterator = hero.belongings.backpack.iterator();
Item curItem;
ArrayList<Item> items = new ArrayList<Item>();
while (iterator.hasNext()) {
curItem = iterator.next();
if (curItem.bones)
items.add(curItem);
}
if (Random.Int(3) < items.size()) {
item = Random.element(items);
if (item.stackable) {
item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2));
}
} else {
if (Dungeon.gold > 100) {
item = new Gold(Random.NormalIntRange(50, Dungeon.gold / 2));
} else {
item = new Gold(50);
}
}
}
return item;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Mimic method spawnAt.
public static Mimic spawnAt(int pos, List<Item> items) {
if (Dungeon.level.pit[pos])
return null;
Char ch = Actor.findChar(pos);
if (ch != null) {
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
int cell = pos + n;
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
candidates.add(cell);
}
}
if (candidates.size() > 0) {
int newPos = Random.element(candidates);
Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
ch.pos = newPos;
Dungeon.level.press(newPos, ch);
} else {
return null;
}
}
Mimic m = new Mimic();
m.items = new ArrayList<>(items);
m.adjustStats(Dungeon.depth);
m.pos = pos;
m.state = m.HUNTING;
GameScene.add(m, 1);
m.sprite.turnTo(pos, Dungeon.hero.pos);
if (Dungeon.level.heroFOV[m.pos]) {
CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
Sample.INSTANCE.play(Assets.SND_MIMIC);
}
// generate an extra reward for killing the mimic
Item reward = null;
do {
switch(Random.Int(5)) {
case 0:
reward = new Gold().random();
break;
case 1:
reward = Generator.randomMissile();
break;
case 2:
reward = Generator.randomArmor();
break;
case 3:
reward = Generator.randomWeapon();
break;
case 4:
reward = Generator.random(Generator.Category.RING);
break;
}
} while (reward == null || Challenges.isItemBlocked(reward));
m.items.add(reward);
return m;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Mob method rollToDropLoot.
public void rollToDropLoot() {
if (Dungeon.hero.lvl > maxLvl + 2)
return;
float lootChance = this.lootChance;
lootChance *= RingOfWealth.dropChanceMultiplier(Dungeon.hero);
if (Random.Float() < lootChance) {
Item loot = createLoot();
if (loot != null) {
Dungeon.level.drop(loot, pos).sprite.drop();
}
}
// ring of wealth logic
if (Ring.getBonus(Dungeon.hero, RingOfWealth.Wealth.class) > 0) {
int rolls = 1;
if (properties.contains(Property.BOSS))
rolls = 15;
else if (properties.contains(Property.MINIBOSS))
rolls = 5;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
if (bonus != null) {
for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop();
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Skeleton method createLoot.
@Override
protected Item createLoot() {
Item loot;
do {
loot = Generator.randomWeapon();
// 50% chance of re-rolling tier 4 or 5 melee weapons
} while (((MeleeWeapon) loot).tier >= 4 && Random.Int(2) == 0);
loot.level(0);
return loot;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class PrisonBossLevel method createItems.
@Override
protected void createItems() {
Item item = Bones.get();
if (item != null) {
drop(item, randomRespawnCell()).type = Heap.Type.REMAINS;
}
drop(new IronKey(10), randomPrisonCell());
}
Aggregations