AI system in Developer Help
|
|
New() ..() spawn while(src) sleep(rand(15,18)) var/mob/target target=locate(/mob/player) in oview(7,src) if(target) if(src.aggresive) while(target in oview(7)) if(target.x == src.x&&target.y != src.y && target.y > src.y) step(src,NORTH) else if(target.x == src.x&&target.y != src.y && target.y < src.y) step(src,SOUTH) else if(target.x != src.x&&target.y == src.y && target.x < src.x) step(src,WEST) else if(target.x != src.x&&target.y == src.y && target.x > src.x) step(src,EAST) else if(target.x> src.x&&target.y > src.y) switch(rand(1,2)) if(1) step(src,EAST) if(2) step(src,NORTH) else if(target.x < src.x && target.y < src.y) switch(rand(1,2)) if(1) step(src,WEST) if(2) step(src,SOUTH) else if(target.x < src.x&&target.y > src.y) switch(rand(1,2)) if(1) step(src,WEST) if(2) step(src,NORTH) else if(target.x > src.x && target.y < src.y) switch(rand(1,2)) if(1) step(src,EAST) if(2) step(src,SOUTH) else switch(rand(1,4)) if(1) step(src,NORTH) if(2) step(src,SOUTH) if(3) step(src,EAST) if(4) step(src,WEST)
|
That`s my AI system.
I wan`t to make that when targeting(players) 5 - 1 step in front of him, NPC turns to him and stop walking. If target(player) move the NPC will follow him untill he is not facing him 5 steps or 1 step infront of him.
P.S
I am not asking how to make this code better.And ty for reading and helping
|
And it's Zeta, and it's horrid.
You've most likely no idea what you are doing, and looking at your older post, I'd dearly recommend just starting from absolute scratch. Like, from here.