From b87754704cf1d7c53ae878d45147a124f90e4498 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 8 Aug 2022 16:07:02 -0400 Subject: [PATCH] v1.4.0: improved logic for directable allies holding a position --- .../assets/messages/actors/actors.properties | 2 ++ .../hero/abilities/huntress/SpiritHawk.java | 6 +++++ .../hero/abilities/rogue/ShadowClone.java | 10 ++++++- .../actors/mobs/npcs/DirectableAlly.java | 26 ++++++++++++++----- .../items/artifacts/DriedRose.java | 4 ++- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/core/src/main/assets/messages/actors/actors.properties b/core/src/main/assets/messages/actors/actors.properties index cea1ff882..44828cb2d 100644 --- a/core/src/main/assets/messages/actors/actors.properties +++ b/core/src/main/assets/messages/actors/actors.properties @@ -427,6 +427,7 @@ actors.hero.abilities.rogue.shadowclone.name=shadow clone actors.hero.abilities.rogue.shadowclone.short_desc=The Rogue summons a _Shadow Clone_, which can be directed to aid him in combat. actors.hero.abilities.rogue.shadowclone.desc=The Rogue summons a shadowy mimic of himself, which can be directed to aid him in combat. Directing the shadow clone does not cost any charge.\n\nThe clone has 80 HP, no armor, and deals 10-20 damage. All of these traits can be improved with talents, such that the clone benefits from weapons and armor the hero has. actors.hero.abilities.rogue.shadowclone$shadowally.name=shadow rogue +actors.hero.abilities.rogue.shadowclone$shadowally.direct_defend=Your clone moves to that position. actors.hero.abilities.rogue.shadowclone$shadowally.direct_follow=Your clone moves to follow you. actors.hero.abilities.rogue.shadowclone$shadowally.direct_attack=Your clone moves to attack! actors.hero.abilities.rogue.shadowclone$shadowally.desc=A copy of the Rogue, made from shadowy darkness. It stands stock still, with empty eyes and tiny wisps of darkness rising from it like steam.\n\nThe clone is not a perfect copy of the Rogue, but is still a decent fighter, and can benefit from the Rogue's equipment with the right talents. @@ -444,6 +445,7 @@ actors.hero.abilities.huntress.spirithawk.no_space=There is no free space near y actors.hero.abilities.huntress.spirithawk.short_desc=The Huntress summons a _Spirit Hawk_ familiar, which can help her scout locations and distract enemies. actors.hero.abilities.huntress.spirithawk.desc=The Huntress summons a spirit hawk familiar, which can be directed by using the ability again while it is summoned. The hawk lasts for 100 turns, directing the hawk does not cost any charge.\n\nThe hawk has minimal health and attacking power, but is fast, evasive, and accurate. It shares its entire field of vision with the Huntress at all times. It is immune to all area-bound effects, such as fire and poison gas. It will not attack unless specifically directed to. actors.hero.abilities.huntress.spirithawk$hawkally.name=spirit hawk +actors.hero.abilities.huntress.spirithawk$hawkally.direct_defend=Your hawk moves to that position. actors.hero.abilities.huntress.spirithawk$hawkally.direct_follow=Your hawk moves to follow you. actors.hero.abilities.huntress.spirithawk$hawkally.direct_attack=Your hawk moves to attack! actors.hero.abilities.huntress.spirithawk$hawkally.desc=A magical hawk, summoned by the Huntress. It glows a bright ethereal blue, its head constantly shifts around as it surveys the area.\n\nWhile it isn't much of a fighter its speed and vision make it excellent for scouting and distracting enemies.\n\nTurns remaining: %d. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/huntress/SpiritHawk.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/huntress/SpiritHawk.java index c49ed5d27..b34792685 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/huntress/SpiritHawk.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/huntress/SpiritHawk.java @@ -238,6 +238,12 @@ public class SpiritHawk extends ArmorAbility { GameScene.updateFog(); } + @Override + public void defendPos(int cell) { + GLog.i(Messages.get(this, "direct_defend")); + super.defendPos(cell); + } + @Override public void followHero() { GLog.i(Messages.get(this, "direct_follow")); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/rogue/ShadowClone.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/rogue/ShadowClone.java index e1c1fbe35..e2aa7a226 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/rogue/ShadowClone.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/rogue/ShadowClone.java @@ -181,6 +181,12 @@ public class ShadowClone extends ArmorAbility { return result; } + @Override + public void defendPos(int cell) { + GLog.i(Messages.get(this, "direct_defend")); + super.defendPos(cell); + } + @Override public void followHero() { GLog.i(Messages.get(this, "direct_follow")); @@ -248,7 +254,9 @@ public class ShadowClone extends ArmorAbility { float speed = super.speed(); //moves 2 tiles at a time when returning to the hero - if (state == WANDERING && defendingPos == -1){ + if (state == WANDERING + && defendingPos == -1 + && Dungeon.level.distance(pos, Dungeon.hero.pos) > 1){ speed *= 2; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/DirectableAlly.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/DirectableAlly.java index 52d6c99de..7c46f01ea 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/DirectableAlly.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/DirectableAlly.java @@ -33,6 +33,7 @@ public class DirectableAlly extends NPC { alignment = Char.Alignment.ALLY; intelligentAlly = true; WANDERING = new Wandering(); + HUNTING = new Hunting(); state = WANDERING; //before other mobs @@ -79,12 +80,6 @@ public class DirectableAlly extends NPC { return; } - //TODO commenting this out for now, it should be pointless?? - /*if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){ - fieldOfView = new boolean[Dungeon.level.length()]; - } - Dungeon.level.updateFieldOfView( this, fieldOfView );*/ - if (Actor.findChar(cell) == Dungeon.hero){ followHero(); @@ -115,7 +110,10 @@ public class DirectableAlly extends NPC { @Override public boolean act( boolean enemyInFOV, boolean justAlerted ) { - if ( enemyInFOV && !movingToDefendPos && attacksAutomatically) { + if ( enemyInFOV + && attacksAutomatically + && !movingToDefendPos + && (defendingPos == -1 || !Dungeon.level.heroFOV[defendingPos] || canAttack(enemy))) { enemySeen = true; @@ -150,4 +148,18 @@ public class DirectableAlly extends NPC { } + private class Hunting extends Mob.Hunting { + + @Override + public boolean act(boolean enemyInFOV, boolean justAlerted) { + if (enemyInFOV && defendingPos != -1 && Dungeon.level.heroFOV[defendingPos] && !canAttack(enemy)){ + target = defendingPos; + state = WANDERING; + return true; + } + return super.act(enemyInFOV, justAlerted); + } + + } + } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 1a99f3676..994ba01f2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -662,7 +662,9 @@ public class DriedRose extends Artifact { } //moves 2 tiles at a time when returning to the hero - if (state == WANDERING && defendingPos == -1){ + if (state == WANDERING + && defendingPos == -1 + && Dungeon.level.distance(pos, Dungeon.hero.pos) > 1){ speed *= 2; }