mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-25 11:07:45 +00:00
really refresh status instead of remove and add new one.
This commit is contained in:
parent
1e431ee924
commit
39447bd39b
7 changed files with 43 additions and 25 deletions
|
@ -25,7 +25,7 @@ public:
|
|||
auto freecure = action.getSourceChara()->getStatusEffectById( STATUS_ID_FREECURE );
|
||||
if( freecure.second )
|
||||
{
|
||||
action.getSourceChara()->removeStatusEffect( freecure.first, true, true );
|
||||
action.getSourceChara()->removeStatusEffect( freecure.first );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,26 +150,31 @@ void EffectResult::execute()
|
|||
//case Common::ActionEffectType::ApplyStatusEffect2:
|
||||
{
|
||||
uint64_t lastTickOverride = 0;
|
||||
//remove same effect from the same source (refreshing old buff)
|
||||
//refreshing old buff
|
||||
for( auto const& entry : m_target->getStatusEffectMap() )
|
||||
{
|
||||
auto statusEffect = entry.second;
|
||||
if( statusEffect->getId() == m_value && statusEffect->getSrcActorId() == m_source->getId() )
|
||||
{
|
||||
lastTickOverride = statusEffect->getLastTickMs();
|
||||
// refreshing does not show "-status" flying text, and we don't send status list now because we are adding a new one
|
||||
m_target->removeStatusEffect( entry.first, false, false );
|
||||
break;
|
||||
if( m_pPreBuiltStatusEffect )
|
||||
{
|
||||
statusEffect->refresh( m_pPreBuiltStatusEffect->getEffectEntry() );
|
||||
}
|
||||
else
|
||||
{
|
||||
statusEffect->refresh();
|
||||
}
|
||||
m_target->sendStatusEffectUpdate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pPreBuiltStatusEffect )
|
||||
{
|
||||
m_pPreBuiltStatusEffect->setLastTick( lastTickOverride );
|
||||
m_target->addStatusEffect( m_pPreBuiltStatusEffect );
|
||||
}
|
||||
else
|
||||
m_target->addStatusEffectById( m_value, m_statusDuration, *m_source, m_param2, lastTickOverride );
|
||||
m_target->addStatusEffectById( m_value, m_statusDuration, *m_source, m_param2 );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -538,22 +538,20 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf
|
|||
sendStatusEffectUpdate(); // although client buff displays correctly without this but retail sends it so we do it as well
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param, uint64_t lastTickOverride )
|
||||
void Sapphire::Entity::Chara::addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
{
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||
effect->setParam( param );
|
||||
effect->setLastTick( lastTickOverride == 0 ? Util::getTimeMs() : lastTickOverride );
|
||||
addStatusEffect( effect );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param, uint64_t lastTickOverride )
|
||||
void Sapphire::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param )
|
||||
{
|
||||
if( getStatusEffectById( id ).second )
|
||||
return;
|
||||
|
||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||
effect->setParam( param );
|
||||
effect->setLastTick( lastTickOverride == 0 ? Util::getTimeMs() : lastTickOverride );
|
||||
addStatusEffect( effect );
|
||||
}
|
||||
|
||||
|
@ -575,19 +573,19 @@ void Sapphire::Entity::Chara::statusEffectFreeSlot( uint8_t slotId )
|
|||
m_statusEffectFreeSlotQueue.push( slotId );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::removeSingleStatusEffectById( uint32_t id, bool sendActorControl, bool sendStatusList )
|
||||
void Sapphire::Entity::Chara::removeSingleStatusEffectById( uint32_t id, bool sendStatusList )
|
||||
{
|
||||
for( auto effectIt : m_statusEffectMap )
|
||||
{
|
||||
if( effectIt.second->getId() == id )
|
||||
{
|
||||
removeStatusEffect( effectIt.first, sendActorControl, sendStatusList );
|
||||
removeStatusEffect( effectIt.first );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Chara::removeStatusEffect( uint8_t effectSlotId, bool sendActorControl, bool sendStatusList )
|
||||
void Sapphire::Entity::Chara::removeStatusEffect( uint8_t effectSlotId, bool sendStatusList )
|
||||
{
|
||||
auto pEffectIt = m_statusEffectMap.find( effectSlotId );
|
||||
if( pEffectIt == m_statusEffectMap.end() )
|
||||
|
@ -600,9 +598,7 @@ void Sapphire::Entity::Chara::removeStatusEffect( uint8_t effectSlotId, bool sen
|
|||
auto pEffect = pEffectIt->second;
|
||||
pEffect->removeStatus();
|
||||
|
||||
if( sendActorControl )
|
||||
sendToInRangeSet( makeActorControl( getId(), StatusEffectLose, pEffect->getId() ), isPlayer() );
|
||||
|
||||
sendToInRangeSet( makeActorControl( getId(), StatusEffectLose, pEffect->getId() ), true );
|
||||
if( sendStatusList )
|
||||
sendStatusEffectUpdate();
|
||||
}
|
||||
|
@ -723,7 +719,7 @@ void Sapphire::Entity::Chara::updateStatusEffects()
|
|||
if( effect->isMarkedToRemove() || ( duration > 0 && ( currentTimeMs - startTime ) > duration ) )
|
||||
{
|
||||
// remove status effect
|
||||
removeStatusEffect( effectIndex, true, true );
|
||||
removeStatusEffect( effectIndex );
|
||||
// break because removing invalidates iterators
|
||||
break;
|
||||
}
|
||||
|
@ -991,7 +987,7 @@ float Sapphire::Entity::Chara::applyShieldProtection( float damage )
|
|||
{
|
||||
for( auto const& slotId : destroyedShieldSlotList )
|
||||
{
|
||||
removeStatusEffect( slotId, true, false );
|
||||
removeStatusEffect( slotId, false );
|
||||
}
|
||||
sendStatusEffectUpdate();
|
||||
}
|
||||
|
|
|
@ -147,9 +147,9 @@ namespace Sapphire::Entity
|
|||
/// Status effect functions
|
||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||
|
||||
void removeStatusEffect( uint8_t effectSlotId, bool sendActorControl, bool sendStatusList );
|
||||
void removeStatusEffect( uint8_t effectSlotId, bool sendStatusList = true );
|
||||
|
||||
void removeSingleStatusEffectById( uint32_t id, bool sendActorControl, bool sendStatusList );
|
||||
void removeSingleStatusEffectById( uint32_t id, bool sendStatusList = true );
|
||||
|
||||
void updateStatusEffects();
|
||||
|
||||
|
@ -175,10 +175,10 @@ namespace Sapphire::Entity
|
|||
const uint32_t* getModelArray() const;
|
||||
|
||||
// add a status effect by id
|
||||
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0, uint64_t lastTickOverride = 0 );
|
||||
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0 );
|
||||
|
||||
// add a status effect by id if it doesn't exist
|
||||
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0, uint64_t lastTickOverride = 0 );
|
||||
void addStatusEffectByIdIfNotExist( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0 );
|
||||
|
||||
/// End Status Effect Functions
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw,
|
|||
case ClientTriggerType::RemoveStatusEffect: // Remove status (clicking it off)
|
||||
{
|
||||
// todo: check if status can be removed by client from exd
|
||||
player.removeSingleStatusEffectById( static_cast< uint32_t >( param1 ), true, true );
|
||||
player.removeSingleStatusEffectById( static_cast< uint32_t >( param1 ) );
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::CastCancel: // Cancel cast
|
||||
|
|
|
@ -325,4 +325,18 @@ void Sapphire::StatusEffect::StatusEffect::onBeforeActionStart( Sapphire::World:
|
|||
bool Sapphire::StatusEffect::StatusEffect::isMarkedToRemove()
|
||||
{
|
||||
return m_markToRemove;
|
||||
}
|
||||
|
||||
void Sapphire::StatusEffect::StatusEffect::refresh()
|
||||
{
|
||||
m_value = 0;
|
||||
m_cachedSourceCritBonus = 0;
|
||||
m_cachedSourceCrit = 0;
|
||||
applyStatus();
|
||||
}
|
||||
|
||||
void Sapphire::StatusEffect::StatusEffect::refresh( Sapphire::World::Action::StatusEffectEntry newEntry )
|
||||
{
|
||||
m_effectEntry = newEntry;
|
||||
refresh();
|
||||
}
|
|
@ -57,6 +57,9 @@ public:
|
|||
|
||||
bool isMarkedToRemove();
|
||||
|
||||
void refresh();
|
||||
void refresh( Sapphire::World::Action::StatusEffectEntry newEntry );
|
||||
|
||||
private:
|
||||
uint32_t m_id;
|
||||
Entity::CharaPtr m_sourceActor;
|
||||
|
|
Loading…
Add table
Reference in a new issue