Made AI smarter

This commit is contained in:
Anuken
2017-12-06 19:14:51 -05:00
parent 8e80af26d7
commit c461c80122
4 changed files with 49 additions and 11 deletions
+16 -2
View File
@@ -33,11 +33,25 @@ public class Pathfind{
enemy.findClosestNode();
}
Tile[] path = enemy.path;
if(enemy.idletime > Enemy.maxIdle){
//TODO reverse
Tile target = path[enemy.node];
if(Vars.world.raycastWorld(enemy.x, enemy.y, target.worldx(), target.worldy()) != null){
if(enemy.node > 1)
enemy.node = enemy.node - 1;
}else{
//what's the problem, then?
}
enemy.idletime = 0;
}
//-1 is only possible here if both pathfindings failed, which should NOT happen
//check graph code
Tile[] path = enemy.path;
Tile prev = path[enemy.node - 1];
Tile target = path[enemy.node];