This commit is contained in:
GabsPuNs
2026-05-14 21:52:21 -04:00
parent 1b2f5c6fe8
commit f8a2d644f5
291 changed files with 7363 additions and 18368 deletions

View File

@@ -90,7 +90,9 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
{
#ifndef _FINAL_BUILD
if(app.GetMobsDontAttackEnabled())
{
return shared_ptr<Player>();
}
#endif
shared_ptr<Player> player = level->getNearestAttackablePlayer(shared_from_this(), 64);
@@ -99,8 +101,7 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
if (isLookingAtMe(player))
{
aggroedByPlayer = true;
if (aggroTime == 0)
level->playEntitySound(player, eSoundType_MOB_ENDERMAN_STARE, 1, 1);
if (aggroTime == 0) level->playEntitySound(player, eSoundType_MOB_ENDERMAN_STARE, 1, 1);
if (aggroTime++ == 5)
{
aggroTime = 0;
@@ -109,7 +110,9 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
}
}
else
{
aggroTime = 0;
}
}
return nullptr;
}
@@ -117,8 +120,7 @@ shared_ptr<Entity> EnderMan::findAttackTarget()
bool EnderMan::isLookingAtMe(shared_ptr<Player> player)
{
shared_ptr<ItemInstance> helmet = player->inventory->armor[3];
if (helmet != nullptr && helmet->id == Tile::pumpkin_Id)
return false;
if (helmet != nullptr && helmet->id == Tile::pumpkin_Id) return false;
Vec3 *look = player->getViewVector(1)->normalize();
Vec3 *dir = Vec3::newTemp(x - player->x, (bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()), z - player->z);
@@ -126,8 +128,9 @@ bool EnderMan::isLookingAtMe(shared_ptr<Player> player)
dir = dir->normalize();
double dot = look->dot(dir);
if (dot > 1 - 0.025 / dist)
{
return player->canSee(shared_from_this());
}
return false;
}
@@ -141,7 +144,9 @@ void EnderMan::aiStep()
speed->removeModifier(SPEED_MODIFIER_ATTACKING);
if (attackTarget != nullptr)
{
speed->addModifier(new AttributeModifier(*SPEED_MODIFIER_ATTACKING));
}
}
lastAttackTarget = attackTarget;
@@ -185,6 +190,7 @@ void EnderMan::aiStep()
}
}
for (int i = 0; i < 2; i++)
{
level->addParticle(eParticleType_ender, x + (random->nextDouble() - 0.5) * bbWidth, y + random->nextDouble() * bbHeight - 0.25f, z + (random->nextDouble() - 0.5) * bbWidth,
@@ -215,11 +221,15 @@ void EnderMan::aiStep()
}
if (isCreepy() && !aggroedByPlayer && random->nextInt(100) == 0)
{
setCreepy(false);
}
jumping = false;
if (attackTarget != nullptr)
{
lookAt(attackTarget, 100, 100);
}
if (!level->isClientSide && isAlive())
{
@@ -228,8 +238,9 @@ void EnderMan::aiStep()
if ( attackTarget->instanceof(eTYPE_PLAYER) && isLookingAtMe(dynamic_pointer_cast<Player>(attackTarget)))
{
if (attackTarget->distanceToSqr(shared_from_this()) < 4 * 4)
{
teleport();
}
teleportTime = 0;
}
else if (attackTarget->distanceToSqr(shared_from_this()) > 16 * 16)
@@ -237,7 +248,9 @@ void EnderMan::aiStep()
if (teleportTime++ >= 30)
{
if (teleportTowards(attackTarget))
{
teleportTime = 0;
}
}
}
}
@@ -296,16 +309,21 @@ bool EnderMan::teleport(double xx, double yy, double zz)
yt--;
}
else
{
landed = true;
}
}
if (landed)
{
setPos(x, y, z);
if (level->getCubes(shared_from_this(), bb)->empty() && !level->containsAnyLiquid(bb))
{
ok = true;
}
}
}
if (ok)
{
int count = 128;
@@ -393,17 +411,22 @@ bool EnderMan::hurt(DamageSource *source, float damage)
if ( dynamic_cast<EntityDamageSource *>(source) != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER))
{
if (!dynamic_pointer_cast<Player>(source->getEntity())->abilities.invulnerable)
{
aggroedByPlayer = true;
}
else setCreepy(false);
}
if (dynamic_cast<IndirectEntityDamageSource *>(source) != nullptr)
{
aggroedByPlayer = false;
for (int i = 0; i < 64; i++)
{
if (teleport())
{
return true;
}
}
return false;
}
@@ -418,10 +441,4 @@ bool EnderMan::isCreepy()
void EnderMan::setCreepy(bool creepy)
{
entityData->set(DATA_CREEPY, static_cast<BYTE>(creepy ? 1 : 0));
}
// TU25 Addition
float EnderMan::getEyeHeight()
{
return 2.55f;
}