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": [],
|
"nextCombo": [],
|
||||||
"statuses": {
|
"statuses": {
|
||||||
"caster": [],
|
"caster": [],
|
||||||
"target": []
|
"target": [
|
||||||
|
{
|
||||||
|
"id": 150,
|
||||||
|
"duration": 30000,
|
||||||
|
"statusRefreshPolicy": 17,
|
||||||
|
"flag": 8192,
|
||||||
|
"modifiers": [
|
||||||
|
{
|
||||||
|
"modifier": "TickHeal",
|
||||||
|
"value": 50
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"134": {
|
"134": {
|
||||||
|
@ -2101,7 +2114,20 @@
|
||||||
"nextCombo": [],
|
"nextCombo": [],
|
||||||
"statuses": {
|
"statuses": {
|
||||||
"caster": [],
|
"caster": [],
|
||||||
"target": []
|
"target": [
|
||||||
|
{
|
||||||
|
"id": 158,
|
||||||
|
"duration": 21000,
|
||||||
|
"statusRefreshPolicy": 17,
|
||||||
|
"flag": 8192,
|
||||||
|
"modifiers": [
|
||||||
|
{
|
||||||
|
"modifier": "TickHeal",
|
||||||
|
"value": 150
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"138": {
|
"138": {
|
||||||
|
|
|
@ -937,7 +937,8 @@ namespace Sapphire::Common
|
||||||
Invisibilty = 512,
|
Invisibilty = 512,
|
||||||
CanStatusOff = 1024,
|
CanStatusOff = 1024,
|
||||||
FcBuff = 2048,
|
FcBuff = 2048,
|
||||||
RemoveOnSuccessfulHit = 4096
|
RemoveOnSuccessfulHit = 4096,
|
||||||
|
ReplaceSameCaster = 8192
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class StatusRefreshPolicy : uint8_t
|
enum class StatusRefreshPolicy : uint8_t
|
||||||
|
|
|
@ -649,6 +649,9 @@ void Action::Action::applyStatusEffect( bool isSelf, Entity::CharaPtr& target, E
|
||||||
}
|
}
|
||||||
case Common::StatusRefreshPolicy::ReplaceOrApply:
|
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 );
|
pActionBuilder->applyStatusEffect( target, status.id, status.duration, 0, std::move( status.modifiers ), status.flag, statusToSource, true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ void ActionResult::execute()
|
||||||
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_result.Value && m_bShouldOverride )
|
if( statusEffect->getId() == m_result.Value && m_bShouldOverride && statusEffect->getSrcActorId() == m_pStatus->getSrcActorId() )
|
||||||
{
|
{
|
||||||
statusEffect->refresh( m_pStatus->getDuration() );
|
statusEffect->refresh( m_pStatus->getDuration() );
|
||||||
m_pStatus->setSlot( statusEffect->getSlot() );
|
m_pStatus->setSlot( statusEffect->getSlot() );
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "ActionResultBuilder.h"
|
#include "ActionResultBuilder.h"
|
||||||
#include "ActionResult.h"
|
#include "ActionResult.h"
|
||||||
|
|
||||||
#include <Actor/Player.h>
|
#include <Actor/Player.h>
|
||||||
|
|
|
@ -49,12 +49,6 @@ Chara::Chara( ObjKind type ) :
|
||||||
m_lastAttack = Common::Util::getTimeMs();
|
m_lastAttack = Common::Util::getTimeMs();
|
||||||
|
|
||||||
m_bonusStats.fill( 0 );
|
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;
|
Chara::~Chara() = default;
|
||||||
|
@ -521,12 +515,6 @@ int8_t Chara::getStatusEffectFreeSlot()
|
||||||
{
|
{
|
||||||
int8_t freeEffectSlot = -1;
|
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 )
|
if( m_statusEffectSlots.size() >= MAX_STATUS_EFFECTS )
|
||||||
return freeEffectSlot;
|
return freeEffectSlot;
|
||||||
|
|
||||||
|
@ -544,15 +532,11 @@ int8_t Chara::getStatusEffectFreeSlot()
|
||||||
|
|
||||||
void Chara::statusEffectFreeSlot( uint8_t slotId )
|
void Chara::statusEffectFreeSlot( uint8_t slotId )
|
||||||
{
|
{
|
||||||
// m_statusEffectFreeSlotQueue.push( slotId );
|
|
||||||
m_statusEffectSlots.erase( slotId );
|
m_statusEffectSlots.erase( slotId );
|
||||||
// std::set< uint8_t > shiftedSlots;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chara::replaceSingleStatusEffect( uint32_t slotId, StatusEffect::StatusEffectPtr pStatus )
|
void Chara::replaceSingleStatusEffect( uint32_t slotId, StatusEffect::StatusEffectPtr pStatus )
|
||||||
{
|
{
|
||||||
// removeStatusEffect( slotId, false );
|
|
||||||
// addStatusEffect( pStatus );
|
|
||||||
pStatus->setSlot( slotId );
|
pStatus->setSlot( slotId );
|
||||||
m_statusEffectMap[ slotId ] = pStatus;
|
m_statusEffectMap[ slotId ] = pStatus;
|
||||||
pStatus->applyStatus();
|
pStatus->applyStatus();
|
||||||
|
@ -630,13 +614,11 @@ std::map< uint8_t, Sapphire::StatusEffect::StatusEffectPtr >::iterator Chara::re
|
||||||
|
|
||||||
auto it = m_statusEffectMap.erase( pEffectIt );
|
auto it = m_statusEffectMap.erase( pEffectIt );
|
||||||
|
|
||||||
// for( const auto& effectIt : m_statusEffectMap )
|
|
||||||
for( auto effectIt = it; effectIt != m_statusEffectMap.end(); )
|
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
|
// if the status is *after* the one being removed, shift the slots down by one
|
||||||
auto shifted_slot = effectIt->first - 1;
|
auto shifted_slot = effectIt->first - 1;
|
||||||
|
|
||||||
auto node_slot = m_statusEffectSlots.extract( effectIt->first );
|
auto node_slot = m_statusEffectSlots.extract( effectIt->first );
|
||||||
node_slot.value() = shifted_slot;
|
node_slot.value() = shifted_slot;
|
||||||
m_statusEffectSlots.insert( std::move( node_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 );
|
Logger::warn( "Shifted slot {} to slot: {}", effectSlotId, shifted_slot );
|
||||||
++effectIt;
|
++effectIt;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::warn( "Slot id being freed: {}", effectSlotId );
|
Logger::warn( "Slot id being freed: {}", effectSlotId );
|
||||||
|
|
|
@ -86,7 +86,6 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
/*! Status effects */
|
/*! Status effects */
|
||||||
const uint8_t MAX_STATUS_EFFECTS = 30;
|
const uint8_t MAX_STATUS_EFFECTS = 30;
|
||||||
std::queue< uint8_t > m_statusEffectFreeSlotQueue;
|
|
||||||
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
|
std::vector< std::pair< uint8_t, uint32_t > > m_statusEffectList;
|
||||||
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
std::map< uint8_t, StatusEffect::StatusEffectPtr > m_statusEffectMap;
|
||||||
std::set< uint8_t > m_statusEffectSlots;
|
std::set< uint8_t > m_statusEffectSlots;
|
||||||
|
|
Loading…
Add table
Reference in a new issue