I need to say that if there is ANY entity near to another then do something.. There is some command do this? It' s for an ai, i want that ai check every time if there are other ai or building or player near it.. How can i do it?
Aza
Aza
Function EntityNear(Entity1, Entity2, Distance#= 2) ;"Distance#=2" mean that the default distance to check ; for is 2, so if you wanted 2 to be your default, and be ; able to change it, do this If EntityDistance(Entity1, Entity2) > Distance# then ;If your entity distances are further than your designated "near" variable, then do nothing EndIf If EntityDistance(Entity1, Entity2) =< Distance# then Return True EndIf End Function
If EntityNear(Zombie, Building) = True Then ;such and such Endif ;OR If EntityNear(Zombie, Building, 10) = True Then ;If the zombie is 10 units or less from the building then such and such Endif
Function distxz(entity1, entity2) distx# = EntityX(entity1) - EntityX(entity2) distz# = EntityZ(entity1) - EntityZ(entity2) distxz# = Sqr(distx^2 + distz^2) Return distxz# End Function
Function EntityNear(Entity1, Entity2, Distance#= 2) ;"Distance#=2" mean that the default distance to check ; for is 2, so if you wanted 2 to be your default, and be ; able to change it, do this If EntityDistance(Entity1, Entity2) > Distance# then ;If your entity distances are further than your designated "near" variable, then do nothing EndIf If EntityDistance(Entity1, Entity2) =< Distance# then Return True EndIf End Function