Decompile fn_23815 (CSession::GetPetTalkText)
Batch #1885 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_23815 CSession::GetPetTalkText: logic confirmed by peer review Reviewed-by: ragnarok-clanker
This commit is contained in:
parent
260999b6d1
commit
ec71daa13b
2 changed files with 68 additions and 0 deletions
|
|
@ -233,6 +233,7 @@ public:
|
|||
const char* GetPetString(int id);
|
||||
const char* GetPetTalkName(int job);
|
||||
const char* GetPetTalkActionName(int action);
|
||||
void GetPetTalkText(int job, int hungerState, int action, char* text);
|
||||
const char* GetMonsterTalkEventName(int event);
|
||||
bool UpdateHomunSkill(const CSkillInfo& value, unsigned char notify);
|
||||
bool UpdateMercSkill(const CSkillInfo& value, unsigned char notify);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
#include "Client/Session.h"
|
||||
#include "Contents/MessageTable.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
// OFFSET: 0x00E0AD10
|
||||
// FUNCTION: fn_23805
|
||||
|
|
@ -30,3 +35,65 @@ const char* CSession::GetPetTalkActionName(int action) {
|
|||
return "normal";
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: 0x00E12470
|
||||
// FUNCTION: fn_23815
|
||||
void CSession::GetPetTalkText(int job, int hungerState, int action, char* text) {
|
||||
*text = '\0';
|
||||
char name[256];
|
||||
std::strcpy(name, "monster_talk_table");
|
||||
XmlNode* node = this->m_petTalkTable.FindChild(DecodeMessageRot(name));
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::strcpy(name, g_session.GetPetTalkName(job));
|
||||
node = node->FindChild(DecodeMessageRot(name));
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* hunger;
|
||||
switch (hungerState) {
|
||||
case 1:
|
||||
hunger = "bit_hungry";
|
||||
break;
|
||||
case 2:
|
||||
hunger = "noting";
|
||||
break;
|
||||
case 3:
|
||||
hunger = "full";
|
||||
break;
|
||||
case 4:
|
||||
hunger = "so_full";
|
||||
break;
|
||||
default:
|
||||
hunger = "hungry";
|
||||
break;
|
||||
}
|
||||
std::strcpy(name, hunger);
|
||||
node = node->FindChild(DecodeMessageRot(name));
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* actionName = g_session.GetPetTalkActionName(action);
|
||||
std::strcpy(name, actionName);
|
||||
XmlNode* entry = node->FindChild(DecodeMessageRot(name));
|
||||
if (entry == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<const char*> talks;
|
||||
do {
|
||||
talks.push_back(entry->Text().c_str());
|
||||
std::strcpy(name, actionName);
|
||||
entry = entry->FindSibling(DecodeMessageRot(name));
|
||||
} while (entry != nullptr);
|
||||
|
||||
const int count = static_cast<int>(talks.size());
|
||||
if (count != 0) {
|
||||
std::strcpy(text, talks[std::rand() % count]);
|
||||
DecodeMessageRot(text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue