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
|
||||
|
||||
|
@ -335,7 +335,7 @@ void Sapphire::Action::Action::damageTarget( uint32_t potency, Entity::Chara& ch
|
|||
{
|
||||
entry.value = static_cast< int16_t >( potency / 10 );
|
||||
// todo: rename this? need to confirm how it works again
|
||||
entry.bonusPercent = 1;
|
||||
entry.valueMultiplier = 1;
|
||||
}
|
||||
else
|
||||
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() );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
@ -387,7 +387,7 @@ void Sapphire::Action::Action::healTarget( uint32_t potency, Entity::Chara& char
|
|||
{
|
||||
entry.value = static_cast< int16_t >( potency / 10 );
|
||||
// todo: rename this? need to confirm how it works again
|
||||
entry.bonusPercent = 1;
|
||||
entry.valueMultiplier = 1;
|
||||
}
|
||||
else
|
||||
entry.value = static_cast< int16_t >( potency );
|
||||
|
|
|
@ -68,14 +68,14 @@ namespace Sapphire::Action
|
|||
* @param potency The amount of damage the target takes
|
||||
* @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
|
||||
* @param potency Amount of healing to apply
|
||||
* @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).
|
||||
|
|
|
@ -52,12 +52,12 @@ namespace Sapphire::Entity
|
|||
// EventHandlers
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*! start an event action */
|
||||
void eventActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
|
||||
ActionCallback interruptCallback, uint64_t additional );
|
||||
void eventActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
|
||||
/*! start an event item action */
|
||||
void eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback,
|
||||
ActionCallback interruptCallback, uint64_t additional );
|
||||
void eventItemActionStart( uint32_t eventId, uint32_t action, Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback, uint64_t additional );
|
||||
|
||||
/*! start/register a normal event */
|
||||
void
|
||||
|
|
|
@ -278,8 +278,8 @@ void Sapphire::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlaye
|
|||
|
||||
void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
||||
uint32_t action,
|
||||
ActionCallback finishCallback,
|
||||
ActionCallback interruptCallback,
|
||||
Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback,
|
||||
uint64_t additional )
|
||||
{
|
||||
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,
|
||||
uint32_t action,
|
||||
ActionCallback finishCallback,
|
||||
ActionCallback interruptCallback,
|
||||
Action::ActionCallback finishCallback,
|
||||
Action::ActionCallback interruptCallback,
|
||||
uint64_t additional )
|
||||
{
|
||||
// Action::ActionPtr pEventItemAction = Action::make_EventItemAction( getAsChara(), eventId, action,
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace Action
|
|||
{
|
||||
TYPE_FORWARD( Action );
|
||||
TYPE_FORWARD( EventAction );
|
||||
|
||||
using ActionCallback = std::function< void( Entity::Player&, uint32_t, uint64_t ) >;
|
||||
}
|
||||
|
||||
namespace Network
|
||||
|
@ -113,8 +115,6 @@ namespace Scripting
|
|||
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;
|
||||
}
|
||||
|
||||
if( targetId != player.getId() )
|
||||
if( targetId == 0 )
|
||||
{
|
||||
action->setTargetChara( player.getAsChara() );
|
||||
}
|
||||
else if( targetId != player.getId() )
|
||||
{
|
||||
auto target = player.lookupTargetById( targetId );
|
||||
if( !target )
|
||||
|
@ -127,13 +131,16 @@ bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
|||
if( player.getLevel() < actionData.classJobLevel )
|
||||
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
|
||||
auto exdData = framework()->get< Data::ExdDataGenerated >();
|
||||
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 )
|
||||
return false;
|
||||
|
||||
|
@ -141,6 +148,18 @@ bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
|||
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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue