v1.3.0: improved logic for 'on death' badges and bleeding
This commit is contained in:
@@ -21,8 +21,11 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Sacrificial;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
@@ -40,27 +43,39 @@ public class Bleeding extends Buff {
|
||||
|
||||
protected float level;
|
||||
|
||||
//used in specific cases where the source of the bleed is important for death logic
|
||||
private Class source;
|
||||
|
||||
public float level(){
|
||||
return level;
|
||||
}
|
||||
|
||||
private static final String LEVEL = "level";
|
||||
private static final String SOURCE = "source";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( LEVEL, level );
|
||||
|
||||
bundle.put( SOURCE, source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
level = bundle.getFloat( LEVEL );
|
||||
source = bundle.getClass( SOURCE );
|
||||
}
|
||||
|
||||
public void set( float level ) {
|
||||
this.level = Math.max(this.level, level);
|
||||
set( level, null );
|
||||
}
|
||||
|
||||
public void set( float level, Class source ){
|
||||
if (this.level < level) {
|
||||
this.level = Math.max(this.level, level);
|
||||
this.source = source;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +109,11 @@ public class Bleeding extends Buff {
|
||||
}
|
||||
|
||||
if (target == Dungeon.hero && !target.isAlive()) {
|
||||
if (source == Chasm.class){
|
||||
Badges.validateDeathFromFalling();
|
||||
} else if (source == Sacrificial.class){
|
||||
Badges.validateDeathFromFriendlyMagic();
|
||||
}
|
||||
Dungeon.fail( getClass() );
|
||||
GLog.n( Messages.get(this, "ondeath") );
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Sacrificial extends Weapon.Enchantment {
|
||||
|
||||
float procChance = 1/12f * procChanceMultiplier(attacker);
|
||||
if (Random.Float() < procChance) {
|
||||
Buff.affect(attacker, Bleeding.class).set(Math.max(1, attacker.HP/6));
|
||||
Buff.affect(attacker, Bleeding.class).set(Math.max(1, attacker.HP/6), getClass());
|
||||
}
|
||||
|
||||
return damage;
|
||||
|
||||
@@ -149,7 +149,7 @@ public class Chasm implements Hero.Doom {
|
||||
|
||||
//The lower the hero's HP, the more bleed and the less upfront damage.
|
||||
//Hero has a 50% chance to bleed out at 66% HP, and begins to risk instant-death at 25%
|
||||
Buff.affect( hero, FallBleed.class).set( Math.round(hero.HT / (6f + (6f*(hero.HP/(float)hero.HT)))));
|
||||
Buff.affect( hero, Bleeding.class).set( Math.round(hero.HT / (6f + (6f*(hero.HP/(float)hero.HT)))), Chasm.class);
|
||||
hero.damage( Math.max( hero.HP / 2, Random.NormalIntRange( hero.HP / 2, hero.HT / 4 )), new Chasm() );
|
||||
}
|
||||
|
||||
@@ -172,9 +172,10 @@ public class Chasm implements Hero.Doom {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//pre-1.3.0
|
||||
public static class FallBleed extends Bleeding implements Hero.Doom {
|
||||
|
||||
|
||||
@Override
|
||||
public void onDeath() {
|
||||
Badges.validateDeathFromFalling();
|
||||
|
||||
Reference in New Issue
Block a user