From c1692a2e3be114c2807fdaaea0fa4fcd3d4bbc5d Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 00:16:33 -0700 Subject: Added classes for splash potions and wither skulls --- src/Entities/SplashPotionEntity.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/Entities/SplashPotionEntity.h (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h new file mode 100644 index 000000000..d82a7bfcd --- /dev/null +++ b/src/Entities/SplashPotionEntity.h @@ -0,0 +1,34 @@ +// +// SplashPotionEntity.h +// + +#pragma once + +#include "ProjectileEntity.h" + + + + + +// tolua_begin + +class cSplashPotionEntity : +public cProjectileEntity +{ + typedef cProjectileEntity super; + +public: + + // tolua_end + + CLASS_PROTODEF(cSplashPotionEntity); + + cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + +protected: + + // cProjectileEntity overrides: + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; + virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + +} ; // tolua_export -- cgit v1.2.3 From 58f35af6e71f11844b9c6c1d1ebd2d7390439cca Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 21:56:01 -0700 Subject: Added splash potion functionality --- src/Entities/SplashPotionEntity.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index d82a7bfcd..b64b668a5 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -5,7 +5,8 @@ #pragma once #include "ProjectileEntity.h" - +#include "EntityEffects.h" +#include "../World.h" @@ -13,7 +14,7 @@ // tolua_begin class cSplashPotionEntity : -public cProjectileEntity + public cProjectileEntity { typedef cProjectileEntity super; @@ -23,7 +24,7 @@ public: CLASS_PROTODEF(cSplashPotionEntity); - cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); protected: @@ -31,4 +32,27 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + /** Splashes the potion, fires its particle effects and sounds + * @param a_HitPos The position where the potion will splash + */ + void Splash(const Vector3d & a_HitPos); + + cEntityEffect::eType m_EntityEffectType; + cEntityEffect m_EntityEffect; + int m_PotionName; + + class cSplashPotionCallback : + public cPlayerListCallback + { + public: + cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); + + virtual bool Item(cPlayer * a_Player) override; + + private: + const Vector3d &m_HitPos; + cEntityEffect::eType &m_EntityEffectType; + cEntityEffect &m_EntityEffect; + }; + } ; // tolua_export -- cgit v1.2.3 From 52abd90a28736ca07ad4b2df1259f3b54fd74c9d Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:14:34 -0700 Subject: Applies splash potion effects to mobs as well as players --- src/Entities/SplashPotionEntity.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index b64b668a5..0f84e6387 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -7,6 +7,7 @@ #include "ProjectileEntity.h" #include "EntityEffects.h" #include "../World.h" +#include "Entity.h" @@ -42,12 +43,12 @@ protected: int m_PotionName; class cSplashPotionCallback : - public cPlayerListCallback + public cEntityCallback { public: cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); - virtual bool Item(cPlayer * a_Player) override; + virtual bool Item(cEntity *a_Entity) override; private: const Vector3d &m_HitPos; -- cgit v1.2.3 From f5529e544cf8350daf8a20bb8d997f85ee2824f7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 16 Jun 2014 20:22:17 -0700 Subject: EntityEffects.x -> EntityEffect.x, Object-Oriented effects Changed effect map to take a pointer of the effect as a result. --- src/Entities/SplashPotionEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 0f84e6387..548ba3a3e 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -5,7 +5,7 @@ #pragma once #include "ProjectileEntity.h" -#include "EntityEffects.h" +#include "EntityEffect.h" #include "../World.h" #include "Entity.h" -- cgit v1.2.3 From 8cbd43e0434323dcb1ccba6e1b95a3ca16d35d44 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 18:58:11 -0700 Subject: Added splash potions to NBT serialization and retrieval --- src/Entities/SplashPotionEntity.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 548ba3a3e..ad656d8ab 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -27,6 +27,14 @@ public: cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); + cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; } + cEntityEffect GetEntityEffect() { return m_EntityEffect; } + int GetPotionName() { return m_PotionName; } + + void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } + void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } + void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; } + protected: // cProjectileEntity overrides: -- cgit v1.2.3 From cc452f51c8c4e1c886932d2f7965c7b3e4ab42fe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 22:41:42 +0200 Subject: Restructured cSplashPotionEntity code. The callback doesn't need declaration in the header. Renamed PotionName to PotionParticleType. --- src/Entities/SplashPotionEntity.h | 46 ++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index ad656d8ab..076e477da 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -25,43 +25,35 @@ public: CLASS_PROTODEF(cSplashPotionEntity); - cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName); - - cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; } - cEntityEffect GetEntityEffect() { return m_EntityEffect; } - int GetPotionName() { return m_PotionName; } + cSplashPotionEntity( + cEntity * a_Creator, + double a_X, double a_Y, double a_Z, + const Vector3d & a_Speed, + cEntityEffect::eType a_EntityEffectType, + cEntityEffect a_EntityEffect, + int a_PotionParticleType + ); + + cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; } + cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; } + int GetPotionParticleType(void) const { return m_PotionParticleType; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } - void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; } + void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; } protected: + cEntityEffect::eType m_EntityEffectType; + cEntityEffect m_EntityEffect; + int m_PotionParticleType; + + // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; /** Splashes the potion, fires its particle effects and sounds - * @param a_HitPos The position where the potion will splash - */ + @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); - - cEntityEffect::eType m_EntityEffectType; - cEntityEffect m_EntityEffect; - int m_PotionName; - - class cSplashPotionCallback : - public cEntityCallback - { - public: - cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); - - virtual bool Item(cEntity *a_Entity) override; - - private: - const Vector3d &m_HitPos; - cEntityEffect::eType &m_EntityEffectType; - cEntityEffect &m_EntityEffect; - }; - } ; // tolua_export -- cgit v1.2.3 From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Entities/SplashPotionEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 076e477da..2c78b55d2 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,4 @@ protected: /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); -} ; // tolua_export +} ; // tolua_export -- cgit v1.2.3 From 93c6520e1e6fa957c5d7b7aee71b7ae7e462d77d Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:46:31 -0700 Subject: Fixed splash potion color on toss --- src/Entities/SplashPotionEntity.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 2c78b55d2..1e056de68 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,6 @@ protected: /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); + + virtual void SpawnOn(cClientHandle & a_Client) override; } ; // tolua_export -- cgit v1.2.3 From f5bcfdc58c7b5d69abbb222787bb2229c0b54088 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:51:39 -0700 Subject: Splash potions: Renamed PotionParticleType to PotionColor for clarity --- src/Entities/SplashPotionEntity.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 1e056de68..a33b06990 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -31,22 +31,22 @@ public: const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, - int a_PotionParticleType + int a_PotionColor ); - cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; } - cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; } - int GetPotionParticleType(void) const { return m_PotionParticleType; } + cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } + cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; } + int GetPotionColor(void) const { return m_PotionColor; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } - void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; } + void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; } protected: cEntityEffect::eType m_EntityEffectType; cEntityEffect m_EntityEffect; - int m_PotionParticleType; + int m_PotionColor; // cProjectileEntity overrides: -- cgit v1.2.3 From 9e155c6add9a6108ee86d775910e9a396466ee7b Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:38:36 -0700 Subject: Added destroy-timer system to splash potion entities --- src/Entities/SplashPotionEntity.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index a33b06990..290dd81d4 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -52,10 +52,30 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else + { + super::Tick(a_Dt, a_Chunk); + } + } /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); virtual void SpawnOn(cClientHandle & a_Client) override; + +private: + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export -- cgit v1.2.3 From 4191be7ddba820af4ed0c505a8d62416c2b7a8b4 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 15:36:13 -0700 Subject: Removed redundant semicolons and re-added warning --- src/Entities/SplashPotionEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 290dd81d4..dd14ea82f 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -23,7 +23,7 @@ public: // tolua_end - CLASS_PROTODEF(cSplashPotionEntity); + CLASS_PROTODEF(cSplashPotionEntity) cSplashPotionEntity( cEntity * a_Creator, -- cgit v1.2.3 From 0298d34406b1582e882795bf4d9d3fea18fd0135 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 02:56:59 -0700 Subject: Moved potion static functions to EntityEffect to create splash potions through world --- src/Entities/SplashPotionEntity.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index dd14ea82f..db1672f9b 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -29,9 +29,7 @@ public: cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cEntityEffect::eType a_EntityEffectType, - cEntityEffect a_EntityEffect, - int a_PotionColor + cItem a_Item ); cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } -- cgit v1.2.3 From 16e0beb5b6f6c4c103acfccc1940585513b5c258 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:55:40 -0700 Subject: SplashPotionEntity: Use `const cItem &` instead of a cItem --- src/Entities/SplashPotionEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/SplashPotionEntity.h') diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index db1672f9b..4afc5f204 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -29,7 +29,7 @@ public: cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, - cItem a_Item + const cItem & a_Item ); cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } -- cgit v1.2.3