by PrimalLove » Tue Feb 24, 2015 9:21 pm
Here are a couple of suggestions:
1. Place a few bprints in there so you can see where things are getting hung up.
2. How many of these turret monster things are you spawning? If it is like one or two per map I'd suggest not using findradius because the distance you are searching, plus the fact that all the monsters will be running this same routine you might want to consider a different method to alert them to the enemy.
3. Do any of the monsters actually have a self.owner? I ask because I see alot of additional conditions in your while statement that may just not even need to be there. If none of them do you can also get rid of the last self.goalentity stuff at the bottom of the function because its not needed. But if some of them do indeed have a self.owner then I suppose this is fine. I also question the head.owner != self.owner but I am not sure of how the rest of your mod works so I am going to assume this is a condition you need. It may not be best to put it in the first if statement tho.
4. The purpose of your while statement as I see it is to find the closest enemy possible by walking through the list of potential enemies and setting the dist each time to keep track of different locations of enemies as you walk through the list. It appears tho you are not actually using it in this way. Instead restricting it to only the one entity you hope to find? I say this because even if you have multiple turret monsters, it will return after the first one it finds. Making setting the dist afterwards rather pointless. As it is now it will just go after the first turret it finds. I'd suggest setting it to selected as you were previously and not having head.classname in your traceline condition statement. Without a bit more information about how your mod is intended to work I have nothing specifically I can point to that would lead me to think it wouldn't work other than some things I pointed out before that may be causing problems.
5. If the self.owner stuff is not needed and you only plan for them to look for one turret per map you can greatly shorten this routine up and make it much more efficient. Hard to stay for sure without a bit more info.