rodecomp/Source/Contents/PetTalk.cpp
ragnarok-clanker 858265cc69 Maintenance: Second pass: name remaining numeric switch case labels (identifier-only; no code change). ~3,500 more labels across 150
Batch #14936 by ragnarok-clanker: no function's compiled code changes; checked with 158 compiled unit(s), including every includer of Source/Client/Mode/GameModeEnums.h, Source/Client/Mode/ModeMessage.h, Source/Contents/Actors/ActorEnums.h, Source/Contents/Actors/PetEnums.h, Source/Contents/Combat/CombatTypes.h, Source/Contents/Configuration/ServiceEnums.h, Source/Contents/Effects/EffectPrimId.h, Source/Contents/Hotkeys/InterfaceHotkey.h, Source/Contents/Items/ItemId.h, Source/Contents/Items/ItemType.h, Source/Network/Packets/ModeResultEnums.h, Source/Network/Packets/NoticeEnums.h, Source/Network/Packets/PacketId.h, Source/UI/Window/UIEnums.h, Source/UI/Window/WindowId.h.
2026-11-08 12:37:46 +00:00

100 lines
2.2 KiB
C++

#include "Client/Session.h"
#include "Contents/Actors/PetEnums.h"
#include "Contents/MessageTable.h"
#include <cstdlib>
#include <cstring>
#include <vector>
// OFFSET: 0x00E0AD10
// FUNCTION: fn_23805
const char* CSession::GetPetTalkActionName(int action) {
switch (action) {
case PM_FEEDING:
return "feeding";
case PM_HUNTING:
return "hunting";
case PM_DANGER:
return "danger";
case PM_DEAD:
return "dead";
case PM_NORMAL:
return "stand";
case PM_CONNENCT:
return "connect";
case PM_LEVELUP:
return "levelup";
case PM_PERFORMANCE1:
return "perfor_1";
case PM_PERFORMANCE2:
return "perfor_2";
case PM_PERFORMANCE3:
return "perfor_3";
case PM_PERFORMANCE_S:
return "perfor_s";
default:
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 PET_HUNGRY:
hunger = "bit_hungry";
break;
case PET_SATISFIED:
hunger = "noting";
break;
case PET_ENOUGH:
hunger = "full";
break;
case PET_FULL:
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);
}
}