From aaad18bf7b444730bea2189fe6b3a82e8d320d6b Mon Sep 17 00:00:00 2001 From: Lucy <44952533+Skyliegirl33@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:07:15 +0100 Subject: [PATCH] Add job actions for warrior --- src/world/Action/Action.cpp | 16 +++++++++ src/world/Action/Action.h | 2 ++ src/world/Action/Job/Warrior.cpp | 61 ++++++++++++++++++++++++++++++++ src/world/Action/Job/Warrior.h | 20 +++++++++++ src/world/CMakeLists.txt | 1 + 5 files changed, 100 insertions(+) create mode 100644 src/world/Action/Job/Warrior.cpp create mode 100644 src/world/Action/Job/Warrior.h diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 1b4faff6..e2ff4b27 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -31,6 +31,8 @@ #include #include "WorldServer.h" +#include "Job/Warrior.h" + using namespace Sapphire; using namespace Sapphire::Common; using namespace Sapphire::Network; @@ -604,6 +606,8 @@ void Action::Action::handleAction() if( m_lutEntry.statuses.caster.size() > 0 || m_lutEntry.statuses.target.size() > 0 ) handleStatusEffects(); + handleJobAction(); + m_effectBuilder->buildAndSendPackets( m_hitActors ); // TODO: disabled, reset kills our queued actions @@ -643,6 +647,18 @@ void Action::Action::handleStatusEffects() } } +void Action::Action::handleJobAction() +{ + switch( m_pSource->getClass() ) + { + case ClassJob::Warrior: + { + Warrior::onAction( *m_pSource->getAsPlayer(), *this ); + break; + } + } +} + bool Action::Action::preCheck() { if( auto player = m_pSource->getAsPlayer() ) diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index f6f18304..081be92e 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -111,6 +111,8 @@ namespace Sapphire::World::Action void handleStatusEffects(); + void handleJobAction(); + /*! * @brief Adds an actor filter to this action. * @param filter The ptr to the ActorFilter to add diff --git a/src/world/Action/Job/Warrior.cpp b/src/world/Action/Job/Warrior.cpp new file mode 100644 index 00000000..0e8434ad --- /dev/null +++ b/src/world/Action/Job/Warrior.cpp @@ -0,0 +1,61 @@ +#include "Warrior.h" + +#include +#include +#include + +using namespace Sapphire; +using namespace Sapphire::World::Action; + +void Warrior::onAction( Entity::Player& player, Action& action ) +{ + switch( action.getId() ) + { + case Maim: + case StormsEye: + case StormsPath: + case SkullSunder: + case ButchersBlock: + { + if( action.isComboAction() && !action.isCorrectCombo() ) + break; + + if( player.hasStatusEffect( Defiance ) ) + handleWrath( player, action ); + break; + } + } +} + +void Warrior::handleWrath( Entity::Player& player, Action& action ) +{ + auto effectToApply = Wrath; + auto asChara = player.getAsChara(); + + if( player.hasStatusEffect( Wrath ) ) + { + player.replaceSingleStatusEffectById( Wrath ); + effectToApply = WrathII; + } + else if( player.hasStatusEffect( WrathII ) ) + { + player.replaceSingleStatusEffectById( WrathII ); + effectToApply = WrathIII; + } + else if( player.hasStatusEffect( WrathIII ) ) + { + player.replaceSingleStatusEffectById( WrathIII ); + effectToApply = WrathIV; + } + else if( player.hasStatusEffect( WrathIV ) ) + { + player.replaceSingleStatusEffectById( WrathIV ); + effectToApply = Infuriated; + } + + if( !player.hasStatusEffect( Infuriated ) ) + { + action.applyStatusEffectSelf( effectToApply ); + player.addStatusEffectByIdIfNotExist( effectToApply, 30000, *asChara ); + } +} \ No newline at end of file diff --git a/src/world/Action/Job/Warrior.h b/src/world/Action/Job/Warrior.h new file mode 100644 index 00000000..49474331 --- /dev/null +++ b/src/world/Action/Job/Warrior.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include "ForwardsZone.h" +#include +#include +#include +#include + +namespace Sapphire::World::Action +{ + class Warrior + { + public: + static void onAction( Entity::Player& player, Action& action ); + + private: + static void handleWrath( Entity::Player& player, Action& action ); + }; +} \ No newline at end of file diff --git a/src/world/CMakeLists.txt b/src/world/CMakeLists.txt index 632151e2..9ba8c3aa 100644 --- a/src/world/CMakeLists.txt +++ b/src/world/CMakeLists.txt @@ -7,6 +7,7 @@ file( GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp Actor/*.cpp Action/*.cpp + Action/Job/*.cpp ContentFinder/*.cpp DebugCommand/*.cpp Event/*.cpp