diff options
author | keyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-18 04:42:45 +0200 |
---|---|---|
committer | keyboard.osh@gmail.com <keyboard.osh@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-18 04:42:45 +0200 |
commit | b75fc5f4e8dc837f069e89541b52144defa2d1b9 (patch) | |
tree | 2e9a05e1ed16da917c5e8651b1bb70100a9db153 /source/World.cpp | |
parent | Noise: removed the unused SSE branches and unused interpolation methods. Removed the Noise.inc file. (diff) | |
download | cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar.gz cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar.bz2 cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar.lz cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar.xz cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.tar.zst cuberite-b75fc5f4e8dc837f069e89541b52144defa2d1b9.zip |
Diffstat (limited to 'source/World.cpp')
-rw-r--r-- | source/World.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source/World.cpp b/source/World.cpp index 74a7ea399..6b1e5f8c8 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -703,6 +703,68 @@ bool cWorld::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback +void cWorld::DoExplosiontAt(float a_ExplosionSize, int a_BlockX, int a_BlockY, int a_BlockZ) +{ + //TODO implement explosion using cBlockArea, add damage to pawns, add support for pickups, and implement block hardiness + Vector3d explosion_pos = Vector3d(a_BlockX,a_BlockY,a_BlockZ); + cVector3iList BlocksAffected; + for (int i=0;i<a_ExplosionSize;i++) + { + for (int j=0;j<a_ExplosionSize;j++) + { + for (int k=0;k<a_ExplosionSize;k++) + { + DigBlock(a_BlockX+i,a_BlockY+j,a_BlockZ+k); + DigBlock(a_BlockX+i,a_BlockY-j,a_BlockZ+k); + DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ-k); + DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ-k); + DigBlock(a_BlockX+i,a_BlockY+j,a_BlockZ-k); + DigBlock(a_BlockX+i,a_BlockY-j,a_BlockZ-k); + DigBlock(a_BlockX-i,a_BlockY+j,a_BlockZ+k); + DigBlock(a_BlockX-i,a_BlockY-j,a_BlockZ+k); + BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ+k)); + BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ+k)); + BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ-k)); + BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ-k)); + BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY+j,a_BlockZ-k)); + BlocksAffected.push_back(&Vector3i(a_BlockX+i,a_BlockY-j,a_BlockZ-k)); + BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY+j,a_BlockZ+k)); + BlocksAffected.push_back(&Vector3i(a_BlockX-i,a_BlockY-j,a_BlockZ+k)); + } + } + + } + BroadcastSoundEffect("random.explode", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f); + { + cCSLock Lock(m_CSPlayers); + for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + { + cClientHandle * ch = (*itr)->GetClientHandle(); + if ((ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed()) + { + continue; + } + Vector3d distance_explosion = (*itr)->GetPosition() - explosion_pos; + if (distance_explosion.SqrLength() < 4096.0) + { + double real_distance = sqrt( distance_explosion.SqrLength()); + if (real_distance <= 0.0004) + real_distance = 0.0004; + double power = a_ExplosionSize / real_distance; + if (power <= 1) + power = 0; + distance_explosion.Normalize(); + distance_explosion *= power; + ch->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_ExplosionSize,BlocksAffected,(float)distance_explosion.x,(float)distance_explosion.y,(float)distance_explosion.z); + } + } + } +} + + + + + bool cWorld::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback) { return m_ChunkMap->DoWithChestAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback); |