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.Tengu;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.PrismaticImage;
|
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.Heap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
|
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
|
||||||
@@ -736,6 +737,22 @@ public abstract class Char extends Actor {
|
|||||||
shielded -= dmg;
|
shielded -= dmg;
|
||||||
HP -= 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 (HP < 0 && src instanceof Char && alignment == Alignment.ENEMY){
|
||||||
if (((Char) src).buff(Kinetic.KineticTracker.class) != null){
|
if (((Char) src).buff(Kinetic.KineticTracker.class) != null){
|
||||||
int dmgToAdd = -HP;
|
int dmgToAdd = -HP;
|
||||||
|
|||||||
+25
-21
@@ -21,14 +21,13 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
|
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.Char;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
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.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
|
||||||
import com.watabou.utils.Random;
|
|
||||||
|
|
||||||
public class Grim extends Weapon.Enchantment {
|
public class Grim extends Weapon.Enchantment {
|
||||||
|
|
||||||
@@ -39,27 +38,16 @@ public class Grim extends Weapon.Enchantment {
|
|||||||
|
|
||||||
int level = Math.max( 0, weapon.buffedLvl() );
|
int level = Math.max( 0, weapon.buffedLvl() );
|
||||||
|
|
||||||
int enemyHealth = defender.HP - damage;
|
//scales from 0 - 50% based on how low hp the enemy is, plus 0-5% per level
|
||||||
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
|
|
||||||
float maxChance = 0.5f + .05f*level;
|
float maxChance = 0.5f + .05f*level;
|
||||||
float chanceMulti = (float)Math.pow( ((defender.HT - enemyHealth) / (float)defender.HT), 2);
|
maxChance *= procChanceMultiplier(attacker);
|
||||||
float chance = maxChance * chanceMulti;
|
|
||||||
|
|
||||||
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) {
|
if (attacker instanceof Hero && weapon.hasEnchant(Grim.class, attacker)){
|
||||||
|
defender.buff(GrimTracker.class).qualifiesForBadge = true;
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
return damage;
|
||||||
@@ -70,4 +58,20 @@ public class Grim extends Weapon.Enchantment {
|
|||||||
return BLACK;
|
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