From 477b3e7861ca03aec5c46b4c192f5cc1b5f07c4d Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 16:45:39 -0700 Subject: Moved cArrowEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 195 +------------------------------------- 1 file changed, 3 insertions(+), 192 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index fd3e80e5f..079adcc5f 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -4,15 +4,17 @@ // Implements the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types #include "Globals.h" + #include "../Bindings/PluginManager.h" #include "ProjectileEntity.h" #include "../ClientHandle.h" -#include "Player.h" #include "../LineBlockTracer.h" #include "../BoundingBox.h" #include "../ChunkMap.h" #include "../Chunk.h" +#include "ProjectileArrow.h" + @@ -406,197 +408,6 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cArrowEntity: - -cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5), - m_PickupState(psNoPickup), - m_DamageCoeff(2), - m_IsCritical(false), - m_Timer(0), - m_HitGroundTimer(0), - m_bIsCollected(false), - m_HitBlockPos(Vector3i(0, 0, 0)) -{ - SetSpeed(a_Speed); - SetMass(0.1); - SetYawFromSpeed(); - SetPitchFromSpeed(); - LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}", - m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(), - GetYaw(), GetPitch() - ); -} - - - - - -cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) : - super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5), - m_PickupState(psInSurvivalOrCreative), - m_DamageCoeff(2), - m_IsCritical((a_Force >= 1)), - m_Timer(0), - m_HitGroundTimer(0), - m_HasTeleported(false), - m_bIsCollected(false), - m_HitBlockPos(0, 0, 0) -{ -} - - - - - -bool cArrowEntity::CanPickup(const cPlayer & a_Player) const -{ - switch (m_PickupState) - { - case psNoPickup: return false; - case psInSurvivalOrCreative: return (a_Player.IsGameModeSurvival() || a_Player.IsGameModeCreative()); - case psInCreative: return a_Player.IsGameModeCreative(); - } - ASSERT(!"Unhandled pickup state"); - return false; -} - - - - - -void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - if (a_HitFace == BLOCK_FACE_NONE) { return; } - - super::OnHitSolidBlock(a_HitPos, a_HitFace); - int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z; - - switch (a_HitFace) - { - case BLOCK_FACE_XM: // Strangely, bounding boxes / block tracers return the actual block for these two directions, so AddFace not needed - case BLOCK_FACE_YM: - { - break; - } - default: AddFaceDirection(a_X, a_Y, a_Z, a_HitFace, true); - } - - m_HitBlockPos = Vector3i(a_X, a_Y, a_Z); - - // Broadcast arrow hit sound - m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); -} - - - - - -void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat()) - { - // Not an entity that interacts with an arrow - return; - } - - int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); - if (m_IsCritical) - { - Damage += m_World->GetTickRandomNumber(Damage / 2 + 2); - } - a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); - - // Broadcast successful hit sound - m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); - - Destroy(); -} - - - - - -void cArrowEntity::CollectedBy(cPlayer * a_Dest) -{ - if ((m_IsInGround) && (!m_bIsCollected) && (CanPickup(*a_Dest))) - { - int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW); - if (NumAdded > 0) // Only play effects if there was space in inventory - { - m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest); - // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) - m_World->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); - m_bIsCollected = true; - } - } -} - - - - - -void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - m_Timer += a_Dt; - - if (m_bIsCollected) - { - if (m_Timer > 500.f) // 0.5 seconds - { - Destroy(); - return; - } - } - else if (m_Timer > 1000 * 60 * 5) // 5 minutes - { - Destroy(); - return; - } - - if (m_IsInGround) - { - // When an arrow hits, the client doesn't think its in the ground and keeps on moving, IF BroadcastMovementUpdate() and TeleportEntity was called during flight, AT ALL - // Fix is to simply not sync with the client and send a teleport to confirm pos after arrow has stabilised (around 1 sec after landing) - // We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync - // Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position - - if (!m_HasTeleported) // Sent a teleport already, don't do again - { - if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case - { - m_World->BroadcastTeleportEntity(*this); - m_HasTeleported = true; - } - else - { - m_HitGroundTimer += a_Dt; - } - } - - int RelPosX = m_HitBlockPos.x - a_Chunk.GetPosX() * cChunkDef::Width; - int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width; - cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ); - - if (Chunk == NULL) - { - // Inside an unloaded chunk, abort - return; - } - - if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed? - { - m_IsInGround = false; // Yes, begin simulating physics again - } - } -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cThrownEggEntity: -- cgit v1.2.3 From de23a115a5a33a864111262f4dae08b524af422f Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:02:47 -0700 Subject: Moved cThrownEggEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 59 +-------------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 079adcc5f..b4c162e35 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -14,6 +14,7 @@ #include "../Chunk.h" #include "ProjectileArrow.h" +#include "ProjectileEgg.h" @@ -408,64 +409,6 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cThrownEggEntity: - -cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -{ - SetSpeed(a_Speed); -} - - - - - -void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - TrySpawnChicken(a_HitPos); - - Destroy(); -} - - - - - -void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - int TotalDamage = 0; - // TODO: If entity is Ender Crystal, destroy it - - TrySpawnChicken(a_HitPos); - a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - - Destroy(true); -} - - - - - -void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos) -{ - if (m_World->GetTickRandomNumber(7) == 1) - { - m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); - } - else if (m_World->GetTickRandomNumber(32) == 1) - { - m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); - m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); - m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); - m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); - } -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cThrownEnderPearlEntity : -- cgit v1.2.3 From bc5c28a0beef335edf3b930e069b9152ef0a912f Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:08:39 -0700 Subject: Moved cThrownEnderPearl out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 55 +-------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index b4c162e35..d7e1f56a7 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -15,6 +15,7 @@ #include "ProjectileArrow.h" #include "ProjectileEgg.h" +#include "ProjectileEnderPearl.h" @@ -409,60 +410,6 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cThrownEnderPearlEntity : - -cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -{ - SetSpeed(a_Speed); -} - - - - - -void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - // TODO: Tweak a_HitPos based on block face. - TeleportCreator(a_HitPos); - - Destroy(); -} - - - - - -void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - int TotalDamage = 0; - // TODO: If entity is Ender Crystal, destroy it - - TeleportCreator(a_HitPos); - a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - - Destroy(true); -} - - - - - -void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) -{ - // Teleport the creator here, make them take 5 damage: - if (m_Creator != NULL) - { - m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5); - m_Creator->TakeDamage(dtEnderPearl, this, 5, 0); - } -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cThrownSnowballEntity : -- cgit v1.2.3 From 2f9580ad650ff69e71991b87d6b554ce080624a3 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:19:45 -0700 Subject: Moved cExpBottleEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index d7e1f56a7..6060b56df 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -16,6 +16,7 @@ #include "ProjectileArrow.h" #include "ProjectileEgg.h" #include "ProjectileEnderPearl.h" +#include "ProjectileExpBottle.h" @@ -457,32 +458,6 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cBottleOEnchantingEntity : - -cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : -super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -{ - SetSpeed(a_Speed); -} - - - - - -void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - // Spawn an experience orb with a reward between 3 and 11. - m_World->BroadcastSoundParticleEffect(2002, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0); - m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8)); - - Destroy(); -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFireworkEntity : -- cgit v1.2.3 From 08b77f488041e99d4b53173f85ee9b8bcc3e9493 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:24:44 -0700 Subject: Moved cThrownSnowballEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 48 +-------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 6060b56df..6b137ebe7 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -17,6 +17,7 @@ #include "ProjectileEgg.h" #include "ProjectileEnderPearl.h" #include "ProjectileExpBottle.h" +#include "ProjectileSnowball.h" @@ -411,53 +412,6 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cThrownSnowballEntity : - -cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -{ - SetSpeed(a_Speed); -} - - - - - -void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - Destroy(); -} - - - - - -void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - int TotalDamage = 0; - if (a_EntityHit.IsMob()) - { - cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType(); - if (MobType == cMonster::mtBlaze) - { - TotalDamage = 3; - } - else if (MobType == cMonster::mtEnderDragon) - { - TotalDamage = 1; - } - } - // TODO: If entity is Ender Crystal, destroy it - a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); - - Destroy(true); -} - - - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFireworkEntity : -- cgit v1.2.3 From de7eaa573560253c9e78fbfa6614cd60763383bf Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:35:31 -0700 Subject: Moved cFireChargeEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 56 ++------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 6b137ebe7..ab7753d41 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -18,6 +18,7 @@ #include "ProjectileEnderPearl.h" #include "ProjectileExpBottle.h" #include "ProjectileSnowball.h" +#include "ProjectileFireCharge.h" @@ -520,57 +521,4 @@ void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a { Destroy(); Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cFireChargeEntity : - -cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkFireCharge, a_Creator, a_X, a_Y, a_Z, 0.3125, 0.3125) -{ - SetSpeed(a_Speed); - SetGravity(0); -} - - - - - -void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) -{ - if (m_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) - { - m_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 1); - } -} - - - - - -void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); -} - - - - - -void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); - - // TODO: Some entities are immune to hits - a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning -} - - - - +} \ No newline at end of file -- cgit v1.2.3 From cb93a57963257a905334489fcca8d164999dcf50 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:41:07 -0700 Subject: Moved cGhastFireballEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 44 +-------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index ab7753d41..3a5ac059b 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -19,6 +19,7 @@ #include "ProjectileExpBottle.h" #include "ProjectileSnowball.h" #include "ProjectileFireCharge.h" +#include "ProjectileGhastFireball.h" @@ -478,47 +479,4 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk) } m_ExplodeTimer++; -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cGhastFireballEntity : - -cGhastFireballEntity::cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkGhastFireball, a_Creator, a_X, a_Y, a_Z, 1, 1) -{ - SetSpeed(a_Speed); - SetGravity(0); -} - - - - - -void cGhastFireballEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) -{ - m_World->DoExplosionAt(1, a_BlockX, a_BlockY, a_BlockZ, true, esGhastFireball, this); -} - - - - - -void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); -} - - - - - -void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) -{ - Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); } \ No newline at end of file -- cgit v1.2.3 From e3c3795aa40e59af86d90b45b209f367563942fb Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Apr 2014 17:50:05 -0700 Subject: Moved cFireworkEntity out of ProjectileEntity.h --- src/Entities/ProjectileEntity.cpp | 72 +-------------------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 3a5ac059b..4784d4b0c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -19,6 +19,7 @@ #include "ProjectileExpBottle.h" #include "ProjectileSnowball.h" #include "ProjectileFireCharge.h" +#include "ProjectileFirework.h" #include "ProjectileGhastFireball.h" @@ -408,75 +409,4 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) { // Overriden in arrow UNUSED(a_Dest); -} - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cFireworkEntity : - -cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) : -super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), - m_ExplodeTimer(0), - m_FireworkItem(a_Item) -{ -} - - - - - -void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) -{ - int RelX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; - int PosY = POSY_TOINT; - - if ((PosY < 0) || (PosY >= cChunkDef::Height)) - { - goto setspeed; - } - - if (m_IsInGround) - { - if (a_Chunk.GetBlock(RelX, POSY_TOINT + 1, RelZ) == E_BLOCK_AIR) - { - m_IsInGround = false; - } - else - { - return; - } - } - else - { - if (a_Chunk.GetBlock(RelX, POSY_TOINT + 1, RelZ) != E_BLOCK_AIR) - { - OnHitSolidBlock(GetPosition(), BLOCK_FACE_YM); - return; - } - } - -setspeed: - AddSpeedY(1); - AddPosition(GetSpeed() * (a_Dt / 1000)); -} - - - - - -void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk) -{ - super::Tick(a_Dt, a_Chunk); - - if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks) - { - m_World->BroadcastEntityStatus(*this, esFireworkExploding); - Destroy(); - } - - m_ExplodeTimer++; } \ No newline at end of file -- cgit v1.2.3 From 15324f3bbdaf7529636cc1930e1c1b87ef911d86 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 09:42:31 -0700 Subject: Fixed ToLua errors, added newlines --- src/Entities/ProjectileEntity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 4784d4b0c..b2e6d469e 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -409,4 +409,4 @@ void cProjectileEntity::CollectedBy(cPlayer * a_Dest) { // Overriden in arrow UNUSED(a_Dest); -} \ No newline at end of file +} -- cgit v1.2.3 From 9b0cb3fd97701370915a9a5b3d5b237fa7f90e06 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 17:03:06 -0700 Subject: Fixed projectile source filenames, indentations --- src/Entities/ProjectileEntity.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Entities/ProjectileEntity.cpp') diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index b2e6d469e..3e48d310c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -13,14 +13,14 @@ #include "../ChunkMap.h" #include "../Chunk.h" -#include "ProjectileArrow.h" -#include "ProjectileEgg.h" -#include "ProjectileEnderPearl.h" -#include "ProjectileExpBottle.h" -#include "ProjectileSnowball.h" -#include "ProjectileFireCharge.h" -#include "ProjectileFirework.h" -#include "ProjectileGhastFireball.h" +#include "ArrowEntity.h" +#include "ThrownEggEntity.h" +#include "ThrownEnderPearlEntity.h" +#include "ExpBottleEntity.h" +#include "ThrownSnowballEntity.h" +#include "FireChargeEntity.h" +#include "FireworkEntity.h" +#include "GhastFireballEntity.h" -- cgit v1.2.3