mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
minor refactoring, fix adventurer actions not working
This commit is contained in:
parent
c5a0b97f33
commit
f692c7bccf
6 changed files with 38 additions and 19 deletions
|
@ -318,7 +318,7 @@ void Sapphire::Action::Action::buildEffectPackets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Action::Action::damageTarget( uint32_t potency, Entity::Chara& chara )
|
void Sapphire::Action::Action::damageTarget( uint16_t potency, Entity::Chara& chara )
|
||||||
{
|
{
|
||||||
// todo: scale potency into damage from stats
|
// todo: scale potency into damage from stats
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ void Sapphire::Action::Action::damageTarget( uint32_t potency, Entity::Chara& ch
|
||||||
{
|
{
|
||||||
entry.value = static_cast< int16_t >( potency / 10 );
|
entry.value = static_cast< int16_t >( potency / 10 );
|
||||||
// todo: rename this? need to confirm how it works again
|
// todo: rename this? need to confirm how it works again
|
||||||
entry.bonusPercent = 1;
|
entry.valueMultiplier = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry.value = static_cast< int16_t >( potency );
|
entry.value = static_cast< int16_t >( potency );
|
||||||
|
@ -371,7 +371,7 @@ void Sapphire::Action::Action::damageTarget( uint32_t potency, Entity::Chara& ch
|
||||||
m_effects[ EffectPacketIdentity::DamageEffect ].m_hitActors.emplace_back( chara.getId() );
|
m_effects[ EffectPacketIdentity::DamageEffect ].m_hitActors.emplace_back( chara.getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Action::Action::healTarget( uint32_t potency, Entity::Chara& chara )
|
void Sapphire::Action::Action::healTarget( uint16_t potency, Entity::Chara& chara )
|
||||||
{
|
{
|
||||||
// todo: scale potency into healing from stats
|
// todo: scale potency into healing from stats
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ void Sapphire::Action::Action::healTarget( uint32_t potency, Entity::Chara& char
|
||||||
{
|
{
|
||||||
entry.value = static_cast< int16_t >( potency / 10 );
|
entry.value = static_cast< int16_t >( potency / 10 );
|
||||||
// todo: rename this? need to confirm how it works again
|
// todo: rename this? need to confirm how it works again
|
||||||
entry.bonusPercent = 1;
|
entry.valueMultiplier = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry.value = static_cast< int16_t >( potency );
|
entry.value = static_cast< int16_t >( potency );
|
||||||
|
|
|
@ -68,14 +68,14 @@ namespace Sapphire::Action
|
||||||
* @param potency The amount of damage the target takes
|
* @param potency The amount of damage the target takes
|
||||||
* @param chara The chara to inflict damage upon
|
* @param chara The chara to inflict damage upon
|
||||||
*/
|
*/
|
||||||
void damageTarget( uint32_t potency, Entity::Chara& chara );
|
void damageTarget( uint16_t potency, Entity::Chara& chara );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Heals a target and adds the effect entry
|
* @brief Heals a target and adds the effect entry
|
||||||
* @param potency Amount of healing to apply
|
* @param potency Amount of healing to apply
|
||||||
* @param chara Chara to receive healing
|
* @param chara Chara to receive healing
|
||||||
*/
|
*/
|
||||||
void healTarget( uint32_t potency, Entity::Chara& chara );
|
void healTarget( uint16_t potency, Entity::Chara& chara );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
|
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
|
||||||
|
|
|
@ -52,12 +52,12 @@ namespace Sapphire::Entity
|
||||||
// EventHandlers
|
// EventHandlers
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/*! start an event action */
|
/*! start an event action */
|
||||||
void eventActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
|
void eventActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||||
ActionCallback interruptCallback, uint64_t additional );
|
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||||
|
|
||||||
/*! start an event item action */
|
/*! start an event item action */
|
||||||
void eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
|
void eventItemActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||||
ActionCallback interruptCallback, uint64_t additional );
|
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||||
|
|
||||||
/*! start/register a normal event */
|
/*! start/register a normal event */
|
||||||
void
|
void
|
||||||
|
|
|
@ -278,8 +278,8 @@ void Sapphire::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlaye
|
||||||
|
|
||||||
void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
||||||
uint32_t action,
|
uint32_t action,
|
||||||
ActionCallback finishCallback,
|
Action::ActionCallback finishCallback,
|
||||||
ActionCallback interruptCallback,
|
Action::ActionCallback interruptCallback,
|
||||||
uint64_t additional )
|
uint64_t additional )
|
||||||
{
|
{
|
||||||
auto pEventAction = Action::make_EventAction( getAsChara(), eventId, action,
|
auto pEventAction = Action::make_EventAction( getAsChara(), eventId, action,
|
||||||
|
@ -309,8 +309,8 @@ void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
||||||
|
|
||||||
void Sapphire::Entity::Player::eventItemActionStart( uint32_t eventId,
|
void Sapphire::Entity::Player::eventItemActionStart( uint32_t eventId,
|
||||||
uint32_t action,
|
uint32_t action,
|
||||||
ActionCallback finishCallback,
|
Action::ActionCallback finishCallback,
|
||||||
ActionCallback interruptCallback,
|
Action::ActionCallback interruptCallback,
|
||||||
uint64_t additional )
|
uint64_t additional )
|
||||||
{
|
{
|
||||||
// Action::ActionPtr pEventItemAction = Action::make_EventItemAction( getAsChara(), eventId, action,
|
// Action::ActionPtr pEventItemAction = Action::make_EventItemAction( getAsChara(), eventId, action,
|
||||||
|
|
|
@ -85,6 +85,8 @@ namespace Action
|
||||||
{
|
{
|
||||||
TYPE_FORWARD( Action );
|
TYPE_FORWARD( Action );
|
||||||
TYPE_FORWARD( EventAction );
|
TYPE_FORWARD( EventAction );
|
||||||
|
|
||||||
|
using ActionCallback = std::function< void( Entity::Player&, uint32_t, uint64_t ) >;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Network
|
namespace Network
|
||||||
|
@ -113,8 +115,6 @@ namespace Scripting
|
||||||
class NativeScriptMgr;
|
class NativeScriptMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,11 @@ void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& play
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( targetId != player.getId() )
|
if( targetId == 0 )
|
||||||
|
{
|
||||||
|
action->setTargetChara( player.getAsChara() );
|
||||||
|
}
|
||||||
|
else if( targetId != player.getId() )
|
||||||
{
|
{
|
||||||
auto target = player.lookupTargetById( targetId );
|
auto target = player.lookupTargetById( targetId );
|
||||||
if( !target )
|
if( !target )
|
||||||
|
@ -127,13 +131,16 @@ bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
||||||
if( player.getLevel() < actionData.classJobLevel )
|
if( player.getLevel() < actionData.classJobLevel )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( player.getClass() != static_cast< Common::ClassJob >( actionData.classJob ) )
|
auto currentClass = player.getClass();
|
||||||
|
auto actionClass = static_cast< Common::ClassJob >( actionData.classJob );
|
||||||
|
|
||||||
|
if( actionClass != Common::ClassJob::Adventurer && currentClass != actionClass )
|
||||||
{
|
{
|
||||||
// check if not a base class action
|
// check if not a base class action
|
||||||
auto exdData = framework()->get< Data::ExdDataGenerated >();
|
auto exdData = framework()->get< Data::ExdDataGenerated >();
|
||||||
assert( exdData );
|
assert( exdData );
|
||||||
|
|
||||||
auto classJob = exdData->get< Data::ClassJob >( static_cast< uint8_t >( player.getClass() ) );
|
auto classJob = exdData->get< Data::ClassJob >( static_cast< uint8_t >( currentClass ) );
|
||||||
if( !classJob )
|
if( !classJob )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -141,6 +148,18 @@ bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset target on actions that can only be casted on yourself while having a target set
|
||||||
|
// todo: check what actions send when targeting an enemy
|
||||||
|
if( actionData.canTargetSelf &&
|
||||||
|
!actionData.canTargetFriendly &&
|
||||||
|
!actionData.canTargetHostile &&
|
||||||
|
!actionData.canTargetParty )
|
||||||
|
{
|
||||||
|
currentAction.setTargetChara( currentAction.getSourceChara() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: party/enemy validation
|
||||||
|
|
||||||
// validate range
|
// validate range
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue