v1.4.0: improved logic for directable allies holding a position

This commit is contained in:
Evan Debenham
2022-08-08 16:07:02 -04:00
parent db6dd57576
commit b87754704c
5 changed files with 39 additions and 9 deletions

View File

@@ -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.

View File

@@ -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"));

View File

@@ -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;
}

View File

@@ -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);
}
}
}

View File

@@ -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;
}