For situations like this, I also find shoveling the logic into its own process can be helpful. That also means down the line, if you want different mobs to have different targeting rules (such as one that can't attack enemies that are "flying" or something), you can just overload it. There's a small performance cost, but for something like this I think it would be worth it.
Yeah. In practice, I'd also use variables instead of the constants 4 and 10. Maybe some boolean variables too to enable or disable some of the checks (ex: a var you can set to make it ignore the team check). This way you can make minor customizations by changing some vars or you can override the proc to make larger changes.
Also, for your last example, I think adding parenthesis around the statements would make it even clearer:
> for(var/mob/m in oview(10,src))
> var/too_close = (get_dist(src, m) <= 4)
> var/friendly = (m.team == team && m.team != NONE)
>
Heh, if this was in a project of mine I'd have put the parenthesis there too, but I figured people would like it more without the parenthesis =)
Anyway, nice article. We need more developers like you around :)
Thanks!
Also, for your last example, I think adding parenthesis around the statements would make it even clearer:
Anyway, nice article. We need more developers like you around :)