mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
somewhat basic but working effect result delay
This commit is contained in:
parent
f3ba1ce6c0
commit
c9c481d63a
7 changed files with 89 additions and 28 deletions
|
@ -24,11 +24,11 @@ EffectBuilder::EffectBuilder( Entity::CharaPtr source, uint32_t actionId, uint16
|
|||
|
||||
}
|
||||
|
||||
uint32_t EffectBuilder::getResultDelayMs()
|
||||
uint64_t EffectBuilder::getResultDelayMs()
|
||||
{
|
||||
// todo: actually figure this retarded shit out
|
||||
|
||||
return Common::Util::getTimeMs() + 1000;
|
||||
return Common::Util::getTimeMs() + 850;
|
||||
}
|
||||
|
||||
EffectResultPtr EffectBuilder::getResult( Entity::CharaPtr& chara )
|
||||
|
@ -69,11 +69,9 @@ void EffectBuilder::buildAndSendPackets()
|
|||
Logger::debug( "EffectBuilder result: " );
|
||||
Logger::debug( "Targets afflicted: {}", m_resolvedEffects.size() );
|
||||
|
||||
// test shit
|
||||
for( auto& effect : m_resolvedEffects )
|
||||
for( auto it = m_resolvedEffects.begin(); it != m_resolvedEffects.end(); )
|
||||
{
|
||||
auto& result = effect.second;
|
||||
|
||||
auto result = it->second;
|
||||
Logger::debug( " - id: {}", result->getTarget()->getId() );
|
||||
|
||||
auto seq = m_sourceChara->getCurrentTerritory()->getNextEffectSequence();
|
||||
|
@ -85,6 +83,10 @@ void EffectBuilder::buildAndSendPackets()
|
|||
effectPacket->addEffect( result->buildEffectEntry() );
|
||||
|
||||
m_sourceChara->sendToInRangeSet( effectPacket, true );
|
||||
}
|
||||
|
||||
// add effect to territory
|
||||
m_sourceChara->getCurrentTerritory()->addEffectResult( std::move( result ) );
|
||||
|
||||
it = m_resolvedEffects.erase( it );
|
||||
}
|
||||
}
|
|
@ -9,14 +9,6 @@ namespace Sapphire::World::Action
|
|||
class EffectBuilder
|
||||
{
|
||||
public:
|
||||
enum HitSeverity
|
||||
{
|
||||
Normal,
|
||||
Critical,
|
||||
DirectHit,
|
||||
CriticalDirectHit
|
||||
};
|
||||
|
||||
EffectBuilder( Entity::CharaPtr source, uint32_t actionId, uint16_t sequence );
|
||||
|
||||
|
||||
|
@ -32,7 +24,7 @@ namespace Sapphire::World::Action
|
|||
private:
|
||||
EffectResultPtr getResult( Entity::CharaPtr& chara );
|
||||
|
||||
uint32_t getResultDelayMs();
|
||||
uint64_t getResultDelayMs();
|
||||
|
||||
private:
|
||||
uint32_t m_actionId;
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
|
||||
#include <Util/Util.h>
|
||||
|
||||
#include "Actor/Chara.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
using namespace Sapphire::World::Action;
|
||||
|
||||
|
||||
EffectResult::EffectResult( Entity::CharaPtr target, uint32_t runAfter ) :
|
||||
EffectResult::EffectResult( Entity::CharaPtr target, uint64_t runAfter ) :
|
||||
m_target( std::move( target ) ),
|
||||
m_runAfter( runAfter ),
|
||||
m_delayMs( runAfter ),
|
||||
m_value( 0 ),
|
||||
m_severity( Common::ActionHitSeverityType::NormalDamage )
|
||||
m_severity( Common::ActionHitSeverityType::NormalDamage ),
|
||||
m_type( Common::ActionEffectType::Nothing ),
|
||||
m_param( 0 )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -25,6 +29,11 @@ uint32_t EffectResult::getValue() const
|
|||
return m_value;
|
||||
}
|
||||
|
||||
uint64_t EffectResult::getDelay()
|
||||
{
|
||||
return m_delayMs;
|
||||
}
|
||||
|
||||
void EffectResult::setParam( uint8_t param )
|
||||
{
|
||||
m_param = param;
|
||||
|
@ -57,4 +66,25 @@ Common::EffectEntry EffectResult::buildEffectEntry() const
|
|||
entry.param = m_param;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void EffectResult::execute()
|
||||
{
|
||||
switch( m_type )
|
||||
{
|
||||
case Common::ActionEffectType::Damage:
|
||||
{
|
||||
m_target->takeDamage( m_value );
|
||||
break;
|
||||
}
|
||||
|
||||
case Common::ActionEffectType::Heal:
|
||||
{
|
||||
m_target->heal( m_value );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace Sapphire::World::Action
|
|||
class EffectResult
|
||||
{
|
||||
public:
|
||||
explicit EffectResult( Entity::CharaPtr target, uint32_t delayMs );
|
||||
explicit EffectResult( Entity::CharaPtr target, uint64_t delayMs );
|
||||
|
||||
void damage( uint32_t amount, Common::ActionHitSeverityType severity );
|
||||
void heal( uint32_t amount, Common::ActionHitSeverityType severity );
|
||||
|
@ -22,12 +22,16 @@ namespace Sapphire::World::Action
|
|||
|
||||
uint32_t getValue() const;
|
||||
|
||||
uint64_t getDelay();
|
||||
|
||||
void setParam( uint8_t param );
|
||||
|
||||
Common::EffectEntry buildEffectEntry() const;
|
||||
|
||||
void execute();
|
||||
|
||||
private:
|
||||
uint64_t m_runAfter;
|
||||
uint64_t m_delayMs;
|
||||
|
||||
Entity::CharaPtr m_target;
|
||||
|
||||
|
|
|
@ -462,7 +462,7 @@ float CalcStats::calcAutoAttackDamage( const Sapphire::Entity::Chara& chara )
|
|||
{
|
||||
Logger::debug( format, pot, aa, ap, det, ten, factor );
|
||||
}
|
||||
|
||||
|
||||
// todo: traits
|
||||
|
||||
factor = std::floor( factor * speed( chara ) );
|
||||
|
@ -494,15 +494,15 @@ float CalcStats::calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_
|
|||
|
||||
auto factor = std::floor( pot * wd * ap * det * ten );
|
||||
|
||||
constexpr auto format = "dmg: pot: {} wd: {} ap: {} det: {} ten: {} = {}";
|
||||
constexpr auto format = "dmg: pot: {} ({}) wd: {} ({}) ap: {} det: {} ten: {} = {}";
|
||||
|
||||
if( auto player = const_cast< Entity::Chara& >( chara ).getAsPlayer() )
|
||||
{
|
||||
player->sendDebug( format, pot, wd, ap, det, ten, factor );
|
||||
player->sendDebug( format, pot, ptc, wd, wepDmg, ap, det, ten, factor );
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::debug( format, pot, wd, ap, det, ten, factor );
|
||||
Logger::debug( format, pot, ptc, wd, wepDmg, ap, det, ten, factor );
|
||||
}
|
||||
|
||||
// todo: the rest
|
||||
|
|
|
@ -31,15 +31,15 @@
|
|||
#include "Actor/SpawnPoint.h"
|
||||
#include "Actor/BNpcTemplate.h"
|
||||
|
||||
#include "Action/EffectResult.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
|
||||
#include "Session.h"
|
||||
#include "ForwardsZone.h"
|
||||
#include "ServerMgr.h"
|
||||
#include "CellHandler.h"
|
||||
#include "Territory.h"
|
||||
#include "Framework.h"
|
||||
|
||||
#include "Manager/RNGMgr.h"
|
||||
|
@ -486,6 +486,8 @@ bool Sapphire::Territory::update( uint64_t tickCount )
|
|||
|
||||
updateSpawnPoints();
|
||||
|
||||
processEffectResults( tickCount );
|
||||
|
||||
if( !m_playerMap.empty() )
|
||||
m_lastActivityTime = tickCount;
|
||||
|
||||
|
@ -1006,7 +1008,7 @@ Sapphire::Entity::BNpcPtr
|
|||
|
||||
Sapphire::Entity::BNpcPtr Sapphire::Territory::getActiveBNpcByLevelId( uint32_t levelId )
|
||||
{
|
||||
for( auto bnpcIt : m_bNpcMap )
|
||||
for( const auto& bnpcIt : m_bNpcMap )
|
||||
{
|
||||
if( bnpcIt.second->getLevelId() == levelId )
|
||||
return bnpcIt.second;
|
||||
|
@ -1018,3 +1020,28 @@ std::shared_ptr< Sapphire::World::Navi::NaviProvider > Sapphire::Territory::getN
|
|||
{
|
||||
return m_pNaviProvider;
|
||||
}
|
||||
|
||||
void Sapphire::Territory::addEffectResult( Sapphire::World::Action::EffectResultPtr result )
|
||||
{
|
||||
m_effectResults.emplace_back( std::move( result ) );
|
||||
}
|
||||
|
||||
void Sapphire::Territory::processEffectResults( uint64_t tickCount )
|
||||
|
||||
{
|
||||
// todo: move this to generic territory/instance delay wrapper cause it might be useful scheduling other things
|
||||
for( auto it = m_effectResults.begin(); it != m_effectResults.end(); )
|
||||
{
|
||||
auto effect = *it;
|
||||
|
||||
if( tickCount < effect->getDelay() )
|
||||
{
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
|
||||
effect->execute();
|
||||
|
||||
it = m_effectResults.erase( it );
|
||||
}
|
||||
}
|
|
@ -65,6 +65,8 @@ namespace Sapphire
|
|||
uint32_t m_effectCounter;
|
||||
std::shared_ptr< World::Navi::NaviProvider > m_pNaviProvider;
|
||||
|
||||
std::vector< World::Action::EffectResultPtr > m_effectResults;
|
||||
|
||||
public:
|
||||
Territory();
|
||||
|
||||
|
@ -174,6 +176,10 @@ namespace Sapphire
|
|||
uint32_t getNextEffectSequence();
|
||||
|
||||
std::shared_ptr< World::Navi::NaviProvider > getNaviProvider();
|
||||
|
||||
void addEffectResult( World::Action::EffectResultPtr result );
|
||||
|
||||
void processEffectResults( uint64_t tickCount );
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue