Search in sources :

Example 6 with Buff

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);
        }
    }
}
Also used : Buff(com.watabou.pixeldungeon.actors.buffs.Buff) RingOfEvasion(com.watabou.pixeldungeon.items.rings.RingOfEvasion)

Example 7 with Buff

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();
        }
    }
}
Also used : Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 8 with Buff

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;
}
Also used : Shadows(com.watabou.pixeldungeon.actors.buffs.Shadows) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Awareness(com.watabou.pixeldungeon.actors.buffs.Awareness) Blindness(com.watabou.pixeldungeon.actors.buffs.Blindness) Buff(com.watabou.pixeldungeon.actors.buffs.Buff) MindVision(com.watabou.pixeldungeon.actors.buffs.MindVision) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Buff (com.watabou.pixeldungeon.actors.buffs.Buff)8 Heap (com.watabou.pixeldungeon.items.Heap)2 Image (com.watabou.noosa.Image)1 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)1 Awareness (com.watabou.pixeldungeon.actors.buffs.Awareness)1 Blindness (com.watabou.pixeldungeon.actors.buffs.Blindness)1 MindVision (com.watabou.pixeldungeon.actors.buffs.MindVision)1 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 CheckedCell (com.watabou.pixeldungeon.effects.CheckedCell)1 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)1 RingOfAccuracy (com.watabou.pixeldungeon.items.rings.RingOfAccuracy)1 RingOfDetection (com.watabou.pixeldungeon.items.rings.RingOfDetection)1 RingOfEvasion (com.watabou.pixeldungeon.items.rings.RingOfEvasion)1 RingOfHaste (com.watabou.pixeldungeon.items.rings.RingOfHaste)1 Bundlable (com.watabou.utils.Bundlable)1 SparseArray (com.watabou.utils.SparseArray)1