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