fixed dragon's ranged attack

This commit is contained in:
2024-07-24 13:41:51 -04:00
parent 3e3ee4ba38
commit 8baccd8fd7
3 changed files with 8 additions and 6 deletions

View File

@ -16,6 +16,9 @@ long_result dragon::act(level *lvl, character *pc, bool hostile) {
if (is_adjacent(pos, pc->get_pos()) && hostile) if (is_adjacent(pos, pc->get_pos()) && hostile)
return attack(pc); return attack(pc);
if (is_adjacent(guards, pc->get_pos()))
return attack(pc);
return {NOTHING, ""}; return {NOTHING, ""};
} }

View File

@ -3,7 +3,6 @@
#include "constants.h" #include "constants.h"
#include "player.h" #include "player.h"
#include "level.h" #include "level.h"
#include "enemies/dragon.h"
enemy_base::enemy_base(RNG *rng, const feature enabled_features, enemy_base::enemy_base(RNG *rng, const feature enabled_features,
const enum race &nrace, const position &pos, const enum race &nrace, const position &pos,
@ -18,10 +17,6 @@ int enemy_base::get_room_num() const {
long_result enemy_base::act(level *lvl, character *pc, bool hostile) { long_result enemy_base::act(level *lvl, character *pc, bool hostile) {
if (is_adjacent(pos, pc->get_pos()) && hostile) if (is_adjacent(pos, pc->get_pos()) && hostile)
return attack(pc); return attack(pc);
else if (race == DRAGON &&
is_adjacent(static_cast<dragon * >(this)->get_guards(),
pc->get_pos()))
return attack(pc);
if (enabled_features & FEATURE_ENEMIES_CHASE && hostile && if (enabled_features & FEATURE_ENEMIES_CHASE && hostile &&
distance_sqr(pos, pc->get_pos()) <= DIST_THRESHOLD_SQR) { distance_sqr(pos, pc->get_pos()) <= DIST_THRESHOLD_SQR) {

View File

@ -2,6 +2,7 @@
#include "constants.h" #include "constants.h"
#include "pc.h" #include "pc.h"
#include "enemies/dragon.h"
game::game(const enum race starting_race, game::game(const enum race starting_race,
const feature enabled_features, const feature enabled_features,
@ -90,7 +91,10 @@ character *game::move_enemies() {
continue; continue;
} }
if (the_world && !is_adjacent(ch->get_pos(), player->get_pos())) if (the_world && !(is_adjacent(ch->get_pos(), player->get_pos()) ||
(ch->get_race() == DRAGON &&
is_adjacent(static_cast<dragon * >(ch)->get_guards(),
player->get_pos()))))
continue; continue;
bool hostile = ch->get_race() == MERCHANT ? bool hostile = ch->get_race() == MERCHANT ?