Unlocked combat now works and weirdly this fixes the enemies not running away when scared.
This commit is contained in:
parent
e9365e0d87
commit
f6c8163acd
2 changed files with 17 additions and 2 deletions
|
|
@ -73,8 +73,15 @@ void System::enemy_ai_initialize() {
|
|||
if(world.has<ai::EntityAI>(ent)) {
|
||||
auto& enemy = world.get<ai::EntityAI>(ent);
|
||||
auto& personality = world.get<Personality>(ent);
|
||||
int dist_to_player = map.distance(pos.location);
|
||||
|
||||
enemy.set_state("detect_enemy", map.distance(pos.location) < personality.hearing_distance);
|
||||
if(dist_to_player > 1) {
|
||||
// not near the player so can't be in combat
|
||||
enemy.set_state("enemy_found", false);
|
||||
enemy.set_state("in_combat", false);
|
||||
}
|
||||
|
||||
enemy.set_state("detect_enemy", dist_to_player < personality.hearing_distance);
|
||||
enemy.update();
|
||||
} else {
|
||||
auto ai_start = ai::load_state(config.ai_start_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue