1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 15:47:46 +00:00
sapphire/src/scripts/action/common/ActionTeleport5.cpp

41 lines
935 B
C++
Raw Normal View History

#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
using namespace Sapphire;
class ActionTeleport5 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionTeleport5() :
Sapphire::ScriptAPI::ActionScript( 5 )
{
}
void onExecute( Sapphire::World::Action::Action& action ) override
{
auto pPlayer = action.getSourceChara()->getAsPlayer();
if( !pPlayer )
return;
auto teleportQuery = pPlayer->getTeleportQuery();
if( pPlayer->getCurrency( Common::CurrencyType::Gil ) < teleportQuery.cost ||
2019-03-07 22:24:42 +11:00
teleportQuery.targetAetheryte == 0 )
{
action.interrupt();
return;
}
pPlayer->removeCurrency( Common::CurrencyType::Gil, teleportQuery.cost );
warpMgr().requestPlayerTeleport( *pPlayer, teleportQuery.targetAetheryte, 1 );
pPlayer->clearTeleportQuery();
}
};
EXPOSE_SCRIPT( ActionTeleport5 );