diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 21:00:29 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-22 21:00:29 +0200 |
commit | b414b33afab3a0df16c07211d9602a1eb596b10f (patch) | |
tree | 61f0fbab95e633b1e4293bdbd8fe66f200e6ea76 /src/Mobs/Monster.cpp | |
parent | d (diff) | |
download | cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar.gz cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar.bz2 cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar.lz cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar.xz cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.tar.zst cuberite-b414b33afab3a0df16c07211d9602a1eb596b10f.zip |
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r-- | src/Mobs/Monster.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 9afdce562..757a0d700 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -748,93 +748,6 @@ void cMonster::EventSeePlayer(cPlayer * a_SeenPlayer, cChunk & a_Chunk) void cMonster::EventLosePlayer(void) { SetTarget(nullptr); - m_EMState = IDLE; -} - - - - - -void cMonster::InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) -{ - if (m_PathfinderActivated) - { - return; // Still getting there - } - - m_IdleInterval += a_Dt; - - if (m_IdleInterval > std::chrono::seconds(1)) - { - auto & Random = GetRandomProvider(); - - // At this interval the results are predictable - int rem = Random.RandInt(1, 7); - m_IdleInterval -= std::chrono::seconds(1); // So nothing gets dropped when the server hangs for a few seconds - - Vector3d Dist; - Dist.x = static_cast<double>(Random.RandInt(-5, 5)); - Dist.z = static_cast<double>(Random.RandInt(-5, 5)); - - if ((Dist.SqrLength() > 2) && (rem >= 3)) - { - - Vector3d Destination(GetPosX() + Dist.x, GetPosition().y, GetPosZ() + Dist.z); - - cChunk * Chunk = a_Chunk.GetNeighborChunk(static_cast<int>(Destination.x), static_cast<int>(Destination.z)); - if ((Chunk == nullptr) || !Chunk->IsValid()) - { - return; - } - - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width; - int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width; - int YBelowUs = static_cast<int>(Destination.y) - 1; - if (YBelowUs >= 0) - { - Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta); - if (BlockType != E_BLOCK_STATIONARY_WATER) // Idle mobs shouldn't enter water on purpose - { - MoveToPosition(Destination); - } - } - } - } -} - - - - - -// What to do if in Chasing State -// This state should always be defined in each child class -void cMonster::InStateChasing(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) -{ - UNUSED(a_Dt); -} - - - - - -// What to do if in Escaping State -void cMonster::InStateEscaping(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) -{ - UNUSED(a_Dt); - - if (GetTarget() != nullptr) - { - Vector3d newloc = GetPosition(); - newloc.x = (GetTarget()->GetPosition().x < newloc.x)? (newloc.x + m_SightDistance): (newloc.x - m_SightDistance); - newloc.z = (GetTarget()->GetPosition().z < newloc.z)? (newloc.z + m_SightDistance): (newloc.z - m_SightDistance); - MoveToPosition(newloc); - } - else - { - m_EMState = IDLE; // This shouldnt be required but just to be safe - } } |