mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-07 03:16:55 +08:00
Move monster speed to monsters.ini (#4500)
* Add walking and running speed to monsters.ini * Add entry to CONTRIBUTORS * Add SetRelativeRunSpeed to APIDesc.lua * Fix typo * Remove unnecessary cast Co-Authored-By: peterbell10 <peterbell10@live.co.uk> * Use relative walk speed as a modifier to base walk and run speeds * Rename Default to Base in Walk/Run Speeds * Update docs. --------- Co-authored-by: peterbell10 <peterbell10@live.co.uk> Co-authored-by: Alexander Harkness <me@bearbin.net>
This commit is contained in:
parent
44cb43f13c
commit
5e258c6d95
@ -9,6 +9,7 @@ as provided in the LICENSE file.
|
||||
9caihezi
|
||||
AirOne01
|
||||
Altenius
|
||||
anguslmm (Angus McLean)
|
||||
ashquarky
|
||||
BasedDoge (Donated AlchemistVillage prefabs)
|
||||
bearbin (Alexander Harkness)
|
||||
|
@ -9240,7 +9240,7 @@ a_Player:OpenWindow(Window);
|
||||
Type = "number",
|
||||
},
|
||||
},
|
||||
Notes = "Returns the relative walk speed of this mob. Standard is 1.0",
|
||||
Notes = "Returns the walk speed multiplier of this mob. Base is set in monsters.ini (will default to 1 if not set).",
|
||||
},
|
||||
HasCustomName =
|
||||
{
|
||||
@ -9404,7 +9404,7 @@ a_Player:OpenWindow(Window);
|
||||
Type = "number",
|
||||
},
|
||||
},
|
||||
Notes = "Sets the relative walk speed of this mob. The default relative speed is 1.0.",
|
||||
Notes = "Sets the walk speed multiplier of this mob. Base is set in monsters.ini (will default to 1 if not set).",
|
||||
},
|
||||
StringToMobType =
|
||||
{
|
||||
|
@ -175,6 +175,8 @@ AttackRange=1.0
|
||||
AttackRate=1.0
|
||||
MaxHealth=16
|
||||
SightDistance=25.0
|
||||
WalkSpeed=1.0
|
||||
RunSpeed=1.3
|
||||
|
||||
[Squid]
|
||||
AttackDamage=0.0
|
||||
@ -211,6 +213,7 @@ AttackRange=1.0
|
||||
AttackRate=1.0
|
||||
MaxHealth=20
|
||||
SightDistance=25.0
|
||||
WalkSpeed=2.0
|
||||
|
||||
[Zombie]
|
||||
AttackDamage=4.0
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -20,7 +20,6 @@ cWolf::cWolf(void) :
|
||||
m_CollarColor(E_META_DYE_ORANGE),
|
||||
m_NotificationCooldown(0)
|
||||
{
|
||||
m_RelativeWalkSpeed = 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user