diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 21:31:45 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 21:31:45 +0200 |
commit | a54cbf40ffa40cd72f20f6491f34e4b2338687dd (patch) | |
tree | a0b656e9b890f8268239bea23a12feb8dcaa738b /src/Mobs/Behaviors/BehaviorItemFollower.cpp | |
parent | removed some attack code from Monster (diff) | |
download | cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar.gz cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar.bz2 cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar.lz cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar.xz cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.tar.zst cuberite-a54cbf40ffa40cd72f20f6491f34e4b2338687dd.zip |
Diffstat (limited to 'src/Mobs/Behaviors/BehaviorItemFollower.cpp')
-rw-r--r-- | src/Mobs/Behaviors/BehaviorItemFollower.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.cpp b/src/Mobs/Behaviors/BehaviorItemFollower.cpp index 2b0377c46..22c20d6b4 100644 --- a/src/Mobs/Behaviors/BehaviorItemFollower.cpp +++ b/src/Mobs/Behaviors/BehaviorItemFollower.cpp @@ -17,7 +17,30 @@ cBehaviorItemFollower::cBehaviorItemFollower(cMonster * a_Parent) : -bool cBehaviorItemFollower::Tick() +bool cBehaviorItemFollower::IsControlDesired() +{ + cItems FollowedItems; + m_Parent->GetFollowedItems(FollowedItems); + if (FollowedItems.Size() > 0) + { + cPlayer * a_Closest_Player = m_Parent->GetNearestPlayer(); + if (a_Closest_Player != nullptr) + { + cItem EquippedItem = a_Closest_Player->GetEquippedItem(); + if (FollowedItems.ContainsType(EquippedItem)) + { + return true; // We take control of the monster. Now it'll call our tick + } + } + } + return false; +} + + + + + +void cBehaviorItemFollower::Tick() { cItems FollowedItems; m_Parent->GetFollowedItems(FollowedItems); @@ -31,9 +54,7 @@ bool cBehaviorItemFollower::Tick() { Vector3d PlayerPos = a_Closest_Player->GetPosition(); m_Parent->MoveToPosition(PlayerPos); - return true; // We took control of the monster, prevent other Behaviors from doing so } } } - return false; } |