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/EntityEffect.h | 438 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+) create mode 100644 src/Entities/EntityEffect.h (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h new file mode 100644 index 000000000..ae7958e11 --- /dev/null +++ b/src/Entities/EntityEffect.h @@ -0,0 +1,438 @@ +#pragma once + +class cPawn; + +// tolua_begin +class cEntityEffect +{ +public: + + /** All types of entity effects (numbers correspond to IDs) */ + enum eType + { + effNoEffect = 0, + effSpeed = 1, + effSlowness = 2, + effHaste = 3, + effMiningFatigue = 4, + effStrength = 5, + effInstantHealth = 6, + effInstantDamage = 7, + effJumpBoost = 8, + effNausea = 9, + effRegeneration = 10, + effResistance = 11, + effFireResistance = 12, + effWaterBreathing = 13, + effInvisibility = 14, + effBlindness = 15, + effNightVision = 16, + effHunger = 17, + effWeakness = 18, + effPoison = 19, + effWither = 20, + effHealthBoost = 21, + effAbsorption = 22, + effSaturation = 23, + } ; + + /** Creates an empty entity effect */ + cEntityEffect(void); + + /** Creates an entity effect of the specified type + @param a_Duration How long this effect will last, in ticks + @param a_Intensity How strong the effect will be applied + @param a_Creator The pawn that produced this entity effect + @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ + cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); + + virtual ~cEntityEffect(void); + + /** Creates a pointer to the proper entity effect from the effect type + @warning This function creates raw pointers that must be manually managed. + @param a_EffectType The effect type to create the effect from + @param a_Duration How long this effect will last, in ticks + @param a_Intensity How strong the effect will be applied + @param a_Creator The pawn that produced this entity effect + @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ + static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier); + + /** Returns how many ticks this effect has been active for */ + int GetTicks() { return m_Ticks; } + /** Returns the duration of the effect */ + int GetDuration() { return m_Duration; } + /** Returns how strong the effect will be applied */ + short GetIntensity() { return m_Intensity; } + /** Returns the pawn that produced this entity effect */ + cPawn *GetCreator() { return m_Creator; } + /** Returns the distance modifier for affecting potency */ + double GetDistanceModifier() { return m_DistanceModifier; } + + void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } + void SetDuration(int a_Duration) { m_Duration = a_Duration; } + void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } + void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } + void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } + + virtual void OnTick(cPawn & a_Target); + virtual void OnActivate(cPawn & a_Target); + virtual void OnDeactivate(cPawn & a_Target); + +protected: + /** How many ticks this effect has been active for */ + int m_Ticks; + + /** How long this effect will last, in ticks */ + int m_Duration; + + /** How strong the effect will be applied */ + short m_Intensity; + + /** The pawn that produced this entity effect (threw the potion, etc) */ + cPawn *m_Creator; + + /** The distance modifier for affecting potency */ + double m_DistanceModifier; +}; + +/************************************************************************ + **** Speed + ************************************************************************/ +class cEntityEffectSpeed: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Slowness + ************************************************************************/ +class cEntityEffectSlowness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Haste + ************************************************************************/ +class cEntityEffectHaste: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Mining Fatigue + ************************************************************************/ +class cEntityEffectMiningFatigue: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Strength + ************************************************************************/ +class cEntityEffectStrength: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Instant Health + ************************************************************************/ +class cEntityEffectInstantHealth: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnActivate(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Instant Damage + ************************************************************************/ +class cEntityEffectInstantDamage: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnActivate(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Jump Boost + ************************************************************************/ +class cEntityEffectJumpBoost: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Nausea + ************************************************************************/ +class cEntityEffectNausea: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Regeneration + ************************************************************************/ +class cEntityEffectRegeneration: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Resistance + ************************************************************************/ +class cEntityEffectResistance: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Fire Resistance + ************************************************************************/ +class cEntityEffectFireResistance: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Water Breathing + ************************************************************************/ +class cEntityEffectWaterBreathing: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Invisibility + ************************************************************************/ +class cEntityEffectInvisibility: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Blindness + ************************************************************************/ +class cEntityEffectBlindness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Night Vision + ************************************************************************/ +class cEntityEffectNightVision: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Hunger + ************************************************************************/ +class cEntityEffectHunger: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Weakness + ************************************************************************/ +class cEntityEffectWeakness: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Poison + ************************************************************************/ +class cEntityEffectPoison: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Wither + ************************************************************************/ +class cEntityEffectWither: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + +/************************************************************************ + **** Health Boost + ************************************************************************/ +class cEntityEffectHealthBoost: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Absorption + ************************************************************************/ +class cEntityEffectAbsorption: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } +}; + +/************************************************************************ + **** Saturation + ************************************************************************/ +class cEntityEffectSaturation: + public cEntityEffect +{ + typedef cEntityEffect super; +public: + cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + { + } + + virtual void OnTick(cPawn & a_Target) override; +}; + + + +// tolua_end -- cgit v1.2.3 From 4e6395d6ff9f34edb4dd36dc1f8e845c56b499f4 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 17:27:29 -0700 Subject: For now, removed creator member from Entity Effect for pointer safety --- src/Entities/EntityEffect.h | 104 ++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 56 deletions(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ae7958e11..c593fba81 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -42,9 +42,8 @@ public: /** Creates an entity effect of the specified type @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_Creator The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1); + cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1); virtual ~cEntityEffect(void); @@ -53,9 +52,8 @@ public: @param a_EffectType The effect type to create the effect from @param a_Duration How long this effect will last, in ticks @param a_Intensity How strong the effect will be applied - @param a_Creator The pawn that produced this entity effect @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ - static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier); + static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier); /** Returns how many ticks this effect has been active for */ int GetTicks() { return m_Ticks; } @@ -63,15 +61,12 @@ public: int GetDuration() { return m_Duration; } /** Returns how strong the effect will be applied */ short GetIntensity() { return m_Intensity; } - /** Returns the pawn that produced this entity effect */ - cPawn *GetCreator() { return m_Creator; } /** Returns the distance modifier for affecting potency */ double GetDistanceModifier() { return m_DistanceModifier; } void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } - void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } virtual void OnTick(cPawn & a_Target); @@ -88,9 +83,6 @@ protected: /** How strong the effect will be applied */ short m_Intensity; - /** The pawn that produced this entity effect (threw the potion, etc) */ - cPawn *m_Creator; - /** The distance modifier for affecting potency */ double m_DistanceModifier; }; @@ -103,8 +95,8 @@ class cEntityEffectSpeed: { typedef cEntityEffect super; public: - cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSpeed(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -117,8 +109,8 @@ class cEntityEffectSlowness: { typedef cEntityEffect super; public: - cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSlowness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -131,8 +123,8 @@ class cEntityEffectHaste: { typedef cEntityEffect super; public: - cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHaste(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -145,8 +137,8 @@ class cEntityEffectMiningFatigue: { typedef cEntityEffect super; public: - cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -159,8 +151,8 @@ class cEntityEffectStrength: { typedef cEntityEffect super; public: - cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectStrength(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -173,8 +165,8 @@ class cEntityEffectInstantHealth: { typedef cEntityEffect super; public: - cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInstantHealth(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -189,8 +181,8 @@ class cEntityEffectInstantDamage: { typedef cEntityEffect super; public: - cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInstantDamage(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -205,8 +197,8 @@ class cEntityEffectJumpBoost: { typedef cEntityEffect super; public: - cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectJumpBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -219,8 +211,8 @@ class cEntityEffectNausea: { typedef cEntityEffect super; public: - cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -233,8 +225,8 @@ class cEntityEffectRegeneration: { typedef cEntityEffect super; public: - cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectRegeneration(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -249,8 +241,8 @@ class cEntityEffectResistance: { typedef cEntityEffect super; public: - cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -263,8 +255,8 @@ class cEntityEffectFireResistance: { typedef cEntityEffect super; public: - cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectFireResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -277,8 +269,8 @@ class cEntityEffectWaterBreathing: { typedef cEntityEffect super; public: - cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -291,8 +283,8 @@ class cEntityEffectInvisibility: { typedef cEntityEffect super; public: - cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectInvisibility(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -305,8 +297,8 @@ class cEntityEffectBlindness: { typedef cEntityEffect super; public: - cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectBlindness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -319,8 +311,8 @@ class cEntityEffectNightVision: { typedef cEntityEffect super; public: - cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectNightVision(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -333,8 +325,8 @@ class cEntityEffectHunger: { typedef cEntityEffect super; public: - cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHunger(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -349,8 +341,8 @@ class cEntityEffectWeakness: { typedef cEntityEffect super; public: - cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWeakness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -365,8 +357,8 @@ class cEntityEffectPoison: { typedef cEntityEffect super; public: - cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectPoison(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -381,8 +373,8 @@ class cEntityEffectWither: { typedef cEntityEffect super; public: - cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectWither(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } @@ -397,8 +389,8 @@ class cEntityEffectHealthBoost: { typedef cEntityEffect super; public: - cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectHealthBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -411,8 +403,8 @@ class cEntityEffectAbsorption: { typedef cEntityEffect super; public: - cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectAbsorption(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; @@ -425,8 +417,8 @@ class cEntityEffectSaturation: { typedef cEntityEffect super; public: - cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier) + cEntityEffectSaturation(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): + super(a_Duration, a_Intensity, a_DistanceModifier) { } -- cgit v1.2.3 From f77723128c6582e9c184706c7140c8bcf9c390c4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:23:23 -0700 Subject: Changed separating comment style from asterisks to slashes. --- src/Entities/EntityEffect.h | 138 ++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index c593fba81..6e53d83b8 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -87,9 +87,9 @@ protected: double m_DistanceModifier; }; -/************************************************************************ - **** Speed - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Speed +///////////////////////////////////////////////////////////////////////// class cEntityEffectSpeed: public cEntityEffect { @@ -101,9 +101,9 @@ public: } }; -/************************************************************************ - **** Slowness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Slowness +///////////////////////////////////////////////////////////////////////// class cEntityEffectSlowness: public cEntityEffect { @@ -115,9 +115,9 @@ public: } }; -/************************************************************************ - **** Haste - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Haste +///////////////////////////////////////////////////////////////////////// class cEntityEffectHaste: public cEntityEffect { @@ -129,9 +129,9 @@ public: } }; -/************************************************************************ - **** Mining Fatigue - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Mining Fatigue +///////////////////////////////////////////////////////////////////////// class cEntityEffectMiningFatigue: public cEntityEffect { @@ -143,9 +143,9 @@ public: } }; -/************************************************************************ - **** Strength - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Strength +///////////////////////////////////////////////////////////////////////// class cEntityEffectStrength: public cEntityEffect { @@ -157,9 +157,9 @@ public: } }; -/************************************************************************ - **** Instant Health - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Health +///////////////////////////////////////////////////////////////////////// class cEntityEffectInstantHealth: public cEntityEffect { @@ -173,9 +173,9 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -/************************************************************************ - **** Instant Damage - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Instant Damage +///////////////////////////////////////////////////////////////////////// class cEntityEffectInstantDamage: public cEntityEffect { @@ -189,9 +189,9 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -/************************************************************************ - **** Jump Boost - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Jump Boost +///////////////////////////////////////////////////////////////////////// class cEntityEffectJumpBoost: public cEntityEffect { @@ -203,9 +203,9 @@ public: } }; -/************************************************************************ - **** Nausea - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Nausea +///////////////////////////////////////////////////////////////////////// class cEntityEffectNausea: public cEntityEffect { @@ -217,9 +217,9 @@ public: } }; -/************************************************************************ - **** Regeneration - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Regeneration +///////////////////////////////////////////////////////////////////////// class cEntityEffectRegeneration: public cEntityEffect { @@ -233,9 +233,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Resistance - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Resistance +///////////////////////////////////////////////////////////////////////// class cEntityEffectResistance: public cEntityEffect { @@ -247,9 +247,9 @@ public: } }; -/************************************************************************ - **** Fire Resistance - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Fire Resistance +///////////////////////////////////////////////////////////////////////// class cEntityEffectFireResistance: public cEntityEffect { @@ -261,9 +261,9 @@ public: } }; -/************************************************************************ - **** Water Breathing - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Water Breathing +///////////////////////////////////////////////////////////////////////// class cEntityEffectWaterBreathing: public cEntityEffect { @@ -275,9 +275,9 @@ public: } }; -/************************************************************************ - **** Invisibility - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Invisibility +///////////////////////////////////////////////////////////////////////// class cEntityEffectInvisibility: public cEntityEffect { @@ -289,9 +289,9 @@ public: } }; -/************************************************************************ - **** Blindness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Blindness +///////////////////////////////////////////////////////////////////////// class cEntityEffectBlindness: public cEntityEffect { @@ -303,9 +303,9 @@ public: } }; -/************************************************************************ - **** Night Vision - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Night Vision +///////////////////////////////////////////////////////////////////////// class cEntityEffectNightVision: public cEntityEffect { @@ -317,9 +317,9 @@ public: } }; -/************************************************************************ - **** Hunger - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Hunger +///////////////////////////////////////////////////////////////////////// class cEntityEffectHunger: public cEntityEffect { @@ -333,9 +333,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Weakness - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Weakness +///////////////////////////////////////////////////////////////////////// class cEntityEffectWeakness: public cEntityEffect { @@ -349,9 +349,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Poison - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Poison +///////////////////////////////////////////////////////////////////////// class cEntityEffectPoison: public cEntityEffect { @@ -365,9 +365,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Wither - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Wither +///////////////////////////////////////////////////////////////////////// class cEntityEffectWither: public cEntityEffect { @@ -381,9 +381,9 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -/************************************************************************ - **** Health Boost - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Health Boost +///////////////////////////////////////////////////////////////////////// class cEntityEffectHealthBoost: public cEntityEffect { @@ -395,9 +395,9 @@ public: } }; -/************************************************************************ - **** Absorption - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Absorption +///////////////////////////////////////////////////////////////////////// class cEntityEffectAbsorption: public cEntityEffect { @@ -409,9 +409,9 @@ public: } }; -/************************************************************************ - **** Saturation - ************************************************************************/ +///////////////////////////////////////////////////////////////////////// +// Saturation +///////////////////////////////////////////////////////////////////////// class cEntityEffectSaturation: public cEntityEffect { -- cgit v1.2.3 From 0409daf7360d503e9e2b6258fa2582d7bdd7e5a0 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:43:49 -0700 Subject: EntityEffect: Inlined functions, added explicit copy constructor and operator. --- src/Entities/EntityEffect.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index 6e53d83b8..c6532a9bd 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -45,7 +45,15 @@ public: @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */ cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1); - virtual ~cEntityEffect(void); + /** Creates an entity effect by copying another + @param a_OtherEffect The other effect to copy */ + cEntityEffect(const cEntityEffect & a_OtherEffect); + + /** Creates an entity effect by copying another + @param a_OtherEffect The other effect to copy */ + cEntityEffect & operator=(cEntityEffect a_OtherEffect); + + virtual ~cEntityEffect(void) {}; /** Creates a pointer to the proper entity effect from the effect type @warning This function creates raw pointers that must be manually managed. @@ -70,8 +78,8 @@ public: void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } virtual void OnTick(cPawn & a_Target); - virtual void OnActivate(cPawn & a_Target); - virtual void OnDeactivate(cPawn & a_Target); + virtual void OnActivate(cPawn & a_Target) { } + virtual void OnDeactivate(cPawn & a_Target) { } protected: /** How many ticks this effect has been active for */ -- cgit v1.2.3 From 061010288a99fd11f91bf713ac68068c57f79be7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 14 Jul 2014 13:46:15 -0700 Subject: Readability and clarity changes --- src/Entities/EntityEffect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index c6532a9bd..ea0716d59 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -220,7 +220,7 @@ class cEntityEffectNausea: typedef cEntityEffect super; public: cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1): - super(a_Duration, a_Intensity, a_DistanceModifier) + super(a_Duration, a_Intensity, a_DistanceModifier) { } }; -- cgit v1.2.3 From f5259d765147cecb44a40ce5308387aba60cef8f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 11:24:48 +0200 Subject: Only the cEntityEffect::effXXX constants are Lua-exported. The rest of the classes don't need exporting, there's no interface using them anyway. --- src/Entities/EntityEffect.h | 171 ++++++++++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 71 deletions(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ea0716d59..a06c1512d 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -36,6 +36,8 @@ public: effSaturation = 23, } ; + // tolua_end + /** Creates an empty entity effect */ cEntityEffect(void); @@ -93,11 +95,12 @@ protected: /** The distance modifier for affecting potency */ double m_DistanceModifier; -}; +}; // tolua_export + + + + -///////////////////////////////////////////////////////////////////////// -// Speed -///////////////////////////////////////////////////////////////////////// class cEntityEffectSpeed: public cEntityEffect { @@ -109,9 +112,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Slowness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectSlowness: public cEntityEffect { @@ -123,9 +127,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Haste -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHaste: public cEntityEffect { @@ -137,9 +142,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Mining Fatigue -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectMiningFatigue: public cEntityEffect { @@ -151,9 +157,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Strength -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectStrength: public cEntityEffect { @@ -165,9 +172,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Instant Health -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInstantHealth: public cEntityEffect { @@ -181,9 +189,10 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Instant Damage -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInstantDamage: public cEntityEffect { @@ -197,9 +206,10 @@ public: virtual void OnActivate(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Jump Boost -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectJumpBoost: public cEntityEffect { @@ -211,9 +221,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Nausea -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectNausea: public cEntityEffect { @@ -225,9 +236,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Regeneration -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectRegeneration: public cEntityEffect { @@ -241,9 +253,10 @@ public: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Resistance -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectResistance: public cEntityEffect { @@ -255,9 +268,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Fire Resistance -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectFireResistance: public cEntityEffect { @@ -269,9 +283,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Water Breathing -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWaterBreathing: public cEntityEffect { @@ -283,9 +298,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Invisibility -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectInvisibility: public cEntityEffect { @@ -297,9 +313,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Blindness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectBlindness: public cEntityEffect { @@ -311,9 +328,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Night Vision -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectNightVision: public cEntityEffect { @@ -325,9 +343,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Hunger -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHunger: public cEntityEffect { @@ -338,12 +357,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Weakness -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWeakness: public cEntityEffect { @@ -354,12 +375,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Poison -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectPoison: public cEntityEffect { @@ -370,12 +393,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Wither -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectWither: public cEntityEffect { @@ -386,12 +411,14 @@ public: { } + // cEntityEffect overrides: virtual void OnTick(cPawn & a_Target) override; }; -///////////////////////////////////////////////////////////////////////// -// Health Boost -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectHealthBoost: public cEntityEffect { @@ -403,9 +430,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Absorption -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectAbsorption: public cEntityEffect { @@ -417,9 +445,10 @@ public: } }; -///////////////////////////////////////////////////////////////////////// -// Saturation -///////////////////////////////////////////////////////////////////////// + + + + class cEntityEffectSaturation: public cEntityEffect { @@ -435,4 +464,4 @@ public: -// tolua_end + -- 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/EntityEffect.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/Entities/EntityEffect.h') diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index a06c1512d..ebd611ff0 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -7,7 +7,7 @@ class cEntityEffect { public: - /** All types of entity effects (numbers correspond to IDs) */ + /** All types of entity effects (numbers correspond to protocol / storage types) */ enum eType { effNoEffect = 0, @@ -66,21 +66,30 @@ public: static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier); /** Returns how many ticks this effect has been active for */ - int GetTicks() { return m_Ticks; } + int GetTicks(void) const { return m_Ticks; } + /** Returns the duration of the effect */ - int GetDuration() { return m_Duration; } + int GetDuration(void) const { return m_Duration; } + /** Returns how strong the effect will be applied */ - short GetIntensity() { return m_Intensity; } + short GetIntensity(void) const { return m_Intensity; } + /** Returns the distance modifier for affecting potency */ - double GetDistanceModifier() { return m_DistanceModifier; } + double GetDistanceModifier(void) const { return m_DistanceModifier; } void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; } void SetDuration(int a_Duration) { m_Duration = a_Duration; } void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; } void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; } + /** Called on each tick. + By default increases the m_Ticks, descendants may override to provide additional processing. */ virtual void OnTick(cPawn & a_Target); + + /** Called when the effect is first added to an entity */ virtual void OnActivate(cPawn & a_Target) { } + + /** Called when the effect is removed from an entity */ virtual void OnDeactivate(cPawn & a_Target) { } protected: -- cgit v1.2.3