summaryrefslogtreecommitdiff
path: root/actor.py
diff options
context:
space:
mode:
authorLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
committerLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
commit9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch)
tree9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /actor.py
parent11cc316b74d5f3f283413a33e7693b314741aa4a (diff)
downloadmanachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip
Initial commit
Diffstat (limited to 'actor.py')
-rw-r--r--actor.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/actor.py b/actor.py
new file mode 100644
index 0000000..f963941
--- /dev/null
+++ b/actor.py
@@ -0,0 +1,29 @@
+import net.mapserv as mapserv
+from net.common import distance
+
+
+def find_nearest_being(name='', type='', ignored_ids=[], allowed_jobs=[]):
+
+ if mapserv.beings_cache is None:
+ return None
+
+ min_disance = 1000000
+ px = mapserv.player_pos['x']
+ py = mapserv.player_pos['y']
+ nearest = None
+
+ for b in mapserv.beings_cache.values():
+ if b.id in ignored_ids:
+ continue
+ if name and b.name != name:
+ continue
+ if type and b.type != type:
+ continue
+ if allowed_jobs and b.job not in allowed_jobs:
+ continue
+ dist = distance(px, py, b.x, b.y)
+ if dist < min_disance:
+ min_disance = dist
+ nearest = b
+
+ return nearest