mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-25 19:17: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 );
|
auto freecure = action.getSourceChara()->getStatusEffectById( STATUS_ID_FREECURE );
|
||||||
if( freecure.second )
|
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:
|
//case Common::ActionEffectType::ApplyStatusEffect2:
|
||||||
{
|
{
|
||||||
uint64_t lastTickOverride = 0;
|
uint64_t lastTickOverride = 0;
|
||||||
//remove same effect from the same source (refreshing old buff)
|
//refreshing old buff
|
||||||
for( auto const& entry : m_target->getStatusEffectMap() )
|
for( auto const& entry : m_target->getStatusEffectMap() )
|
||||||
{
|
{
|
||||||
auto statusEffect = entry.second;
|
auto statusEffect = entry.second;
|
||||||
if( statusEffect->getId() == m_value && statusEffect->getSrcActorId() == m_source->getId() )
|
if( statusEffect->getId() == m_value && statusEffect->getSrcActorId() == m_source->getId() )
|
||||||
{
|
{
|
||||||
lastTickOverride = statusEffect->getLastTickMs();
|
if( m_pPreBuiltStatusEffect )
|
||||||
// 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 );
|
statusEffect->refresh( m_pPreBuiltStatusEffect->getEffectEntry() );
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statusEffect->refresh();
|
||||||
|
}
|
||||||
|
m_target->sendStatusEffectUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_pPreBuiltStatusEffect )
|
if( m_pPreBuiltStatusEffect )
|
||||||
{
|
{
|
||||||
m_pPreBuiltStatusEffect->setLastTick( lastTickOverride );
|
|
||||||
m_target->addStatusEffect( m_pPreBuiltStatusEffect );
|
m_target->addStatusEffect( m_pPreBuiltStatusEffect );
|
||||||
}
|
}
|
||||||
else
|
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;
|
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
|
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 );
|
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||||
effect->setParam( param );
|
effect->setParam( param );
|
||||||
effect->setLastTick( lastTickOverride == 0 ? Util::getTimeMs() : lastTickOverride );
|
|
||||||
addStatusEffect( effect );
|
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 )
|
if( getStatusEffectById( id ).second )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
auto effect = StatusEffect::make_StatusEffect( id, source.getAsChara(), getAsChara(), duration, 3000, m_pFw );
|
||||||
effect->setParam( param );
|
effect->setParam( param );
|
||||||
effect->setLastTick( lastTickOverride == 0 ? Util::getTimeMs() : lastTickOverride );
|
|
||||||
addStatusEffect( effect );
|
addStatusEffect( effect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,19 +573,19 @@ void Sapphire::Entity::Chara::statusEffectFreeSlot( uint8_t slotId )
|
||||||
m_statusEffectFreeSlotQueue.push( 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 )
|
for( auto effectIt : m_statusEffectMap )
|
||||||
{
|
{
|
||||||
if( effectIt.second->getId() == id )
|
if( effectIt.second->getId() == id )
|
||||||
{
|
{
|
||||||
removeStatusEffect( effectIt.first, sendActorControl, sendStatusList );
|
removeStatusEffect( effectIt.first );
|
||||||
break;
|
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 );
|
auto pEffectIt = m_statusEffectMap.find( effectSlotId );
|
||||||
if( pEffectIt == m_statusEffectMap.end() )
|
if( pEffectIt == m_statusEffectMap.end() )
|
||||||
|
@ -600,9 +598,7 @@ void Sapphire::Entity::Chara::removeStatusEffect( uint8_t effectSlotId, bool sen
|
||||||
auto pEffect = pEffectIt->second;
|
auto pEffect = pEffectIt->second;
|
||||||
pEffect->removeStatus();
|
pEffect->removeStatus();
|
||||||
|
|
||||||
if( sendActorControl )
|
sendToInRangeSet( makeActorControl( getId(), StatusEffectLose, pEffect->getId() ), true );
|
||||||
sendToInRangeSet( makeActorControl( getId(), StatusEffectLose, pEffect->getId() ), isPlayer() );
|
|
||||||
|
|
||||||
if( sendStatusList )
|
if( sendStatusList )
|
||||||
sendStatusEffectUpdate();
|
sendStatusEffectUpdate();
|
||||||
}
|
}
|
||||||
|
@ -723,7 +719,7 @@ void Sapphire::Entity::Chara::updateStatusEffects()
|
||||||
if( effect->isMarkedToRemove() || ( duration > 0 && ( currentTimeMs - startTime ) > duration ) )
|
if( effect->isMarkedToRemove() || ( duration > 0 && ( currentTimeMs - startTime ) > duration ) )
|
||||||
{
|
{
|
||||||
// remove status effect
|
// remove status effect
|
||||||
removeStatusEffect( effectIndex, true, true );
|
removeStatusEffect( effectIndex );
|
||||||
// break because removing invalidates iterators
|
// break because removing invalidates iterators
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -991,7 +987,7 @@ float Sapphire::Entity::Chara::applyShieldProtection( float damage )
|
||||||
{
|
{
|
||||||
for( auto const& slotId : destroyedShieldSlotList )
|
for( auto const& slotId : destroyedShieldSlotList )
|
||||||
{
|
{
|
||||||
removeStatusEffect( slotId, true, false );
|
removeStatusEffect( slotId, false );
|
||||||
}
|
}
|
||||||
sendStatusEffectUpdate();
|
sendStatusEffectUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,9 @@ namespace Sapphire::Entity
|
||||||
/// Status effect functions
|
/// Status effect functions
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
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();
|
void updateStatusEffects();
|
||||||
|
|
||||||
|
@ -175,10 +175,10 @@ namespace Sapphire::Entity
|
||||||
const uint32_t* getModelArray() const;
|
const uint32_t* getModelArray() const;
|
||||||
|
|
||||||
// add a status effect by id
|
// 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
|
// 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
|
/// End Status Effect Functions
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw,
|
||||||
case ClientTriggerType::RemoveStatusEffect: // Remove status (clicking it off)
|
case ClientTriggerType::RemoveStatusEffect: // Remove status (clicking it off)
|
||||||
{
|
{
|
||||||
// todo: check if status can be removed by client from exd
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
case ClientTriggerType::CastCancel: // Cancel cast
|
case ClientTriggerType::CastCancel: // Cancel cast
|
||||||
|
|
|
@ -326,3 +326,17 @@ bool Sapphire::StatusEffect::StatusEffect::isMarkedToRemove()
|
||||||
{
|
{
|
||||||
return m_markToRemove;
|
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();
|
bool isMarkedToRemove();
|
||||||
|
|
||||||
|
void refresh();
|
||||||
|
void refresh( Sapphire::World::Action::StatusEffectEntry newEntry );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
Entity::CharaPtr m_sourceActor;
|
Entity::CharaPtr m_sourceActor;
|
||||||
|
|
Loading…
Add table
Reference in a new issue