Enemies how fight back when cornered, either by being blocked by another enemy or when at a dead end walls.

master
Zed A. Shaw 3 days ago
parent 586343a614
commit fc8e65f4d6
  1. 2
      battle.cpp
  2. 1
      gui/fsm.cpp
  3. 8
      systems.cpp

@ -15,8 +15,10 @@ namespace combat {
if(enemy.ai.active()) { if(enemy.ai.active()) {
if(enemy.ai.wants_to("kill_enemy")) { if(enemy.ai.wants_to("kill_enemy")) {
fmt::println(">> enemy {} wants to KILL", entity);
pending_actions.emplace_back(enemy, BattleAction::ATTACK); pending_actions.emplace_back(enemy, BattleAction::ATTACK);
} else if(enemy.ai.wants_to("run_away")) { } else if(enemy.ai.wants_to("run_away")) {
fmt::println(">> enemy {} wants to RUN", entity);
pending_actions.emplace_back(enemy, BattleAction::ESCAPE); pending_actions.emplace_back(enemy, BattleAction::ESCAPE);
} }
} }

@ -194,7 +194,6 @@ namespace gui {
} }
} break; } break;
case MOUSE_CLICK: case MOUSE_CLICK:
fmt::println("CLICK: {}", $router.left_button);
mouse_action(guecs::NO_MODS); mouse_action(guecs::NO_MODS);
break; break;
case MOUSE_MOVE: { case MOUSE_MOVE: {

@ -102,16 +102,20 @@ void System::enemy_pathing() {
if(ent != level.player) { if(ent != level.player) {
auto& enemy_ai = world.get<ai::EntityAI>(ent); auto& enemy_ai = world.get<ai::EntityAI>(ent);
Point out = position.location; // copy Point out = position.location; // copy
bool found_path = false;
if(enemy_ai.wants_to("find_enemy")) { if(enemy_ai.wants_to("find_enemy")) {
map.random_walk(out, motion.random, PATHING_TOWARD); found_path = map.random_walk(out, motion.random, PATHING_TOWARD);
} else if(enemy_ai.wants_to("run_away")) { } else if(enemy_ai.wants_to("run_away")) {
map.random_walk(out, motion.random, PATHING_AWAY); found_path = map.random_walk(out, motion.random, PATHING_AWAY);
} else { } else {
motion = {0,0}; motion = {0,0};
return; // enemy doesn't want to move return; // enemy doesn't want to move
} }
enemy_ai.set_state("cant_move", !found_path);
enemy_ai.update();
motion = { int(out.x - position.location.x), int(out.y - position.location.y)}; motion = { int(out.x - position.location.x), int(out.y - position.location.y)};
} }
}); });

Loading…
Cancel
Save