diff --git a/scripts/native/aetheryte/Aethernet.cpp b/scripts/native/aetheryte/Aethernet.cpp new file mode 100644 index 00000000..3f3cb023 --- /dev/null +++ b/scripts/native/aetheryte/Aethernet.cpp @@ -0,0 +1,48 @@ +#include "../ScriptObject.h" + +#define ACTION_ATTUNE 0x13 + +#define AetheryteBaseId 0x50000 +#define AETHERYTE_MENU_AETHERNET 1 +#define AETHERYTE_MENU_HOUSING 2 +#define AETHERYTE_MENU_HOME_POINT 3 +#define AETHERYTE_MENU_FAVORITE_POINT 4 +#define AETHERYTE_MENU_FAVORITE_POINT_SECURITY_TOKEN 5 + +class Aethernet : public QuestScript +{ +public: + Aethernet() : QuestScript( "Aethernet", 0x50001 ) + {} + + virtual void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) + { + if( player.isAetheryteRegistered( eventId & 0xFFFF ) ) + { + player.eventPlay( eventId, 2, 0, []( Entity::Player& ply, uint32_t evntId, uint16_t p1, uint16_t p2, uint16_t p3 ) + { + if( p1 == 256 ) + { + ply.teleport( p2, 2 ); + } + } ); + } + else + { + player.eventActionStart( eventId, ACTION_ATTUNE, []( Entity::Player& ply, uint32_t evntId, uint64_t additional ) + { + ply.registerAetheryte( evntId & 0xFFFF ); + ply.eventPlay( evntId, 3, 0, 0, 0 ); + }, + [] ( Entity::Player& ply, uint32_t evntId, uint64_t additional ) + { + + }, 0 ); + + player.unlock(); + } + + } +}; + +EXPORT_SCRIPTOBJECT( Aethernet ) \ No newline at end of file diff --git a/scripts/native/aetheryte/Aetheryte.cpp b/scripts/native/aetheryte/Aetheryte.cpp new file mode 100644 index 00000000..fd9af4ef --- /dev/null +++ b/scripts/native/aetheryte/Aetheryte.cpp @@ -0,0 +1,12 @@ +#include "../ScriptObject.h" + +class Aetheryte : public QuestScript +{ +public: + Aetheryte() : QuestScript( "Aetheryte", 0x50000 ) + {} + + +}; + +EXPORT_SCRIPTOBJECT( Aetheryte ) \ No newline at end of file diff --git a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp index 26007799..9dc2bcab 100644 --- a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp @@ -31,6 +31,7 @@ #include "StatusEffect/StatusEffect.h" #include "Session.h" #include +#include #include @@ -558,7 +559,23 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, Debu player.sendDebug( "Because reasons of filling chat with nonsense, please enter a search term" ); else { + std::set< Core::Scripting::ScriptInfo* > scripts; + g_scriptMgr.getNativeScriptHandler().findScripts( scripts, params ); + if( scripts.size() > 0 ) + { + player.sendDebug( "Found " + std::to_string( scripts.size() ) + " scripts" ); + + for( auto it = scripts.begin(); it != scripts.end(); ++it ) + { + auto script = *it; + player.sendDebug( " - '" + script->script_name + "' loaded at @ 0x" + + boost::str( boost::format( "%|X|" ) % script->handle ) + + ", script ptr: 0x" + boost::str( boost::format( "%|X|" ) % script->script ) ); + } + } + else + player.sendDebug( "No scripts found with search term: " + params ); } } else if( subCommand == "load" || subCommand == "l" ) diff --git a/src/servers/Server_Zone/Script/NativeScript.cpp b/src/servers/Server_Zone/Script/NativeScript.cpp index 8496033f..c2b8d9dd 100644 --- a/src/servers/Server_Zone/Script/NativeScript.cpp +++ b/src/servers/Server_Zone/Script/NativeScript.cpp @@ -8,11 +8,11 @@ namespace Core { StatusEffectScript* NativeScript::getStatusEffectScript( uint32_t statusId ) { - auto script = m_statusEffectScripts.find( statusId ); - if( script == m_statusEffectScripts.end() ) - return nullptr; + auto script = m_statusEffectScripts.find( statusId ); + if( script == m_statusEffectScripts.end() ) + return nullptr; - return script->second; + return script->second; } ActionScript* NativeScript::getActionScript( uint32_t actionId ) @@ -139,6 +139,12 @@ namespace Core { return false; } + void NativeScript::findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ) + { + return m_loader.findScripts( scripts, search ); + } + + boost::shared_ptr< NativeScript > create_script_engine( ) { diff --git a/src/servers/Server_Zone/Script/NativeScript.h b/src/servers/Server_Zone/Script/NativeScript.h index fc5cbcca..8c9e7928 100644 --- a/src/servers/Server_Zone/Script/NativeScript.h +++ b/src/servers/Server_Zone/Script/NativeScript.h @@ -2,6 +2,7 @@ #define NATIVE_SCRIPT_H #include +#include #include #include @@ -36,6 +37,7 @@ namespace Scripting { bool loadScript( const std::string& path ); bool unloadScript( const std::string& name ); + void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ); const std::string getModuleExtension(); diff --git a/src/servers/Server_Zone/Script/ScriptLoader.cpp b/src/servers/Server_Zone/Script/ScriptLoader.cpp index cce73255..e7b661a7 100644 --- a/src/servers/Server_Zone/Script/ScriptLoader.cpp +++ b/src/servers/Server_Zone/Script/ScriptLoader.cpp @@ -142,4 +142,15 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::getScriptInfo( std:: } return nullptr; +} + +void Core::Scripting::ScriptLoader::findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ) +{ + for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it ) + { + if( it->second->script_name.find( search ) != std::string::npos ) + { + scripts.insert( it->second ); + } + } } \ No newline at end of file diff --git a/src/servers/Server_Zone/Script/ScriptLoader.h b/src/servers/Server_Zone/Script/ScriptLoader.h index 393ff88f..0f452d19 100644 --- a/src/servers/Server_Zone/Script/ScriptLoader.h +++ b/src/servers/Server_Zone/Script/ScriptLoader.h @@ -2,9 +2,11 @@ #define SAPPHIRE_SCRIPTLOADER_H #include +#include +#include + #include "NativeScriptApi.h" #include "ScriptInfo.h" -#include #ifdef _WIN32 #include @@ -33,6 +35,8 @@ namespace Scripting { ScriptInfo* getScriptInfo( std::string name ); ScriptObject* getScriptObject( ModuleHandle handle ); bool isModuleLoaded( std::string name ); + + void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ); }; } diff --git a/src/servers/Server_Zone/Script/ScriptManager.cpp b/src/servers/Server_Zone/Script/ScriptManager.cpp index b32168ca..328932ba 100644 --- a/src/servers/Server_Zone/Script/ScriptManager.cpp +++ b/src/servers/Server_Zone/Script/ScriptManager.cpp @@ -114,10 +114,18 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac uint16_t eventType = eventId >> 16; - auto script = m_nativeScriptHandler->getQuestScript( eventId ); - if( script ) + // aethernet/aetherytes need to be handled separately + // todo: probably a nicer way to do this would be to switch the param for getQuestScript + if( eventType == Common::EventType::Aetheryte ) { - player.sendDebug( "Calling: " + objName + "." + eventName ); + auto aetherInfo = g_exdData.getAetheryteInfo( eventId & 0xFFFF ); + auto scriptId = 0x50000; + if( !aetherInfo->isAetheryte ) + scriptId = 0x50001; + + auto script = m_nativeScriptHandler->getQuestScript( scriptId ); + if( !script ) + return false; player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 ); @@ -127,17 +135,31 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac } else { - if ( eventType == Common::EventType::Quest ) + auto script = m_nativeScriptHandler->getQuestScript( eventId ); + if( script ) { - auto questInfo = g_exdData.getQuestInfo( eventId ); - if ( questInfo ) - { - player.sendUrgent( "Quest not implemented: " + questInfo->name ); + player.sendDebug( "Calling: " + objName + "." + eventName ); - } + player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 ); + + script->onTalk( eventId, player, actorId ); + + player.checkEvent( eventId ); } + else + { + if ( eventType == Common::EventType::Quest ) + { + auto questInfo = g_exdData.getQuestInfo( eventId ); + if ( questInfo ) + { + player.sendUrgent( "Quest not implemented: " + questInfo->name ); - return false; + } + } + + return false; + } } return true;