From a69ca2e15d6b4eb29c39c585aadf00000d3688c5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 29 Mar 2024 12:11:45 -0400 Subject: [PATCH] v2.4.0: added a game log warning to dimensional sundial --- .../assets/messages/items/items.properties | 1 + .../items/trinkets/DimensionalSundial.java | 19 ++++++++++++++++--- .../scenes/GameScene.java | 8 ++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 7e19ea5e5..9f492ff8b 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1310,6 +1310,7 @@ items.trinkets.ratskull.name=rat skull items.trinkets.ratskull.desc=This macabre trinket isn't much larger than the skull of a normal rat, which is somehow a rarity down in this dungeon. The skull's magical influence seems to attract the more rare denizens of the dungeon, making them appear far more often.\n\nAt its current level this trinket will make rare exotic enemies _%dx_ as likely to appear. The skull is only half as effective at attracting crystal mimics and armored statues, however. items.trinkets.dimensionalsundial.name=dimensional sundial +items.trinkets.dimensionalsundial.warning=Your sundial isn't casting a shadow, you feel uneasy. items.trinkets.dimensionalsundial.desc=Despite being underground, this sundial is still casting a shadow according to the sun's position. Even more strangely, the shadow's position seems to have no relation to the sun in this world. When no shadow is cast, the sundial seems to attract danger.\n\nAt its current level, this trinket will increase the spawning rate of enemies by _%d%%_ when it is nighttime in real life (9pm to 7am). items.trinkets.trinketcatalyst.name=trinket catalyst diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/DimensionalSundial.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/DimensionalSundial.java index ffc250dff..48cfdad34 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/DimensionalSundial.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/trinkets/DimensionalSundial.java @@ -23,10 +23,12 @@ package com.shatteredpixel.shatteredpixeldungeon.items.trinkets; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import java.util.Calendar; import java.util.GregorianCalendar; +//TODO this maybe should do something during the day too? Perhaps lightly reduce enemy spawn rates? public class DimensionalSundial extends Trinket { { @@ -43,10 +45,21 @@ public class DimensionalSundial extends Trinket { return Messages.get(this, "desc", (int)(100*(enemySpawnMultiplier(buffedLvl())-1f))); } + public static boolean sundialWarned = false; + public static float spawnMultiplierAtCurrentTime(){ - Calendar cal = GregorianCalendar.getInstance(); - if (cal.get(Calendar.HOUR_OF_DAY) >= 21 || cal.get(Calendar.HOUR_OF_DAY) <= 6 ){ - return enemySpawnMultiplier(); + float spawnMulti = enemySpawnMultiplier(); + if (spawnMulti > 1f) { + Calendar cal = GregorianCalendar.getInstance(); + if (cal.get(Calendar.HOUR_OF_DAY) >= 21 || cal.get(Calendar.HOUR_OF_DAY) <= 6) { + if (!sundialWarned){ + GLog.w(Messages.get(DimensionalSundial.class, "warning")); + sundialWarned = true; + } + return spawnMulti; + } else { + return 1f; + } } else { return 1f; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 275038a19..15dfd52df 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -58,6 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; +import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial; import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Journal; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; @@ -560,6 +561,13 @@ public class GameScene extends PixelScene { Dungeon.hero.buff(AscensionChallenge.class).saySwitch(); } + DimensionalSundial.sundialWarned = true; + if (DimensionalSundial.spawnMultiplierAtCurrentTime() > 1){ + GLog.w(Messages.get(DimensionalSundial.class, "warning")); + } else { + DimensionalSundial.sundialWarned = false; + } + InterlevelScene.mode = InterlevelScene.Mode.NONE;