From d192dcf4b0ee37ea399511cb1c5f80e911a8951c Mon Sep 17 00:00:00 2001 From: Josh Aune Date: Thu, 1 Oct 2015 02:11:58 -0600 Subject: [PATCH 1/3] Movement primitives stop and is_moving --- spock/plugins/helpers/movement.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spock/plugins/helpers/movement.py b/spock/plugins/helpers/movement.py index 07dc520..94f34b0 100644 --- a/spock/plugins/helpers/movement.py +++ b/spock/plugins/helpers/movement.py @@ -22,6 +22,11 @@ def __init__(self): def move_to(self, x, y, z): self.move_location = Vector3(x, y, z) + def stop(self): + self.move_location = None + + def is_moving(self): + return self.move_location is not None @pl_announce('Movement') class MovementPlugin(PluginBase): From 09e374e094a837acc929258d23c781cdb62791bb Mon Sep 17 00:00:00 2001 From: Josh Aune Date: Thu, 1 Oct 2015 02:14:01 -0600 Subject: [PATCH 2/3] Improve path finding finish point accuracy. Helpful to ensure bot has dropped off to a lower block --- spock/plugins/helpers/movement.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spock/plugins/helpers/movement.py b/spock/plugins/helpers/movement.py index 94f34b0..31a079f 100644 --- a/spock/plugins/helpers/movement.py +++ b/spock/plugins/helpers/movement.py @@ -73,9 +73,9 @@ def do_pathfinding(self): move = self.movement clinfo = self.clientinfo if move.move_location is not None: - if move.move_location.x == math.floor(clinfo.position.x) \ - and move.move_location.z == math.floor(clinfo.position.z): - move.move_location = None + if round(move.move_location.x, 2) == round(clinfo.position.x, 2) \ + and round(move.move_location.z, 2) == round(clinfo.position.z, 2): + move.stop() else: self.physics.move_target(move.move_location) self.physics.walk() From 7e42276b4293581917caec6389075819c946c071 Mon Sep 17 00:00:00 2001 From: Josh Aune Date: Thu, 1 Oct 2015 02:27:49 -0600 Subject: [PATCH 3/3] flake8 fixes --- spock/plugins/helpers/movement.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spock/plugins/helpers/movement.py b/spock/plugins/helpers/movement.py index 31a079f..f3d99e3 100644 --- a/spock/plugins/helpers/movement.py +++ b/spock/plugins/helpers/movement.py @@ -6,7 +6,6 @@ """ import logging -import math from spock.plugins.base import PluginBase from spock.utils import pl_announce @@ -28,6 +27,7 @@ def stop(self): def is_moving(self): return self.move_location is not None + @pl_announce('Movement') class MovementPlugin(PluginBase): requires = ('Net', 'Physics', 'ClientInfo', 'Event') @@ -74,7 +74,8 @@ def do_pathfinding(self): clinfo = self.clientinfo if move.move_location is not None: if round(move.move_location.x, 2) == round(clinfo.position.x, 2) \ - and round(move.move_location.z, 2) == round(clinfo.position.z, 2): + and round(move.move_location.z, 2) == \ + round(clinfo.position.z, 2): move.stop() else: self.physics.move_target(move.move_location)