mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 00:27:44 +00:00
Allow action scripts to add effect.
This commit is contained in:
parent
2cf93ce861
commit
4bed2f4c30
8 changed files with 35 additions and 10 deletions
|
@ -622,6 +622,7 @@ namespace Sapphire::Common
|
|||
TpLoss = 12,
|
||||
TpGain = 13,
|
||||
GpGain = 14,
|
||||
ApplyStatusEffect = 15,
|
||||
/*!
|
||||
* @brief Tells the client that it should show combo indicators on actions.
|
||||
*
|
||||
|
@ -668,13 +669,13 @@ namespace Sapphire::Common
|
|||
{
|
||||
Common::ActionEffectType effectType;
|
||||
Common::ActionHitSeverityType hitSeverity;
|
||||
uint8_t param;
|
||||
uint8_t unk;
|
||||
/*!
|
||||
* @brief Shows an additional percentage in the battle log
|
||||
*
|
||||
* Has no effect on what is shown and stored in value
|
||||
*/
|
||||
int8_t bonusPercent;
|
||||
uint8_t param; // this one is the real param
|
||||
uint8_t valueMultiplier; // This multiplies whatever value is in the 'value' param by 10. Possibly a workaround for big numbers
|
||||
uint8_t flags;
|
||||
int16_t value;
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
if( !sourceChara->isPlayer() )
|
||||
return;
|
||||
|
||||
action.getEffectbuilder()->applyStatusEffect( sourceChara, 50, 30 );
|
||||
|
||||
sourceChara->getAsPlayer()->addStatusEffectByIdIfNotExist( 50, 20000, *sourceChara, 30 );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "Action.h"
|
||||
#include "EffectBuilder.h"
|
||||
|
||||
#include <Inventory/Item.h>
|
||||
|
||||
|
@ -449,7 +448,11 @@ void Action::Action::buildEffects()
|
|||
}
|
||||
|
||||
if( !hasLutEntry || m_hitActors.empty() )
|
||||
{
|
||||
// send any effect packet added by script or an empty one just to play animation for other players
|
||||
m_effectBuilder->buildAndSendPackets();
|
||||
return;
|
||||
}
|
||||
|
||||
// no script exists but we have a valid lut entry
|
||||
if( auto player = getSourceChara()->getAsPlayer() )
|
||||
|
@ -787,3 +790,8 @@ bool Action::Action::hasValidLutEntry() const
|
|||
return m_lutEntry.potency != 0 || m_lutEntry.comboPotency != 0 || m_lutEntry.flankPotency != 0 || m_lutEntry.frontPotency != 0 ||
|
||||
m_lutEntry.rearPotency != 0 || m_lutEntry.curePotency != 0 || m_lutEntry.restoreMPPercentage != 0;
|
||||
}
|
||||
|
||||
Action::EffectBuilderPtr Action::Action::getEffectbuilder()
|
||||
{
|
||||
return m_effectBuilder;
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
#include "ActionLut.h"
|
||||
#include "Util/ActorFilter.h"
|
||||
#include "ForwardsZone.h"
|
||||
#include "EffectBuilder.h"
|
||||
|
||||
namespace Sapphire::Data
|
||||
{
|
||||
|
@ -89,6 +90,8 @@ namespace Sapphire::World::Action
|
|||
*/
|
||||
bool snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors );
|
||||
|
||||
EffectBuilderPtr getEffectbuilder();
|
||||
|
||||
void buildEffects();
|
||||
|
||||
/*!
|
||||
|
|
|
@ -84,6 +84,13 @@ void EffectBuilder::comboSucceed( Entity::CharaPtr& target )
|
|||
moveToResultList( target, nextResult );
|
||||
}
|
||||
|
||||
void EffectBuilder::applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param )
|
||||
{
|
||||
EffectResultPtr nextResult = make_EffectResult( target, 0 );
|
||||
nextResult->applyStatusEffect( statusId, param );
|
||||
moveToResultList( target, nextResult );
|
||||
}
|
||||
|
||||
void EffectBuilder::buildAndSendPackets()
|
||||
{
|
||||
auto targetCount = m_resolvedEffects.size();
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace Sapphire::World::Action
|
|||
|
||||
void comboSucceed( Entity::CharaPtr& target );
|
||||
|
||||
void applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param );
|
||||
|
||||
void buildAndSendPackets();
|
||||
|
||||
|
||||
|
|
|
@ -35,11 +35,6 @@ uint64_t EffectResult::getDelay()
|
|||
return m_delayMs;
|
||||
}
|
||||
|
||||
void EffectResult::setParam( uint8_t param )
|
||||
{
|
||||
m_param = param;
|
||||
}
|
||||
|
||||
void EffectResult::damage( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionEffectResultFlag flag )
|
||||
{
|
||||
m_severity = severity;
|
||||
|
@ -80,6 +75,14 @@ void EffectResult::comboSucceed()
|
|||
m_type = Common::ActionEffectType::ComboSucceed;
|
||||
}
|
||||
|
||||
void EffectResult::applyStatusEffect( uint16_t statusId, uint8_t param )
|
||||
{
|
||||
m_value = statusId;
|
||||
m_param = param;
|
||||
|
||||
m_type = Common::ActionEffectType::ApplyStatusEffect;
|
||||
}
|
||||
|
||||
Common::EffectEntry EffectResult::buildEffectEntry() const
|
||||
{
|
||||
Common::EffectEntry entry{};
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Sapphire::World::Action
|
|||
void restoreMP( uint32_t amount, Common::ActionEffectResultFlag flag = Common::ActionEffectResultFlag::None );
|
||||
void startCombo( uint16_t actionId );
|
||||
void comboSucceed();
|
||||
void applyStatusEffect( uint16_t statusId, uint8_t param );
|
||||
|
||||
Entity::CharaPtr getTarget() const;
|
||||
|
||||
|
@ -27,8 +28,6 @@ namespace Sapphire::World::Action
|
|||
|
||||
uint64_t getDelay();
|
||||
|
||||
void setParam( uint8_t param );
|
||||
|
||||
Common::EffectEntry buildEffectEntry() const;
|
||||
|
||||
void execute();
|
||||
|
|
Loading…
Add table
Reference in a new issue