If a mob is moving to( using move_to(target))a target and the the target becomes invisible he continue following the target and the oview() proc "can see" the mob normally, as if he was visible.
Numbered Steps to Reproduce Problem:
1-A mob starts following you;
2-Become invisible(doesn't matter how much);
3-Continue running from him;
4-He continue following you.
Code Snippet (if applicable) to Reproduce Problem:
proc
Watching()
for(var/mob/m in oview(src))
if(m.client)
target = m
break
action()
if(target)
if(target in oview(src))
dir = get_dir(src,target)
if(bounds_dist(src,target) > 4)
move_to(target)
else
target << "OK"
stop()
slow_down()
else
world << "OK2"
target = ""
Watching()
stop()
slow_down()
else
Watching()
..()
Expected Results:
Since he can't see me he suppose to have no target, start looking to another and stop walking.
Actual Results:
If I move when he is on view he start following me and oview() starts to "see" me as a normal visible mob, and if I run from my Enemy's view he doesn't stop moving, he walks in the last direction he was walking before I run away from him and sometimes he follow me normally.If I put these
action()
if(target)
stop()
slow_down()
if(target in oview(src))
he stops doing that last part but he becomes really slow.
When does the problem NOT occur?
If I'm already invisible when I see him, and I not move.
Workarounds:
I think it's a problem in the action proc, so if I use another proc with the while loop for the ai he probably will not have these problems.
I'm using BYOND 494.1125
There are really two problems here:
1. The mob continues moving to a mob even after it turns invisible. This happens because when you call move_to(), the library finds a path to the target. Once it's got that path it keeps following it. If you want to stop that you can do so in the action proc, for example:
But, this isn't really a problem. The mob doesn't actually follow the target, it moves to the target's location. If the mob turns invisible, the AI mob will run to its last known location. This behavior is probably fine.
2. The second problem is that move_to doesn't check if the target is invisible. So, once your target has turned invisible you'll continue to find paths to them even though you can't see them. To fix this, you can override move_to() like this:
In move_to() you can include some type of check to make sure the target is visible.