diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 16:13:31 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-30 16:13:31 +0200 |
commit | 48dff0f03c5df964a411e310f8905aaa3c84ac27 (patch) | |
tree | fe76a724ce321fabd6cb261a41799b741ca0a394 /src | |
parent | removed agressiveMonster (diff) | |
download | cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar.gz cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar.bz2 cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar.lz cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar.xz cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.tar.zst cuberite-48dff0f03c5df964a411e310f8905aaa3c84ac27.zip |
Diffstat (limited to 'src')
65 files changed, 340 insertions, 482 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.cpp b/src/Mobs/Behaviors/BehaviorAggressive.cpp index b55c1b476..2e3333e89 100644 --- a/src/Mobs/Behaviors/BehaviorAggressive.cpp +++ b/src/Mobs/Behaviors/BehaviorAggressive.cpp @@ -34,6 +34,9 @@ void cBehaviorAggressive::PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chu cPawn * cBehaviorAggressive::FindNewTarget() { cPlayer * Closest = m_Parent->GetNearestPlayer(); - if (!Closest->CanMobsTarget()) return nullptr; + if ((Closest != nullptr) && (!Closest->CanMobsTarget())) + { + return nullptr; + } return Closest; // May be null } diff --git a/src/Mobs/Behaviors/BehaviorAttacker.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp index 00eb53179..67a27a277 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.cpp +++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp @@ -16,6 +16,7 @@ cBehaviorAttacker::cBehaviorAttacker() : , m_AttackCoolDownTicksLeft(0) , m_TicksSinceLastDamaged(100) , m_IsStriking(false) + , m_Target(nullptr) { } @@ -24,13 +25,14 @@ cBehaviorAttacker::cBehaviorAttacker() : -void cBehaviorAttacker::AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker) +void cBehaviorAttacker::AttachToMonster(cMonster & a_Parent) { m_Parent = &a_Parent; m_Parent->AttachTickBehavior(this); m_Parent->AttachDestroyBehavior(this); m_Parent->AttachPostTickBehavior(this); m_Parent->AttachDoTakeDamageBehavior(this); + m_Parent->m_BehaviorAttackerPointer = this; } @@ -90,6 +92,7 @@ void cBehaviorAttacker::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) ASSERT((GetTarget() == nullptr) || (GetTarget()->IsPawn() && (GetTarget()->GetWorld() == m_Parent->GetWorld()))); if (GetTarget() != nullptr) { + m_Parent->SetLookingAt(m_Target); if (TargetOutOfSight()) { SetTarget(nullptr); @@ -237,8 +240,8 @@ bool cBehaviorAttacker::TargetIsInStrikeRadiusAndLineOfSight() Vector3d MyHeadPosition = m_Parent->GetPosition() + Vector3d(0, m_Parent->GetHeight(), 0); Vector3d AttackDirection(GetTarget()->GetPosition() + Vector3d(0, GetTarget()->GetHeight(), 0) - MyHeadPosition); - if (TargetIsInStrikeRadius() && - !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())) && + if (TargetIsInStrikeRadius()/* && + !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length()))*/ && (m_Parent->GetHealth() > 0.0) ) { @@ -279,7 +282,7 @@ void cBehaviorAttacker::ResetStrikeCooldown() void cBehaviorAttacker::StrikeTargetIfReady() { - if (m_AttackCoolDownTicksLeft != 0) + if (m_AttackCoolDownTicksLeft == 0) { StrikeTarget(); } diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h index 4d99fda21..78ed70994 100644 --- a/src/Mobs/Behaviors/BehaviorAttacker.h +++ b/src/Mobs/Behaviors/BehaviorAttacker.h @@ -3,7 +3,6 @@ class cBehaviorAttacker; #include "Behavior.h" -class cBehaviorStriker; /** Grants attack capability to the mob. Note that this is not the same as agression! @@ -15,7 +14,7 @@ class cBehaviorAttacker : public cBehavior public: cBehaviorAttacker(); - void AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker); + void AttachToMonster(cMonster & a_Parent); // Our host monster will call these once it loads its config file diff --git a/src/Mobs/Behaviors/BehaviorAttackerMelee.h b/src/Mobs/Behaviors/BehaviorAttackerMelee.h index 49a51ff71..b079c94fc 100644 --- a/src/Mobs/Behaviors/BehaviorAttackerMelee.h +++ b/src/Mobs/Behaviors/BehaviorAttackerMelee.h @@ -4,7 +4,7 @@ /** Makes the mob fight back any other mob that damages it. Mob should have BehaviorAttacker to work. This behavior does not make sense in combination with BehaviorCoward. */ -class cBehaviorAttackerMelee : cBehaviorAttacker +class cBehaviorAttackerMelee : public cBehaviorAttacker { public: bool StrikeTarget(int a_StrikeTickCnt) override; diff --git a/src/Mobs/Behaviors/BehaviorBreeder.cpp b/src/Mobs/Behaviors/BehaviorBreeder.cpp index d06a3cb96..7ede92c52 100644 --- a/src/Mobs/Behaviors/BehaviorBreeder.cpp +++ b/src/Mobs/Behaviors/BehaviorBreeder.cpp @@ -26,6 +26,7 @@ void cBehaviorBreeder::AttachToMonster(cMonster & a_Parent) m_Parent->AttachPostTickBehavior(this); m_Parent->AttachRightClickBehavior(this); m_Parent->AttachDestroyBehavior(this); + m_Parent->m_BehaviorBreederPointer = this; } diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h index 780827910..07812b9db 100644 --- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h +++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h @@ -8,13 +8,9 @@ class cBehaviorDayLightBurner : cBehavior { public: void AttachToMonster(cMonster & a_Parent); - void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk); - // Functions our host Monster should invoke: - void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - private: cMonster * m_Parent; // Our Parent cEntity * m_Attacker; // The entity we're running away from diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 7ada21369..df54be1fd 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -9,10 +9,11 @@ cBlaze::cBlaze(void) : - super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", 0.6, 1.8) + super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", 0.6, 1.8) { - SetGravity(-8.0f); - SetAirDrag(0.05f); + m_EMPersonality = AGGRESSIVE; + SetGravity(-8.0f); + SetAirDrag(0.05f); } @@ -21,11 +22,11 @@ cBlaze::cBlaze(void) : void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) - { - unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD); - } + if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) + { + unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD); + } } @@ -35,23 +36,23 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) /* bool cBlaze::Attack(std::chrono::milliseconds a_Dt) { - if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) - { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - - auto FireCharge = cpp14::make_unique<cFireChargeEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - auto FireChargePtr = FireCharge.get(); - if (!FireChargePtr->Initialize(std::move(FireCharge), *m_World)) - { - return false; - } - - ResetAttackCooldown(); - // ToDo: Shoot 3 fireballs instead of 1. - - return true; - } - return false; + if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) + { + // Setting this higher gives us more wiggle room for attackrate + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + + auto FireCharge = cpp14::make_unique<cFireChargeEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + auto FireChargePtr = FireCharge.get(); + if (!FireChargePtr->Initialize(std::move(FireCharge), *m_World)) + { + return false; + } + + ResetAttackCooldown(); + // ToDo: Shoot 3 fireballs instead of 1. + + return true; + } + return false; }*/ diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h index 7e389fa6c..1fb165a37 100644 --- a/src/Mobs/Blaze.h +++ b/src/Mobs/Blaze.h @@ -1,21 +1,16 @@ - #pragma once -#include "AggressiveMonster.h" - - - - +#include "Monster.h" class cBlaze : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cBlaze(void); + cBlaze(void); - CLASS_PROTODEF(cBlaze) + CLASS_PROTODEF(cBlaze) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; } ; diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index 27eb92e7d..51d9cd630 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -20,7 +20,6 @@ SET (SRCS Monster.cpp Mooshroom.cpp Ocelot.cpp - PassiveAggressiveMonster.cpp Path.cpp PathFinder.cpp Pig.cpp @@ -59,7 +58,6 @@ SET (HDRS MonsterTypes.h Mooshroom.h Ocelot.h - PassiveAggressiveMonster.h Path.h PathFinder.h Pig.h diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 8d8e15d85..0e33282c0 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -8,8 +8,9 @@ cCaveSpider::cCaveSpider(void) : - super("CaveSpider", mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5) + super("CaveSpider", mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5) { + m_EMPersonality = AGGRESSIVE; } @@ -18,14 +19,14 @@ cCaveSpider::cCaveSpider(void) : void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { - super::Tick(a_Dt, a_Chunk); - if (!IsTicking()) - { - // The base class tick destroyed us - return; - } - - m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; + super::Tick(a_Dt, a_Chunk); + if (!IsTicking()) + { + // The base class tick destroyed us + return; + } + + m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; } @@ -34,17 +35,17 @@ void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) /* bool cCaveSpider::Attack(std::chrono::milliseconds a_Dt) { - if (!super::Attack(a_Dt)) - { - return false; - } - - if (GetTarget()->IsPawn()) - { - // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds - static_cast<cPawn *>(GetTarget())->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); - } - return true; + if (!super::Attack(a_Dt)) + { + return false; + } + + if (GetTarget()->IsPawn()) + { + // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds + static_cast<cPawn *>(GetTarget())->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); + } + return true; }*/ @@ -53,16 +54,16 @@ bool cCaveSpider::Attack(std::chrono::milliseconds a_Dt) void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - unsigned int LootingLevel = 0; - if (a_Killer != nullptr) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING); - if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) - { - AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE); - } + unsigned int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING); + if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) + { + AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE); + } } diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index 71ee0b244..f59809d03 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -1,23 +1,23 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cCaveSpider : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cCaveSpider(void); + cCaveSpider(void); - CLASS_PROTODEF(cCaveSpider) + CLASS_PROTODEF(cCaveSpider) - virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; } ; diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index cc691fa5b..a7b27fc11 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -10,6 +10,7 @@ cChicken::cChicken(void) : { SetGravity(-2.0f); SetAirDrag(0.0f); + m_EMPersonality = PASSIVE; m_BehaviorBreeder.AttachToMonster(*this); m_BehaviorCoward.AttachToMonster(*this); m_BehaviorItemFollower.AttachToMonster(*this); diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index b5703fc1f..3d94986bb 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -32,21 +32,3 @@ void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER); AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF); } - - - - - -cBehaviorBreeder * cCow::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cCow::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index 78b584bdc..58380065a 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -22,9 +22,6 @@ public: { a_Items.Add(E_ITEM_WHEAT); } - - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 65576ff25..8de236863 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -17,6 +17,7 @@ cCreeper::cCreeper(void) : m_BurnedWithFlintAndSteel(false), m_ExplodingTimer(0) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h index 2ef72650b..28a0dd512 100644 --- a/src/Mobs/Creeper.h +++ b/src/Mobs/Creeper.h @@ -1,35 +1,35 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cCreeper : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cCreeper(void); + cCreeper(void); - CLASS_PROTODEF(cCreeper) + CLASS_PROTODEF(cCreeper) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual void OnRightClicked(cPlayer & a_Player) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + virtual void OnRightClicked(cPlayer & a_Player) override; - bool IsBlowing(void) const {return m_bIsBlowing; } - bool IsCharged(void) const {return m_bIsCharged; } - bool IsBurnedWithFlintAndSteel(void) const {return m_BurnedWithFlintAndSteel; } + bool IsBlowing(void) const {return m_bIsBlowing; } + bool IsCharged(void) const {return m_bIsCharged; } + bool IsBurnedWithFlintAndSteel(void) const {return m_BurnedWithFlintAndSteel; } private: - bool m_bIsBlowing, m_bIsCharged, m_BurnedWithFlintAndSteel; - int m_ExplodingTimer; + bool m_bIsBlowing, m_bIsCharged, m_BurnedWithFlintAndSteel; + int m_ExplodingTimer; } ; diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp index 360fe581b..4db5baf87 100644 --- a/src/Mobs/EnderDragon.cpp +++ b/src/Mobs/EnderDragon.cpp @@ -11,6 +11,7 @@ cEnderDragon::cEnderDragon(void) : // TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand super("EnderDragon", mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", 16.0, 8.0) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h index 43acdcd54..0528af77c 100644 --- a/src/Mobs/EnderDragon.h +++ b/src/Mobs/EnderDragon.h @@ -1,16 +1,12 @@ #pragma once -#include "AggressiveMonster.h" - - - - +#include "Monster.h" class cEnderDragon : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: cEnderDragon(void); diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 6aa72369f..72301b21a 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -79,6 +79,7 @@ cEnderman::cEnderman(void) : CarriedBlock(E_BLOCK_AIR), CarriedMeta(0) { + m_EMPersonality = PASSIVE; } diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h index 0dc648468..c3568e1db 100644 --- a/src/Mobs/Enderman.h +++ b/src/Mobs/Enderman.h @@ -1,39 +1,37 @@ - #pragma once - -#include "PassiveAggressiveMonster.h" +#include "Monster.h" class cEnderman : - public cPassiveAggressiveMonster + public cMonster { - typedef cPassiveAggressiveMonster super; + typedef cMonster super; public: - cEnderman(void); + cEnderman(void); - CLASS_PROTODEF(cEnderman) + CLASS_PROTODEF(cEnderman) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - bool IsScreaming(void) const {return m_bIsScreaming; } - BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; } - NIBBLETYPE GetCarriedMeta(void) const {return CarriedMeta; } + bool IsScreaming(void) const {return m_bIsScreaming; } + BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; } + NIBBLETYPE GetCarriedMeta(void) const {return CarriedMeta; } - /** Returns if the current sky light level is sufficient for the enderman to become aggravated */ - bool CheckLight(void); - /** Returns if the enderman gets hit by the rain */ - bool CheckRain(void); + /** Returns if the current sky light level is sufficient for the enderman to become aggravated */ + bool CheckLight(void); + /** Returns if the enderman gets hit by the rain */ + bool CheckRain(void); private: - bool m_bIsScreaming; - BLOCKTYPE CarriedBlock; - NIBBLETYPE CarriedMeta; + bool m_bIsScreaming; + BLOCKTYPE CarriedBlock; + NIBBLETYPE CarriedMeta; } ; diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index 97a27be5a..d9cd31f45 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -9,8 +9,9 @@ cGhast::cGhast(void) : - super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4) + super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4) { + m_EMPersonality = AGGRESSIVE; } @@ -19,13 +20,13 @@ cGhast::cGhast(void) : void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - unsigned int LootingLevel = 0; - if (a_Killer != nullptr) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); - AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR); + unsigned int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR); } @@ -34,23 +35,23 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) // mobTODO /*bool cGhast::Attack(std::chrono::milliseconds a_Dt) { - if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) - { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; - - auto GhastBall = cpp14::make_unique<cGhastFireballEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - auto GhastBallPtr = GhastBall.get(); - if (!GhastBallPtr->Initialize(std::move(GhastBall), *m_World)) - { - return false; - } - - ResetAttackCooldown(); - return true; - } - return false; + if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) + { + // Setting this higher gives us more wiggle room for attackrate + Vector3d Speed = GetLookVector() * 20; + Speed.y = Speed.y + 1; + + auto GhastBall = cpp14::make_unique<cGhastFireballEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + auto GhastBallPtr = GhastBall.get(); + if (!GhastBallPtr->Initialize(std::move(GhastBall), *m_World)) + { + return false; + } + + ResetAttackCooldown(); + return true; + } + return false; }*/ diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h index c3423590a..7fea31ae8 100644 --- a/src/Mobs/Ghast.h +++ b/src/Mobs/Ghast.h @@ -1,25 +1,23 @@ - #pragma once - -#include "AggressiveMonster.h" +#include "Monster.h" class cGhast : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cGhast(void); + cGhast(void); - CLASS_PROTODEF(cGhast) + CLASS_PROTODEF(cGhast) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - bool IsCharging(void) const {return false; } + bool IsCharging(void) const {return false; } } ; diff --git a/src/Mobs/Giant.cpp b/src/Mobs/Giant.cpp index 0f235e10f..c25b4e6a0 100644 --- a/src/Mobs/Giant.cpp +++ b/src/Mobs/Giant.cpp @@ -10,7 +10,7 @@ cGiant::cGiant(void) : super("Giant", mtGiant, "entity.zombie.hurt", "entity.zombie.death", 3.6, 10.8) { - + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h index 70e93894c..f1734437b 100644 --- a/src/Mobs/Giant.h +++ b/src/Mobs/Giant.h @@ -1,16 +1,16 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cGiant : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: cGiant(void); diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index f36f98ea8..ca6b04d55 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -11,6 +11,7 @@ cGuardian::cGuardian(void) : super("Guardian", mtGuardian, "entity.guardian.hurt", "entity.guardian.death", 0.875, 0.8) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Guardian.h b/src/Mobs/Guardian.h index 289654f57..988f36832 100644 --- a/src/Mobs/Guardian.h +++ b/src/Mobs/Guardian.h @@ -1,16 +1,16 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cGuardian : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: cGuardian(); diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 247de9699..6ff53df69 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -197,21 +197,3 @@ void cHorse::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) super::HandleSpeedFromAttachee(a_Forward * m_MaxSpeed, a_Sideways * m_MaxSpeed); } } - - - - - -cBehaviorBreeder * cHorse::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cHorse::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index 3c5a50671..e96a1f8a9 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -42,9 +42,6 @@ public: a_Items.Add(E_ITEM_GOLDEN_CARROT); a_Items.Add(E_ITEM_GOLDEN_APPLE); } - - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; diff --git a/src/Mobs/IronGolem.cpp b/src/Mobs/IronGolem.cpp index 448ed8dc0..223161c68 100644 --- a/src/Mobs/IronGolem.cpp +++ b/src/Mobs/IronGolem.cpp @@ -10,6 +10,7 @@ cIronGolem::cIronGolem(void) : super("IronGolem", mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", 1.4, 2.9) { + m_EMPersonality = PASSIVE; } diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h index 7d35686e7..c35452e3b 100644 --- a/src/Mobs/IronGolem.h +++ b/src/Mobs/IronGolem.h @@ -1,16 +1,16 @@ #pragma once -#include "PassiveAggressiveMonster.h" +#include "Monster.h" class cIronGolem : - public cPassiveAggressiveMonster + public cMonster { - typedef cPassiveAggressiveMonster super; + typedef cMonster super; public: cIronGolem(void); diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp index 4d70a0291..dd4e6916e 100644 --- a/src/Mobs/MagmaCube.cpp +++ b/src/Mobs/MagmaCube.cpp @@ -10,6 +10,7 @@ cMagmaCube::cMagmaCube(int a_Size) : super("MagmaCube", mtMagmaCube, Printf("entity.%smagmacube.hurt", GetSizeName(a_Size).c_str()), Printf("entity.%smagmacube.death", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h index 5fc8105ba..960ff0c90 100644 --- a/src/Mobs/MagmaCube.h +++ b/src/Mobs/MagmaCube.h @@ -1,15 +1,15 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cMagmaCube : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: /** Creates a MagmaCube of the specified size; with 1 being the smallest */ diff --git a/src/Mobs/MobPointer.cpp b/src/Mobs/MobPointer.cpp index 6e3bccee1..8fb64867d 100644 --- a/src/Mobs/MobPointer.cpp +++ b/src/Mobs/MobPointer.cpp @@ -56,7 +56,7 @@ cMobPointer& cMobPointer::operator=(cMobPointer&& a_MobPointer) -void cMobPointer::operator=(cPawn * a_Pointer) +void cMobPointer::SetPointer(cPawn * a_Pointer) { m_Pointer = a_Pointer; } diff --git a/src/Mobs/MobPointer.h b/src/Mobs/MobPointer.h index 77f4cd6cd..3534d760d 100644 --- a/src/Mobs/MobPointer.h +++ b/src/Mobs/MobPointer.h @@ -17,7 +17,7 @@ public: cMobPointer& operator=(const cMobPointer& a_MobPointer); // Copy assignment operator cMobPointer& operator=(cMobPointer&& a_MobPointer); // Move assignment operator - void operator=(cPawn * a_Pointer); // set Pointer + void SetPointer(cPawn * a_Pointer); // set Pointer /** Returns the raw pointer. The returned raw pointer must be used locally and then discarded. it MUST NOT be preserved across ticks. diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 7472e3391..fc1c1678d 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -85,6 +85,8 @@ static const struct cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : super(etMonster, a_Width, a_Height) + , m_BehaviorBreederPointer(nullptr) + , m_BehaviorAttackerPointer(nullptr) , m_EMPersonality(AGGRESSIVE) , m_NearestPlayerIsStale(true) , m_PathFinder(a_Width, a_Height) @@ -115,6 +117,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A , m_LookingAt(nullptr) , m_CurrentTickControllingBehavior(nullptr) , m_NewTickControllingBehavior(nullptr) + , m_PinnedBehavior(nullptr) , m_TickControllingBehaviorState(Normal) { if (!a_ConfigName.empty()) @@ -328,8 +331,12 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) // If we're in a regular tick cycle if (m_TickControllingBehaviorState == Normal) { - - if (m_PinnedBehavior != nullptr) + if (IsLeashed()) + { + // do not tick behaviors + // mobTodo temporary leash special case. Needs a behavior eventually. + } + else if (m_PinnedBehavior != nullptr) { // A behavior is pinned. We give it control automatically. ASSERT(m_CurrentTickControllingBehavior == m_PinnedBehavior); @@ -470,7 +477,9 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) SetPitchAndYawFromDestination(a_IsFollowingPath); // Leash calculations - if ((m_TicksAlive % LEASH_ACTIONS_TICK_STEP) == 0) + if ((m_TickControllingBehaviorState == Normal) && + ((m_TicksAlive % LEASH_ACTIONS_TICK_STEP) == 0) + ) { CalcLeashActions(); } @@ -988,7 +997,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) void cMonster::SetLookingAt(cPawn * a_NewTarget) { - m_LookingAt = a_NewTarget; + m_LookingAt.SetPointer(a_NewTarget); /* ASSERT((a_NewTarget == nullptr) || (IsTicking())); @@ -1029,7 +1038,7 @@ bool cMonster::IsPathFinderActivated() const cBehaviorBreeder * cMonster::GetBehaviorBreeder() { - return nullptr; + return m_BehaviorBreederPointer; } @@ -1038,7 +1047,7 @@ cBehaviorBreeder * cMonster::GetBehaviorBreeder() const cBehaviorBreeder * cMonster::GetBehaviorBreeder() const { - return nullptr; + return static_cast<const cBehaviorBreeder *>(m_BehaviorBreederPointer); } @@ -1047,16 +1056,7 @@ const cBehaviorBreeder * cMonster::GetBehaviorBreeder() const cBehaviorAttacker * cMonster::GetBehaviorAttacker() { - return nullptr; -} - - - - - -cBehaviorDayLightBurner * cMonster::GetBehaviorDayLightBurner() -{ - return nullptr; + return m_BehaviorAttackerPointer; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index f97cd3e3f..1ed443aad 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -200,10 +200,11 @@ public: bool IsPathFinderActivated() const; // Behavior getters (most are probably not used. mobTodo - cleanup most of them) - virtual cBehaviorBreeder * GetBehaviorBreeder(); - virtual const cBehaviorBreeder * GetBehaviorBreeder() const; - virtual cBehaviorAttacker * GetBehaviorAttacker(); - virtual cBehaviorDayLightBurner * GetBehaviorDayLightBurner(); // mobTodo this is probably temporary + cBehaviorBreeder * GetBehaviorBreeder(); + const cBehaviorBreeder * GetBehaviorBreeder() const; + cBehaviorAttacker * GetBehaviorAttacker();\ + cBehaviorBreeder * m_BehaviorBreederPointer; + cBehaviorAttacker * m_BehaviorAttackerPointer; // Polymorphic behavior functions virtual void InheritFromParents(cMonster * a_Parent1, cMonster * a_Parent2); diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 7a1feefcb..91baaee66 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -78,21 +78,3 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player) } break; } } - - - - - -cBehaviorBreeder * cMooshroom::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cMooshroom::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index fa92c770f..06e5cf8ce 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -28,9 +28,6 @@ public: { a_Items.Add(E_ITEM_WHEAT); } - - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp deleted file mode 100644 index 28f45994c..000000000 --- a/src/Mobs/PassiveAggressiveMonster.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "PassiveAggressiveMonster.h" - -#include "../Entities/Player.h" - - - - - -cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : - super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height) -{ - m_EMPersonality = PASSIVE; -} diff --git a/src/Mobs/PassiveAggressiveMonster.h b/src/Mobs/PassiveAggressiveMonster.h deleted file mode 100644 index 8a45bcfb1..000000000 --- a/src/Mobs/PassiveAggressiveMonster.h +++ /dev/null @@ -1,21 +0,0 @@ - -#pragma once - -#include "AggressiveMonster.h" - - - - - -class cPassiveAggressiveMonster : - public cAggressiveMonster -{ - typedef cAggressiveMonster super; - -public: - cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); -} ; - - - - diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 6c3de4427..ce5e9dca0 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -131,24 +131,3 @@ bool cPig::DoTakeDamage(TakeDamageInfo & a_TDI) } return true; } - - - - - -cBehaviorBreeder * cPig::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cPig::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} - - - diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 276ac1df8..9a138f83e 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -30,8 +30,6 @@ public: } bool IsSaddled(void) const { return m_bIsSaddled; } - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp index 070396ded..0be458e3b 100644 --- a/src/Mobs/Rabbit.cpp +++ b/src/Mobs/Rabbit.cpp @@ -49,21 +49,3 @@ void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer) RareDrops.Add(cItem(E_ITEM_RABBITS_FOOT)); AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); } - - - - - -cBehaviorBreeder * cRabbit::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cRabbit::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h index 89760cd7c..119ba280b 100644 --- a/src/Mobs/Rabbit.h +++ b/src/Mobs/Rabbit.h @@ -46,9 +46,6 @@ public: eRabbitType GetRabbitType() const { return m_Type; } int GetMoreCarrotTicks() const { return m_MoreCarrotTicks; } - - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index cca3b944f..bd69db6c2 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -209,21 +209,3 @@ NIBBLETYPE cSheep::GenerateNaturalRandomColor(void) return E_META_WOOL_PINK; } } - - - - - -cBehaviorBreeder * cSheep::GetBehaviorBreeder() -{ - return &m_BehaviorBreeder; -} - - - - - -const cBehaviorBreeder * cSheep::GetBehaviorBreeder() const -{ - return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder); -} diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 8ed91915e..89fa41edf 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -43,8 +43,6 @@ public: int GetFurColor(void) const { return m_WoolColor; } void SetFurColor(int a_WoolColor) { m_WoolColor = a_WoolColor; } - virtual cBehaviorBreeder * GetBehaviorBreeder() override; - virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: // Tick controlling behaviors diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h index 9988ca015..20b75474d 100644 --- a/src/Mobs/Silverfish.h +++ b/src/Mobs/Silverfish.h @@ -1,24 +1,24 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cSilverfish : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cSilverfish(void) : - super("Silverfish", mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.7) - { - } + cSilverfish(void) : + super("Silverfish", mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.7) + { + } - CLASS_PROTODEF(cSilverfish) + CLASS_PROTODEF(cSilverfish) } ; diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 55616cc28..15be6c790 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -10,10 +10,10 @@ cSkeleton::cSkeleton(bool IsWither) : - super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", 0.6, 1.8), - m_bIsWither(IsWither) + super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", 0.6, 1.8), + m_bIsWither(IsWither) { - + m_EMPersonality = AGGRESSIVE; } @@ -22,26 +22,26 @@ cSkeleton::cSkeleton(bool IsWither) : void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - unsigned int LootingLevel = 0; - if (a_Killer != nullptr) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - if (IsWither()) - { - AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL); - cItems RareDrops; - RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1)); - AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); - } - else - { - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW); - - } - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE); - AddRandomArmorDropItem(a_Drops, LootingLevel); - AddRandomWeaponDropItem(a_Drops, LootingLevel); + unsigned int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + if (IsWither()) + { + AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL); + cItems RareDrops; + RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1)); + AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); + } + else + { + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW); + + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE); + AddRandomArmorDropItem(a_Drops, LootingLevel); + AddRandomWeaponDropItem(a_Drops, LootingLevel); } @@ -50,25 +50,25 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) //mobTodo /*bool cSkeleton::Attack(std::chrono::milliseconds a_Dt) { - StopMovingToPosition(); // Todo handle this in a better way, the skeleton does some uneeded recalcs due to inStateChasing - auto & Random = GetRandomProvider(); - if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) - { - Vector3d Inaccuracy = Vector3d(Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25)); - Vector3d Speed = (GetTarget()->GetPosition() + Inaccuracy - GetPosition()) * 5; - Speed.y += Random.RandInt(-1, 1); - - auto Arrow = cpp14::make_unique<cArrowEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); - auto ArrowPtr = Arrow.get(); - if (!ArrowPtr->Initialize(std::move(Arrow), *m_World)) - { - return false; - } - - ResetAttackCooldown(); - return true; - } - return false; + StopMovingToPosition(); // Todo handle this in a better way, the skeleton does some uneeded recalcs due to inStateChasing + auto & Random = GetRandomProvider(); + if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0)) + { + Vector3d Inaccuracy = Vector3d(Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25)); + Vector3d Speed = (GetTarget()->GetPosition() + Inaccuracy - GetPosition()) * 5; + Speed.y += Random.RandInt(-1, 1); + + auto Arrow = cpp14::make_unique<cArrowEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); + auto ArrowPtr = Arrow.get(); + if (!ArrowPtr->Initialize(std::move(Arrow), *m_World)) + { + return false; + } + + ResetAttackCooldown(); + return true; + } + return false; }*/ @@ -77,8 +77,8 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle) { - super::SpawnOn(a_ClientHandle); - a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); + super::SpawnOn(a_ClientHandle); + a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); } diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 91e094c4c..56e7339e0 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -1,33 +1,33 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cSkeleton : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cSkeleton(bool IsWither); + cSkeleton(bool IsWither); - CLASS_PROTODEF(cSkeleton) + CLASS_PROTODEF(cSkeleton) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - /*virtual bool Attack(std::chrono::milliseconds a_Dt) override;*/ - virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + /*virtual bool Attack(std::chrono::milliseconds a_Dt) override;*/ + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - virtual bool IsUndead(void) override { return true; } + virtual bool IsUndead(void) override { return true; } - bool IsWither(void) const { return m_bIsWither; } + bool IsWither(void) const { return m_bIsWither; } private: - bool m_bIsWither; + bool m_bIsWither; } ; diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 92c181798..d5409ec11 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -19,6 +19,7 @@ cSlime::cSlime(int a_Size) : ), m_Size(a_Size) { + m_EMPersonality = AGGRESSIVE; SetMaxHealth(a_Size * a_Size); // SetAttackDamage(a_Size); //mobTodo myBehavior.setaTTACKDamage } diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 26bc6716d..f4f1aabd4 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -1,39 +1,38 @@ - #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cSlime : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ - cSlime(int a_Size); + /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ + cSlime(int a_Size); - CLASS_PROTODEF(cSlime) + CLASS_PROTODEF(cSlime) - // cAggressiveMonster overrides: - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - // virtual bool Attack(std::chrono::milliseconds a_Dt) override; - virtual void KilledBy(TakeDamageInfo & a_TDI) override; + // cAggressiveMonster overrides: + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + // virtual bool Attack(std::chrono::milliseconds a_Dt) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; - int GetSize(void) const { return m_Size; } + int GetSize(void) const { return m_Size; } - /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds. - Returns either "big" or "small". */ - static AString GetSizeName(int a_Size); + /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds. + Returns either "big" or "small". */ + static AString GetSizeName(int a_Size); protected: - /** Size of the slime, with 1 being the smallest. - Vanilla uses sizes 1, 2 and 4 only. */ - int m_Size; + /** Size of the slime, with 1 being the smallest. + Vanilla uses sizes 1, 2 and 4 only. */ + int m_Size; } ; diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index c86577a1e..fd8ce1112 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -11,6 +11,7 @@ cSnowGolem::cSnowGolem(void) : super("SnowGolem", mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", 0.4, 1.8) { + m_EMPersonality = PASSIVE; } diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h index 708ddbef9..59026b3ec 100644 --- a/src/Mobs/SnowGolem.h +++ b/src/Mobs/SnowGolem.h @@ -1,16 +1,16 @@ #pragma once -#include "PassiveAggressiveMonster.h" +#include "Monster.h" class cSnowGolem : - public cPassiveAggressiveMonster + public cMonster { - typedef cPassiveAggressiveMonster super; + typedef cMonster super; public: cSnowGolem(void); diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp index 608bcd853..e8d65157c 100644 --- a/src/Mobs/Spider.cpp +++ b/src/Mobs/Spider.cpp @@ -11,6 +11,7 @@ cSpider::cSpider(void) : super("Spider", mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h index 296c9f261..de2c8d533 100644 --- a/src/Mobs/Spider.h +++ b/src/Mobs/Spider.h @@ -1,24 +1,24 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cSpider : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: - cSpider(void); + cSpider(void); - CLASS_PROTODEF(cSpider) + CLASS_PROTODEF(cSpider) - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; } ; diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp index 3f56108ae..e9baf5512 100644 --- a/src/Mobs/Witch.cpp +++ b/src/Mobs/Witch.cpp @@ -11,6 +11,7 @@ cWitch::cWitch(void) : super("Witch", mtWitch, "entity.witch.hurt", "entity.witch.death", 0.6, 1.8) { + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h index 79cc993bc..7013f998a 100644 --- a/src/Mobs/Witch.h +++ b/src/Mobs/Witch.h @@ -1,16 +1,16 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cWitch : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: cWitch(); diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index dd85d7d2b..99b9a3ce8 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -16,6 +16,7 @@ cWither::cWither(void) : { SetMaxHealth(300); SetHealth(GetMaxHealth() / 3); + m_EMPersonality = AGGRESSIVE; } diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 5f6ec607c..023fc773c 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -1,16 +1,16 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" class cWither : - public cAggressiveMonster + public cMonster { - typedef cAggressiveMonster super; + typedef cMonster super; public: cWither(void); diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index f57832c92..c08e572fb 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -22,6 +22,7 @@ cWolf::cWolf(void) : m_NotificationCooldown(0) { m_RelativeWalkSpeed = 2; + m_EMPersonality = PASSIVE; } diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index 851cf888b..515cd33e8 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -1,7 +1,7 @@ #pragma once -#include "PassiveAggressiveMonster.h" +#include "Monster.h" #include "../UUID.h" diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index 6f889e182..4f616c609 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -10,11 +10,18 @@ cZombie::cZombie(bool a_IsVillagerZombie) : - super("Zombie", mtZombie, "entity.zombie.hurt", "entity.zombie.death", 0.6, 1.8), - m_IsVillagerZombie(a_IsVillagerZombie), - m_IsConverting(false) + super("Zombie", mtZombie, "entity.zombie.hurt", "entity.zombie.death", 0.6, 1.8), + m_IsVillagerZombie(a_IsVillagerZombie), + m_IsConverting(false) { - + m_EMPersonality = AGGRESSIVE; + + m_BehaviorAttackerMelee.AttachToMonster(*this); + m_BehaviorWanderer.AttachToMonster(*this); + m_BehaviorAggressive.AttachToMonster(*this); + m_BehaviourDayLightBurner.AttachToMonster(*this); + GetMonsterConfig("Zombie"); + // Todo I need the config to load after attaching attackerMelee but this is not clean. } @@ -23,17 +30,17 @@ cZombie::cZombie(bool a_IsVillagerZombie) : void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - unsigned int LootingLevel = 0; - if (a_Killer != nullptr) - { - LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); - } - AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH); - cItems RareDrops; - RareDrops.Add(cItem(E_ITEM_IRON)); - RareDrops.Add(cItem(E_ITEM_CARROT)); - RareDrops.Add(cItem(E_ITEM_POTATO)); - AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); - AddRandomArmorDropItem(a_Drops, LootingLevel); - AddRandomWeaponDropItem(a_Drops, LootingLevel); + unsigned int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH); + cItems RareDrops; + RareDrops.Add(cItem(E_ITEM_IRON)); + RareDrops.Add(cItem(E_ITEM_CARROT)); + RareDrops.Add(cItem(E_ITEM_POTATO)); + AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); + AddRandomArmorDropItem(a_Drops, LootingLevel); + AddRandomWeaponDropItem(a_Drops, LootingLevel); } diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 66b6b6362..1bb2ebd45 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -1,7 +1,12 @@ #pragma once -#include "AggressiveMonster.h" +#include "Monster.h" +#include "Behaviors/BehaviorAttackerMelee.h" +#include "Behaviors/BehaviorWanderer.h" + +#include "Behaviors/BehaviorAggressive.h" +#include "Behaviors/BehaviorDayLightBurner.h" @@ -21,12 +26,18 @@ public: bool IsVillagerZombie(void) const { return m_IsVillagerZombie; } bool IsConverting (void) const { return m_IsConverting; } - private: bool m_IsVillagerZombie; bool m_IsConverting; + // tick behaviors + cBehaviorAttackerMelee m_BehaviorAttackerMelee; + cBehaviorWanderer m_BehaviorWanderer; + + // other behaviors + cBehaviorAggressive m_BehaviorAggressive; + cBehaviorDayLightBurner m_BehaviourDayLightBurner; } ; diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp index 2581d3751..07dbf4aa0 100644 --- a/src/Mobs/ZombiePigman.cpp +++ b/src/Mobs/ZombiePigman.cpp @@ -11,6 +11,7 @@ cZombiePigman::cZombiePigman(void) : super("ZombiePigman", mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8) { + m_EMPersonality = PASSIVE; } diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index 23a7be8da..dad420da7 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -1,15 +1,15 @@ #pragma once -#include "PassiveAggressiveMonster.h" +#include "Monster.h" class cZombiePigman : - public cPassiveAggressiveMonster + public cMonster { - typedef cPassiveAggressiveMonster super; + typedef cMonster super; public: cZombiePigman(void); |