diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-27 08:13:40 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-08-27 08:13:40 +0200 |
commit | e274d0dd8a6eefeb6e84272ffd09ac55b2c08900 (patch) | |
tree | 377f52ed5738810c157e631ec31f626fbe5acef6 /src/Mobs/Squid.cpp | |
parent | d (diff) | |
parent | Implement anvil chunk sparsing (diff) | |
download | cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.gz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.bz2 cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.lz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.xz cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.tar.zst cuberite-e274d0dd8a6eefeb6e84272ffd09ac55b2c08900.zip |
Diffstat (limited to 'src/Mobs/Squid.cpp')
-rw-r--r-- | src/Mobs/Squid.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp index 00cc07e14..8ae688a1b 100644 --- a/src/Mobs/Squid.cpp +++ b/src/Mobs/Squid.cpp @@ -46,13 +46,35 @@ void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { return; } - int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; - BLOCKTYPE BlockType; - if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) + + if (!IsSubmerged()) + { + if (m_AirLevel <= 0) + { + // Runs the air tick timer to check whether the squid should be damaged + if (m_AirTickTimer <= 0) + { + // Damage squid + TakeDamage(dtSuffocating, nullptr, 1, 1, 0); + // Reset timer + m_AirTickTimer = DROWNING_TICKS; + } + else + { + m_AirTickTimer--; + } + } + else + { + // Reduce air supply + m_AirLevel--; + } + } + else { - // Burn for 10 ticks, then decide again - StartBurning(10); + // Set the air back to maximum + m_AirLevel = MAX_AIR_LEVEL; + m_AirTickTimer = DROWNING_TICKS; } super::Tick(a_Dt, a_Chunk); |