|
|
|
@ -102,16 +102,20 @@ void System::enemy_pathing() { |
|
|
|
|
if(ent != level.player) { |
|
|
|
|
auto& enemy_ai = world.get<ai::EntityAI>(ent); |
|
|
|
|
Point out = position.location; // copy
|
|
|
|
|
bool found_path = false; |
|
|
|
|
|
|
|
|
|
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")) { |
|
|
|
|
map.random_walk(out, motion.random, PATHING_AWAY); |
|
|
|
|
found_path = map.random_walk(out, motion.random, PATHING_AWAY); |
|
|
|
|
} else { |
|
|
|
|
motion = {0,0}; |
|
|
|
|
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)}; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|