diff options
Diffstat (limited to '')
-rwxr-xr-x | compile.sh | 1 | ||||
-rw-r--r-- | src/Mobs/Behaviors/Behavior.h | 5 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorAggressive.h | 7 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorBreeder.cpp | 2 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorBreeder.h | 9 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorChaser.h | 3 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorCoward.cpp | 4 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorCoward.h | 5 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorDayLightBurner.h | 5 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorItemFollower.h | 8 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorItemReplacer.cpp | 40 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorItemReplacer.h | 26 | ||||
-rw-r--r-- | src/Mobs/Behaviors/BehaviorWanderer.h | 4 | ||||
-rw-r--r-- | src/Mobs/Behaviors/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Mobs/Cow.cpp | 21 | ||||
-rw-r--r-- | src/Mobs/Cow.h | 18 |
16 files changed, 90 insertions, 70 deletions
diff --git a/compile.sh b/compile.sh index 5076be7fe..ab36726a2 100755 --- a/compile.sh +++ b/compile.sh @@ -13,7 +13,6 @@ set -e # Constants: DEFAULT_BUILDTYPE="Release" # Other options: "Debug" DEFAULT_BRANCH="master" # Other options: None currently -DEFAULT_THREADS=2 # Constants not modifiable through command line: UPSTREAM_REPO="origin" diff --git a/src/Mobs/Behaviors/Behavior.h b/src/Mobs/Behaviors/Behavior.h index 1bfefbf8d..27833cc9b 100644 --- a/src/Mobs/Behaviors/Behavior.h +++ b/src/Mobs/Behaviors/Behavior.h @@ -4,6 +4,11 @@ struct TakeDamageInfo; class cChunk; class cPlayer; class cMonster; +class cPawn; +class cWorld; +class cItems; +class cEntity; +struct TakeDamageInfo; #include <chrono> class cBehavior diff --git a/src/Mobs/Behaviors/BehaviorAggressive.h b/src/Mobs/Behaviors/BehaviorAggressive.h index 8905b7341..88c226b27 100644 --- a/src/Mobs/Behaviors/BehaviorAggressive.h +++ b/src/Mobs/Behaviors/BehaviorAggressive.h @@ -4,15 +4,8 @@ class cBehaviorAggressive; #include "Behavior.h" - -class cPawn; -class cMonster; class cBehaviorChaser; - - - - /** The mob is agressive toward specific mobtypes, or toward the player. This Behavior has a dependency on BehaviorChaser. */ class cBehaviorAggressive : public cBehavior diff --git a/src/Mobs/Behaviors/BehaviorBreeder.cpp b/src/Mobs/Behaviors/BehaviorBreeder.cpp index 8d569ea03..d1d167b8b 100644 --- a/src/Mobs/Behaviors/BehaviorBreeder.cpp +++ b/src/Mobs/Behaviors/BehaviorBreeder.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "BehaviorBreeder.h" @@ -23,7 +22,6 @@ cBehaviorBreeder::cBehaviorBreeder() : void cBehaviorBreeder::AttachToMonster(cMonster & a_Parent) { - LOGD("mobDebug - Behavior Breeder: Attach"); m_Parent = &a_Parent; m_Parent->AttachTickBehavior(this); m_Parent->AttachPostTickBehavior(this); diff --git a/src/Mobs/Behaviors/BehaviorBreeder.h b/src/Mobs/Behaviors/BehaviorBreeder.h index 94830c42b..a3d0b51af 100644 --- a/src/Mobs/Behaviors/BehaviorBreeder.h +++ b/src/Mobs/Behaviors/BehaviorBreeder.h @@ -4,15 +4,6 @@ class cBehaviorBreeder; #include "Behavior.h" -class cWorld; -class cMonster; -class cPlayer; -class cItems; - - - - - /** Grants breeding capabilities to the mob. */ class cBehaviorBreeder : public cBehavior { diff --git a/src/Mobs/Behaviors/BehaviorChaser.h b/src/Mobs/Behaviors/BehaviorChaser.h index 1c64c7b07..20b60a921 100644 --- a/src/Mobs/Behaviors/BehaviorChaser.h +++ b/src/Mobs/Behaviors/BehaviorChaser.h @@ -3,9 +3,6 @@ class cBehaviorChaser; #include "Behavior.h" - -class cMonster; -class cPawn; class cBehaviorStriker; diff --git a/src/Mobs/Behaviors/BehaviorCoward.cpp b/src/Mobs/Behaviors/BehaviorCoward.cpp index 852a12e6c..c2c59a633 100644 --- a/src/Mobs/Behaviors/BehaviorCoward.cpp +++ b/src/Mobs/Behaviors/BehaviorCoward.cpp @@ -41,7 +41,7 @@ bool cBehaviorCoward::ControlStarting(std::chrono::milliseconds a_Dt, cChunk & a { UNUSED(a_Dt); UNUSED(a_Chunk); - m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() * 2); + m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() * 3); return true; } @@ -50,7 +50,7 @@ bool cBehaviorCoward::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a_C { UNUSED(a_Dt); UNUSED(a_Chunk); - m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() / 2); + m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() / 3); return true; } diff --git a/src/Mobs/Behaviors/BehaviorCoward.h b/src/Mobs/Behaviors/BehaviorCoward.h index d5ffa4312..9058419e3 100644 --- a/src/Mobs/Behaviors/BehaviorCoward.h +++ b/src/Mobs/Behaviors/BehaviorCoward.h @@ -4,11 +4,6 @@ // Makes the mob run away from any other mob that damages it -//fwds -class cMonster; -class cItems; -class cEntity; -struct TakeDamageInfo; class cBehaviorCoward : cBehavior { diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h index d1299c0c6..780827910 100644 --- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h +++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h @@ -4,11 +4,6 @@ #include "Behavior.h" #include "../../World.h" -// fwds -class cMonster; -class cEntity; -class cChunk; - class cBehaviorDayLightBurner : cBehavior { public: diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.h b/src/Mobs/Behaviors/BehaviorItemFollower.h index c84779a5e..a8160f537 100644 --- a/src/Mobs/Behaviors/BehaviorItemFollower.h +++ b/src/Mobs/Behaviors/BehaviorItemFollower.h @@ -5,20 +5,12 @@ class cBehaviorItemFollower; #include "Behavior.h" -// fwds -class cMonster; -class cItems; - class cBehaviorItemFollower : public cBehavior { public: void AttachToMonster(cMonster & a_Parent); - void GetBreedingItems(cItems & a_Items); - // Functions our host Monster should invoke: - bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; private: diff --git a/src/Mobs/Behaviors/BehaviorItemReplacer.cpp b/src/Mobs/Behaviors/BehaviorItemReplacer.cpp new file mode 100644 index 000000000..b53f08b33 --- /dev/null +++ b/src/Mobs/Behaviors/BehaviorItemReplacer.cpp @@ -0,0 +1,40 @@ +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "BehaviorItemReplacer.h" +#include "../Monster.h" +#include "../Entities/Player.h" + + +cBehaviorItemReplacer::cBehaviorItemReplacer(short a_OriginalItem, short a_NewItem) : + m_OriginalItem(a_OriginalItem) , + m_NewItem(a_NewItem) +{ + +} + + + + + +void cBehaviorItemReplacer::AttachToMonster(cMonster & a_Parent) +{ + m_Parent = &a_Parent; + m_Parent->AttachRightClickBehavior(this); +} + + + + + +void cBehaviorItemReplacer::OnRightClicked(cPlayer & a_Player) +{ + short HeldItem = a_Player.GetEquippedItem().m_ItemType; + if (HeldItem == m_OriginalItem) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + a_Player.GetInventory().AddItem(m_NewItem); + } + } +} diff --git a/src/Mobs/Behaviors/BehaviorItemReplacer.h b/src/Mobs/Behaviors/BehaviorItemReplacer.h new file mode 100644 index 000000000..e35729f0e --- /dev/null +++ b/src/Mobs/Behaviors/BehaviorItemReplacer.h @@ -0,0 +1,26 @@ +#pragma once + + +class cBehaviorItemReplacer; + +#include "Behavior.h" + +/** When right clicked while holding a_OriginalItem, a mob having this behavior replaces the original item +with a_NewItem. This is used for milking cows. +*/ +class cBehaviorItemReplacer : public cBehavior +{ + +public: + cBehaviorItemReplacer(short a_OriginalItem, short a_NewItem); + void AttachToMonster(cMonster & a_Parent); + void OnRightClicked(cPlayer & a_Player) override; +private: + // Our parent + cMonster * m_Parent; + short m_OriginalItem; // Replace this item with NewItem + short m_NewItem; +}; + + + diff --git a/src/Mobs/Behaviors/BehaviorWanderer.h b/src/Mobs/Behaviors/BehaviorWanderer.h index 577881c2f..c694eb331 100644 --- a/src/Mobs/Behaviors/BehaviorWanderer.h +++ b/src/Mobs/Behaviors/BehaviorWanderer.h @@ -4,10 +4,6 @@ #include <chrono> #include "Behavior.h" -class cMonster; -class cEntity; -class cChunk; - class cBehaviorWanderer : cBehavior { diff --git a/src/Mobs/Behaviors/CMakeLists.txt b/src/Mobs/Behaviors/CMakeLists.txt index 017fc0f35..68b4bf731 100644 --- a/src/Mobs/Behaviors/CMakeLists.txt +++ b/src/Mobs/Behaviors/CMakeLists.txt @@ -13,6 +13,7 @@ SET (SRCS BehaviorCoward.cpp BehaviorItemDropper.cpp BehaviorItemFollower.cpp + BehaviorItemReplacer.cpp BehaviorStriker.cpp BehaviorWanderer.cpp ) @@ -26,6 +27,7 @@ SET (HDRS BehaviorCoward.h BehaviorItemDropper.h BehaviorItemFollower.h + BehaviorItemReplacer.h BehaviorStriker.h BehaviorWanderer.h ) diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index d3208465a..f3c5c821b 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -6,13 +6,15 @@ -cCow::cCow(void) : super("Cow", mtCow, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3) +cCow::cCow(void) : + super("Cow", mtCow, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3), + m_BehaviorItemReplacer(E_ITEM_BUCKET, E_ITEM_MILK) { m_BehaviorBreeder.AttachToMonster(*this); m_BehaviorCoward.AttachToMonster(*this); m_BehaviorItemFollower.AttachToMonster(*this); m_BehaviorWanderer.AttachToMonster(*this); - // mobTodo Behavior itemReplacer for the bucket + m_BehaviorItemReplacer.AttachToMonster(*this); } @@ -34,22 +36,7 @@ void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) -/* - * mobTodo behavior iTemReplacer - * void cCow::OnRightClicked(cPlayer & a_Player) -{ - super::OnRightClicked(a_Player); - short HeldItem = a_Player.GetEquippedItem().m_ItemType; - if (HeldItem == E_ITEM_BUCKET) - { - if (!a_Player.IsGameModeCreative()) - { - a_Player.GetInventory().RemoveOneEquippedItem(); - a_Player.GetInventory().AddItem(E_ITEM_MILK); - } - } -}*/ diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index 8f79e630f..b12da9030 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -1,16 +1,17 @@ - #pragma once -#include "PassiveMonster.h" - - - - +#include "Behaviors/BehaviorBreeder.h" +#include "Behaviors/BehaviorItemFollower.h" +#include "Behaviors/BehaviorItemReplacer.h" +#include "Behaviors/BehaviorCoward.h" +#include "Behaviors/BehaviorWanderer.h" +#include "Monster.h" class cCow : public cMonster { public: cCow(); + ~cCow() {} typedef cMonster super; CLASS_PROTODEF(cCow) @@ -25,11 +26,14 @@ public: virtual cBehaviorBreeder * GetBehaviorBreeder() override; virtual const cBehaviorBreeder * GetBehaviorBreeder() const override; private: + // Tick controlling behaviors cBehaviorBreeder m_BehaviorBreeder; cBehaviorItemFollower m_BehaviorItemFollower; cBehaviorCoward m_BehaviorCoward; - cBehaviorWanderer m_BehaviorWanderer; + cBehaviorItemReplacer m_BehaviorWanderer; + // Non tick controlling behaviors + cBehaviorWanderer m_BehaviorItemReplacer; } ; |