From 5cc7b0c87b6afb8a198db8563b7df6df558e3f0b Mon Sep 17 00:00:00 2001 From: Mordred Date: Sat, 11 Mar 2023 20:52:52 +0100 Subject: [PATCH] Converted autoattacks to the action system --- src/tools/action_parse/actions/player.json | 4 +-- src/world/Action/Action.cpp | 15 +++++---- src/world/Actor/BNpc.cpp | 28 ++++------------ src/world/Actor/Chara.cpp | 22 ++++++------- src/world/Actor/Chara.h | 6 ++-- src/world/Actor/Player.cpp | 16 ++------- src/world/Actor/Player.h | 6 ---- src/world/Manager/ActionMgr.cpp | 27 +++++++++------- src/world/Manager/ActionMgr.h | 6 ++-- src/world/Network/Handlers/ActionHandler.cpp | 2 +- src/world/Network/Util/PacketUtil.cpp | 8 +++-- src/world/Session.cpp | 34 ++++++++++++-------- src/world/Session.h | 2 ++ src/world/Task/ActionIntegrityTask.cpp | 6 ++-- src/world/WorldServer.cpp | 11 ++++--- 15 files changed, 93 insertions(+), 100 deletions(-) diff --git a/src/tools/action_parse/actions/player.json b/src/tools/action_parse/actions/player.json index 149d05aa..e6c9cb3e 100644 --- a/src/tools/action_parse/actions/player.json +++ b/src/tools/action_parse/actions/player.json @@ -1,7 +1,7 @@ { "7": { "name": "Attack", - "potency": 0, + "potency": 110, "comboPotency": 0, "flankPotency": 0, "frontPotency": 0, @@ -16,7 +16,7 @@ }, "8": { "name": "Shot", - "potency": 0, + "potency": 100, "comboPotency": 0, "flankPotency": 0, "frontPotency": 0, diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index bf14dae8..3de95214 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -333,9 +333,11 @@ void Action::Action::start() // todo: m_recastTimeMs needs to be adjusted for player sks/sps auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, m_cooldownGroup, getId(), m_recastTimeMs / 10 ); - player->setRecastGroup( m_cooldownGroup, static_cast< float >( m_castTimeMs ) / 1000.f ); - - server().queueForPlayer( player->getCharacterId(), actionStartPkt ); + if( player ) + { + player->setRecastGroup( m_cooldownGroup, static_cast< float >( m_castTimeMs ) / 1000.f ); + server().queueForPlayer( player->getCharacterId(), actionStartPkt ); + } onStart(); @@ -369,7 +371,6 @@ void Action::Action::onStart() void Action::Action::interrupt() { assert( m_pSource ); - // things that aren't players don't care about cooldowns and state flags if( m_pSource->isPlayer() ) { @@ -409,7 +410,6 @@ void Action::Action::onInterrupt() void Action::Action::execute() { assert( m_pSource ); - // subtract costs first, if somehow the caster stops meeting those requirements cancel the cast if( !consumeResources() ) { @@ -464,6 +464,10 @@ std::pair< uint32_t, Common::ActionHitSeverityType > Action::Action::calcDamage( wepDmg = item->getMagicalDmg(); else wepDmg = item->getPhysicalDmg(); + + // is auto attack + if( getId() == 7 || getId() == 8 ) + return Math::CalcStats::calcAutoAttackDamage( *m_pSource->getAsPlayer() ); } return Math::CalcStats::calcActionDamage( *m_pSource, potency, wepDmg ); @@ -574,7 +578,6 @@ void Action::Action::buildActionResults() shouldRestoreMP = false; } } - m_actionResultBuilder->sendActionResults( m_hitActors ); // TODO: disabled, reset kills our queued actions diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index dbf779e6..f353a88b 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include