diff options
author | Angus <anguslmm@gmail.com> | 2024-11-10 12:28:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-10 12:28:39 +0100 |
commit | 5e258c6d95a22664e1f9bfa8e778e007e69b4ef2 (patch) | |
tree | ea9e9a5dbc28af2607223cba64e5762d80c7669b /src | |
parent | Fix Block Entity Placement in Generation (#5060) (diff) | |
download | cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar.gz cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar.bz2 cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar.lz cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar.xz cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.tar.zst cuberite-5e258c6d95a22664e1f9bfa8e778e007e69b4ef2.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Mobs/Monster.cpp | 14 | ||||
-rw-r--r-- | src/Mobs/Monster.h | 7 | ||||
-rw-r--r-- | src/Mobs/Wolf.cpp | 1 | ||||
-rw-r--r-- | src/MonsterConfig.cpp | 9 |
4 files changed, 25 insertions, 6 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 788d1b66f..d14746513 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -227,8 +227,18 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk) // Don't let the mob move too much if he's falling. Distance *= 0.25f; } - // Apply walk speed: - Distance *= m_RelativeWalkSpeed; + + if ((m_EMState == CHASING) || (m_EMState == ESCAPING)) + { + // Apply run speed: + Distance *= m_BaseRunSpeed * m_RelativeWalkSpeed; + } + else + { + // Apply walk speed: + Distance *= m_BaseWalkSpeed * m_RelativeWalkSpeed; + } + /* Reduced default speed. Close to Vanilla, easier for mobs to follow m_NextWayPointPositions, hence better pathfinding. */ diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 0127ec4ce..24a1d189f 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -146,7 +146,10 @@ public: bool BurnsInDaylight() const { return m_BurnsInDaylight; } // tolua_export double GetRelativeWalkSpeed(void) const { return m_RelativeWalkSpeed; } // tolua_export - void SetRelativeWalkSpeed(double a_WalkSpeed) { m_RelativeWalkSpeed = a_WalkSpeed; } // tolua_export + void SetRelativeWalkSpeed(double a_Speed) { m_RelativeWalkSpeed = a_Speed; } // tolua_export + + void SetBaseWalkSpeed(double a_Speed) { m_BaseWalkSpeed = a_Speed; } + void SetBaseRunSpeed(double a_Speed) { m_BaseRunSpeed = a_Speed; } // Overridables to handle ageable mobs virtual bool IsTame (void) const { return false; } @@ -326,6 +329,8 @@ protected: bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk); bool m_BurnsInDaylight; double m_RelativeWalkSpeed; + double m_BaseWalkSpeed; + double m_BaseRunSpeed; int m_AmbientSoundTimer; diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 553ca1c73..edcb54075 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -20,7 +20,6 @@ cWolf::cWolf(void) : m_CollarColor(E_META_DYE_ORANGE), m_NotificationCooldown(0) { - m_RelativeWalkSpeed = 2; } diff --git a/src/MonsterConfig.cpp b/src/MonsterConfig.cpp index 271a72a7f..2ee7e7393 100644 --- a/src/MonsterConfig.cpp +++ b/src/MonsterConfig.cpp @@ -17,6 +17,8 @@ struct cMonsterConfig::sAttributesStruct double m_AttackRange; double m_AttackRate; double m_MaxHealth; + double m_BaseWalkSpeed; + double m_BaseRunSpeed; bool m_IsFireproof; bool m_BurnsInDaylight; }; @@ -71,10 +73,12 @@ void cMonsterConfig::Initialize() AString Name = MonstersIniFile.GetKeyName(i); Attributes.m_Name = Name; Attributes.m_AttackDamage = MonstersIniFile.GetValueI(Name, "AttackDamage", 0); - Attributes.m_AttackRange = MonstersIniFile.GetValueF(Name, "AttackRange", 0); + Attributes.m_AttackRange = MonstersIniFile.GetValueI(Name, "AttackRange", 0); Attributes.m_SightDistance = MonstersIniFile.GetValueI(Name, "SightDistance", 0); Attributes.m_AttackRate = MonstersIniFile.GetValueF(Name, "AttackRate", 0); Attributes.m_MaxHealth = MonstersIniFile.GetValueF(Name, "MaxHealth", 1); + Attributes.m_BaseWalkSpeed = MonstersIniFile.GetValueF(Name, "WalkSpeed", 1); + Attributes.m_BaseRunSpeed = MonstersIniFile.GetValueF(Name, "RunSpeed", Attributes.m_BaseWalkSpeed); Attributes.m_IsFireproof = MonstersIniFile.GetValueB(Name, "IsFireproof", false); Attributes.m_BurnsInDaylight = MonstersIniFile.GetValueB(Name, "BurnsInDaylight", false); m_pState->AttributesList.push_front(Attributes); @@ -97,6 +101,8 @@ void cMonsterConfig::AssignAttributes(cMonster * a_Monster, const AString & a_Na a_Monster->SetSightDistance (itr->m_SightDistance); a_Monster->SetAttackRate (static_cast<float>(itr->m_AttackRate)); a_Monster->SetMaxHealth (static_cast<float>(itr->m_MaxHealth)); + a_Monster->SetBaseWalkSpeed (itr->m_BaseWalkSpeed); + a_Monster->SetBaseRunSpeed (itr->m_BaseRunSpeed); a_Monster->SetIsFireproof (itr->m_IsFireproof); a_Monster->SetBurnsInDaylight(itr->m_BurnsInDaylight); return; @@ -107,4 +113,3 @@ void cMonsterConfig::AssignAttributes(cMonster * a_Monster, const AString & a_Na - |