mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-23 10:17:44 +00:00
Change slot implementation to update statuses correctly
This commit is contained in:
parent
2c9a7a7618
commit
fab2af1fa3
7 changed files with 37 additions and 27 deletions
|
@ -2041,7 +2041,20 @@
|
|||
"nextCombo": [],
|
||||
"statuses": {
|
||||
"caster": [],
|
||||
"target": []
|
||||
"target": [
|
||||
{
|
||||
"id": 150,
|
||||
"duration": 30000,
|
||||
"statusRefreshPolicy": 17,
|
||||
"flag": 8192,
|
||||
"modifiers": [
|
||||
{
|
||||
"modifier": "TickHeal",
|
||||
"value": 50
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"134": {
|
||||
|
@ -2101,7 +2114,20 @@
|
|||
"nextCombo": [],
|
||||
"statuses": {
|
||||
"caster": [],
|
||||
"target": []
|
||||
"target": [
|
||||
{
|
||||
"id": 158,
|
||||
"duration": 21000,
|
||||
"statusRefreshPolicy": 17,
|
||||
"flag": 8192,
|
||||
"modifiers": [
|
||||
{
|
||||
"modifier": "TickHeal",
|
||||
"value": 150
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"138": {
|
||||
|
|
|
@ -937,7 +937,8 @@ namespace Sapphire::Common
|
|||
Invisibilty = 512,
|
||||
CanStatusOff = 1024,
|
||||
FcBuff = 2048,
|
||||
RemoveOnSuccessfulHit = 4096
|
||||
RemoveOnSuccessfulHit = 4096,
|
||||
ReplaceSameCaster = 8192
|
||||
};
|
||||
|
||||
enum class StatusRefreshPolicy : uint8_t
|
||||
|
|
|
@ -649,6 +649,9 @@ void Action::Action::applyStatusEffect( bool isSelf, Entity::CharaPtr& target, E
|
|||
}
|
||||
case Common::StatusRefreshPolicy::ReplaceOrApply:
|
||||
{
|
||||
if( (status.flag & static_cast< uint32_t >( Common::StatusEffectFlag::ReplaceSameCaster ) && hasSameStatusFromSameCaster) || hasSameStatus )
|
||||
pActionBuilder->replaceStatusEffect( referenceStatus, target, status.id, status.duration, 0, std::move( status.modifiers ), status.flag, statusToSource );
|
||||
else
|
||||
pActionBuilder->applyStatusEffect( target, status.id, status.duration, 0, std::move( status.modifiers ), status.flag, statusToSource, true );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ void ActionResult::execute()
|
|||
for( auto const& entry : m_target->getStatusEffectMap() )
|
||||
{
|
||||
auto statusEffect = entry.second;
|
||||
if( statusEffect->getId() == m_result.Value && m_bShouldOverride )
|
||||
if( statusEffect->getId() == m_result.Value && m_bShouldOverride && statusEffect->getSrcActorId() == m_pStatus->getSrcActorId() )
|
||||
{
|
||||
statusEffect->refresh( m_pStatus->getDuration() );
|
||||
m_pStatus->setSlot( statusEffect->getSlot() );
|
||||
|
|
|
@ -49,12 +49,6 @@ Chara::Chara( ObjKind type ) :
|
|||
m_lastAttack = Common::Util::getTimeMs();
|
||||
|
||||
m_bonusStats.fill( 0 );
|
||||
|
||||
// initialize the free slot queue
|
||||
for( uint8_t i = 0; i < MAX_STATUS_EFFECTS; i++ )
|
||||
{
|
||||
m_statusEffectFreeSlotQueue.push( i );
|
||||
}
|
||||
}
|
||||
|
||||
Chara::~Chara() = default;
|
||||
|
@ -521,12 +515,6 @@ int8_t Chara::getStatusEffectFreeSlot()
|
|||
{
|
||||
int8_t freeEffectSlot = -1;
|
||||
|
||||
// if( m_statusEffectFreeSlotQueue.empty() )
|
||||
// return freeEffectSlot;
|
||||
|
||||
// freeEffectSlot = static_cast< int8_t >( m_statusEffectFreeSlotQueue.front() );
|
||||
// m_statusEffectFreeSlotQueue.pop();
|
||||
|
||||
if( m_statusEffectSlots.size() >= MAX_STATUS_EFFECTS )
|
||||
return freeEffectSlot;
|
||||
|
||||
|
@ -544,15 +532,11 @@ int8_t Chara::getStatusEffectFreeSlot()
|
|||
|
||||
void Chara::statusEffectFreeSlot( uint8_t slotId )
|
||||
{
|
||||
// m_statusEffectFreeSlotQueue.push( slotId );
|
||||
m_statusEffectSlots.erase( slotId );
|
||||
// std::set< uint8_t > shiftedSlots;
|
||||
}
|
||||
|
||||
void Chara::replaceSingleStatusEffect( uint32_t slotId, StatusEffect::StatusEffectPtr pStatus )
|
||||
{
|
||||
// removeStatusEffect( slotId, false );
|
||||
// addStatusEffect( pStatus );
|
||||
pStatus->setSlot( slotId );
|
||||
m_statusEffectMap[ slotId ] = pStatus;
|
||||
pStatus->applyStatus();
|
||||
|
@ -630,13 +614,11 @@ std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr >::iterator Chara::re
|
|||
|
||||
auto it = m_statusEffectMap.erase( pEffectIt );
|
||||
|
||||
// for( const auto& effectIt : m_statusEffectMap )
|
||||
for( auto effectIt = it; effectIt != m_statusEffectMap.end(); )
|
||||
{
|
||||
// if( effectIt.first > effectSlotId )
|
||||
// {
|
||||
// if the status is *after* the one being removed, shift the slots down by one
|
||||
auto shifted_slot = effectIt->first - 1;
|
||||
|
||||
auto node_slot = m_statusEffectSlots.extract( effectIt->first );
|
||||
node_slot.value() = shifted_slot;
|
||||
m_statusEffectSlots.insert( std::move( node_slot ) );
|
||||
|
@ -649,7 +631,6 @@ std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr >::iterator Chara::re
|
|||
|
||||
Logger::warn( "Shifted slot {} to slot: {}", effectSlotId, shifted_slot );
|
||||
++effectIt;
|
||||
// }
|
||||
}
|
||||
|
||||
Logger::warn( "Slot id being freed: {}", effectSlotId );
|
||||
|
|
|
@ -86,7 +86,6 @@ namespace Sapphire::Entity
|
|||
|
||||
/*! Status effects */
|
||||
const uint8_t MAX_STATUS_EFFECTS = 30;
|
||||
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
|
||||
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
|
||||
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
||||
std::set< uint8_t > m_statusEffectSlots;
|
||||
|
|
Loading…
Add table
Reference in a new issue