use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class Ring method renewBuff.
private void renewBuff() {
if (buff != null) {
Char owner = buff.target;
buff.detach();
if ((buff = buff()) != null) {
buff.attachTo(owner);
}
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class Shock method hit.
private void hit(Char ch, int damage) {
if (damage < 1) {
return;
}
affected.add(ch);
ch.damage(Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);
ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
ch.sprite.flash();
points[nPoints++] = ch.pos;
HashSet<Char> ns = new HashSet<Char>();
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
if (n != null && !affected.contains(n)) {
ns.add(n);
}
}
if (ns.size() > 0) {
hit(Random.element(ns), Random.Int(damage / 2, damage));
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfDisintegration method onZap.
@Override
protected void onZap(int cell) {
boolean terrainAffected = false;
int level = power();
int maxDistance = distance();
Ballistica.distance = Math.min(Ballistica.distance, maxDistance);
ArrayList<Char> chars = new ArrayList<Char>();
for (int i = 1; i < Ballistica.distance; i++) {
int c = Ballistica.trace[i];
Char ch;
if ((ch = Actor.findChar(c)) != null) {
chars.add(ch);
}
int terr = Dungeon.level.map[c];
if (terr == Terrain.DOOR || terr == Terrain.SIGN) {
Dungeon.level.destroy(c);
GameScene.updateMap(c);
terrainAffected = true;
} else if (terr == Terrain.HIGH_GRASS) {
Level.set(c, Terrain.GRASS);
GameScene.updateMap(c);
terrainAffected = true;
}
CellEmitter.center(c).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
}
if (terrainAffected) {
Dungeon.observe();
}
int lvl = level + chars.size();
int dmgMin = lvl;
int dmgMax = 8 + lvl * lvl / 3;
for (Char ch : chars) {
ch.damage(Random.NormalIntRange(dmgMin, dmgMax), this);
ch.sprite.centerEmitter().burst(PurpleParticle.BURST, Random.IntRange(1, 2));
ch.sprite.flash();
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class Hero method handle.
public boolean handle(int cell) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Cook(cell);
} else if (Level.fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact((NPC) ch);
} else {
curAction = new HeroAction.Attack(ch);
}
} else if (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get(cell)) != null && heap.type != Heap.Type.HIDDEN) {
switch(heap.type) {
case HEAP:
curAction = new HeroAction.PickUp(cell);
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell);
break;
default:
curAction = new HeroAction.OpenChest(cell);
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock(cell);
} else if (cell == Dungeon.level.exit) {
curAction = new HeroAction.Descend(cell);
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend(cell);
} else {
curAction = new HeroAction.Move(cell);
lastAction = null;
}
return act();
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class ConfusionGas method evolve.
@Override
protected void evolve() {
super.evolve();
Char ch;
for (int i = 0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) {
Buff.prolong(ch, Vertigo.class, Vertigo.duration(ch));
}
}
}
Aggregations