v2.1.0: fixed interactions with grim and damage reducing effects
This commit is contained in:
@@ -78,6 +78,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Elemental;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Tengu;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.PrismaticImage;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
|
||||
@@ -736,6 +737,22 @@ public abstract class Char extends Actor {
|
||||
shielded -= dmg;
|
||||
HP -= dmg;
|
||||
|
||||
if (HP > 0 && buff(Grim.GrimTracker.class) != null){
|
||||
|
||||
float finalChance = buff(Grim.GrimTracker.class).maxChance;
|
||||
finalChance *= (float)Math.pow( ((HT - HP) / (float)HT), 2);
|
||||
|
||||
if (Random.Float() < finalChance) {
|
||||
dmg += HP;
|
||||
HP = 0;
|
||||
|
||||
sprite.emitter().burst( ShadowParticle.UP, 5 );
|
||||
if (!isAlive() && buff(Grim.GrimTracker.class).qualifiesForBadge){
|
||||
Badges.validateGrimWeapon();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HP < 0 && src instanceof Char && alignment == Alignment.ENEMY){
|
||||
if (((Char) src).buff(Kinetic.KineticTracker.class) != null){
|
||||
int dmgToAdd = -HP;
|
||||
|
||||
@@ -21,14 +21,13 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Grim extends Weapon.Enchantment {
|
||||
|
||||
@@ -39,27 +38,16 @@ public class Grim extends Weapon.Enchantment {
|
||||
|
||||
int level = Math.max( 0, weapon.buffedLvl() );
|
||||
|
||||
int enemyHealth = defender.HP - damage;
|
||||
if (enemyHealth <= 0) return damage; //no point in proccing if they're already dead.
|
||||
|
||||
//scales from 0 - 50% based on how low hp the enemy is, plus 5% per level
|
||||
//scales from 0 - 50% based on how low hp the enemy is, plus 0-5% per level
|
||||
float maxChance = 0.5f + .05f*level;
|
||||
float chanceMulti = (float)Math.pow( ((defender.HT - enemyHealth) / (float)defender.HT), 2);
|
||||
float chance = maxChance * chanceMulti;
|
||||
maxChance *= procChanceMultiplier(attacker);
|
||||
|
||||
chance *= procChanceMultiplier(attacker);
|
||||
//we defer logic using an actor here so we can know the true final damage
|
||||
//see Char.damage
|
||||
Buff.affect(defender, GrimTracker.class).maxChance = maxChance;
|
||||
|
||||
if (Random.Float() < chance) {
|
||||
|
||||
defender.damage( defender.HP, this );
|
||||
defender.sprite.emitter().burst( ShadowParticle.UP, 5 );
|
||||
|
||||
if (!defender.isAlive() && attacker instanceof Hero
|
||||
//this prevents unstable from triggering grim achievement
|
||||
&& weapon.hasEnchant(Grim.class, attacker)) {
|
||||
Badges.validateGrimWeapon();
|
||||
}
|
||||
|
||||
if (attacker instanceof Hero && weapon.hasEnchant(Grim.class, attacker)){
|
||||
defender.buff(GrimTracker.class).qualifiesForBadge = true;
|
||||
}
|
||||
|
||||
return damage;
|
||||
@@ -70,4 +58,20 @@ public class Grim extends Weapon.Enchantment {
|
||||
return BLACK;
|
||||
}
|
||||
|
||||
public static class GrimTracker extends Buff {
|
||||
|
||||
{
|
||||
actPriority = Actor.VFX_PRIO;
|
||||
}
|
||||
|
||||
public float maxChance;
|
||||
public boolean qualifiesForBadge;
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
detach();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user