diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 18:40:23 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-23 18:40:23 +0200 |
commit | 4dd4ccef715a50fb1b833c91ca33988b2a951737 (patch) | |
tree | e500a14e152942c8ded0727c53a81fe52be44f15 | |
parent | d (diff) | |
download | cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.gz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.bz2 cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.lz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.xz cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.tar.zst cuberite-4dd4ccef715a50fb1b833c91ca33988b2a951737.zip |
-rw-r--r-- | src/Mobs/AggressiveMonster.cpp | 4 | ||||
-rw-r--r-- | src/Mobs/Behaviors/Behavior.cpp | 1 | ||||
-rw-r--r-- | src/Mobs/Behaviors/Behavior.h | 2 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.cpp | 15 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.h | 5 | ||||
-rw-r--r-- | src/Mobs/Monster.h | 18 |
6 files changed, 21 insertions, 24 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 1cb32fc70..7d44e36b9 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -34,10 +34,10 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) for (;;) { m_BehaviorAggressive.Tick(); - if (BehaviorChaser->ActiveTick()) + /*if (BehaviorChaser->Tick()) { break; - } + }*/ if ((BehaviorWanderer != nullptr) && BehaviorWanderer->ActiveTick(a_Dt, a_Chunk)) { break; diff --git a/src/Mobs/Behaviors/Behavior.cpp b/src/Mobs/Behaviors/Behavior.cpp index e7c8a2c8b..a8f719f66 100644 --- a/src/Mobs/Behaviors/Behavior.cpp +++ b/src/Mobs/Behaviors/Behavior.cpp @@ -8,6 +8,7 @@ bool cBehavior::IsControlDesired() { + LOGD("ERROR: Probably forgot to implement cBehavior::IsControlDesired but implement cBehavior::Tick"); return false; } diff --git a/src/Mobs/Behaviors/Behavior.h b/src/Mobs/Behaviors/Behavior.h index c3e5cad8e..ce719f7e4 100644 --- a/src/Mobs/Behaviors/Behavior.h +++ b/src/Mobs/Behaviors/Behavior.h @@ -1,3 +1,5 @@ +#pragma once + class cBehavior { public: diff --git a/src/Mobs/Behaviors/BehaviorChaser.cpp b/src/Mobs/Behaviors/BehaviorChaser.cpp index 2cdafe98f..3ac7c5123 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.cpp +++ b/src/Mobs/Behaviors/BehaviorChaser.cpp @@ -23,8 +23,18 @@ cBehaviorChaser::cBehaviorChaser(cMonster * a_Parent) : +bool cBehaviorChaser::IsControlDesired() +{ + // If we have a target, we have something to do! Return true and control the mob Ticks. + // Otherwise return false. + return (GetTarget() != nullptr); +} + + -bool cBehaviorChaser::Tick() + + +void cBehaviorChaser::Tick() { // Stop targeting out of range targets if (GetTarget() != nullptr) @@ -45,10 +55,8 @@ bool cBehaviorChaser::Tick() // Not important now, but important for future extensibility, e.g. // cow chases wheat but using the netherman approacher to teleport around. } - return true; } } - return false; } void cBehaviorChaser::ApproachTarget() @@ -146,6 +154,7 @@ bool cBehaviorChaser::TargetIsInStrikeRange() Attack(a_Dt); } */ + return ((m_Target->GetPosition() - m_Parent->GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); } diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorChaser.h index e924a9db3..75f3fc121 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.h +++ b/src/Mobs/Behaviors/BehaviorChaser.h @@ -13,14 +13,15 @@ class cBehaviorStriker; The mob may possess this trait and not attack anyone or only attack when provoked. Unlike most traits, this one has several forms, and therefore it is an abstract type You should use one of its derived classes, and you cannot use it directly. */ -class cBehaviorChaser +class cBehaviorChaser : public cBehavior { public: cBehaviorChaser(cMonster * a_Parent); // Functions our host Monster should invoke: - bool Tick() override; + bool IsControlDesired() override; + void Tick() override; void Destroyed() override; void PostTick() override; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 2ff411040..3e0a913bf 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -115,10 +115,6 @@ public: /** Returns whether this mob is undead (skeleton, zombie, etc.) */ virtual bool IsUndead(void); - int GetAttackRate() { return static_cast<int>(m_AttackRate); } - void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; } - void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; } - void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; } void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; } int GetSightDistance() { return m_SightDistance; } @@ -255,13 +251,6 @@ public: /** Returns if the ultimate, final destination has been reached. */ bool ReachedFinalDestination(void) { return ((m_FinalDestination - GetPosition()).SqrLength() < WAYPOINT_RADIUS * WAYPOINT_RADIUS); } - /** Returns whether or not the target is close enough for attack. */ - bool TargetIsInRange(void) - { - ASSERT(GetTarget() != nullptr); - return ((GetTarget()->GetPosition() - GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); - } - /** Returns whether the monster needs to jump to reach a given height. */ inline bool DoesPosYRequireJump(double a_PosY) { @@ -289,11 +278,7 @@ public: AString m_SoundHurt; AString m_SoundDeath; - float m_AttackRate; - int m_AttackDamage; - int m_AttackRange; - int m_AttackCoolDownTicksLeft; - int m_SightDistance; + int m_SightDistance; // mobTodo what to do with this? float m_DropChanceWeapon; float m_DropChanceHelmet; @@ -301,7 +286,6 @@ public: float m_DropChanceLeggings; float m_DropChanceBoots; bool m_CanPickUpLoot; - int m_TicksSinceLastDamaged; // How many ticks ago we were last damaged by a player? double m_RelativeWalkSpeed; |