1
0

Uncommented pickup spawner code

This commit is contained in:
Tiger Wang 2014-02-02 21:24:06 +00:00
parent e56d41175b
commit ba398c06d7

View File

@ -1719,7 +1719,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
cBlockHandler * Handler = BlockHandler(Block);
Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
//m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
}
area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
@ -1747,7 +1747,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
{
if (a_Entity->IsPickup())
{
if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible
if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
{
return false;
}
@ -1761,21 +1761,25 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
Vector3d AbsoluteEntityPos(abs(EntityPos.x), abs(EntityPos.y), abs(EntityPos.z));
Vector3d MaxExplosionBoundary(m_ExplosionSizeSq, m_ExplosionSizeSq, m_ExplosionSizeSq);
// Work out how far we are from the edge of the TNT's explosive effect
AbsoluteEntityPos -= m_ExplosionPos;
AbsoluteEntityPos = MaxExplosionBoundary - AbsoluteEntityPos;
double FinalDamage = ((AbsoluteEntityPos.x + AbsoluteEntityPos.y + AbsoluteEntityPos.z) / 3) * m_ExplosionSize;
FinalDamage = a_Entity->GetMaxHealth() - abs(FinalDamage);
// Clip damage values
if (FinalDamage > a_Entity->GetMaxHealth())
FinalDamage = a_Entity->GetMaxHealth();
else if (FinalDamage < 0)
return false;
if (!a_Entity->IsTNT())
if (!a_Entity->IsTNT()) // Don't apply damage to other TNT entities, they should be invincible
{
a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0);
}
// Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt()
Vector3d distance_explosion = a_Entity->GetPosition() - m_ExplosionPos;
if (distance_explosion.SqrLength() < 4096.0)
{