mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 13:47:46 +00:00
Merge pull request #201 from takhlaq/tools
updated quest_parser for c++ scripting, fixed typo in pcb_reader
This commit is contained in:
commit
c0fb85379c
6 changed files with 460 additions and 128 deletions
|
@ -6,9 +6,10 @@ file(GLOB_RECURSE SCRIPT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
|||
|
||||
include_directories("${CMAKE_SOURCE_DIR}/src/servers/")
|
||||
include_directories("${CMAKE_SOURCE_DIR}/src/servers/sapphire_zone/")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yc${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h /FI${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yc\"${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h\" /FI\"${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h\"")
|
||||
endif()
|
||||
|
||||
message( "exec: ${EXECUTABLE_OUTPUT_DIRECTORY}" )
|
||||
|
|
259
scripts/native/quest/ManFst004.cpp
Normal file
259
scripts/native/quest/ManFst004.cpp
Normal file
|
@ -0,0 +1,259 @@
|
|||
// This is an automatically generated C++ script template
|
||||
// Content needs to be added by hand to make it function
|
||||
// In order for this script to be loaded, change its extension to .cpp
|
||||
// and move it to the correct folder in <root>/scripts/native/
|
||||
|
||||
#include <ScriptObject.h>
|
||||
|
||||
// Quest Script: ManFst004_00124
|
||||
// Quest Name: Close to Home
|
||||
// Quest ID: 65660
|
||||
// Start NPC: 1001140
|
||||
// End NPC: 1000100
|
||||
|
||||
class ManFst004 : public EventScript
|
||||
{
|
||||
private:
|
||||
// Basic quest information
|
||||
// Quest vars / flags used
|
||||
// GetQuestBitFlag8
|
||||
// GetQuestUI8AL
|
||||
// GetQuestUI8BH
|
||||
// GetQuestUI8BL
|
||||
// GetQuestUI8CH
|
||||
|
||||
// Steps in this quest ( 0 is before accepting,
|
||||
// 1 is first, 255 means ready for turning it in
|
||||
enum Sequence : uint8_t
|
||||
{
|
||||
Seq0 = 0,
|
||||
Seq1 = 1,
|
||||
SeqFinish = 255,
|
||||
};
|
||||
|
||||
// Quest rewards
|
||||
static constexpr auto RewardExpFactor = 100;
|
||||
static constexpr auto RewardGil = 107;
|
||||
|
||||
// Entities found in the script data of the quest
|
||||
static constexpr auto Actor0 = 1001140;
|
||||
static constexpr auto Actor1 = 2;
|
||||
static constexpr auto Actor2 = 1000323;
|
||||
static constexpr auto Actor20 = 1000159;
|
||||
static constexpr auto Actor3 = 1000768;
|
||||
static constexpr auto Actor4 = 1000100;
|
||||
static constexpr auto BindActor0 = 6229224;
|
||||
static constexpr auto Item0 = 2000120;
|
||||
static constexpr auto LocActor0 = 1003159;
|
||||
static constexpr auto LocMarker01 = 2153091;
|
||||
static constexpr auto LocMarker02 = 2153104;
|
||||
static constexpr auto LocMarker03 = 2153111;
|
||||
static constexpr auto LocMarker04 = 2154539;
|
||||
static constexpr auto LocMarker05 = 2154540;
|
||||
static constexpr auto LocMarker06 = 2154541;
|
||||
static constexpr auto LocMarker07 = 2210446;
|
||||
static constexpr auto LocMarker08 = 2210454;
|
||||
static constexpr auto LocMarker09 = 2210461;
|
||||
static constexpr auto LocMotion0 = 799;
|
||||
static constexpr auto Poprange0 = 2280858;
|
||||
static constexpr auto RewardDesion = 1;
|
||||
static constexpr auto Seq0Actor0 = 0;
|
||||
static constexpr auto Seq0Actor0Lq = 50;
|
||||
static constexpr auto Seq1Actor0 = 4;
|
||||
static constexpr auto Seq1Actor1 = 1;
|
||||
static constexpr auto Seq1Actor1Wait = 51;
|
||||
static constexpr auto Seq1Actor2 = 2;
|
||||
static constexpr auto Seq1Actor3 = 3;
|
||||
static constexpr auto Seq1Actor3Npctradeno = 99;
|
||||
static constexpr auto Seq1Actor3Npctradeok = 100;
|
||||
static constexpr auto Seq2Actor4 = 5;
|
||||
static constexpr auto Territorytype0 = 132;
|
||||
static constexpr auto UnlockDesion = 14;
|
||||
|
||||
public:
|
||||
ManFst004() : EventScript( "Close to Home", 65660 ){};
|
||||
~ManFst004(){};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Event Handlers
|
||||
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
|
||||
{
|
||||
auto actor = Event::mapEventActorToRealActor( actorId );
|
||||
if( actor == ManFst004::Actor0 )
|
||||
{
|
||||
Scene00000( player );
|
||||
}
|
||||
else if( actor == ManFst004::Actor1 )
|
||||
{
|
||||
// starting the Aetheryte eventaction
|
||||
// player.eventStart( actorId, 0x050002, 7, 0, 0);
|
||||
// starting the eventaction 0x13 ( attuning )
|
||||
player.eventActionStart( 0x050002, 0x13,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||
{
|
||||
player.sendQuestMessage( 0x050002, 0, 1, 0, 0 );
|
||||
player.registerAetheryte( 2 );
|
||||
player.learnAction( 1 );
|
||||
Scene00051( player );
|
||||
},
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint64_t additional ) {},
|
||||
eventId );
|
||||
}
|
||||
else if( actor == ManFst004::Actor2 )
|
||||
{
|
||||
Scene00002( player );
|
||||
}
|
||||
else if( actor == ManFst004::Actor3 )
|
||||
{
|
||||
Scene00003( player );
|
||||
}
|
||||
else if( actor == ManFst004::Actor4 )
|
||||
{
|
||||
Scene00005( player );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void checkQuestCompletion( Entity::Player& player, uint32_t varIdx )
|
||||
{
|
||||
if( varIdx == 3 )
|
||||
{
|
||||
player.sendQuestMessage( m_id, 1, 0, 0, 0 );
|
||||
}
|
||||
else if( varIdx == 2 )
|
||||
{
|
||||
player.sendQuestMessage( m_id, 2, 0, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendQuestMessage( m_id, 0, 0, 0, 0 );
|
||||
}
|
||||
|
||||
auto questId = m_id;
|
||||
|
||||
auto QUEST_VAR_ATTUNE = player.getQuestUI8AL( questId );
|
||||
auto QUEST_VAR_CLASS = player.getQuestUI8BH( questId );
|
||||
auto QUEST_VAR_TRADE = player.getQuestUI8BL( questId );
|
||||
|
||||
if( QUEST_VAR_ATTUNE == 1 && QUEST_VAR_CLASS == 1 && QUEST_VAR_TRADE == 1 )
|
||||
{
|
||||
player.updateQuest( questId, SeqFinish );
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Available Scenes in this quest, not necessarly all are used
|
||||
void Scene00000( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 0, 0x2000,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
if( param2 == 1 ) // accept quest
|
||||
{
|
||||
Scene00050( player );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00001( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 1, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
player.setQuestUI8AL( m_id, 1 );
|
||||
checkQuestCompletion( player, 0 );
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00002( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 2, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
player.setQuestUI8BH( m_id, 1 );
|
||||
checkQuestCompletion( player, 3 );
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00003( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 3, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
if( param2 == 1 )
|
||||
{
|
||||
Scene00100( player );
|
||||
}
|
||||
else
|
||||
{
|
||||
Scene00099( player );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00004( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 4, 0, 0, 0 );
|
||||
}
|
||||
|
||||
void Scene00005( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 5, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, 0, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
if( param2 == 1 ) // finish quest
|
||||
{
|
||||
if( player.giveQuestRewards( m_id, 0 ) )
|
||||
{
|
||||
player.finishQuest( m_id );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00050( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 50, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, 0/*unk*/, 0/*unk*/,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
// accepting quest "close to home"
|
||||
player.updateQuest( m_id, 1 );
|
||||
player.setQuestUI8CH( m_id, 1 ); // receive key item
|
||||
// event is done, need to teleport to real zone.
|
||||
player.setZone( 132 );
|
||||
//player.setZone(183); back to starting griania for debug purpose
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00051( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 51, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
Scene00001( player );
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00099( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 99, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
Scene00004( player );
|
||||
});
|
||||
}
|
||||
|
||||
void Scene00100( Entity::Player& player )
|
||||
{
|
||||
player.eventPlay( m_id, 100, 0,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||
{
|
||||
player.setQuestUI8CH( m_id, 0 ); // remove key item, since we have just traded it
|
||||
player.setQuestUI8BL( m_id, 1 );
|
||||
checkQuestCompletion( player, 2 );
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPORT_SCRIPTOBJECT( ManFst004 );
|
|
@ -3,7 +3,7 @@
|
|||
namespace Core {
|
||||
namespace Version {
|
||||
|
||||
const std::string GIT_HASH = "232d9cd1addda0a363375b86054cc479fc69b2ef";
|
||||
const std::string GIT_HASH = "d799f2e3c2d745f9d9e07d6e37664fc031b7c264";
|
||||
const std::string VERSION = "-128-NOTFOUND";
|
||||
|
||||
} /* Version */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _EVENTHELPER_H
|
||||
#define _EVENTHELPER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Core {
|
||||
|
@ -10,7 +10,6 @@ namespace Core {
|
|||
std::string getEventName( uint32_t eventId );
|
||||
|
||||
uint32_t mapEventActorToRealActor( uint32_t eventActorId );
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
//#include <boost/algorithm/string.hpp>
|
||||
#endif
|
||||
|
||||
std::string gamePath( "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
struct face
|
||||
|
@ -103,18 +105,19 @@ std::string zoneNameToPath( const std::string& name )
|
|||
}
|
||||
}
|
||||
}
|
||||
inFile.close();
|
||||
}
|
||||
if( !path.empty() )
|
||||
{
|
||||
//path = path.substr( path.find_first_of( "/" ) + 1, path.size() - path.find_first_of( "/" ));
|
||||
//path = std::string( "ffxiv/" ) + path;
|
||||
path = std::string( "bg" ) + path.substr( 0, path.find( "/level/" ) );
|
||||
path = std::string( "bg/" ) + path.substr( 0, path.find( "/level/" ) );
|
||||
std::cout << "[Info] " << "Found path for " << name << ": " << path << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error( "Unable to find path for " + name +
|
||||
".\n\tPlease open 0a0000.win32.index with FFXIV Explorer and extract territorytype.exh as CSV\n\tand copy territorytype.exh.csv into pcb_reader.exe directory" );
|
||||
".\n\tPlease double check spelling or open 0a0000.win32.index with FFXIV Explorer and extract territorytype.exh as CSV\n\tand copy territorytype.exh.csv into pcb_reader.exe directory if using standalone" );
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
@ -125,7 +128,7 @@ void readFileToBuffer( const std::string& path, std::vector< char >& buf )
|
|||
if( inFile.good() )
|
||||
{
|
||||
inFile.seekg( 0, inFile.end );
|
||||
int32_t fileSize = inFile.tellg();
|
||||
int32_t fileSize = (int32_t)inFile.tellg();
|
||||
buf.resize( fileSize );
|
||||
inFile.seekg( 0, inFile.beg );
|
||||
inFile.read( &buf[0], fileSize );
|
||||
|
@ -142,7 +145,6 @@ int main( int argc, char* argv[] )
|
|||
auto startTime = std::chrono::system_clock::now();
|
||||
|
||||
// todo: support expansions
|
||||
std::string gamePath = "C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv";
|
||||
std::string zoneName = "r1f1";
|
||||
|
||||
if( argc > 1 )
|
||||
|
@ -166,7 +168,6 @@ int main( int argc, char* argv[] )
|
|||
#ifndef STANDALONE
|
||||
xiv::dat::GameData data1( gamePath );
|
||||
xiv::exd::ExdData eData( data1 );
|
||||
|
||||
const xiv::dat::Cat& test = data1.get_category( "bg" );
|
||||
|
||||
auto test_file = data1.get_file( bgLgbPath );
|
||||
|
|
|
@ -1,38 +1,84 @@
|
|||
|
||||
#include <GameData.h>
|
||||
#include <File.h>
|
||||
#include <DatCat.h>
|
||||
#include <ExdData.h>
|
||||
#include <ExdCat.h>
|
||||
#include <Exd.h>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <Exd.h>
|
||||
#include <ExdCat.h>
|
||||
#include <ExdData.h>
|
||||
#include <File.h>
|
||||
#include <GameData.h>
|
||||
#include <DatCat.h>
|
||||
|
||||
#include <common/Exd/ExdData.h>
|
||||
#include <common/Logging/Logger.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
Core::Logger g_log;
|
||||
Core::Data::ExdData g_exdData;
|
||||
|
||||
|
||||
void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::set< std::string > additionalList )
|
||||
{
|
||||
std::string header(
|
||||
"// This is an automatically generated chai script template\n"
|
||||
"// Content needs to be added by hand to make it function\n"
|
||||
"// In order for this script to be loaded, change its extension to .chai\n"
|
||||
"// and move it to the correct folder in bin/scripts/chai/quest\n"
|
||||
"\n"
|
||||
const std::string onTalkStr(
|
||||
" void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n"
|
||||
" {\n"
|
||||
" auto actor = Event::mapEventActorToRealActor( actorId );\n"
|
||||
" }\n\n"
|
||||
);
|
||||
|
||||
std::size_t splitPos = pQuestData->name_intern.find( "_" );
|
||||
std::string className = pQuestData->name_intern.substr( 0, splitPos );
|
||||
const std::string onWithinRangeStr(
|
||||
" void onWithinRange( uint32_t eventId, Entity::Player& player, uint64_t eRangeId, float x, float y, float z ) override\n"
|
||||
" {\n"
|
||||
" }\n\n"
|
||||
);
|
||||
|
||||
std::string sceneStr = " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n";
|
||||
std::string seqStr = " // Steps in this quest ( 0 is before accepting, \n // 1 is first, 255 means ready for turning it in\n";
|
||||
std::string questVarStr = " // Quest vars / flags used\n";
|
||||
const std::string onEmoteStr(
|
||||
" void onEmote( uint32_t eventId, Entity::Player& player, uint64_t actorId, uint32_t emoteId ) override\n"
|
||||
" {\n"
|
||||
" }\n\n"
|
||||
);
|
||||
|
||||
std::string titleCase( const std::string& str )
|
||||
{
|
||||
if( str.empty() )
|
||||
return str;
|
||||
|
||||
std::string retStr(str);
|
||||
std::transform( str.begin(), str.end(), retStr.begin(), ::tolower );
|
||||
std::locale loc;
|
||||
retStr[0] = std::toupper( str[0], loc );
|
||||
for( size_t i = 1; i < str.size(); ++i )
|
||||
{
|
||||
if( str[i - 1] == ' ' || str[i - 1] == '_' || ( std::isdigit( str[i - 1], loc ) && !std::isdigit( str[i], loc ) ) )
|
||||
retStr[i] = std::toupper( str[i], loc );
|
||||
}
|
||||
return retStr;
|
||||
}
|
||||
|
||||
void createScript( boost::shared_ptr< Core::Data::QuestInfo >& pQuestData, std::set< std::string >& additionalList )
|
||||
{
|
||||
std::string header(
|
||||
"// This is an automatically generated C++ script template\n"
|
||||
"// Content needs to be added by hand to make it function\n"
|
||||
"// In order for this script to be loaded, change its extension to .cpp\n"
|
||||
"// and move it to the correct folder in <root>/scripts/native/\n"
|
||||
"\n"
|
||||
"#include <ScriptObject.h>\n\n"
|
||||
);
|
||||
|
||||
std::size_t splitPos( pQuestData->name_intern.find( "_" ) );
|
||||
std::string className( pQuestData->name_intern.substr( 0, splitPos ) );
|
||||
//className = "Quest" + className;
|
||||
std::string sceneStr( " //////////////////////////////////////////////////////////////////////\n // Available Scenes in this quest, not necessarly all are used\n" );
|
||||
std::string seqStr;
|
||||
seqStr.reserve( 0xFFF );
|
||||
seqStr += ( " // Steps in this quest ( 0 is before accepting, \n // 1 is first, 255 means ready for turning it in\n" );
|
||||
std::string questVarStr( " // Quest vars / flags used\n" );
|
||||
|
||||
seqStr += " enum Sequence : uint8_t\n {\n";
|
||||
for( auto &entry : additionalList )
|
||||
{
|
||||
if( entry.find( "OnScene" ) != std::string::npos )
|
||||
|
@ -43,12 +89,19 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
std::size_t numOff = sceneId.find_first_not_of( "0" );
|
||||
sceneId = numOff != std::string::npos ? sceneId.substr( numOff ) : "0";
|
||||
|
||||
sceneStr += " def " + sceneName + "( player )\n";
|
||||
sceneStr += " {\n";
|
||||
sceneStr += " player.eventPlay( this.id, " + sceneId + ", NONE,\n";
|
||||
sceneStr += " fun( player, eventId, param1, param2, param3 )\n";
|
||||
sceneStr += " {} );\n";
|
||||
sceneStr += " }\n\n";
|
||||
sceneStr += std::string(
|
||||
" void " +
|
||||
sceneName +
|
||||
"( Entity::Player& player )\n"
|
||||
" {\n"
|
||||
" player.eventPlay( this->getId(), " +
|
||||
sceneId +
|
||||
", 0,\n"
|
||||
" [&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )\n"
|
||||
" {\n"
|
||||
" });\n"
|
||||
" }\n\n"
|
||||
);
|
||||
}
|
||||
else if( entry.find( "Flag" ) != std::string::npos ||
|
||||
entry.find( "QuestUI" ) != std::string::npos )
|
||||
|
@ -59,38 +112,41 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
{
|
||||
if( entry.find( "SEQ_FINISH" ) != std::string::npos )
|
||||
{
|
||||
seqStr += " this.SEQ_FINISH = 255;\n";
|
||||
seqStr += " SeqFinish = 255,\n";
|
||||
}
|
||||
else if( entry.find( "SEQ_OFFER" ) != std::string::npos )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string seqName = entry;
|
||||
std::string seqName = titleCase( entry );
|
||||
boost::replace_all( seqName, "_", "" );
|
||||
|
||||
std::string seqId = entry.substr( 4 );
|
||||
seqStr += " this." + seqName + " = " + seqId + ";\n";
|
||||
seqStr += " " + seqName + " = " + seqId + ",\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
std::string rewards = " // Quest rewards \n";
|
||||
rewards += ( pQuestData->reward_exp_factor != 0 ) ? " this.RewardExpFactor = " + std::to_string( pQuestData->reward_exp_factor ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_gil != 0 ) ? " this.RewardGil = " + std::to_string( pQuestData->reward_gil ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_emote != 0 ) ? " this.RewardEmote = " + std::to_string( pQuestData->reward_emote ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action != 0 ) ? " this.RewardAction = " + std::to_string( pQuestData->reward_action ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action_general1 != 0 ) ? " this.RewardGeneralAction1 = " + std::to_string( pQuestData->reward_action_general1 ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action_general2 != 0 ) ? " this.RewardGeneralAction2 = " + std::to_string( pQuestData->reward_action_general2 ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_gc_seals != 0 ) ? " this.RewardGCSeals = " + std::to_string( pQuestData->reward_gc_seals ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_other != 0 ) ? " this.RewardOther = " + std::to_string( pQuestData->reward_other ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_reputation != 0 ) ? " this.RewardReputation = " + std::to_string( pQuestData->reward_reputation ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_tome_type != 0 ) ? " this.RewardTomeType = " + std::to_string( pQuestData->reward_tome_type ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_tome_count != 0 ) ? " this.RewardTomeCount = " + std::to_string( pQuestData->reward_tome_count ) + ";\n" : "";
|
||||
rewards += ( pQuestData->instanced_content_unlock != 0 ) ? " this.InstancedContentUnlock = " + std::to_string( pQuestData->instanced_content_unlock ) + ";\n" : "";
|
||||
seqStr += " };\n";
|
||||
std::string rewards;
|
||||
rewards.reserve( 0xFFF );
|
||||
rewards += " // Quest rewards \n";
|
||||
rewards += ( pQuestData->reward_exp_factor != 0 ) ? " static constexpr auto RewardExpFactor = " + std::to_string( pQuestData->reward_exp_factor ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_gil != 0 ) ? " static constexpr auto RewardGil = " + std::to_string( pQuestData->reward_gil ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_emote != 0 ) ? " static constexpr auto RewardEmote = " + std::to_string( pQuestData->reward_emote ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action != 0 ) ? " static constexpr auto RewardAction = " + std::to_string( pQuestData->reward_action ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action_general1 != 0 ) ? " static constexpr auto RewardGeneralAction1 = " + std::to_string( pQuestData->reward_action_general1 ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_action_general2 != 0 ) ? " static constexpr auto RewardGeneralAction2 = " + std::to_string( pQuestData->reward_action_general2 ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_gc_seals != 0 ) ? " static constexpr auto RewardGCSeals = " + std::to_string( pQuestData->reward_gc_seals ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_other != 0 ) ? " static constexpr auto RewardOther = " + std::to_string( pQuestData->reward_other ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_reputation != 0 ) ? " static constexpr auto RewardReputation = " + std::to_string( pQuestData->reward_reputation ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_tome_type != 0 ) ? " static constexpr auto RewardTomeType = " + std::to_string( pQuestData->reward_tome_type ) + ";\n" : "";
|
||||
rewards += ( pQuestData->reward_tome_count != 0 ) ? " static constexpr auto RewardTomeCount = " + std::to_string( pQuestData->reward_tome_count ) + ";\n" : "";
|
||||
rewards += ( pQuestData->instanced_content_unlock != 0 ) ? " static constexpr auto InstancedContentUnlock = " + std::to_string( pQuestData->instanced_content_unlock ) + ";\n" : "";
|
||||
|
||||
if( pQuestData->reward_item.size() > 0 )
|
||||
{
|
||||
rewards += " this.RewardItem = [";
|
||||
rewards += " static constexpr auto RewardItem[] = { ";
|
||||
for( size_t ca = 0; ca < pQuestData->reward_item.size(); ca++ )
|
||||
{
|
||||
rewards += std::to_string( pQuestData->reward_item.at( ca ) );
|
||||
|
@ -99,12 +155,12 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
rewards += ", ";
|
||||
}
|
||||
}
|
||||
rewards += "];\n";
|
||||
rewards += " };\n";
|
||||
}
|
||||
|
||||
if( pQuestData->reward_item.size() > 0 )
|
||||
{
|
||||
rewards += " this.RewardItemCount = [";
|
||||
rewards += " static constexpr auto RewardItemCount[] = { ";
|
||||
for( size_t ca = 0; ca < pQuestData->reward_item_count.size(); ca++ )
|
||||
{
|
||||
rewards += std::to_string( pQuestData->reward_item_count.at( ca ) );
|
||||
|
@ -113,12 +169,12 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
rewards += ", ";
|
||||
}
|
||||
}
|
||||
rewards += "];\n";
|
||||
rewards += " };\n";
|
||||
}
|
||||
|
||||
if( pQuestData->reward_item_optional.size() > 0 )
|
||||
{
|
||||
rewards += " this.RewardItemOptional = [";
|
||||
rewards += " static constexpr auto RewardItemOptional[] = { ";
|
||||
for( size_t ca = 0; ca < pQuestData->reward_item_optional.size(); ca++ )
|
||||
{
|
||||
rewards += std::to_string( pQuestData->reward_item_optional.at( ca ) );
|
||||
|
@ -127,12 +183,12 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
rewards += ", ";
|
||||
}
|
||||
}
|
||||
rewards += "];\n";
|
||||
rewards += " };\n";
|
||||
}
|
||||
|
||||
if( pQuestData->reward_item_optional_count.size() > 0 )
|
||||
{
|
||||
rewards += " this.RewardItemOptionalCount = [";
|
||||
rewards += " static constexpr auto RewardItemOptionalCount[] = { ";
|
||||
for( size_t ca = 0; ca < pQuestData->reward_item_optional_count.size(); ca++ )
|
||||
{
|
||||
rewards += std::to_string( pQuestData->reward_item_optional_count.at( ca ) );
|
||||
|
@ -141,7 +197,7 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
rewards += ", ";
|
||||
}
|
||||
}
|
||||
rewards += "];\n";
|
||||
rewards += " };\n";
|
||||
}
|
||||
|
||||
bool hasERange = false;
|
||||
|
@ -168,10 +224,11 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
script_entities.push_back( pQuestData->script_entity.at( ca ) + " = " + std::to_string( pQuestData->script_value.at( ca ) ) );
|
||||
}
|
||||
std::sort( script_entities.begin(), script_entities.end() );
|
||||
|
||||
for( auto& entity : script_entities )
|
||||
{
|
||||
sentities += " this." + entity + ";\n";
|
||||
auto name = titleCase( entity );
|
||||
boost::replace_all( name, "_", "" );
|
||||
sentities += " static constexpr auto " + name + ";\n";
|
||||
}
|
||||
|
||||
std::string additional = "// Quest Script: " + pQuestData->name_intern + "\n";
|
||||
|
@ -180,78 +237,82 @@ void createScript( boost::shared_ptr< Core::Data::QuestInfo > pQuestData, std::s
|
|||
additional += "// Start NPC: " + std::to_string( pQuestData->enpc_resident_start ) + "\n";
|
||||
additional += "// End NPC: " + std::to_string( pQuestData->enpc_resident_end ) + "\n\n";
|
||||
|
||||
std::string scriptEntry = " //////////////////////////////////////////////////////////////////////\n";
|
||||
scriptEntry += " // Event Handlers\n";
|
||||
scriptEntry += " def onTalk( eventId, player, actorId )\n";
|
||||
scriptEntry += " {\n";
|
||||
scriptEntry += " var actor = mapActor( actorId );\n";
|
||||
scriptEntry += " }\n\n";
|
||||
std::string scriptEntry;
|
||||
scriptEntry.reserve(0xFFFF);
|
||||
scriptEntry += " //////////////////////////////////////////////////////////////////////\n // Event Handlers\n";
|
||||
|
||||
scriptEntry += onTalkStr;
|
||||
|
||||
if( hasERange )
|
||||
{
|
||||
scriptEntry += " def onWithinRange( eventId, player, eRangeId, x, y, z )\n";
|
||||
scriptEntry += " {\n";
|
||||
scriptEntry += " }\n\n";
|
||||
scriptEntry += onWithinRangeStr;
|
||||
}
|
||||
|
||||
if( hasEmote )
|
||||
{
|
||||
scriptEntry += " def onEmote( eventId, player, actorId, emoteId )\n";
|
||||
scriptEntry += " {\n";
|
||||
scriptEntry += " }\n\n";
|
||||
scriptEntry += onEmoteStr;
|
||||
}
|
||||
|
||||
for( auto enemy : enemy_ids )
|
||||
{
|
||||
scriptEntry += " def onMobKill_" + std::to_string(enemy) + "( player )\n";
|
||||
scriptEntry += " {\n";
|
||||
scriptEntry += " }\n\n";
|
||||
scriptEntry += std::string(
|
||||
" void onMobKill_" + std::to_string( enemy ) + "( Entity::Player& player )\n"
|
||||
" {\n"
|
||||
" }\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
std::string constructor;
|
||||
constructor += " def " + className + "Def()\n";
|
||||
constructor += " {\n";
|
||||
constructor += " // Basic quest information \n";
|
||||
constructor += " this.name = \"" + pQuestData->name + "\";\n";
|
||||
constructor += " this.id = " + std::to_string( pQuestData->id ) + ";\n\n";
|
||||
constructor += std::string(
|
||||
" private:\n"
|
||||
" // Basic quest information \n");
|
||||
constructor += questVarStr + "\n";
|
||||
constructor += seqStr + "\n";
|
||||
constructor += rewards + "\n";
|
||||
constructor += sentities + "\n";
|
||||
constructor += " }\n";
|
||||
|
||||
constructor += " public:\n";
|
||||
constructor += " " + className + "() : EventScript" + "( \"" + pQuestData->name + "\", " + std::to_string( pQuestData->id ) + " ){}; \n";
|
||||
constructor += " ~" + className + "(){}; \n";
|
||||
|
||||
std::string classString(
|
||||
"class " + className + "Def \n"
|
||||
"{\n"
|
||||
+ constructor +
|
||||
"\n"
|
||||
+ sceneStr +
|
||||
"class " + className + " : public EventScript\n"
|
||||
"{\n" +
|
||||
constructor +
|
||||
"\n" +
|
||||
scriptEntry +
|
||||
" private:\n" +
|
||||
sceneStr +
|
||||
"};\n\n"
|
||||
);
|
||||
|
||||
std::string objName = className;
|
||||
std::string initObj = "GLOBAL " + objName + " = " + className + "Def();\n";
|
||||
std::string initObj( "EXPORT_SCRIPTOBJECT( " + className + " );" );
|
||||
|
||||
std::ofstream outputFile;
|
||||
outputFile.open( "generated/" + className + ".chai_generated" );
|
||||
|
||||
outputFile.open( "generated/" + className + ".cpp_generated" );
|
||||
outputFile << header << additional << classString << initObj;
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
int main()
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
|
||||
g_log.init();
|
||||
|
||||
bool unluac = false;
|
||||
// std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
|
||||
std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
|
||||
std::string datLocation( "C:/Program Files (x86)/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/game/sqpack/ffxiv" );
|
||||
if ( argc > 1 )
|
||||
datLocation = std::string( argv[1] );
|
||||
if ( argc > 2 )
|
||||
unluac = (bool)atoi( argv[2] );
|
||||
|
||||
g_log.info( "Setting up EXD data" );
|
||||
if( !g_exdData.init( datLocation ) )
|
||||
{
|
||||
std::cout << datLocation << "\n";
|
||||
g_log.fatal( "Error setting up EXD data " );
|
||||
std::cout << "Usage: quest_parser \"path/to/ffxiv/game/sqpack\" <1/0 unluac export toggle>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -261,9 +322,14 @@ int main()
|
|||
auto QuestDat = g_exdData.setupDatAccess( "Quest", xiv::exd::Language::en );
|
||||
auto rows = QuestDat.get_rows();
|
||||
|
||||
for( auto row : rows )
|
||||
{
|
||||
if ( !boost::filesystem::exists( "./generated" ) )
|
||||
boost::filesystem::create_directory( "./generated" );
|
||||
|
||||
std::cout << "Export in progress";
|
||||
uint32_t updateInterval = rows.size() / 20;
|
||||
uint32_t i = 0;
|
||||
for( const auto& row : rows )
|
||||
{
|
||||
auto questInfo = g_exdData.getQuestInfo( row.first );
|
||||
|
||||
if( questInfo->name.empty() || questInfo->name_intern.empty() )
|
||||
|
@ -302,12 +368,15 @@ int main()
|
|||
outputFile1.open( "generated/" + questInfo->name_intern + ".luab", std::ios::binary );
|
||||
outputFile1.write( §ion[0], section.size() );
|
||||
outputFile1.close();
|
||||
if( unluac )
|
||||
{
|
||||
std::string command = std::string( "java -jar unluac_2015_06_13.jar " ) + "generated/" + questInfo->name_intern + ".luab" + ">> " + "generated/" + questInfo->name_intern + ".lua";
|
||||
if ( system( command.c_str() ) == -1 )
|
||||
{
|
||||
g_log.error( "Error executing java command:\n" + command + "\nerrno: " + std::strerror( errno ) );
|
||||
return errno;
|
||||
}
|
||||
}
|
||||
for( ; ; )
|
||||
{
|
||||
|
||||
|
@ -315,7 +384,7 @@ int main()
|
|||
offset += entry.size() + 1;
|
||||
|
||||
if( entry.size() > 3
|
||||
&& entry.find_first_not_of( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_" ) == std::string::npos )
|
||||
&& entry.find_first_not_of( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-" ) == std::string::npos )
|
||||
{
|
||||
if( entry.find( "SEQ" ) != std::string::npos
|
||||
|| entry.find( "QuestUI" ) != std::string::npos
|
||||
|
@ -333,8 +402,11 @@ int main()
|
|||
|
||||
|
||||
createScript( questInfo, stringList );
|
||||
++i;
|
||||
if( i % updateInterval == 0 )
|
||||
std::cout << ".";
|
||||
//break;
|
||||
}
|
||||
|
||||
std::cout << "\nDone!";
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue