diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 04fed98..edac7d9 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -106,7 +106,10 @@ public: /* 0FAC */ const char* const* m_jobNamesEnd; /* 0FB0 */ unsigned char unknown_0FB0[0x34]; /* 0FE4 */ std::list m_pingSamples; - /* 0FEC */ unsigned char unknown_0FEC[0x6C]; + /* 0FEC */ unsigned char unknown_0FEC[0x24]; + /* 1010 */ std::uint32_t unknown_1010; + /* 1014 */ unsigned char unknown_1014[4]; + /* 1018 */ char unknown_1018[0x40]; /* 1058 */ int m_petActionTable[5][5][7]; /* 1314 */ unsigned char unknown_1314[0x258]; /* 156C */ XmlDocument m_petTalkTable; diff --git a/Source/Contents/MonsterSpeech.cpp b/Source/Contents/MonsterSpeech.cpp new file mode 100644 index 0000000..55924b9 --- /dev/null +++ b/Source/Contents/MonsterSpeech.cpp @@ -0,0 +1,121 @@ +#include "Client/Mode/ActiveGameMode.h" +#include "Client/Mode/CGameMode.h" +#include "Client/Session.h" + +#include +#include +#include +#include + +// STRING: st_16737 +static const char monsterSpeechFather[] = "아빠"; +// STRING: st_16738 +static const char monsterSpeechOlderBrotherHonorific[] = "형님"; +// STRING: st_16739 +static const char monsterSpeechOlderBrother[] = "오빠"; +// STRING: st_16740 +static const char monsterSpeechYoungMaster[] = "도련님"; +// STRING: st_16741 +static const char monsterSpeechBrother[] = "형씨"; +// STRING: st_16742 +static const char monsterSpeechYoungMasterTopic[] = "도련님은"; +// STRING: st_16743 +static const char monsterSpeechYoungMasterObject[] = "도련님을"; +// STRING: st_16744 +static const char monsterSpeechYoungMasterWith[] = "도련님과"; +// STRING: st_16745 +static const char monsterSpeechMother[] = "엄마"; +// STRING: st_16746 +static const char monsterSpeechOlderSisterHonorific[] = "누님"; +// STRING: st_16747 +static const char monsterSpeechOlderSister[] = "언니"; +// STRING: st_16748 +static const char monsterSpeechYoungLady[] = "아가씨"; +// STRING: st_16749 +static const char monsterSpeechYoungLadyTopic[] = "아가씨는"; +// STRING: st_16750 +static const char monsterSpeechYoungLadyObject[] = "아가씨를"; +// STRING: st_16751 +static const char monsterSpeechYoungLadyWith[] = "아가씨와"; + +// GLOBAL: gl_24523 +unsigned char monsterSpeechReplacementCount = 13; + +// GLOBAL: gl_24524 +const char* monsterSpeechReplacements[26] = { + monsterSpeechFather, + monsterSpeechOlderBrotherHonorific, + monsterSpeechOlderBrother, + monsterSpeechYoungMaster, + monsterSpeechBrother, + monsterSpeechYoungMasterTopic, + monsterSpeechYoungMasterObject, + monsterSpeechYoungMasterWith, + monsterSpeechFather, + monsterSpeechFather, + monsterSpeechFather, + monsterSpeechFather, + monsterSpeechFather, + monsterSpeechMother, + monsterSpeechOlderSisterHonorific, + monsterSpeechOlderSister, + monsterSpeechYoungLady, + monsterSpeechYoungLady, + monsterSpeechYoungLadyTopic, + monsterSpeechYoungLadyObject, + monsterSpeechYoungLadyWith, + monsterSpeechMother, + monsterSpeechMother, + monsterSpeechMother, + monsterSpeechMother, + monsterSpeechMother, +}; + +// OFFSET: 0x00E12870 +// FUNCTION: fn_23818 +void FormatMonsterSpeech(char* text, char* output, std::uint32_t aid, int feminine) { + char* source = *text == '\t' ? text + 1 : text; + std::sprintf(output, source); + + int offset = 0; + int length = 0; + char* cursor = output; + while (feminine && monsterSpeechReplacementCount) { + char* found = nullptr; + for (int index = 0; index < monsterSpeechReplacementCount; ++index) { + found = std::strstr(cursor, monsterSpeechReplacements[index]); + if (found) { + const char* replacement = monsterSpeechReplacements[monsterSpeechReplacementCount + index]; + length = static_cast(std::strlen(replacement)); + std::strcpy(found, replacement); + offset = static_cast(found - output); + std::strcat(found, source + offset + length); + cursor = found + length; + break; + } + cursor = output + offset + length; + } + if (!found) { + break; + } + } + + const std::string name = static_cast(g_world.ActiveGameMode())->nameCard.Name(aid); + const char* speaker; + if (!name.empty()) { + speaker = name.c_str(); + } else if (aid == g_session.unknown_1010) { + speaker = g_session.unknown_1018; + } else { + *output = '\0'; + return; + } + + std::sprintf(source, "%s : ", speaker); + std::strcat(source, output); + std::strcpy(output, source); + const std::size_t end = std::strlen(output) - 1; + if (output[end] == '\t') { + output[end] = '\0'; + } +} diff --git a/data/compile.json b/data/compile.json index 2b30f6f..92d69b4 100644 --- a/data/compile.json +++ b/data/compile.json @@ -379,6 +379,7 @@ "Source/Contents/Models/ModelSpatial.cpp": 3, "Source/Contents/Models/ModelTextureAnimation.cpp": 3, "Source/Contents/MonsterResources.cpp": 4, + "Source/Contents/MonsterSpeech.cpp": 4, "Source/Contents/MovementRoute.cpp": 4, "Source/Contents/MovementRouteInterpolation.cpp": 4, "Source/Contents/Movies/BinkMovie.cpp": 3,