Gives all entities the default airlevel on creation (#3942)
* Guardians don't take damage on land * Squids suffocate on land
This commit is contained in:
parent
4b84288801
commit
3c8712d871
@ -56,8 +56,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
|
|||||||
m_TicksSinceLastVoidDamage(0),
|
m_TicksSinceLastVoidDamage(0),
|
||||||
m_IsSwimming(false),
|
m_IsSwimming(false),
|
||||||
m_IsSubmerged(false),
|
m_IsSubmerged(false),
|
||||||
m_AirLevel(0),
|
m_AirLevel(MAX_AIR_LEVEL),
|
||||||
m_AirTickTimer(0),
|
m_AirTickTimer(DROWNING_TICKS),
|
||||||
m_TicksAlive(0),
|
m_TicksAlive(0),
|
||||||
m_IsTicking(false),
|
m_IsTicking(false),
|
||||||
m_ParentChunk(nullptr),
|
m_ParentChunk(nullptr),
|
||||||
|
@ -42,20 +42,11 @@ void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
// that is not where the entity currently resides (FS #411)
|
// that is not where the entity currently resides (FS #411)
|
||||||
Vector3d Pos = GetPosition();
|
Vector3d Pos = GetPosition();
|
||||||
|
|
||||||
// TODO: Not a real behavior, but cool :D
|
|
||||||
int RelY = FloorC(Pos.y);
|
int RelY = FloorC(Pos.y);
|
||||||
if ((RelY < 0) || (RelY >= cChunkDef::Height))
|
if ((RelY < 0) || (RelY >= cChunkDef::Height))
|
||||||
{
|
{
|
||||||
return;
|
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())
|
|
||||||
{
|
|
||||||
// Burn for 10 ticks, then decide again
|
|
||||||
StartBurning(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,35 @@ void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width;
|
|
||||||
int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width;
|
if (!IsSubmerged())
|
||||||
BLOCKTYPE BlockType;
|
|
||||||
if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire())
|
|
||||||
{
|
{
|
||||||
// Burn for 10 ticks, then decide again
|
if (m_AirLevel <= 0)
|
||||||
StartBurning(10);
|
{
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
// Set the air back to maximum
|
||||||
|
m_AirLevel = MAX_AIR_LEVEL;
|
||||||
|
m_AirTickTimer = DROWNING_TICKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user