diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/ChaoticCenser.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/ChaoticCenser.java index f4be42e19..05df6ac68 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/ChaoticCenser.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/ChaoticCenser.java @@ -106,16 +106,16 @@ public class ChaoticCenser extends Trinket { float triggerChance = 0; if (left > 0 && left <= 30) { - if (TargetHealthIndicator.instance != null + if (TargetHealthIndicator.instance != null && TargetHealthIndicator.instance.isVisible() && TargetHealthIndicator.instance.target() != null && TargetHealthIndicator.instance.target().alignment == Char.Alignment.ENEMY && TargetHealthIndicator.instance.target().isAlive()) { - triggerChance = 0.5f; + triggerChance = 0.75f; } } else if (left > -30 && left <= 0) { - if (TargetHealthIndicator.instance != null + if (TargetHealthIndicator.instance != null && TargetHealthIndicator.instance.isVisible() && TargetHealthIndicator.instance.target() != null && TargetHealthIndicator.instance.target().alignment == Char.Alignment.ENEMY && TargetHealthIndicator.instance.target().isAlive()) { @@ -124,7 +124,7 @@ public class ChaoticCenser extends Trinket { triggerChance = 0.2f; } - } else if (left <= -avgTurns/5) { + } else if (left <= -30) { triggerChance = 1f; } @@ -223,37 +223,60 @@ public class ChaoticCenser extends Trinket { } Char target = null; - if (TargetHealthIndicator.instance != null && TargetHealthIndicator.instance.target() != null + if (TargetHealthIndicator.instance != null && TargetHealthIndicator.instance.isVisible() + && TargetHealthIndicator.instance.target() != null && TargetHealthIndicator.instance.target().alignment == Char.Alignment.ENEMY && TargetHealthIndicator.instance.target().isAlive()) { target = TargetHealthIndicator.instance.target(); } HashMap candidateCells = new HashMap<>(); - PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.not(Dungeon.level.solid, null), 3); + PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.not(Dungeon.level.solid, null), 5); - //spawn gas in a random cell 1-3 tiles away, likelihood is 2>3>1 + //spawn gas in a random visible cell 2-5 tiles away, likelihood is 3,4 > 2,5 for (int i = 0; i < Dungeon.level.length(); i++){ - switch (PathFinder.distance[i]){ - case 0: default: break; //do nothing - case 1: candidateCells.put(i, 1f); break; - case 2: candidateCells.put(i, 3f); break; - case 3: candidateCells.put(i, 2f); break; + if (Dungeon.level.heroFOV[i] && PathFinder.distance[i] < Integer.MAX_VALUE) { + switch (PathFinder.distance[i]) { + case 3: + case 4: + candidateCells.put(i, 2f); + break; + case 2: + case 5: + candidateCells.put(i, 1f); + break; + } } } //unless we have a target, then strongly prefer cells closer to target if (target != null){ - float furthest = 0; + int targetpos = target.pos; + if (Dungeon.level.trueDistance(target.pos, Dungeon.hero.pos) >= 4){ + //if target is a distance from the hero, aim in front of them instead + for (int i : PathFinder.NEIGHBOURS8){ + while (!Dungeon.level.solid[targetpos+i] + && Dungeon.level.trueDistance(target.pos+i, Dungeon.hero.pos) < Dungeon.level.trueDistance(targetpos, Dungeon.hero.pos)){ + targetpos = target.pos+i; + } + } + } + float closest = 100; for (int cell : candidateCells.keySet()){ - float dist = Dungeon.level.trueDistance(cell, target.pos); - if (dist > furthest){ - furthest = dist; + float dist = Dungeon.level.distance(cell, targetpos); + if (dist < closest){ + closest = dist; } } for (int cell : candidateCells.keySet()){ - float dist = Dungeon.level.trueDistance(cell, target.pos); - candidateCells.put(cell, furthest - dist); + float dist = Dungeon.level.distance(cell, targetpos); + if (dist - closest == 0) { + candidateCells.put(cell, 4f); + } else if (dist - closest <= 1) { + candidateCells.put(cell, 1f); + } else { + candidateCells.put(cell, 0f); + } } } @@ -280,23 +303,23 @@ public class ChaoticCenser extends Trinket { private static final HashMap, Float> COMMON_GASSES = new HashMap<>(); static { - COMMON_GASSES.put(ToxicGas.class, 500f); - COMMON_GASSES.put(ConfusionGas.class, 500f); - COMMON_GASSES.put(Regrowth.class, 250f); + COMMON_GASSES.put(ToxicGas.class, 300f); + COMMON_GASSES.put(ConfusionGas.class, 300f); + COMMON_GASSES.put(Regrowth.class, 200f); } private static final HashMap, Float> UNCOMMON_GASSES = new HashMap<>(); static { - UNCOMMON_GASSES.put(StormCloud.class, 500f); - UNCOMMON_GASSES.put(SmokeScreen.class, 500f); - UNCOMMON_GASSES.put(StenchGas.class, 250f); + UNCOMMON_GASSES.put(StormCloud.class, 300f); + UNCOMMON_GASSES.put(SmokeScreen.class, 300f); + UNCOMMON_GASSES.put(StenchGas.class, 200f); } private static final HashMap, Float> RARE_GASSES = new HashMap<>(); static { - RARE_GASSES.put(Inferno.class, 500f); - RARE_GASSES.put(Blizzard.class, 500f); - RARE_GASSES.put(CorrosiveGas.class, 250f); + RARE_GASSES.put(Inferno.class, 300f); + RARE_GASSES.put(Blizzard.class, 300f); + RARE_GASSES.put(CorrosiveGas.class, 200f); } private static final HashMap, Integer> MISSILE_VFX = new HashMap<>();