summaryrefslogtreecommitdiff
path: root/plugins/autofollow.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/autofollow.py')
-rw-r--r--plugins/autofollow.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/autofollow.py b/plugins/autofollow.py
new file mode 100644
index 0000000..ff34bde
--- /dev/null
+++ b/plugins/autofollow.py
@@ -0,0 +1,39 @@
+import net.mapserv as mapserv
+import commands
+from utils import extends
+from loggers import debuglog
+
+
+__all__ = [ 'PLUGIN', 'init', 'follow' ]
+
+
+PLUGIN = {
+ 'name': 'autofollow',
+ 'requires': (),
+ 'blocks': (),
+}
+
+follow = ''
+
+
+@extends('smsg_player_move')
+def player_move(data):
+ if follow:
+ b = mapserv.beings_cache[data.id]
+ if b.name == follow:
+ mapserv.cmsg_player_change_dest(data.coor_pair.dst_x,
+ data.coor_pair.dst_y)
+
+
+def follow_cmd(_, player):
+ '''Follow given player, or disable following (if no arg)'''
+ global follow
+ follow = player
+ if player:
+ debuglog.info('Following %s', player)
+ else:
+ debuglog.info('Not following anyone')
+
+
+def init(config):
+ commands.commands['follow'] = follow_cmd