v3.0.1: code changes to waterskin so it smartly handles blood vial fx
This commit is contained in:
@@ -81,27 +81,37 @@ public class Dewdrop extends Item {
|
||||
|
||||
public static boolean consumeDew(int quantity, Hero hero, boolean force){
|
||||
//20 drops for a full heal
|
||||
int heal = Math.round( hero.HT * 0.05f * quantity );
|
||||
int effect = Math.round( hero.HT * 0.05f * quantity );
|
||||
|
||||
int heal = Math.min( hero.HT - hero.HP, effect );
|
||||
|
||||
int effect = Math.min( hero.HT - hero.HP, heal );
|
||||
int shield = 0;
|
||||
if (hero.hasTalent(Talent.SHIELDING_DEW)){
|
||||
shield = heal - effect;
|
||||
|
||||
//When vial is present, this allocates exactly as much of the effect as is needed
|
||||
// to get to 100% HP, and the rest is then given as shielding (without the vial boost)
|
||||
if (quantity > 1 && heal < effect && VialOfBlood.delayBurstHealing()){
|
||||
heal = Math.round(heal/VialOfBlood.totalHealMultiplier());
|
||||
}
|
||||
|
||||
shield = effect - heal;
|
||||
|
||||
int maxShield = Math.round(hero.HT *0.2f*hero.pointsInTalent(Talent.SHIELDING_DEW));
|
||||
int curShield = 0;
|
||||
if (hero.buff(Barrier.class) != null) curShield = hero.buff(Barrier.class).shielding();
|
||||
shield = Math.min(shield, maxShield-curShield);
|
||||
}
|
||||
if (effect > 0 || shield > 0) {
|
||||
|
||||
if (effect > 0 && quantity > 1 && VialOfBlood.delayBurstHealing()){
|
||||
if (heal > 0 || shield > 0) {
|
||||
|
||||
if (heal > 0 && quantity > 1 && VialOfBlood.delayBurstHealing()){
|
||||
Healing healing = Buff.affect(hero, Healing.class);
|
||||
healing.setHeal(effect, 0, VialOfBlood.maxHealPerTurn());
|
||||
healing.setHeal(heal, 0, VialOfBlood.maxHealPerTurn());
|
||||
healing.applyVialEffect();
|
||||
} else {
|
||||
hero.HP += effect;
|
||||
if (effect > 0){
|
||||
hero.sprite.showStatusWithIcon( CharSprite.POSITIVE, Integer.toString(effect), FloatingText.HEALING);
|
||||
hero.HP += heal;
|
||||
if (heal > 0){
|
||||
hero.sprite.showStatusWithIcon( CharSprite.POSITIVE, Integer.toString(heal), FloatingText.HEALING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barrier;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.VialOfBlood;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
@@ -53,7 +54,7 @@ public class Waterskin extends Item {
|
||||
unique = true;
|
||||
}
|
||||
|
||||
private int volume = 0;
|
||||
private int volume = 20;
|
||||
|
||||
private static final String VOLUME = "volume";
|
||||
|
||||
@@ -89,6 +90,15 @@ public class Waterskin extends Item {
|
||||
|
||||
float missingHealthPercent = 1f - (hero.HP / (float)hero.HT);
|
||||
|
||||
//each drop is worth 5% of total health
|
||||
float dropsNeeded = missingHealthPercent / 0.05f;
|
||||
|
||||
//we are getting extra heal value, scale back drops needed accordingly
|
||||
if (dropsNeeded > 1.01f && VialOfBlood.delayBurstHealing()){
|
||||
dropsNeeded /= VialOfBlood.totalHealMultiplier();
|
||||
}
|
||||
|
||||
//add extra drops if we can gain shielding
|
||||
int curShield = 0;
|
||||
if (hero.buff(Barrier.class) != null) curShield = hero.buff(Barrier.class).shielding();
|
||||
int maxShield = Math.round(hero.HT *0.2f*hero.pointsInTalent(Talent.SHIELDING_DEW));
|
||||
@@ -96,17 +106,17 @@ public class Waterskin extends Item {
|
||||
float missingShieldPercent = 1f - (curShield / (float)maxShield);
|
||||
missingShieldPercent *= 0.2f*hero.pointsInTalent(Talent.SHIELDING_DEW);
|
||||
if (missingShieldPercent > 0){
|
||||
missingHealthPercent += missingShieldPercent;
|
||||
dropsNeeded += missingShieldPercent / 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
//trimming off 0.01 drops helps with floating point errors
|
||||
int dropsNeeded = (int)Math.ceil((missingHealthPercent / 0.05f) - 0.01f);
|
||||
dropsNeeded = (int)GameMath.gate(1, dropsNeeded, volume);
|
||||
|
||||
if (Dewdrop.consumeDew(dropsNeeded, hero, true)){
|
||||
volume -= dropsNeeded;
|
||||
Catalog.countUses(Dewdrop.class, dropsNeeded);
|
||||
//trimming off 0.01 drops helps with floating point errors
|
||||
int dropsToConsume = (int)Math.ceil(dropsNeeded - 0.01f);
|
||||
dropsToConsume = (int)GameMath.gate(1, dropsToConsume, volume);
|
||||
|
||||
if (Dewdrop.consumeDew(dropsToConsume, hero, true)){
|
||||
volume -= dropsToConsume;
|
||||
Catalog.countUses(Dewdrop.class, dropsToConsume);
|
||||
|
||||
hero.spend(TIME_TO_DRINK);
|
||||
hero.busy();
|
||||
|
||||
Reference in New Issue
Block a user