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

42 lines
961 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 player = action.getSourceChara()->getAsPlayer();
if( !player )
return;
auto teleportQuery = player->getTeleportQuery();
2019-03-07 22:24:42 +11:00
if( player->getCurrency( Common::CurrencyType::Gil ) < teleportQuery.cost ||
teleportQuery.targetAetheryte == 0 )
{
action.interrupt();
return;
}
player->removeCurrency( Common::CurrencyType::Gil, teleportQuery.cost );
player->setZoningType( Common::ZoneingType::Teleport );
2019-03-07 22:24:42 +11:00
player->teleport( teleportQuery.targetAetheryte );
player->clearTeleportQuery();
}
};
EXPOSE_SCRIPT( ActionTeleport5 );