1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 16:37:45 +00:00

somewhat working action lut stuff

This commit is contained in:
NotAdam 2019-06-02 02:30:54 +10:00
parent 90d1fbc3ea
commit d755ea2a32
14 changed files with 44 additions and 227 deletions

View file

@ -1,23 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionHeavyShot97 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionHeavyShot97() :
Sapphire::ScriptAPI::ActionScript( 97 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
if( auto player = action.getSourceChara()->getAsPlayer() )
player->sendDebug( "Imagine you just hit an enemy for 150 potency. Incredible, right?" );
}
};
EXPOSE_SCRIPT( ActionHeavyShot97 );

View file

@ -1,22 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionCure120 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionCure120() :
Sapphire::ScriptAPI::ActionScript( 120 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionCure120 );

View file

@ -1,24 +0,0 @@
#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::World::Action::Action& action ) override
{
for( auto& chara : action.getHitCharas() )
{
chara->takeDamage( chara->getMaxHp() * 0.5f );
}
}
};
EXPOSE_SCRIPT( ActionAbyssalDrain3641 );

View file

@ -1,23 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionHardSlash3617 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionHardSlash3617() :
Sapphire::ScriptAPI::ActionScript( 3617 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
auto chara = action.getHitChara();
chara->takeDamage( chara->getMaxHp() * 0.34f );
}
};
EXPOSE_SCRIPT( ActionHardSlash3617 );

View file

@ -1,22 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionPowerSlash3627 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionPowerSlash3627() :
Sapphire::ScriptAPI::ActionScript( 3627 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionPowerSlash3627 );

View file

@ -1,22 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionSpinningSlash3619 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionSpinningSlash3619() :
Sapphire::ScriptAPI::ActionScript( 3619 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionSpinningSlash3619 );

View file

@ -1,22 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionSyphonStrike3623 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionSyphonStrike3623() :
Sapphire::ScriptAPI::ActionScript( 3623 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionSyphonStrike3623 );

View file

@ -1,24 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionUnleash3621 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionUnleash3621() :
Sapphire::ScriptAPI::ActionScript( 3621 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
for( auto& chara : action.getHitCharas() )
{
chara->takeDamage( chara->getMaxHp() * 0.34f );
}
}
};
EXPOSE_SCRIPT( ActionUnleash3621 );

View file

@ -1,22 +0,0 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionAsylum3569 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionAsylum3569() :
Sapphire::ScriptAPI::ActionScript( 3569 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionAsylum3569 );

View file

@ -239,17 +239,16 @@ void Action::start()
player->queuePacket( actionStartPkt );
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
if( !pScriptMgr->onStart( *this ) )
{
// check the lut initially and see if we have something usable, otherwise cancel the cast
// Sapphire::World::Action::ActionLut::validEntryExists( getId() );
// script not implemented
// check the lut too and see if we have something usable, otherwise cancel the cast
if( !pScriptMgr->onStart( *this ) && !ActionLut::validEntryExists( getId() ) )
{
// script not implemented and insufficient lut data (no potencies)
interrupt();
if( player )
{
player->sendUrgent( "Action not implemented, missing script for action#{0}", getId() );
player->sendUrgent( "Action not implemented, missing script/lut entry for action#{0}", getId() );
player->setCurrentAction( nullptr );
}
@ -335,7 +334,17 @@ void Action::execute()
if( !m_hitActors.empty() )
{
// only call script if actors are hit
pScriptMgr->onExecute( *this );
if( !pScriptMgr->onExecute( *this ) && ActionLut::validEntryExists( getId() ) )
{
auto lutEntry = ActionLut::getEntry( getId() );
// no script exists but we have a valid lut entry
if( auto player = getSourceChara()->getAsPlayer() )
{
player->sendDebug( "Hit target: pot: {} (f: {}, r: {}), heal pot: {}",
lutEntry.potency, lutEntry.flankPotency, lutEntry.rearPotency, lutEntry.curePotency );
}
}
}
}
else if( auto player = m_pSource->getAsPlayer() )
@ -352,18 +361,18 @@ void Action::execute()
}
}
bool Action::precheck()
bool Action::preCheck()
{
if( auto player = m_pSource->getAsPlayer() )
{
if( !playerPrecheck( *player ) )
if( !playerPreCheck( *player ) )
return false;
}
return true;
}
bool Action::playerPrecheck( Entity::Player& player )
bool Action::playerPreCheck( Entity::Player& player )
{
// lol
if( !player.isAlive() )
@ -393,17 +402,18 @@ bool Action::playerPrecheck( 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( m_actionData->canTargetSelf &&
// !m_actionData->canTargetFriendly &&
// !m_actionData->canTargetHostile &&
// !m_actionData->canTargetParty )
// {
// setTargetId( getSourceChara() );
// }
if( !m_actionData->canTargetSelf && getTargetId() == m_pSource->getId() )
return false;
// todo: party/enemy validation
// todo: does this need to check for party/alliance stuff or it's just same type?
// todo: m_pTarget doesn't exist at this stage because we only fill it when we snapshot targets
// if( !m_actionData->canTargetFriendly && m_pSource->getObjKind() == m_pTarget->getObjKind() )
// return false;
//
// if( !m_actionData->canTargetHostile && m_pSource->getObjKind() != m_pTarget->getObjKind() )
// return false;
// todo: party/dead validation
// validate range

View file

@ -75,7 +75,7 @@ namespace Sapphire::World::Action
* @brief Tests if an action is castable by the current source chara
* @return true if castable, false if the caster doesn't meet the requirements
*/
bool precheck();
bool preCheck();
/*!
* @brief Snapshots characters affected by a cast.
@ -135,7 +135,7 @@ namespace Sapphire::World::Action
bool primaryCostCheck( bool subtractCosts );
bool secondaryCostCheck( bool subtractCosts );
bool playerPrecheck( Entity::Player& player );
bool playerPreCheck( Entity::Player& player );
bool preFilterActor( Entity::Actor& actor ) const;

View file

@ -1,3 +1,4 @@
#include <cassert>
#include "ActionLut.h"
using namespace Sapphire::World::Action;
@ -14,4 +15,13 @@ bool ActionLut::validEntryExists( uint16_t actionId )
// if all of the fields are 0, it's not 'valid' due to parse error or no useful data in the tooltip
return entry.potency != 0 || entry.comboPotency != 0 || entry.flankPotency != 0 || entry.frontPotency != 0 ||
entry.rearPotency != 0 || entry.curePotency != 0;
}
const ActionEntry& ActionLut::getEntry( uint16_t actionId )
{
auto it = m_actionLut.find( actionId );
assert( it != m_actionLut.end() );
return it->second;
}

View file

@ -22,6 +22,7 @@ namespace Sapphire::World::Action
using Lut = std::unordered_map< uint16_t, ActionEntry >;
static bool validEntryExists( uint16_t actionId );
static const ActionEntry& getEntry( uint16_t actionId );
static Lut m_actionLut;
};

View file

@ -90,7 +90,7 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
Action::ActionPtr currentAction,
Data::Action& actionData )
{
if( !currentAction->precheck() )
if( !currentAction->preCheck() )
{
// forcefully interrupt the action and reset the cooldown
currentAction->interrupt();