use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfCorruption method debuffEnemy.
private void debuffEnemy(Mob enemy, HashMap<Class<? extends Buff>, Float> category) {
// do not consider buffs which are already assigned, or that the enemy is immune to.
HashMap<Class<? extends Buff>, Float> debuffs = new HashMap<>(category);
for (Buff existing : enemy.buffs()) {
if (debuffs.containsKey(existing.getClass())) {
debuffs.put(existing.getClass(), 0f);
}
}
for (Class<? extends Buff> toAssign : debuffs.keySet()) {
if (debuffs.get(toAssign) > 0 && enemy.isImmune(toAssign)) {
debuffs.put(toAssign, 0f);
}
}
// all buffs with a > 0 chance are flavor buffs
Class<? extends FlavourBuff> debuffCls = (Class<? extends FlavourBuff>) Random.chances(debuffs);
if (debuffCls != null) {
Buff.append(enemy, debuffCls, 6 + level() * 3);
} else {
// if no debuff can be applied (all are present), then go up one tier
if (category == MINOR_DEBUFFS)
debuffEnemy(enemy, MAJOR_DEBUFFS);
else if (category == MAJOR_DEBUFFS)
corruptEnemy(enemy);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfCorruption method corruptEnemy.
private void corruptEnemy(Mob enemy) {
// cannot re-corrupt or doom an enemy, so give them a major debuff instead
if (enemy.buff(Corruption.class) != null || enemy.buff(Doom.class) != null) {
GLog.w(Messages.get(this, "already_corrupted"));
return;
}
if (!enemy.isImmune(Corruption.class)) {
enemy.HP = enemy.HT;
for (Buff buff : enemy.buffs()) {
if (buff.type == Buff.buffType.NEGATIVE && !(buff instanceof SoulMark)) {
buff.detach();
} else if (buff instanceof PinCushion) {
buff.detach();
}
}
Buff.affect(enemy, Corruption.class);
Statistics.enemiesSlain++;
Badges.validateMonstersSlain();
Statistics.qualifiedForNoKilling = false;
if (enemy.EXP > 0 && curUser.lvl <= enemy.maxLvl) {
curUser.sprite.showStatus(CharSprite.POSITIVE, Messages.get(enemy, "exp", enemy.EXP));
curUser.earnExp(enemy.EXP);
}
enemy.rollToDropLoot();
} else {
Buff.affect(enemy, Doom.class);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method actAscend.
private boolean actAscend(HeroAction.Ascend action) {
int stairs = action.dst;
if (pos == stairs && pos == Dungeon.level.entrance) {
if (Dungeon.depth == 1) {
if (belongings.getItem(Amulet.class) == null) {
GameScene.show(new WndMessage(Messages.get(this, "leave")));
ready();
} else {
Dungeon.win(Amulet.class);
Dungeon.deleteGame(GamesInProgress.curSlot, true);
Game.switchScene(SurfaceScene.class);
}
} else {
curAction = null;
Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
if (buff != null)
buff.detach();
InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
Game.switchScene(InterlevelScene.class);
}
return false;
} else if (getCloser(stairs)) {
return true;
} else {
ready();
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method updateFieldOfView.
public void updateFieldOfView(Char c, boolean[] fieldOfView) {
int cx = c.pos % width();
int cy = c.pos / width();
boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.buff(TimekeepersHourglass.timeStasis.class) == null && c.isAlive();
if (sighted) {
ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
} else {
BArray.setFalse(fieldOfView);
}
int sense = 1;
// Currently only the hero can get mind vision
if (c.isAlive() && c == Dungeon.hero) {
for (Buff b : c.buffs(MindVision.class)) {
sense = Math.max(((MindVision) b).distance, sense);
}
}
if ((sighted && sense > 1) || !sighted) {
int ax = Math.max(0, cx - sense);
int bx = Math.min(cx + sense, width() - 1);
int ay = Math.max(0, cy - sense);
int by = Math.min(cy + sense, height() - 1);
int len = bx - ax + 1;
int pos = ax + ay * width();
for (int y = ay; y <= by; y++, pos += width()) {
System.arraycopy(discoverable, pos, fieldOfView, pos, len);
}
}
// Currently only the hero can get mind vision or awareness
if (c.isAlive() && c == Dungeon.hero) {
Dungeon.hero.mindVisionEnemies.clear();
if (c.buff(MindVision.class) != null) {
for (Mob mob : mobs) {
int p = mob.pos;
if (!fieldOfView[p]) {
Dungeon.hero.mindVisionEnemies.add(mob);
}
}
} else if (((Hero) c).heroClass == HeroClass.HUNTRESS) {
for (Mob mob : mobs) {
int p = mob.pos;
if (distance(c.pos, p) == 2) {
if (!fieldOfView[p]) {
Dungeon.hero.mindVisionEnemies.add(mob);
}
}
}
}
for (Mob m : Dungeon.hero.mindVisionEnemies) {
for (int i : PathFinder.NEIGHBOURS9) {
fieldOfView[m.pos + i] = true;
}
}
if (c.buff(Awareness.class) != null) {
for (Heap heap : heaps.values()) {
int p = heap.pos;
for (int i : PathFinder.NEIGHBOURS9) fieldOfView[p + i] = true;
}
}
}
if (c == Dungeon.hero) {
for (Heap heap : heaps.values()) if (!heap.seen && fieldOfView[heap.pos])
heap.seen = true;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Actor method add.
private static synchronized void add(Actor actor, float time) {
if (all.contains(actor)) {
return;
}
ids.put(actor.id(), actor);
all.add(actor);
actor.time += time;
actor.onAdd();
if (actor instanceof Char) {
Char ch = (Char) actor;
chars.add(ch);
for (Buff buff : ch.buffs()) {
all.add(buff);
buff.onAdd();
}
}
}
Aggregations