Page 1 of 1

Question about distance and path

Posted: Fri Apr 08, 2016 8:38 am
by catarix7
Hi all.
i want to put entity via script on some random point on circle with distance 100 from players base. i used the command to check the spot.

Code: Select all

if (game.get_surface(1).can_place_entity{name = "big-biter", position = {Fin_x, Fin_y}}) then
i would like to know
1. how i can check distance from nearest player building? i found parameter min_player_base_distance in map-setting but do not understand how it works.
2. how i can check that there is a way from my random point to players base (or center of a map). i founded pathfinder in Misanthrope mode but i would prefer to use basic game function.
thank you in advance

Re: Question about distance and path

Posted: Fri Apr 08, 2016 10:22 am
by DaveMcW
There is no built in function to locate the player's base or check distance from it. Certainly not min_player_base_distance.

You could implement your own by using some geometry. Pick a direction from the center of the map, use find_entities_filtered in that direction, and find the building farthest from the center. Then add 100 to get your spawn point.

The API does not include a pathfinder function, which is why Misanthrope had to implement its own.