diff --git a/scripts/native/CMakeLists.txt b/scripts/native/CMakeLists.txt index aeaa0094..6107d58f 100644 --- a/scripts/native/CMakeLists.txt +++ b/scripts/native/CMakeLists.txt @@ -39,7 +39,7 @@ foreach(_scriptDir ${children}) endforeach() add_library("script_${_name}" MODULE "${SCRIPT_FILES}" "${SCRIPT_INCLUDE_FILES}" "${_scriptDir}/ScriptLoader.cpp") - target_link_libraries("script_${_name}" sapphire_zone) + target_link_libraries("script_${_name}" sapphire_zone common xivdat ${Boost_LIBRARIES}) if(MSVC) set_target_properties("script_${_name}" PROPERTIES @@ -53,6 +53,10 @@ foreach(_scriptDir ${children}) ) endif() + if(EXISTS "${_scriptDir}/PreInclude.h") + set(PreScriptIncludes "#include \"${_scriptDir}/PreInclude.h\"") + endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.cpp.in" "${_scriptDir}/ScriptLoader.cpp") add_custom_command(TARGET "script_${_name}" POST_BUILD @@ -63,5 +67,6 @@ foreach(_scriptDir ${children}) unset(ScriptIncludes) unset(ScriptNames) + unset(PreScriptIncludes) endif() endforeach() diff --git a/scripts/native/ScriptLoader.cpp.in b/scripts/native/ScriptLoader.cpp.in index 633ca309..c5cbc42b 100644 --- a/scripts/native/ScriptLoader.cpp.in +++ b/scripts/native/ScriptLoader.cpp.in @@ -1,7 +1,5 @@ -#include - class ScriptObject; - +@PreScriptIncludes@ @ScriptIncludes@ const ScriptObject* ptrs[] = diff --git a/scripts/native/debugcommands/Add.cpp b/scripts/native/debugcommands/Add.cpp new file mode 100644 index 00000000..41031f7a --- /dev/null +++ b/scripts/native/debugcommands/Add.cpp @@ -0,0 +1,102 @@ +#include +#include +#include +#include +#include + +class Add : public DebugCommandScript +{ +public: + Add() : DebugCommandScript( "add", "Executes ADD command", 1 ) + { } + + virtual void run( Entity::Player& player, const std::string& data, const std::string &subCommand, const std::string ¶ms ) + { + if( subCommand == "status" ) + { + int32_t id; + int32_t duration; + uint16_t param; + + sscanf( params.c_str(), "%d %d %hu", &id, &duration, ¶m ); + + StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 ) ); + effect->setParam( param ); + + player.addStatusEffect( effect ); + } + else if( subCommand == "title" ) + { + uint32_t titleId; + sscanf( params.c_str(), "%u", &titleId ); + + player.addTitle( titleId ); + player.sendNotice( "Added title (ID: " + std::to_string( titleId ) + ")" ); + } + else if( subCommand == "spawn" ) + { + int32_t model, name; + + sscanf( params.c_str(), "%d %d", &model, &name ); + + Entity::BattleNpcPtr pBNpc( new Entity::BattleNpc( model, name, player.getPos() ) ); + + auto pZone = player.getCurrentZone(); + pBNpc->setCurrentZone( pZone ); + pZone->pushActor( pBNpc ); + + } + else if( subCommand == "op" ) + { + // temporary research packet + int32_t opcode; + sscanf( params.c_str(), "%x", &opcode ); + Network::Packets::GamePacketPtr pPe( new Network::Packets::GamePacket( opcode, 0x30, player.getId(), player.getId() ) ); + player.queuePacket( pPe ); + } + else if( subCommand == "actrl" ) + { + + // temporary research packet + + int32_t opcode; + int32_t param1; + int32_t param2; + int32_t param3; + int32_t param4; + int32_t param5; + int32_t param6; + int32_t playerId; + + sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &playerId ); + + player.sendNotice( "Injecting ACTOR_CONTROL " + std::to_string( opcode ) ); + + Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( playerId, player.getId() ); + actorControl.data().category = opcode; + actorControl.data().param1 = param1; + actorControl.data().param2 = param2; + actorControl.data().param3 = param3; + actorControl.data().param4 = param4; + actorControl.data().param5 = param5; + actorControl.data().param6 = param6; + player.queuePacket( actorControl ); + + + /*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &playerId); + + Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) ); + + player.queuePacket( noticePacket ); + + Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode, + param1, param2, param3, param4, param5, param6, playerId ); + player.queuePacket( controlPacket );*/ + + } + else + { + player.sendUrgent( subCommand + " is not a valid ADD command." ); + } + } +}; \ No newline at end of file diff --git a/scripts/native/debugcommands/Get.cpp b/scripts/native/debugcommands/Get.cpp new file mode 100644 index 00000000..f20a3abe --- /dev/null +++ b/scripts/native/debugcommands/Get.cpp @@ -0,0 +1,31 @@ +#include + +#include + +class Get : public DebugCommandScript +{ +public: + Get() : DebugCommandScript( "get", "Executes GET commands", 1 ) + { } + + virtual void run( Entity::Player& player, const std::string& data, const std::string& subCommand, const std::string& params ) + { + if( ( subCommand == "pos" ) ) + { + + int16_t map_id = m_objects->m_exd->m_zoneInfoMap[player.getCurrentZone()->getTerritoryId()].map_id; + + player.sendNotice( "Pos:\n" + + std::to_string( player.getPos().x ) + "\n" + + std::to_string( player.getPos().y ) + "\n" + + std::to_string( player.getPos().z ) + "\n" + + std::to_string( player.getRotation() ) + "\nMapId: " + + std::to_string( map_id ) + "\nZoneID: " + + std::to_string(player.getCurrentZone()->getTerritoryId() ) + "\n" ); + } + else + { + player.sendUrgent( subCommand + " is not a valid GET command." ); + } + } +}; \ No newline at end of file diff --git a/scripts/native/debugcommands/Help.cpp b/scripts/native/debugcommands/Help.cpp new file mode 100644 index 00000000..f7ec3947 --- /dev/null +++ b/scripts/native/debugcommands/Help.cpp @@ -0,0 +1,23 @@ +#include + +#include