mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 23:27:45 +00:00
Fixed status effects being added multiple times
This commit is contained in:
parent
4fe030d90d
commit
5ae9099f2b
6 changed files with 31 additions and 1 deletions
|
@ -10,7 +10,7 @@ class skillDef_121Def
|
|||
|
||||
def onFinish( player, target )
|
||||
{
|
||||
target.addStatusEffectById(143, 20000, 0);
|
||||
target.addStatusEffectByIdIfNotExist(143, 20000, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -631,3 +631,14 @@ void Core::Entity::Actor::addStatusEffectById( int32_t id, int32_t duration, uin
|
|||
addStatusEffect( effect );
|
||||
}
|
||||
|
||||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( int32_t id, int32_t duration, uint16_t param )
|
||||
{
|
||||
if( !m_pStatusEffectContainer->hasStatusEffect( id ) )
|
||||
{
|
||||
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, shared_from_this(), shared_from_this(), duration, 3000 ) );
|
||||
effect->setParam( param );
|
||||
addStatusEffect( effect );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,9 @@ public:
|
|||
// add a status effect by id
|
||||
void addStatusEffectById( int32_t id, int32_t duration, uint16_t param = 0 );
|
||||
|
||||
// add a status effect by id if it doesn't exist
|
||||
void addStatusEffectByIdIfNotExist( int32_t id, int32_t duration, uint16_t param = 0 );
|
||||
|
||||
// TODO: Why did i even declare them publicly here?!
|
||||
std::set< ActorPtr > m_inRangeActors;
|
||||
std::set< PlayerPtr > m_inRangePlayers;
|
||||
|
|
|
@ -35,6 +35,7 @@ int Core::Scripting::ScriptManager::init()
|
|||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTargetId ), "getTargetId" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffect ), "addStatusEffect" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectByIdIfNotExist ), "addStatusEffectByIdIfNotExist" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::takeDamage ), "takeDamage" );
|
||||
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
|
||||
|
|
|
@ -185,3 +185,16 @@ void Core::StatusEffect::StatusEffectContainer::update()
|
|||
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, 4, thisTickHeal ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool Core::StatusEffect::StatusEffectContainer::hasStatusEffect( uint32_t id )
|
||||
{
|
||||
for( auto effectIt : m_effectMap )
|
||||
{
|
||||
if( effectIt.second->getId() == id )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -23,6 +23,8 @@ public:
|
|||
void removeStatusEffect( uint8_t effectSlotId );
|
||||
void update();
|
||||
|
||||
bool hasStatusEffect( uint32_t id );
|
||||
|
||||
int8_t getFreeSlot();
|
||||
void freeSlot( uint8_t slotId );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue