Improvements to blaze and ghast (#4547)
This commit is contained in:
+73
-13
@@ -9,8 +9,13 @@
|
||||
|
||||
|
||||
cGhast::cGhast(void) :
|
||||
super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", "entity.ghast.ambient", 4, 4)
|
||||
super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", "entity.ghast.ambient", 4, 4),
|
||||
m_IsCharging(false),
|
||||
m_FlightCooldown(5),
|
||||
m_TicksUntilShot(10)
|
||||
{
|
||||
SetGravity(0);
|
||||
SetAirDrag(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,20 +39,14 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
bool cGhast::Attack(std::chrono::milliseconds a_Dt)
|
||||
{
|
||||
if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0))
|
||||
if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0) && (!m_IsCharging))
|
||||
{
|
||||
// Setting this higher gives us more wiggle room for attackrate
|
||||
Vector3d Speed = GetLookVector() * 20;
|
||||
Speed.y = Speed.y + 1;
|
||||
auto & Random = GetRandomProvider();
|
||||
auto SoundPitchMultiplier = 1.0f + (Random.RandReal(1.0f) - Random.RandReal(1.0f)) * 0.2f;
|
||||
|
||||
auto GhastBall = cpp14::make_unique<cGhastFireballEntity>(this, GetPosition().addedY(1), Speed);
|
||||
auto GhastBallPtr = GhastBall.get();
|
||||
if (!GhastBallPtr->Initialize(std::move(GhastBall), *m_World))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ResetAttackCooldown();
|
||||
m_World->BroadcastSoundEffect("entity.ghast.warn", GetPosition(), 4.0f, SoundPitchMultiplier * 0.9f);
|
||||
m_IsCharging = true;
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -55,3 +54,64 @@ bool cGhast::Attack(std::chrono::milliseconds a_Dt)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cGhast::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
// No fall damage
|
||||
if (a_TDI.DamageType == dtFalling)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return super::DoTakeDamage(a_TDI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cGhast::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
super::Tick(a_Dt, a_Chunk);
|
||||
if (!IsTicking())
|
||||
{
|
||||
// The base class tick destroyed us
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_IsCharging) && (m_TicksUntilShot-- == 0))
|
||||
{
|
||||
m_TicksUntilShot = 10;
|
||||
m_IsCharging = false;
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
|
||||
Vector3d Speed = GetLookVector() * 20;
|
||||
Speed.y = Speed.y + 1;
|
||||
|
||||
auto GhastBall = cpp14::make_unique<cGhastFireballEntity>(this, GetPosition(), Speed);
|
||||
auto GhastBallPtr = GhastBall.get();
|
||||
GhastBallPtr->Initialize(std::move(GhastBall), *m_World);
|
||||
|
||||
m_World->BroadcastSoundEffect("entity.ghast.shoot", GetPosition(), 4.0f, 1.0f);
|
||||
|
||||
ResetAttackCooldown();
|
||||
}
|
||||
|
||||
// TODO: Better flying
|
||||
if (m_FlightCooldown-- == 0)
|
||||
{
|
||||
m_FlightCooldown = 5;
|
||||
auto & Random = GetRandomProvider();
|
||||
auto SpeedVector = Vector3d(Random.RandReal(-0.3, 0.3), Random.RandReal(-0.4, 0.4), Random.RandReal(-0.3, 0.3));
|
||||
|
||||
if (GetPosY() > 120)
|
||||
{
|
||||
SpeedVector = Vector3d(Random.RandReal(-0.4, 0.4), Random.RandReal(-0.45, 0.4), Random.RandReal(-0.4, 0.4));
|
||||
}
|
||||
|
||||
AddSpeed(SpeedVector);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user