mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-21 17:47:45 +00:00
Automatic status reapplication
Status will be reapplied if "canApplyMultipleTimes" is false. Otherwise the status will be applied as a new status.
This commit is contained in:
parent
d1c7b97d9e
commit
6361e4e52e
3 changed files with 27 additions and 1 deletions
|
@ -35,6 +35,8 @@ namespace Sapphire::World::Action
|
|||
j.at( "duration" ).get_to( statusEntry.duration );
|
||||
if( j.contains( "flag" ) )
|
||||
j.at( "flag" ).get_to( statusEntry.flag );
|
||||
if( j.contains( "canApplyMultipleTimes" ) )
|
||||
j.at( "canApplyMultipleTimes" ).get_to( statusEntry.canApplyMultipleTimes );
|
||||
if( j.contains( "modifiers" ) )
|
||||
j.at( "modifiers" ).get_to( statusEntry.modifiers );
|
||||
}
|
||||
|
|
|
@ -492,7 +492,16 @@ void Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEffect )
|
|||
auto& teriMgr = Common::Service< Manager::TerritoryMgr >::ref();
|
||||
auto pZone = teriMgr.getTerritoryByGuId( getTerritoryId() );
|
||||
|
||||
int8_t nextSlot = getStatusEffectFreeSlot();
|
||||
int8_t nextSlot = -1;
|
||||
if( !pEffect->getCanApplyMultipleTimes() )
|
||||
{
|
||||
nextSlot = getStatusEffectSlotWithId( pEffect->getId() );
|
||||
}
|
||||
if( nextSlot == -1 || pEffect->getCanApplyMultipleTimes() )
|
||||
{
|
||||
nextSlot = getStatusEffectFreeSlot();
|
||||
}
|
||||
|
||||
// if there is no slot left, do not add the effect
|
||||
if( nextSlot == -1 )
|
||||
return;
|
||||
|
@ -517,6 +526,19 @@ void Chara::addStatusEffectByIdIfNotExist( StatusEffect::StatusEffectPtr pStatus
|
|||
addStatusEffect( pStatus );
|
||||
}
|
||||
|
||||
int8_t Chara::getStatusEffectSlotWithId( uint8_t id )
|
||||
{
|
||||
for( const auto& effectIt : m_statusEffectMap )
|
||||
{
|
||||
if( effectIt.second->getId() == id )
|
||||
{
|
||||
return effectIt.first;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t Chara::getStatusEffectFreeSlot()
|
||||
{
|
||||
int8_t freeEffectSlot = -1;
|
||||
|
|
|
@ -120,6 +120,8 @@ namespace Sapphire::Entity
|
|||
|
||||
bool hasStatusEffect( uint32_t id );
|
||||
|
||||
int8_t getStatusEffectSlotWithId( uint8_t id );
|
||||
|
||||
int8_t getStatusEffectFreeSlot();
|
||||
|
||||
void statusEffectFreeSlot( uint8_t slotId );
|
||||
|
|
Loading…
Add table
Reference in a new issue