commit
b135ab8b95
@ -115,7 +115,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
|||||||
Damage += ExtraDamage;
|
Damage += ExtraDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KnockbackAmount = 1;
|
// int KnockbackAmount = 1;
|
||||||
int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
|
int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
|
||||||
if (PunchLevel > 0)
|
if (PunchLevel > 0)
|
||||||
{
|
{
|
||||||
@ -130,7 +130,8 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
|||||||
a_EntityHit.SetSpeed(FinalSpeed);
|
a_EntityHit.SetSpeed(FinalSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);
|
// a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount); // TODO fix knockback.
|
||||||
|
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 0); // Until knockback is fixed.
|
||||||
|
|
||||||
if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
|
if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
|
||||||
{
|
{
|
||||||
|
@ -80,9 +80,10 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
Vector3d AttackDirection(m_Target->GetPosition() + Vector3d(0, m_Target->GetHeight(), 0) - MyHeadPosition);
|
Vector3d AttackDirection(m_Target->GetPosition() + Vector3d(0, m_Target->GetHeight(), 0) - MyHeadPosition);
|
||||||
|
|
||||||
|
|
||||||
if (ReachedFinalDestination() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())))
|
if (TargetIsInRange() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())))
|
||||||
{
|
{
|
||||||
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
|
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
|
||||||
|
StopMovingToPosition();
|
||||||
Attack(a_Dt);
|
Attack(a_Dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,8 +517,15 @@ void cMonster::SetPitchAndYawFromDestination()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Vector3d BodyDistance;
|
||||||
Vector3d BodyDistance = m_NextWayPointPosition - GetPosition();
|
if (!m_IsFollowingPath && (m_Target != nullptr))
|
||||||
|
{
|
||||||
|
BodyDistance = m_Target->GetPosition() - GetPosition();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BodyDistance = m_NextWayPointPosition - GetPosition();
|
||||||
|
}
|
||||||
double BodyRotation, BodyPitch;
|
double BodyRotation, BodyPitch;
|
||||||
BodyDistance.Normalize();
|
BodyDistance.Normalize();
|
||||||
VectorToEuler(BodyDistance.x, BodyDistance.y, BodyDistance.z, BodyRotation, BodyPitch);
|
VectorToEuler(BodyDistance.x, BodyDistance.y, BodyDistance.z, BodyRotation, BodyPitch);
|
||||||
|
@ -193,13 +193,16 @@ protected:
|
|||||||
If no suitable position is found, returns cChunkDef::Height. */
|
If no suitable position is found, returns cChunkDef::Height. */
|
||||||
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ);
|
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ);
|
||||||
|
|
||||||
/** Returns if the ultimate, final destination has been reached */
|
/** Returns if the ultimate, final destination has been reached. */
|
||||||
bool ReachedFinalDestination(void) { return ((m_FinalDestination - GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); }
|
bool ReachedFinalDestination(void) { return ((m_FinalDestination - GetPosition()).Length() < GetWidth()/2); }
|
||||||
|
|
||||||
|
/** Returns whether or not the target is close enough for attack. */
|
||||||
|
bool TargetIsInRange(void) { return ((m_FinalDestination - GetPosition()).SqrLength() < (m_AttackRange * m_AttackRange)); }
|
||||||
|
|
||||||
/** Returns if the intermediate waypoint of m_NextWayPointPosition has been reached */
|
/** Returns if the intermediate waypoint of m_NextWayPointPosition has been reached */
|
||||||
bool ReachedNextWaypoint(void) { return ((m_NextWayPointPosition - GetPosition()).SqrLength() < 0.25); }
|
bool ReachedNextWaypoint(void) { return ((m_NextWayPointPosition - GetPosition()).SqrLength() < 0.25); }
|
||||||
|
|
||||||
/** Returns if a monster can reach a given height by jumping */
|
/** Returns if a monster can reach a given height by jumping. */
|
||||||
inline bool DoesPosYRequireJump(int a_PosY)
|
inline bool DoesPosYRequireJump(int a_PosY)
|
||||||
{
|
{
|
||||||
return ((a_PosY > POSY_TOINT) && (a_PosY == POSY_TOINT + 1));
|
return ((a_PosY > POSY_TOINT) && (a_PosY == POSY_TOINT + 1));
|
||||||
|
@ -50,12 +50,13 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
|||||||
|
|
||||||
void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
|
void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
|
||||||
{
|
{
|
||||||
|
cFastRandom Random;
|
||||||
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
|
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
|
||||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
// Setting this higher gives us more wiggle room for attackrate
|
Vector3d Inaccuracy = Vector3d(Random.NextFloat(0.5) - 0.25, Random.NextFloat(0.5) - 0.25, Random.NextFloat(0.5) - 0.25);
|
||||||
Vector3d Speed = GetLookVector() * 20;
|
Vector3d Speed = (m_Target->GetPosition() + Inaccuracy - GetPosition()) * 5;
|
||||||
Speed.y = Speed.y + 1;
|
Speed.y = Speed.y - 1 + Random.NextInt(3);
|
||||||
cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
|
cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
|
||||||
if (Arrow == nullptr)
|
if (Arrow == nullptr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user