From e677ee5ef8c00b01c3b8ad65c40271437237b3e1 Mon Sep 17 00:00:00 2001 From: collett Date: Tue, 14 Jan 2020 23:41:31 +0900 Subject: [PATCH] Dots and hots should tick together one total number per tick. --- src/world/Actor/BNpc.cpp | 1 + src/world/Actor/Chara.cpp | 76 +++++++++++++++++---------------- src/world/Actor/Chara.h | 2 +- src/world/Actor/PlayerEvent.cpp | 2 +- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 54c74953..0a6c5fbe 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -396,6 +396,7 @@ void Sapphire::Entity::BNpc::deaggro( Sapphire::Entity::CharaPtr pChara ) void Sapphire::Entity::BNpc::onTick() { + Chara::onTick(); if( m_state == BNpcState::Retreat ) { regainHp(); diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 6bd8c039..f3cbd2e7 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -709,9 +709,6 @@ void Sapphire::Entity::Chara::updateStatusEffects() { uint64_t currentTimeMs = Util::getTimeMs(); - uint32_t thisTickDmg = 0; - uint32_t thisTickHeal = 0; - for( auto effectIt : m_statusEffectMap ) { uint8_t effectIndex = effectIt.first; @@ -734,41 +731,7 @@ void Sapphire::Entity::Chara::updateStatusEffects() { effect->setLastTick( currentTimeMs ); effect->onTick(); - - auto thisEffect = effect->getTickEffect(); - - switch( thisEffect.first ) - { - - case 1: - { - thisTickDmg += thisEffect.second; - break; - } - - case 2: - { - thisTickHeal += thisEffect.second; - break; - } - - } } - - } - - if( thisTickDmg != 0 ) - { - takeDamage( thisTickDmg ); - sendToInRangeSet( makeActorControl( getId(), HPFloatingText, 0, - static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ), true ); - } - - if( thisTickHeal != 0 ) - { - heal( thisTickHeal ); - sendToInRangeSet( makeActorControl( getId(), HPFloatingText, 0, - static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ), true ); } } @@ -1035,4 +998,43 @@ float Sapphire::Entity::Chara::applyShieldProtection( float damage ) sendEffectResultToUpdateShieldValue(); // yes this is the packet to update shield value } return remainingDamage; +} + +void Sapphire::Entity::Chara::onTick() +{ + uint32_t thisTickDmg = 0; + uint32_t thisTickHeal = 0; + + for( auto effectIt : m_statusEffectMap ) + { + auto thisEffect = effectIt.second->getTickEffect(); + switch( thisEffect.first ) + { + case 1: + { + thisTickDmg += thisEffect.second; + break; + } + + case 2: + { + thisTickHeal += thisEffect.second; + break; + } + } + } + + if( thisTickDmg != 0 ) + { + takeDamage( thisTickDmg ); + sendToInRangeSet( makeActorControl( getId(), HPFloatingText, 0, + static_cast< uint8_t >( ActionEffectType::Damage ), thisTickDmg ), true ); + } + + if( thisTickHeal != 0 ) + { + heal( thisTickHeal ); + sendToInRangeSet( makeActorControl( getId(), HPFloatingText, 0, + static_cast< uint8_t >( ActionEffectType::Heal ), thisTickHeal ), true ); + } } \ No newline at end of file diff --git a/src/world/Actor/Chara.h b/src/world/Actor/Chara.h index fa6c3247..fb0ba97c 100644 --- a/src/world/Actor/Chara.h +++ b/src/world/Actor/Chara.h @@ -252,7 +252,7 @@ namespace Sapphire::Entity virtual void onActionFriendly( Chara& pSource ) {}; - virtual void onTick() {}; + virtual void onTick(); virtual void changeTarget( uint64_t targetId ); diff --git a/src/world/Actor/PlayerEvent.cpp b/src/world/Actor/PlayerEvent.cpp index 0303b4fb..08f830e4 100644 --- a/src/world/Actor/PlayerEvent.cpp +++ b/src/world/Actor/PlayerEvent.cpp @@ -370,7 +370,7 @@ void Sapphire::Entity::Player::onDeath() // TODO: slightly ugly here and way too static. Needs too be done properly void Sapphire::Entity::Player::onTick() { - + Chara::onTick(); // add 3 seconds to total play time m_playTime += 3;