use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Chasm method heroLand.
public static void heroLand() {
Hero hero = Dungeon.hero;
hero.sprite.burst(hero.sprite.blood(), 10);
Camera.main.shake(4, 0.2f);
Dungeon.level.press(hero.pos, hero, true);
Buff.prolong(hero, Cripple.class, Cripple.DURATION);
// The lower the hero's HP, the more bleed and the less upfront damage.
// Hero has a 50% chance to bleed out at 66% HP, and begins to risk instant-death at 25%
Buff.affect(hero, Bleeding.class).set(Math.round(hero.HT / (6f + (6f * (hero.HP / (float) hero.HT)))));
hero.damage(Math.max(hero.HP / 2, Random.NormalIntRange(hero.HP / 2, hero.HT / 4)), new Hero.Doom() {
@Override
public void onDeath() {
Badges.validateDeathFromFalling();
Dungeon.fail(Chasm.class);
GLog.n(Messages.get(Chasm.class, "ondeath"));
}
});
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class HighGrass method trample.
public static void trample(Level level, int pos, Char ch) {
Level.set(pos, Terrain.GRASS);
GameScene.updateMap(pos);
int naturalismLevel = 0;
if (ch != null) {
SandalsOfNature.Naturalism naturalism = ch.buff(SandalsOfNature.Naturalism.class);
if (naturalism != null) {
if (!naturalism.isCursed()) {
naturalismLevel = naturalism.itemLevel() + 1;
naturalism.charge();
} else {
naturalismLevel = -1;
}
}
}
if (naturalismLevel >= 0) {
// Seed, scales from 1/16 to 1/4
if (Random.Int(16 - ((int) (naturalismLevel * 3))) == 0) {
Item seed = Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(3) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
level.drop(seed, pos).sprite.drop();
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
}
} else
level.drop(seed, pos).sprite.drop();
}
// Dew, scales from 1/6 to 1/3
if (Random.Int(24 - naturalismLevel * 3) <= 3) {
level.drop(new Dewdrop(), pos).sprite.drop();
}
}
int leaves = 4;
if (ch instanceof Hero) {
Hero hero = (Hero) ch;
// Barkskin
if (hero.subClass == HeroSubClass.WARDEN) {
Buff.affect(ch, Barkskin.class).level(ch.HT / 3);
leaves += 4;
}
// Camouflage
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class)) {
Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level());
leaves += 4;
}
}
CellEmitter.get(pos).burst(LeafParticle.LEVEL_SPECIFIC, leaves);
if (Dungeon.level.heroFOV[pos])
Dungeon.observe();
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Multiplicity method proc.
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if (Random.Int(20) == 0) {
ArrayList<Integer> spawnPoints = new ArrayList<>();
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = defender.pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
spawnPoints.add(p);
}
}
if (spawnPoints.size() > 0) {
Mob m = null;
if (Random.Int(2) == 0 && defender instanceof Hero) {
m = new MirrorImage();
((MirrorImage) m).duplicate((Hero) defender);
} else {
// FIXME should probably have a mob property for this
if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS) || attacker instanceof Mimic || attacker instanceof Statue) {
m = Dungeon.level.createMob();
} else {
try {
Actor.fixTime();
m = (Mob) attacker.getClass().newInstance();
Bundle store = new Bundle();
attacker.storeInBundle(store);
m.restoreFromBundle(store);
m.HP = m.HT;
// If a thief has stolen an item, that item is not duplicated.
if (m instanceof Thief) {
((Thief) m).item = null;
}
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
m = null;
}
}
}
if (m != null) {
GameScene.add(m);
ScrollOfTeleportation.appear(m, Random.element(spawnPoints));
}
}
}
return damage;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WndTradeItem method sell.
private void sell(Item item) {
Hero hero = Dungeon.hero;
if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
return;
}
item.detachAll(hero.belongings.backpack);
new Gold(item.price()).doPickUp(hero);
// selling items in the sell interface doesn't spend time
hero.spend(-hero.cooldown());
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class DisarmingTrap method activate.
@Override
public void activate() {
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int cell = Dungeon.level.randomRespawnCell();
if (cell != -1) {
Item item = heap.pickUp();
Dungeon.level.drop(item, cell).seen = true;
for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
GameScene.updateFog();
Sample.INSTANCE.play(Assets.SND_TELEPORT);
CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
}
}
if (Dungeon.hero.pos == pos) {
Hero hero = Dungeon.hero;
KindOfWeapon weapon = hero.belongings.weapon;
if (weapon != null && !(weapon instanceof Knuckles) && !weapon.cursed) {
int cell = Dungeon.level.randomRespawnCell();
if (cell != -1) {
hero.belongings.weapon = null;
Dungeon.quickslot.clearItem(weapon);
weapon.updateQuickslot();
Dungeon.level.drop(weapon, cell).seen = true;
for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
GameScene.updateFog();
GLog.w(Messages.get(this, "disarm"));
Sample.INSTANCE.play(Assets.SND_TELEPORT);
CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
}
}
}
}
Aggregations