use of com.watabou.pixeldungeon.actors.buffs.Buff in project pixel-dungeon by watabou.
the class Hero method defenseSkill.
@Override
public int defenseSkill(Char enemy) {
int bonus = 0;
for (Buff buff : buffs(RingOfEvasion.Evasion.class)) {
bonus += ((RingOfEvasion.Evasion) buff).level;
}
float evasion = bonus == 0 ? 1 : (float) Math.pow(1.2, bonus);
if (paralysed) {
evasion /= 2;
}
int aEnc = belongings.armor != null ? belongings.armor.STR - STR() : 0;
if (aEnc > 0) {
return (int) (defenseSkill * evasion / Math.pow(1.5, aEnc));
} else {
if (heroClass == HeroClass.ROGUE) {
if (curAction != null && subClass == HeroSubClass.FREERUNNER && !isStarving()) {
evasion *= 2;
}
return (int) ((defenseSkill - aEnc) * evasion);
} else {
return (int) (defenseSkill * evasion);
}
}
}
use of com.watabou.pixeldungeon.actors.buffs.Buff in project pixel-dungeon by watabou.
the class Actor method add.
private static void add(Actor actor, float time) {
if (all.contains(actor)) {
return;
}
if (actor.id > 0) {
ids.put(actor.id, actor);
}
all.add(actor);
actor.time += time;
actor.onAdd();
if (actor instanceof Char) {
Char ch = (Char) actor;
chars[ch.pos] = ch;
for (Buff buff : ch.buffs()) {
all.add(buff);
buff.onAdd();
}
}
}
use of com.watabou.pixeldungeon.actors.buffs.Buff in project pixel-dungeon by watabou.
the class Level method updateFieldOfView.
public boolean[] updateFieldOfView(Char c) {
int cx = c.pos % WIDTH;
int cy = c.pos / WIDTH;
boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.isAlive();
if (sighted) {
ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
} else {
Arrays.fill(fieldOfView, false);
}
int sense = 1;
if (c.isAlive()) {
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) {
Arrays.fill(fieldOfView, pos, pos + len, true);
}
for (int i = 0; i < LENGTH; i++) {
fieldOfView[i] &= discoverable[i];
}
}
if (c.isAlive()) {
if (c.buff(MindVision.class) != null) {
for (Mob mob : mobs) {
int p = mob.pos;
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
} else if (c == Dungeon.hero && ((Hero) c).heroClass == HeroClass.HUNTRESS) {
for (Mob mob : mobs) {
int p = mob.pos;
if (distance(c.pos, p) == 2) {
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
}
}
if (c.buff(Awareness.class) != null) {
for (Heap heap : heaps.values()) {
int p = heap.pos;
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
}
}
return fieldOfView;
}
Aggregations