From 240ec9b4bdd70f29aea3340f8f684818022122fd Mon Sep 17 00:00:00 2001 From: Hownaer Date: Thu, 28 Aug 2014 23:02:20 +0200 Subject: Added speed entity effect. --- src/ClientHandle.cpp | 2 +- src/Entities/EntityEffect.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/Entities/EntityEffect.h | 4 ++++ 3 files changed, 46 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f9c6a664c..5ad9dc644 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1063,7 +1063,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc (m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_FIRE) ) { - // Players can't destroy blocks with a Sword in the hand. + // Players can't destroy blocks with a sword in the hand. return; } diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 3e28392f4..58b76b21b 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -232,6 +232,47 @@ void cEntityEffect::OnTick(cPawn & a_Target) +//////////////////////////////////////////////////////////////////////////////// +// cEntityEffectSpeed: + +void cEntityEffectSpeed::OnActivate(cPawn & a_Target) +{ + // TODO: Add SetMormalMaxSpeed to cMonster + + if (!a_Target.IsPlayer()) + { + return; + } + 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); +} + + + + + +void cEntityEffectSpeed::OnDeactivate(cPawn & a_Target) +{ + // TODO: Add SetMormalMaxSpeed to cMonster + + if (!a_Target.IsPlayer()) + { + return; + } + cPlayer * Player = (cPlayer*) &a_Target; + + Player->SetNormalMaxSpeed(1.0); + Player->SetSprintingMaxSpeed(1.3); + Player->SetFlyingMaxSpeed(1.0); +} + + + + + //////////////////////////////////////////////////////////////////////////////// // cEntityEffectInstantHealth: diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index 47c298f57..e123a7f77 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -137,6 +137,10 @@ public: super(a_Duration, a_Intensity, a_DistanceModifier) { } + + virtual void OnActivate(cPawn & a_Target) override; + + virtual void OnDeactivate(cPawn & a_Target) override; }; -- cgit v1.2.3