mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
refactoring, make ranged targeted aoe actions work somewhat properly
This commit is contained in:
parent
a09616e0e1
commit
03856a339c
9 changed files with 45 additions and 12 deletions
|
@ -0,0 +1,24 @@
|
||||||
|
#include <Script/NativeScriptApi.h>
|
||||||
|
#include <ScriptObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
#include <Action/Action.h>
|
||||||
|
|
||||||
|
class ActionAbyssalDrain3641 :
|
||||||
|
public Sapphire::ScriptAPI::ActionScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActionAbyssalDrain3641() :
|
||||||
|
Sapphire::ScriptAPI::ActionScript( 3641 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void onExecute( Sapphire::Action::Action& action ) override
|
||||||
|
{
|
||||||
|
for( auto& chara : action.getHitCharas() )
|
||||||
|
{
|
||||||
|
chara->takeDamage( chara->getMaxHp() * 0.5f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPOSE_SCRIPT( ActionAbyssalDrain3641 );
|
|
@ -14,11 +14,9 @@ public:
|
||||||
|
|
||||||
void onExecute( Sapphire::Action::Action& action ) override
|
void onExecute( Sapphire::Action::Action& action ) override
|
||||||
{
|
{
|
||||||
for( auto& chara : action.getHitActors() )
|
auto chara = action.getHitChara();
|
||||||
{
|
|
||||||
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
|
|
||||||
void onExecute( Sapphire::Action::Action& action ) override
|
void onExecute( Sapphire::Action::Action& action ) override
|
||||||
{
|
{
|
||||||
for( auto& chara : action.getHitActors() )
|
for( auto& chara : action.getHitCharas() )
|
||||||
{
|
{
|
||||||
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
chara->takeDamage( chara->getMaxHp() * 0.34f );
|
||||||
}
|
}
|
|
@ -100,6 +100,20 @@ bool Sapphire::Action::Action::init()
|
||||||
m_primaryCostType = static_cast< Common::ActionPrimaryCostType >( m_actionData->costType );
|
m_primaryCostType = static_cast< Common::ActionPrimaryCostType >( m_actionData->costType );
|
||||||
m_primaryCost = m_actionData->cost;
|
m_primaryCost = m_actionData->cost;
|
||||||
|
|
||||||
|
if( !m_actionData->targetArea )
|
||||||
|
{
|
||||||
|
// override pos to target position
|
||||||
|
// todo: this is kinda dirty
|
||||||
|
for( auto& actor : m_pSource->getInRangeActors() )
|
||||||
|
{
|
||||||
|
if( actor->getId() == m_targetId )
|
||||||
|
{
|
||||||
|
m_pos = actor->getPos();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// todo: add missing rows for secondaryCostType/secondaryCostType and rename the current rows to primaryCostX
|
// todo: add missing rows for secondaryCostType/secondaryCostType and rename the current rows to primaryCostX
|
||||||
|
|
||||||
addDefaultActorFilters();
|
addDefaultActorFilters();
|
||||||
|
@ -558,12 +572,12 @@ bool Sapphire::Action::Action::preFilterActor( Sapphire::Entity::Actor& actor )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< Sapphire::Entity::CharaPtr >& Sapphire::Action::Action::getHitActors()
|
std::vector< Sapphire::Entity::CharaPtr >& Sapphire::Action::Action::getHitCharas()
|
||||||
{
|
{
|
||||||
return m_hitActors;
|
return m_hitActors;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getHitActor()
|
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getHitChara()
|
||||||
{
|
{
|
||||||
if( !m_hitActors.empty() )
|
if( !m_hitActors.empty() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,13 +97,13 @@ namespace Sapphire::Action
|
||||||
void addDefaultActorFilters();
|
void addDefaultActorFilters();
|
||||||
|
|
||||||
|
|
||||||
std::vector< Entity::CharaPtr >& getHitActors();
|
std::vector< Entity::CharaPtr >& getHitCharas();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the first hit actor inside the m_hitActors vector.
|
* @brief Returns the first hit actor inside the m_hitActors vector.
|
||||||
* @return The CharaPtr otherwise nullptr
|
* @return The CharaPtr otherwise nullptr
|
||||||
*/
|
*/
|
||||||
Entity::CharaPtr getHitActor();
|
Entity::CharaPtr getHitChara();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @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).
|
||||||
|
|
|
@ -47,9 +47,6 @@ void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& play
|
||||||
|
|
||||||
action->setTargetId( targetId );
|
action->setTargetId( targetId );
|
||||||
|
|
||||||
if( player.getId() == targetId )
|
|
||||||
action->setPos( player.getPos() );
|
|
||||||
|
|
||||||
if( !action->init() )
|
if( !action->init() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue