mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
aethernet works again
This commit is contained in:
parent
bbcc85a9db
commit
1afefc3d79
8 changed files with 137 additions and 15 deletions
48
scripts/native/aetheryte/Aethernet.cpp
Normal file
48
scripts/native/aetheryte/Aethernet.cpp
Normal file
|
@ -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 )
|
12
scripts/native/aetheryte/Aetheryte.cpp
Normal file
12
scripts/native/aetheryte/Aetheryte.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "../ScriptObject.h"
|
||||
|
||||
class Aetheryte : public QuestScript
|
||||
{
|
||||
public:
|
||||
Aetheryte() : QuestScript( "Aetheryte", 0x50000 )
|
||||
{}
|
||||
|
||||
|
||||
};
|
||||
|
||||
EXPORT_SCRIPTOBJECT( Aetheryte )
|
|
@ -31,6 +31,7 @@
|
|||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Session.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
|
@ -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" )
|
||||
|
|
|
@ -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( )
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define NATIVE_SCRIPT_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,9 +2,11 @@
|
|||
#define SAPPHIRE_SCRIPTLOADER_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
|
||||
#include "NativeScriptApi.h"
|
||||
#include "ScriptInfo.h"
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -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 );
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue