From 896090ac0d87f2ac912207efa5b3ec0be4800243 Mon Sep 17 00:00:00 2001 From: Mikhael Danilov Date: Mon, 23 Dec 2024 21:42:18 +0300 Subject: [PATCH] Update status effect display methods and improve level regeneration logic --- .../src/main/assets/scripts/buffs/Counter.lua | 2 +- .../assets/scripts/items/ArmorTemplate.lua | 2 +- .../assets/scripts/items/test/TestItem.lua | 2 +- .../src/main/assets/scripts/npc/BlackCat.lua | 2 +- .../main/assets/scripts/spells/Backstab.lua | 2 +- .../com/watabou/pixeldungeon/actors/Char.java | 3 +-- .../pixeldungeon/actors/hero/Hero.java | 2 +- .../watabou/pixeldungeon/items/DewVial.java | 2 +- .../watabou/pixeldungeon/items/Dewdrop.java | 2 +- .../com/watabou/pixeldungeon/items/Gold.java | 2 +- .../items/armor/glyphs/Viscosity.java | 2 +- .../pixeldungeon/scenes/GameScene.java | 24 +++++++++++++++---- 12 files changed, 30 insertions(+), 17 deletions(-) diff --git a/RemixedDungeon/src/main/assets/scripts/buffs/Counter.lua b/RemixedDungeon/src/main/assets/scripts/buffs/Counter.lua index f4e39483c6..c62b994d1f 100644 --- a/RemixedDungeon/src/main/assets/scripts/buffs/Counter.lua +++ b/RemixedDungeon/src/main/assets/scripts/buffs/Counter.lua @@ -33,6 +33,6 @@ return buff.init{ RPD.debug("counter: %d", self.data.counter) storage.gamePut("CounterBuffTest", self.data.counter) storage.put("CounterBuffTest", self.data.counter) - buff.target:getSprite():showStatus( 0xFF00FF, tostring(self.data.counter)) + buff.target:showStatus( 0xFF00FF, tostring(self.data.counter)) end } \ No newline at end of file diff --git a/RemixedDungeon/src/main/assets/scripts/items/ArmorTemplate.lua b/RemixedDungeon/src/main/assets/scripts/items/ArmorTemplate.lua index b733ec0bee..96ac3ef8e6 100644 --- a/RemixedDungeon/src/main/assets/scripts/items/ArmorTemplate.lua +++ b/RemixedDungeon/src/main/assets/scripts/items/ArmorTemplate.lua @@ -37,7 +37,7 @@ return item.init{ end, defenceProc = function(self, item, attacker, defender, damage) - defender:getSprite():showStatus(0x00b77070,"ouch!") + defender:showStatus(0x00b77070,"ouch!") return damage end, } diff --git a/RemixedDungeon/src/main/assets/scripts/items/test/TestItem.lua b/RemixedDungeon/src/main/assets/scripts/items/test/TestItem.lua index ede64d3161..eaf3dca759 100644 --- a/RemixedDungeon/src/main/assets/scripts/items/test/TestItem.lua +++ b/RemixedDungeon/src/main/assets/scripts/items/test/TestItem.lua @@ -241,7 +241,7 @@ return itemLib.init{ self.data.counter = (self.data.counter or 0) + 1 if item:getOwner():valid() then - item:getOwner():getSprite():showStatus( 0xFF00FF, tostring(self.data.counter)) + item:getOwner():showStatus( 0xFF00FF, tostring(self.data.counter)) end item:spend(1) diff --git a/RemixedDungeon/src/main/assets/scripts/npc/BlackCat.lua b/RemixedDungeon/src/main/assets/scripts/npc/BlackCat.lua index b5ea7b89dc..2631630119 100644 --- a/RemixedDungeon/src/main/assets/scripts/npc/BlackCat.lua +++ b/RemixedDungeon/src/main/assets/scripts/npc/BlackCat.lua @@ -19,7 +19,7 @@ return mob.init({ local hero = RPD.Dungeon.hero hero:STR(math.max(hero:STR()-1,1)) hero:getSprite():emitter():burst( RPD.Sfx.ShadowParticle.CURSE, 6 ) - hero:getSprite():showStatus( 0xFF0000, RPD.textById("Str_lose")) + hero:showStatus( 0xFF0000, RPD.textById("Str_lose")) RPD.playSound( "snd_cursed" ) end, diff --git a/RemixedDungeon/src/main/assets/scripts/spells/Backstab.lua b/RemixedDungeon/src/main/assets/scripts/spells/Backstab.lua index e2beb24590..59a0a3c4ca 100644 --- a/RemixedDungeon/src/main/assets/scripts/spells/Backstab.lua +++ b/RemixedDungeon/src/main/assets/scripts/spells/Backstab.lua @@ -46,7 +46,7 @@ return spell.init{ return false end - victim:getSprite():showStatus(0xff2030,"backstab") + victim:showStatus(0xff2030,"backstab") local weapon = caster:getBelongings().weapon local secondaryWeapon = caster:getBelongings().leftHand diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/Char.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/Char.java index 714153f525..943cd4e36e 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/Char.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/Char.java @@ -397,8 +397,7 @@ public void showStatus(int color, String text) { getSprite().showStatus(color, text); } - @LuaInterface - public void showStatus(int color, String text, Object... args) { + public void showStatus_a(int color, String text, Object... args) { getSprite().showStatus(color, text, args); } diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/Hero.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/Hero.java index 15f57b1fef..188faf4815 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/Hero.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/actors/hero/Hero.java @@ -478,7 +478,7 @@ public void earnExp(int exp) { this.setExp(this.getExpForLevelUp() + exp); - showStatus(CharSprite.POSITIVE, TXT_EXP, exp); + showStatus_a(CharSprite.POSITIVE, TXT_EXP, exp); boolean levelUp = false; diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/DewVial.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/DewVial.java index 57c6dcc0df..f2e0bea430 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/DewVial.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/DewVial.java @@ -70,7 +70,7 @@ public void doDrink(@NotNull Char chr) { int effect = Math.min(chr.ht() - chr.hp(), value); if (effect > 0) { chr.heal(effect, this); - chr.showStatus(CharSprite.POSITIVE, TXT_VALUE, effect); + chr.showStatus_a(CharSprite.POSITIVE, TXT_VALUE, effect); } setVolume(0); diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Dewdrop.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Dewdrop.java index dba4204304..1aca0b0eaf 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Dewdrop.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Dewdrop.java @@ -42,7 +42,7 @@ public boolean doPickUp(@NotNull Char hero ) { int effect = Math.min( hero.ht() - hero.hp(), value[0] * quantity() ); if (effect > 0) { hero.heal(effect, this); - hero.showStatus( CharSprite.POSITIVE, TXT_VALUE, effect ); + hero.showStatus_a( CharSprite.POSITIVE, TXT_VALUE, effect ); collected = true; } } diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Gold.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Gold.java index 238867bbde..7fb90627f6 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Gold.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/Gold.java @@ -46,7 +46,7 @@ public boolean doPickUp(@NotNull Char hero) { Badges.validateGoldCollected(); GameScene.pickUp(this); - hero.showStatus(CharSprite.NEUTRAL, TXT_VALUE, quantity()); + hero.showStatus_a(CharSprite.NEUTRAL, TXT_VALUE, quantity()); hero.spend(TIME_TO_PICK_UP); Sample.INSTANCE.play(Assets.SND_GOLD, 1, 1, Random.Float(0.9f, 1.1f)); diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java index bf2e20bfd3..1a56ac24bd 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java @@ -42,7 +42,7 @@ public int defenceProc(Armor armor, Char attacker, Char defender, int damage ) { } debuff.prolong( damage ); - defender.showStatus( CharSprite.WARNING, StringsManager.getVar(R.string.Viscosity_Status), damage ); + defender.showStatus_a( CharSprite.WARNING, StringsManager.getVar(R.string.Viscosity_Status), damage ); return 0; diff --git a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/scenes/GameScene.java b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/scenes/GameScene.java index 8c5ed481f0..dab4578233 100644 --- a/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/scenes/GameScene.java +++ b/RemixedDungeon/src/main/java/com/watabou/pixeldungeon/scenes/GameScene.java @@ -387,14 +387,28 @@ public void createGameScene(@NotNull Level level, @NotNull Hero hero) { Camera.main.setTarget(hero.getHeroSprite()); + int l_w = level.getWidth(); + int l_h = level.getHeight(); + level.activateScripts(); - // Epic level gen compatibility - createTerrain(level); + boolean epicRegen = false; + if(l_w != level.getWidth() || l_h != level.getHeight()) { + epicRegen = true; + } + + if(epicRegen) { + // Epic level gen compatibility + createTerrain(level); + } + LevelTools.upgradeMap(level); - // Yeah, epic level gen compatibility - Dungeon.initSizeDependentStuff(level.getWidth(), level.getHeight()); - fog.reinit(level.getWidth(), level.getHeight()); + + if(epicRegen) { + // Yeah, epic level gen compatibility + Dungeon.initSizeDependentStuff(level.getWidth(), level.getHeight()); + fog.reinit(level.getWidth(), level.getHeight()); + } level.addVisuals(this);