Merge pull request #2584 from bibo38/firepotion
Implemented the FireResistence potion effects.
This commit is contained in:
commit
b13fd00ec4
@ -1822,8 +1822,9 @@ a_Player:OpenWindow(Window);
|
|||||||
TakeDamage = { Return = "" },
|
TakeDamage = { Return = "" },
|
||||||
KilledBy = { Return = "" },
|
KilledBy = { Return = "" },
|
||||||
GetHealth = { Return = "number" },
|
GetHealth = { Return = "number" },
|
||||||
AddEntityEffect = { Params = "EffectType, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" },
|
AddEntityEffect = { Params = "{{cEntityEffect|EffectType}}, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" },
|
||||||
RemoveEntityEffect = { Params = "EffectType", Return = "", Notes = "Removes a currently applied entity effect" },
|
RemoveEntityEffect = { Params = "{{cEntityEffect|EffectType}}", Return = "", Notes = "Removes a currently applied entity effect" },
|
||||||
|
HasEntityEffect = { Return = "bool", Params = "{{cEntityEffect|EffectType}}", Notes = "Returns true, if the supplied entity effect type is currently applied" }
|
||||||
ClearEntityEffects = { Return = "", Notes = "Removes all currently applied entity effects" },
|
ClearEntityEffects = { Return = "", Notes = "Removes all currently applied entity effects" },
|
||||||
},
|
},
|
||||||
Inherits = "cEntity",
|
Inherits = "cEntity",
|
||||||
|
@ -1104,7 +1104,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
|
|||||||
m_TicksSinceLastBurnDamage++;
|
m_TicksSinceLastBurnDamage++;
|
||||||
if (m_TicksSinceLastBurnDamage >= BURN_TICKS_PER_DAMAGE)
|
if (m_TicksSinceLastBurnDamage >= BURN_TICKS_PER_DAMAGE)
|
||||||
{
|
{
|
||||||
if (!m_IsFireproof)
|
if (!IsFireproof())
|
||||||
{
|
{
|
||||||
TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
|
TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
|
||||||
}
|
}
|
||||||
@ -1175,7 +1175,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
|
|||||||
m_TicksSinceLastLavaDamage++;
|
m_TicksSinceLastLavaDamage++;
|
||||||
if (m_TicksSinceLastLavaDamage >= LAVA_TICKS_PER_DAMAGE)
|
if (m_TicksSinceLastLavaDamage >= LAVA_TICKS_PER_DAMAGE)
|
||||||
{
|
{
|
||||||
if (!m_IsFireproof)
|
if (!IsFireproof())
|
||||||
{
|
{
|
||||||
TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
|
TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
|
||||||
}
|
}
|
||||||
@ -1196,7 +1196,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
|
|||||||
m_TicksSinceLastFireDamage++;
|
m_TicksSinceLastFireDamage++;
|
||||||
if (m_TicksSinceLastFireDamage >= FIRE_TICKS_PER_DAMAGE)
|
if (m_TicksSinceLastFireDamage >= FIRE_TICKS_PER_DAMAGE)
|
||||||
{
|
{
|
||||||
if (!m_IsFireproof)
|
if (!IsFireproof())
|
||||||
{
|
{
|
||||||
TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
|
TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ public:
|
|||||||
/** Sets whether the entity is fireproof */
|
/** Sets whether the entity is fireproof */
|
||||||
void SetIsFireproof(bool a_IsFireproof);
|
void SetIsFireproof(bool a_IsFireproof);
|
||||||
|
|
||||||
bool IsFireproof(void) const { return m_IsFireproof; }
|
virtual bool IsFireproof(void) const { return m_IsFireproof; }
|
||||||
|
|
||||||
/** Puts the entity on fire for the specified amount of ticks */
|
/** Puts the entity on fire for the specified amount of ticks */
|
||||||
void StartBurning(int a_TicksLeftBurning);
|
void StartBurning(int a_TicksLeftBurning);
|
||||||
|
@ -46,6 +46,9 @@ void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hi
|
|||||||
Destroy();
|
Destroy();
|
||||||
Explode(a_HitPos.Floor());
|
Explode(a_HitPos.Floor());
|
||||||
|
|
||||||
// TODO: Some entities are immune to hits
|
if (!a_EntityHit.IsFireproof())
|
||||||
a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
|
{
|
||||||
|
// TODO Damage Entity with 5 damage(from http://minecraft.gamepedia.com/Blaze#Blaze_fireball)
|
||||||
|
a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,15 @@ void cPawn::KilledBy(TakeDamageInfo & a_TDI)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPawn::IsFireproof(void) const
|
||||||
|
{
|
||||||
|
return super::IsFireproof() || HasEntityEffect(cEntityEffect::effFireResistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
|
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
|
||||||
{
|
{
|
||||||
// Check if the plugins allow the addition:
|
// Check if the plugins allow the addition:
|
||||||
@ -98,6 +107,15 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPawn::HasEntityEffect(cEntityEffect::eType a_EffectType) const
|
||||||
|
{
|
||||||
|
return m_EntityEffects.find(a_EffectType) != m_EntityEffects.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cPawn::ClearEntityEffects()
|
void cPawn::ClearEntityEffects()
|
||||||
{
|
{
|
||||||
// Iterate through this entity's applied effects
|
// Iterate through this entity's applied effects
|
||||||
|
@ -23,6 +23,8 @@ public:
|
|||||||
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||||
|
|
||||||
|
virtual bool IsFireproof(void) const override;
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
/** Applies an entity effect
|
/** Applies an entity effect
|
||||||
@ -39,6 +41,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
|
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
|
||||||
|
|
||||||
|
/** Returns true, if the entity effect is currently applied
|
||||||
|
@param a_EffectType The entity effect to check
|
||||||
|
*/
|
||||||
|
bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
|
||||||
|
|
||||||
/** Removes all currently applied entity effects (used when drinking milk) */
|
/** Removes all currently applied entity effects (used when drinking milk) */
|
||||||
void ClearEntityEffects(void);
|
void ClearEntityEffects(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user