From 8f756375e739655f521abd482556d52106af118d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 24 Jul 2018 18:19:43 -0400 Subject: [PATCH] v0.7.0: implemented scroll of foresight --- .../actors/buffs/Foresight.java | 48 ++++++++++++++++++ .../actors/hero/Hero.java | 15 ++++-- .../items/scrolls/exotic/ExoticScroll.java | 6 +-- .../scrolls/exotic/ScrollOfForesight.java | 50 +++++++++++++++++++ .../messages/actors/actors.properties | 3 ++ .../messages/items/items.properties | 3 ++ 6 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Foresight.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfForesight.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Foresight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Foresight.java new file mode 100644 index 000000000..51c50fdeb --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Foresight.java @@ -0,0 +1,48 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; + +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; + +public class Foresight extends FlavourBuff { + + { + type = buffType.POSITIVE; + announced = true; + } + + @Override + public int icon() { + return BuffIndicator.FORESIGHT; + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", dispTurns()); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index d237c44c7..d2d0758c0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Combo; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Foresight; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Fury; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; @@ -1520,8 +1521,10 @@ public class Hero extends Char { by = Dungeon.level.height() - 1; } - TalismanOfForesight.Foresight foresight = buff( TalismanOfForesight.Foresight.class ); - boolean cursed = foresight != null && foresight.isCursed(); + TalismanOfForesight.Foresight talisman = buff( TalismanOfForesight.Foresight.class ); + boolean cursed = talisman != null && talisman.isCursed(); + + boolean foresight = buff(Foresight.class) != null; for (int y = ay; y <= by; y++) { for (int x = ax, p = ax + y * Dungeon.level.width(); x <= bx; x++, p++) { @@ -1543,6 +1546,10 @@ public class Hero extends Char { } else if (cursed) { chance = 0f; + //..and always succeed when affected by foresight buff + } else if (foresight){ + chance = 1f; + //unintentional trap detection scales from 40% at floor 0 to 30% at floor 25 } else if (Dungeon.level.map[p] == Terrain.SECRET_TRAP) { chance = 0.4f - (Dungeon.depth / 250f); @@ -1564,8 +1571,8 @@ public class Hero extends Char { smthFound = true; - if (foresight != null && !foresight.isCursed()) - foresight.charge(); + if (talisman != null && !talisman.isCursed()) + talisman.charge(); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java index ada7d5ba8..81556092e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ExoticScroll.java @@ -75,14 +75,14 @@ public abstract class ExoticScroll extends Scroll { regToExo.put(ScrollOfRecharging.class, ScrollOfMysticalEnergy.class); exoToReg.put(ScrollOfMysticalEnergy.class, ScrollOfRecharging.class); + regToExo.put(ScrollOfMagicMapping.class, ScrollOfForesight.class); + exoToReg.put(ScrollOfForesight.class, ScrollOfMagicMapping.class); + //TODO regToExo.put(ScrollOfTeleportation.class, ScrollOfPetrification.class); exoToReg.put(ScrollOfPetrification.class, ScrollOfTeleportation.class); - regToExo.put(ScrollOfMagicMapping.class, ScrollOfPetrification.class); - exoToReg.put(ScrollOfPetrification.class, ScrollOfMagicMapping.class); - regToExo.put(ScrollOfRetribution.class, ScrollOfPsionicBlast.class); exoToReg.put(ScrollOfPsionicBlast.class, ScrollOfRetribution.class); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfForesight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfForesight.java new file mode 100644 index 000000000..23883d24d --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfForesight.java @@ -0,0 +1,50 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Foresight; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; +import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; +import com.watabou.noosa.audio.Sample; + +public class ScrollOfForesight extends ExoticScroll { + + { + initials = 2; + } + + @Override + public void doRead() { + SpellSprite.show( curUser, SpellSprite.MAP ); + Sample.INSTANCE.play( Assets.SND_READ ); + Invisibility.dispel(); + + Buff.affect(curUser, Foresight.class, 500f); + + setKnown(); + + readAnimation(); + } + +} diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties index 4713bb3cf..4ba7b5391 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties @@ -127,6 +127,9 @@ actors.buffs.earthimbue.desc=You are imbued with the power of earth!\n\nAll phys actors.buffs.fireimbue.name=Imbued with Fire actors.buffs.fireimbue.desc=You are imbued with the power of fire!\n\nAll physical attacks will have a chance to light enemies ablaze. Additionally, you are completely immune to the effects of fire.\n\nTurns of fire imbue remaining: %s. +actors.buffs.foresight.name=Foresight +actors.buffs.foresight.desc=Your senses are heightened, allowing you to immediately notice anything out of place.\n\nWhile under the effect of foresight, anything that enters your search radius is immediately discovered.\n\nTurns of foresight remaining: %s. + actors.buffs.frost.name=Frozen actors.buffs.frost.freezes=%s freezes! actors.buffs.frost.desc=Not to be confused with freezing solid, this more benign freezing simply encases the target in ice.\n\nFreezing acts similarly to paralysis, making it impossible for the target to act. Unlike paralysis, freezing is immediately cancelled if the target takes damage, as the ice will shatter.\n\nTurns of freeze remaining: %s. diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index a493ae155..a02dd700d 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -805,6 +805,9 @@ items.scrolls.exotic.scrollofenchantment.name=scroll of enchantment items.scrolls.exotic.scrollofenchantment.inv_title=enchant an item items.scrolls.exotic.scrollofenchantment.desc= +items.scrolls.exotic.scrollofforesight.name=scroll of foresight +items.scrolls.exotic.scrollofforesight.desc=When this scroll is read, detail of nearby terrain will be constantly fed to the reader's mind in crystal clarity. For the duration of this effect, searching will not be necessary, as the reader will automatically detect everything within their search radius. + items.scrolls.exotic.scrollofmysticalenergy.name=scroll of mystical energy items.scrolls.exotic.scrollofmysticalenergy.desc=