2019-03-07 21:58:12 +11:00
|
|
|
#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 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
void onExecute( Sapphire::World::Action::Action& action ) override
|
2019-03-07 21:58:12 +11:00
|
|
|
{
|
2023-02-10 13:05:53 -03:00
|
|
|
auto pPlayer = action.getSourceChara()->getAsPlayer();
|
2019-03-07 21:58:12 +11:00
|
|
|
|
2023-02-10 13:05:53 -03:00
|
|
|
if( !pPlayer )
|
2019-03-07 21:58:12 +11:00
|
|
|
return;
|
|
|
|
|
2023-02-10 13:05:53 -03:00
|
|
|
auto teleportQuery = pPlayer->getTeleportQuery();
|
2019-03-07 21:58:12 +11:00
|
|
|
|
2023-02-10 13:05:53 -03:00
|
|
|
if( pPlayer->getCurrency( Common::CurrencyType::Gil ) < teleportQuery.cost ||
|
2019-03-07 22:24:42 +11:00
|
|
|
teleportQuery.targetAetheryte == 0 )
|
2019-03-07 21:58:12 +11:00
|
|
|
{
|
|
|
|
action.interrupt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-10 13:05:53 -03:00
|
|
|
pPlayer->removeCurrency( Common::CurrencyType::Gil, teleportQuery.cost );
|
2019-03-07 21:58:12 +11:00
|
|
|
|
2023-02-10 13:05:53 -03:00
|
|
|
warpMgr().requestPlayerTeleport( *pPlayer, teleportQuery.targetAetheryte, 1 );
|
|
|
|
|
|
|
|
pPlayer->clearTeleportQuery();
|
2019-03-07 21:58:12 +11:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPOSE_SCRIPT( ActionTeleport5 );
|