mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[NPC] Support for multiple emotes per type, emote variables (#3801)
* [forage rule feature] add a rule to disabled using common_food_ids from the list in forage.cpp. currently set to enabled. * NPC database emotes now supports basic variables. More than one variable can be used at a time. * Format manifest * Formatting * Formatting * Formatting --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+54
-24
@@ -3046,42 +3046,72 @@ void NPC::SendPayload(int payload_id, std::string payload_value)
|
||||
}
|
||||
|
||||
NPC_Emote_Struct* NPC::GetNPCEmote(uint32 emoteid, uint8 event_) {
|
||||
LinkedListIterator<NPC_Emote_Struct*> iterator(zone->NPCEmoteList);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
NPC_Emote_Struct* nes = iterator.GetData();
|
||||
std::vector<NPC_Emote_Struct *> emotes;
|
||||
for (auto &e: zone->npc_emote_list) {
|
||||
NPC_Emote_Struct *nes = e;
|
||||
if (emoteid == nes->emoteid && event_ == nes->event_) {
|
||||
return nes;
|
||||
emotes.push_back(e);
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
if (emotes.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
else if (emotes.size() == 1) {
|
||||
return emotes[0];
|
||||
}
|
||||
|
||||
int index = zone->random.Roll0(emotes.size());
|
||||
|
||||
return emotes[index];
|
||||
}
|
||||
|
||||
void NPC::DoNPCEmote(uint8 event_, uint32 emoteid)
|
||||
void NPC::DoNPCEmote(uint8 event_, uint32 emoteid, Mob* target)
|
||||
{
|
||||
if (emoteid == 0)
|
||||
{
|
||||
if (emoteid == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NPC_Emote_Struct* nes = GetNPCEmote(emoteid,event_);
|
||||
if(nes == nullptr)
|
||||
{
|
||||
NPC_Emote_Struct *nes = GetNPCEmote(emoteid, event_);
|
||||
if (nes == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(emoteid == nes->emoteid)
|
||||
{
|
||||
if(nes->type == 1)
|
||||
Emote("%s",nes->text);
|
||||
else if(nes->type == 2)
|
||||
Shout("%s",nes->text);
|
||||
else if(nes->type == 3)
|
||||
entity_list.MessageCloseString(this, true, 200, 10, GENERIC_STRING, nes->text);
|
||||
else
|
||||
Say("%s",nes->text);
|
||||
std::string processed = nes->text;
|
||||
Strings::FindReplace(processed, "$mname", GetCleanName());
|
||||
Strings::FindReplace(processed, "$mracep", GetRacePlural() = GetClass());
|
||||
Strings::FindReplace(processed, "$mrace", GetPlayerRaceName(GetRace()));
|
||||
Strings::FindReplace(processed, "$mclass", GetClassIDName(GetClass()));
|
||||
if (target) {
|
||||
Strings::FindReplace(processed, "$name", target->GetCleanName());
|
||||
Strings::FindReplace(processed, "$racep", GetRacePlural() = target->GetClass());
|
||||
Strings::FindReplace(processed, "$race", GetPlayerRaceName(target->GetRace()));
|
||||
Strings::FindReplace(processed, "$class", GetClassIDName(target->GetClass()));
|
||||
}
|
||||
else {
|
||||
Strings::FindReplace(processed, "$name", "foe");
|
||||
Strings::FindReplace(processed, "$race", "race");
|
||||
Strings::FindReplace(processed, "$racep", "races");
|
||||
Strings::FindReplace(processed, "$class", "class");
|
||||
}
|
||||
|
||||
if (emoteid == nes->emoteid) {
|
||||
if (event_ == EQ::constants::EmoteEventTypes::Hailed && target) {
|
||||
DoQuestPause(target);
|
||||
}
|
||||
|
||||
if (nes->type == 1) {
|
||||
Emote("%s", processed.c_str());
|
||||
}
|
||||
else if (nes->type == 2) {
|
||||
Shout("%s", processed.c_str());
|
||||
}
|
||||
else if (nes->type == 3) {
|
||||
entity_list.MessageCloseString(this, true, 200, 10, GENERIC_STRING, processed.c_str());
|
||||
}
|
||||
else {
|
||||
Say("%s", processed.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user