Yes, I see it's not obvious at all. 
This is because creatures at first try to fight with the nearest target, so if the player isn't in this list, he will be omitted and then added in ```engageCombat(iter->first, player, true);``` and it's likely that we will have 2 ```getLOS``` for 1 creature. It could be ok, but with this I tried to minimize ```getLOS``` calls cause each takes ~0.1 ms for me. And if you have, for example 4 guards and 2 creatures, then in default implementation there will be 8 getLOS's in 1 frame (and if it returns false it will be repeated each second according to ```timerUpdateAITargets```) with overall cost of ~ 1 ms (while in order to reach 60 fps 1 frame should be 16.7 ms). Rather costly IMO if to consider it is just determining if something is in LOS of something else. 
With this line and ```canAddTarget``` func we most likely will have 4 calls. This is why I also added ```(fight == 100 && d <= 5000)```.
Also we should think about reaching high numbers of creatures and guards in the scene.