1
0

Merge pull request #2584 from bibo38/firepotion

Implemented the FireResistence potion effects.
This commit is contained in:
Alexander Harkness 2015-10-31 22:18:27 +00:00
commit b13fd00ec4
6 changed files with 37 additions and 8 deletions

View File

@ -1822,8 +1822,9 @@ a_Player:OpenWindow(Window);
TakeDamage = { Return = "" },
KilledBy = { Return = "" },
GetHealth = { Return = "number" },
AddEntityEffect = { Params = "EffectType, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" },
RemoveEntityEffect = { Params = "EffectType", Return = "", Notes = "Removes a currently applied entity effect" },
AddEntityEffect = { Params = "{{cEntityEffect|EffectType}}, {{cEntityEffect}}", Return = "", Notes = "Applies an 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" },
},
Inherits = "cEntity",

View File

@ -1104,7 +1104,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastBurnDamage++;
if (m_TicksSinceLastBurnDamage >= BURN_TICKS_PER_DAMAGE)
{
if (!m_IsFireproof)
if (!IsFireproof())
{
TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
}
@ -1175,7 +1175,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastLavaDamage++;
if (m_TicksSinceLastLavaDamage >= LAVA_TICKS_PER_DAMAGE)
{
if (!m_IsFireproof)
if (!IsFireproof())
{
TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
}
@ -1196,7 +1196,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksSinceLastFireDamage++;
if (m_TicksSinceLastFireDamage >= FIRE_TICKS_PER_DAMAGE)
{
if (!m_IsFireproof)
if (!IsFireproof())
{
TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
}

View File

@ -367,7 +367,7 @@ public:
/** Sets whether the entity is fireproof */
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 */
void StartBurning(int a_TicksLeftBurning);

View File

@ -46,6 +46,9 @@ void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hi
Destroy();
Explode(a_HitPos.Floor());
// TODO: Some entities are immune to hits
a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
if (!a_EntityHit.IsFireproof())
{
// TODO Damage Entity with 5 damage(from http://minecraft.gamepedia.com/Blaze#Blaze_fireball)
a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning
}
}

View File

@ -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)
{
// 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()
{
// Iterate through this entity's applied effects

View File

@ -23,6 +23,8 @@ public:
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsFireproof(void) const override;
// tolua_begin
/** Applies an entity effect
@ -39,6 +41,11 @@ public:
*/
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) */
void ClearEntityEffects(void);