Change TNT Fuse to ticks
This commit is contained in:
parent
baeff21a5b
commit
b37966fd21
@ -116,7 +116,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
|||||||
{
|
{
|
||||||
double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
|
||||||
double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
|
||||||
m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 4, 0); // 4 seconds fuse, no initial velocity
|
m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 80, 0); // 80 ticks fuse, no initial velocity
|
||||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec) :
|
cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) :
|
||||||
super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
|
super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
|
||||||
m_FuseTicks(a_FuseTimeInSec)
|
m_FuseTicks(a_FuseTicks)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,9 +18,9 @@ cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSe
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cTNTEntity::cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec) :
|
cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
|
||||||
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
|
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
|
||||||
m_FuseTicks(a_FuseTimeInSec)
|
m_FuseTicks(a_FuseTicks)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ void cTNTEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
float delta_time = a_Dt / 1000; // Convert miliseconds to seconds
|
|
||||||
m_FuseTicks -= delta_time;
|
m_FuseTicks -= 1;
|
||||||
if (m_FuseTicks <= 0)
|
if (m_FuseTicks <= 0)
|
||||||
{
|
{
|
||||||
Explode();
|
Explode();
|
||||||
|
@ -16,8 +16,8 @@ public:
|
|||||||
// tolua_end
|
// tolua_end
|
||||||
CLASS_PROTODEF(cTNTEntity);
|
CLASS_PROTODEF(cTNTEntity);
|
||||||
|
|
||||||
cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec = 4);
|
cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
|
||||||
cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec = 4);
|
cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
|
||||||
|
|
||||||
// cEntity overrides:
|
// cEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||||
@ -29,15 +29,15 @@ public:
|
|||||||
void Explode(void);
|
void Explode(void);
|
||||||
|
|
||||||
/** Returns the fuse ticks until the tnt will explode */
|
/** Returns the fuse ticks until the tnt will explode */
|
||||||
double GetFuseTicks(void) const { return m_FuseTicks; }
|
int GetFuseTicks(void) const { return m_FuseTicks; }
|
||||||
|
|
||||||
/** Set the fuse ticks until the tnt will explode */
|
/** Set the fuse ticks until the tnt will explode */
|
||||||
void SetFuseTicks(double a_FuseTicks) { m_FuseTicks = a_FuseTicks; }
|
void SetFuseTicks(int a_FuseTicks) { m_FuseTicks = a_FuseTicks; }
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double m_FuseTicks; ///< How much time in seconds is left, while the tnt will explode
|
int m_FuseTicks; ///< How much ticks is left, while the tnt will explode
|
||||||
}; // tolua_export
|
}; // tolua_export
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ public:
|
|||||||
case E_BLOCK_TNT:
|
case E_BLOCK_TNT:
|
||||||
{
|
{
|
||||||
// Activate the TNT:
|
// Activate the TNT:
|
||||||
a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
|
a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 1.0f);
|
||||||
a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
|
a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
|
||||||
a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
|
a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_
|
|||||||
if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
|
if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
|
||||||
{
|
{
|
||||||
m_World.BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
|
m_World.BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
|
||||||
m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
|
m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
|
||||||
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1725,10 +1725,10 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff)
|
void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
|
||||||
{
|
{
|
||||||
UNUSED(a_InitialVelocityCoeff);
|
UNUSED(a_InitialVelocityCoeff);
|
||||||
cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTimeInSec);
|
cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks);
|
||||||
TNT->Initialize(this);
|
TNT->Initialize(this);
|
||||||
// TODO: Add a bit of speed in horiz and vert axes, based on the a_InitialVelocityCoeff
|
// TODO: Add a bit of speed in horiz and vert axes, based on the a_InitialVelocityCoeff
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ public:
|
|||||||
int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward);
|
int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward);
|
||||||
|
|
||||||
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided */
|
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided */
|
||||||
void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff = 1);
|
void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ void cNBTChunkSerializer::AddTNTEntity(cTNTEntity * a_TNT)
|
|||||||
{
|
{
|
||||||
m_Writer.BeginCompound("");
|
m_Writer.BeginCompound("");
|
||||||
AddBasicEntity(a_TNT, "PrimedTnt");
|
AddBasicEntity(a_TNT, "PrimedTnt");
|
||||||
m_Writer.AddByte("Fuse", ((unsigned char)a_TNT->GetFuseTicks()) * 10);
|
m_Writer.AddByte("Fuse", (unsigned char)a_TNT->GetFuseTicks());
|
||||||
m_Writer.EndCompound();
|
m_Writer.EndCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,8 +2184,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
|
|||||||
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
|
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
|
||||||
if (FuseTicks > 0)
|
if (FuseTicks > 0)
|
||||||
{
|
{
|
||||||
int MojangFuseTicks = (int) a_NBT.GetByte(FuseTicks);
|
TNT->SetFuseTicks((int) a_NBT.GetByte(FuseTicks));
|
||||||
TNT->SetFuseTicks((double) MojangFuseTicks / 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a_Entities.push_back(TNT.release());
|
a_Entities.push_back(TNT.release());
|
||||||
|
Loading…
Reference in New Issue
Block a user