summaryrefslogtreecommitdiffstats
path: root/src/Entities/EntityEffect.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-08-30 12:45:39 +0200
committerHowaner <franzi.moos@googlemail.com>2014-08-30 12:45:39 +0200
commit003206b1b038f4616d5318068106573cec4d4ecd (patch)
tree4eb7f2bc1f3eb9d672a5650be83cf28eb78583c8 /src/Entities/EntityEffect.cpp
parentAdded SetWalkSpeed() to cMonster. (diff)
downloadcuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar.gz
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar.bz2
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar.lz
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar.xz
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.tar.zst
cuberite-003206b1b038f4616d5318068106573cec4d4ecd.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/EntityEffect.cpp77
1 files changed, 61 insertions, 16 deletions
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 58b76b21b..9cf20095d 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -237,17 +237,18 @@ void cEntityEffect::OnTick(cPawn & a_Target)
void cEntityEffectSpeed::OnActivate(cPawn & a_Target)
{
- // TODO: Add SetMormalMaxSpeed to cMonster
-
- if (!a_Target.IsPlayer())
+ if (a_Target.IsMob())
{
- return;
+ cMonster * Mob = (cMonster*) &a_Target;
+ Mob->SetWalkSpeed(Mob->GetWalkSpeed() + 0.2 * m_Intensity);
+ }
+ else if (a_Target.IsPlayer())
+ {
+ cPlayer * Player = (cPlayer*) &a_Target;
+ Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() + 0.2 * m_Intensity);
+ Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() + 0.26 * m_Intensity);
+ Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() + 0.2 * m_Intensity);
}
- cPlayer * Player = (cPlayer*) &a_Target;
-
- Player->SetNormalMaxSpeed(1.0 + 0.2 * m_Intensity);
- Player->SetSprintingMaxSpeed(1.3 + 0.26 * m_Intensity);
- Player->SetFlyingMaxSpeed(1.0 + 0.2 * m_Intensity);
}
@@ -256,17 +257,61 @@ void cEntityEffectSpeed::OnActivate(cPawn & a_Target)
void cEntityEffectSpeed::OnDeactivate(cPawn & a_Target)
{
- // TODO: Add SetMormalMaxSpeed to cMonster
+ if (a_Target.IsMob())
+ {
+ cMonster * Mob = (cMonster*) &a_Target;
+ Mob->SetWalkSpeed(Mob->GetWalkSpeed() - 0.2 * m_Intensity);
+ }
+ else if (a_Target.IsPlayer())
+ {
+ cPlayer * Player = (cPlayer*) &a_Target;
+ Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() - 0.2 * m_Intensity);
+ Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() - 0.26 * m_Intensity);
+ Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() - 0.2 * m_Intensity);
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cEntityEffectSlowness:
- if (!a_Target.IsPlayer())
+void cEntityEffectSlowness::OnActivate(cPawn & a_Target)
+{
+ if (a_Target.IsMob())
{
- return;
+ cMonster * Mob = (cMonster*) &a_Target;
+ Mob->SetWalkSpeed(Mob->GetWalkSpeed() - 0.15 * m_Intensity);
}
- cPlayer * Player = (cPlayer*) &a_Target;
+ else if (a_Target.IsPlayer())
+ {
+ cPlayer * Player = (cPlayer*) &a_Target;
+ Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() - 0.15 * m_Intensity);
+ Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() - 0.195 * m_Intensity);
+ Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() - 0.15 * m_Intensity);
+ }
+}
+
+
- Player->SetNormalMaxSpeed(1.0);
- Player->SetSprintingMaxSpeed(1.3);
- Player->SetFlyingMaxSpeed(1.0);
+
+
+void cEntityEffectSlowness::OnDeactivate(cPawn & a_Target)
+{
+ if (a_Target.IsMob())
+ {
+ cMonster * Mob = (cMonster*) &a_Target;
+ Mob->SetWalkSpeed(Mob->GetWalkSpeed() + 0.15 * m_Intensity);
+ }
+ else if (a_Target.IsPlayer())
+ {
+ cPlayer * Player = (cPlayer*) &a_Target;
+ Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() + 0.15 * m_Intensity);
+ Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() + 0.195 * m_Intensity);
+ Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() + 0.15 * m_Intensity);
+ }
}