Explosions and TNT block and entity
#11
If it works, why not? Still, I'd prefer if the whole explosion method was moved into the cChunkMap + cChunk, so that it can manipulate blocks directly.
Reply
Thanks given by:
#12
ok so for some reason i can't edit the World.cpp so i'l just post the changes i made here. you may choose for yourself if you want to implent it or not Wink
	if (GetBlock(a_BlockX, a_BlockY, a_BlockZ) != 9)
	{
		for (int x = 0; x < ExplosionSizeInt; x++)
		{
			for (int y = 0; y < ExplosionSizeInt; y++)
			{
				for (int z = 0; z < ExplosionSizeInt; z++)
				{
					DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ + z);
					DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ + z);
					DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ - z);
					DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ - z);
					DigBlock(a_BlockX + x, a_BlockY + y, a_BlockZ - z);
					DigBlock(a_BlockX + x, a_BlockY - y, a_BlockZ - z);
					DigBlock(a_BlockX - x, a_BlockY + y, a_BlockZ + z);
					DigBlock(a_BlockX - x, a_BlockY - y, a_BlockZ + z);
					BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ + z));
					BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ + z));
					BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY - y, a_BlockZ - z));
					BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ - z));
					BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY + y, a_BlockZ - z));
					BlocksAffected.push_back(Vector3i(a_BlockX + x, a_BlockY - y, a_BlockZ - z));
					BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY + y, a_BlockZ + z));
					BlocksAffected.push_back(Vector3i(a_BlockX - x, a_BlockY - y, a_BlockZ + z));
				}
			}
			
		}
	}
Reply
Thanks given by:
#13
Bad idea: comparing to a number, instead of a named constant. If you come back to this code in a month, you won't know that 9 is "water"
Even worse: You're checking only one value used for water, you need to check two: E_BLOCK_WATER and E_BLOCK_STATIONARY_WATER. Now, how about lava? Obsidian? Bedrock?

Before you start writing a huge IF condition, let me suggest writing a switch block instead, with the block destroying in its default branch Smile
Reply
Thanks given by:
#14
i already tried to make it ignore both water blocks but it didn't realy work. i tried
if (GetBlock(a_BlockX, a_BlockY, a_BlockZ) != 8,9) //should be E_BLOCK_ETC now 
and
if (GetBlock(a_BlockX, a_BlockY, a_BlockZ) != 8||9)  //should be E_BLOCK_ETC now 
that was what i found on google Wink
for the obsydian and bedrock stuff. i don't think the explosion will be IN a obsydian/bedrock block Wink
Reply
Thanks given by:
#15
If you want to do it as an IF statement:
BLOCKTYPE BlockType = GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if ((BlockType == E_BLOCK_WATER) || (BlockType == E_BLOCK_STATIONARY_WATER) || (BlockType == ...))

If you want to do it more intelligently, do a switch:
switch (GetBlock(a_BlockX, a_BlockY, a_BlockZ)
{
	case E_BLOCK_STATIONARY_WATER:
	case E_BLOCK_WATER:
	{
		// TNT in these blocks doesn\'t do environmental damage
		break;
	}

	default:
	{
		// Destroy the neighboring blocks:
		for (int y = 0; y < ExplosionSizeInt; y++) ...
	}
}
Reply
Thanks given by:
#16
Yeah, I was going to rewrite to use chunk (maybe cBlockArea) and to actually create rays of explosions that attempts to destroy the blocks depending on their resistance. It was kind of a big task to make it on the first try (I am also working on the physics for entities which is another big task hehe Smile), so that's why i decided just to implement it as a simple cube as first step Smile
Reply
Thanks given by:
#17
TNT flows with waterBig Grin its pretty cool Smile
Reply
Thanks given by:
#18
Smile yeah, and the idea is that will also collide with other entities once we implement entity on entity collision Smile
Reply
Thanks given by:
#19
:O thats awsomeBig Grin
Reply
Thanks given by:
#20
mmmm, i was thinking: shouldn't explosion be its own class? cExplosion...
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)