1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-21 17:47:45 +00:00

Status automatically overwriten if by same source

Added check for status application that checks if existing status is from the same source. If yes, always overwrite it because the same source can never apply 2 instances of the same status on the same target.
This commit is contained in:
Kooper16 2023-07-22 00:04:37 +02:00
parent 6361e4e52e
commit 28456e7ac6
2 changed files with 22 additions and 7 deletions

View file

@ -492,12 +492,12 @@ void Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEffect )
auto& teriMgr = Common::Service< Manager::TerritoryMgr >::ref();
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
int8_t nextSlot = -1;
if( !pEffect->getCanApplyMultipleTimes() )
int8_t nextSlot = getStatusEffectSlotWithIdAndSource( pEffect->getId(), pEffect->getSrcActorId() );
if( nextSlot == -1 && !pEffect->getCanApplyMultipleTimes() )
{
nextSlot = getStatusEffectSlotWithId( pEffect->getId() );
nextSlot = getStatusEffectSlotWithId( pEffect->getId());
}
if( nextSlot == -1 || pEffect->getCanApplyMultipleTimes() )
if( nextSlot == -1)
{
nextSlot = getStatusEffectFreeSlot();
}
@ -526,11 +526,24 @@ void Chara::addStatusEffectByIdIfNotExist( StatusEffect::StatusEffectPtr pStatus
addStatusEffect( pStatus );
}
int8_t Chara::getStatusEffectSlotWithId( uint8_t id )
int8_t Chara::getStatusEffectSlotWithIdAndSource( uint8_t statusId, uint32_t sourceId )
{
for( const auto& effectIt : m_statusEffectMap )
{
if( effectIt.second->getId() == id )
if( effectIt.second->getId() == statusId && effectIt.second->getSrcActorId() == sourceId )
{
return effectIt.first;
}
}
return -1;
}
int8_t Chara::getStatusEffectSlotWithId( uint8_t statusId )
{
for( const auto& effectIt : m_statusEffectMap )
{
if( effectIt.second->getId() == statusId )
{
return effectIt.first;
}

View file

@ -120,7 +120,9 @@ namespace Sapphire::Entity
bool hasStatusEffect( uint32_t id );
int8_t getStatusEffectSlotWithId( uint8_t id );
int8_t getStatusEffectSlotWithIdAndSource( uint8_t statusId, uint32_t sourceId );
int8_t getStatusEffectSlotWithId( uint8_t statusId );
int8_t getStatusEffectFreeSlot();