use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class Hunger method act.
@Override
public boolean act() {
if (target.isAlive()) {
Hero hero = (Hero) target;
if (isStarving()) {
if (Random.Float() < 0.3f && (target.hp() > 1 || !target.paralysed)) {
GLog.n(TXT_STARVING[hero.getGender()]);
if (hero.getDifficulty() >= 3) {
hero.damage(Math.max(hero.effectiveSTR() - 10, 1), this);
} else {
hero.damage(1, this);
}
hero.interrupt();
}
if (hero.getDifficulty() >= 3 && !Dungeon.level.isSafe()) {
if (Random.Float() < 0.01) {
Buff.prolong(hero, Weakness.class, Weakness.duration(hero));
}
if (Random.Float() < 0.01) {
Buff.prolong(hero, Vertigo.class, Vertigo.duration(hero));
}
}
} else {
int bonus = 0;
for (Buff buff : target.buffs(RingOfSatiety.Satiety.class)) {
bonus += ((RingOfSatiety.Satiety) buff).level;
}
float delta = STEP - bonus;
if (PixelDungeon.realtime()) {
delta *= 0.3;
}
if (hero.getDifficulty() == 0) {
delta *= 0.8;
}
if (Dungeon.level.isSafe()) {
delta = 0;
}
float newLevel = level + delta;
boolean statusUpdated = false;
if (newLevel >= STARVING) {
GLog.n(TXT_STARVING[hero.getGender()]);
statusUpdated = true;
hero.interrupt();
} else if (newLevel >= HUNGRY && level < HUNGRY) {
GLog.w(TXT_HUNGRY[hero.getGender()]);
statusUpdated = true;
}
level = newLevel;
if (statusUpdated) {
BuffIndicator.refreshHero();
}
}
float step = hero.heroClass == HeroClass.ROGUE ? STEP * 1.2f : STEP;
spend(target.hasBuff(Shadows.class) ? step * 1.5f : step);
} else {
deactivate();
}
return true;
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class Level method press.
public void press(int cell, Presser actor) {
Char chr = null;
if (actor != null) {
if (actor instanceof Char) {
chr = (Char) actor;
if (pit[cell] && !chr.isFlying()) {
Chasm.charFall(chr.getPos(), chr);
return;
}
if (actor instanceof Hero) {
pressHero(cell, (Hero) chr);
}
}
if (actor instanceof LevelObject) {
if (pit[cell]) {
((LevelObject) actor).fall();
return;
}
}
if (actor instanceof Item || actor instanceof LevelObject) {
set(cell, Terrain.discover(map[cell]));
}
if (actor.affectLevelObjects()) {
LevelObject levelObject = getTopLevelObject(cell);
if (levelObject != null && levelObject != actor) {
levelObject.bump(actor);
}
}
}
switch(map[cell]) {
case Terrain.TOXIC_TRAP:
ToxicTrap.trigger(cell, chr);
break;
case Terrain.FIRE_TRAP:
FireTrap.trigger(cell, chr);
break;
case Terrain.PARALYTIC_TRAP:
ParalyticTrap.trigger(cell, chr);
break;
case Terrain.POISON_TRAP:
PoisonTrap.trigger(cell, chr);
break;
case Terrain.ALARM_TRAP:
AlarmTrap.trigger(cell, chr);
break;
case Terrain.LIGHTNING_TRAP:
LightningTrap.trigger(cell, chr);
break;
case Terrain.GRIPPING_TRAP:
GrippingTrap.trigger(cell, chr);
break;
case Terrain.SUMMONING_TRAP:
SummoningTrap.trigger(cell, chr);
break;
case Terrain.DOOR:
Door.enter(cell);
break;
}
if (!(actor instanceof Mob)) {
switch(map[cell]) {
case Terrain.HIGH_GRASS:
HighGrass.trample(this, cell, chr);
break;
case Terrain.WELL:
WellWater.affectCell(cell);
break;
case Terrain.ALCHEMY:
Alchemy.transmute(cell);
break;
}
}
if (TerrainFlags.is(map[cell], TerrainFlags.TRAP)) {
if (Dungeon.visible[cell]) {
Sample.INSTANCE.play(Assets.SND_TRAP);
}
if (actor instanceof Hero) {
((Hero) actor).interrupt();
}
set(cell, Terrain.INACTIVE_TRAP);
GameScene.updateMap(cell);
}
Plant plant = plants.get(cell);
if (plant != null) {
plant.activate(chr);
}
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class HighGrass method trample.
public static void trample(Level level, int pos, Char ch) {
level.set(pos, Terrain.GRASS);
GameScene.updateMap(pos);
if (!Dungeon.isChallenged(Challenges.NO_HERBALISM)) {
int herbalismLevel = 0;
if (ch != null) {
Herbalism herbalism = ch.buff(Herbalism.class);
if (herbalism != null) {
herbalismLevel = herbalism.level;
}
}
// Seed
if (herbalismLevel >= 0 && Random.Int(18) <= Random.Int(herbalismLevel + 1)) {
ItemSprite is = level.drop(Generator.random(Generator.Category.SEED), pos).sprite;
if (is != null) {
is.drop();
}
}
// Dew
if (herbalismLevel >= 0 && Random.Int(6) <= Random.Int(herbalismLevel + 1)) {
ItemSprite is = level.drop(new Dewdrop(), pos).sprite;
if (is != null) {
is.drop();
}
}
}
int leaves = 4;
// Barkskin
if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN) {
Buff.affect(ch, Barkskin.class).level(ch.ht() / 3);
leaves = 8;
}
if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.SCOUT) {
Buff.prolong(ch, Invisibility.class, 5);
leaves = 2;
}
Emitter emitter = CellEmitter.get(pos);
if (emitter != null) {
emitter.burst(LeafParticle.LEVEL_SPECIFIC, leaves);
}
Dungeon.observe();
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class MissileWeapon method proc.
@Override
public void proc(Char attacker, Char defender, int damage) {
super.proc(attacker, defender, damage);
if (this instanceof Arrow) {
Arrow arrow = (Arrow) this;
if (arrow.firedFrom != null && arrow.firedFrom.isEnchanted()) {
arrow.firedFrom.getEnchantment().proc(arrow.firedFrom, attacker, defender, damage);
}
}
Hero hero = (Hero) attacker;
if (hero.rangedWeapon == null && stackable) {
if (this != hero.belongings.weapon) {
if (quantity() == 1) {
doUnequip(hero, false, false);
} else {
detach(null);
}
}
}
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class Multiplicity method proc.
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max(0, armor.level());
if (Random.Int(level / 2 + 6) >= 5) {
int imgCell = Dungeon.level.getEmptyCellNextTo(defender.getPos());
if (Dungeon.level.cellValid(imgCell)) {
if (defender instanceof Hero) {
MirrorImage img = new MirrorImage((Hero) defender);
Dungeon.level.spawnMob(img);
WandOfBlink.appear(img, imgCell);
}
if (defender instanceof Mob) {
((Mob) defender).split(imgCell, damage);
}
defender.damage(Random.IntRange(1, defender.ht() / 6), /*attacker*/
this);
checkOwner(defender);
}
}
return damage;
}
Aggregations