PDA

View Full Version : Getting rid of the 0 in npc names


Edgar1898
12-29-2002, 06:09 PM
I made a separate function that gets rid of the 0 is an npcs name when it is needed. I made added this because I didnt really like the way it was displaying the npc's name. Useful for quests and such that you dont want the name to be Priest of Discord0 says. blah blah blah.... anyways here it is:
Add the following to entity.h:
void NPCMessage(Mob* sender, bool skipsender, float dist, int32 type, const char* message, ...);

Add this to entity.cpp:
void EntityList::NPCMessage(Mob* sender, bool skipsender, float dist, int32 type, const char* message, ...) {
va_list argptr;
char buffer[4096];
char *findzero;
int stripzero;
va_start(argptr, message);
vsnprintf(buffer, 4095, message, argptr);
va_end(argptr);
findzero = strstr( buffer, "0" );
stripzero = (int)(findzero - buffer + 2);
if (stripzero > 2) //Incase its not an npc, you dont want to crash the zone
strncpy(buffer + stripzero," ",1);
float dist2 = dist * dist; //pow(dist, 2);

LinkedListIterator<Entity*> iterator(list);

cout << "Message:" << buffer << endl;
if (dist2==0) { //If 0 then send to the whole zone
iterator.Reset();
while(iterator.MoreElements())
{
if (iterator.GetData()->IsClient())
{
Client* client = iterator.GetData()->CastToClient();
client->Message(type, buffer);
}
iterator.Advance();
}
}
else {
iterator.Reset();
while(iterator.MoreElements())
{
if (iterator.GetData()->IsClient() && iterator.GetData()->CastToClient()->DistNoRoot(sender) <= dist2 && (!skipsender || iterator.GetData() != sender)) {
iterator.GetData()->CastToClient()->Message(type, buffer);
}
iterator.Advance();
}
}
}

after you do that just call this function instead of MessageClose or Message. IE in Wesquest.cpp change:

else if (strstr(command,"SAY") != NULL) {
entity_list.MessageClose(this, false, 400, 0, "%s says, '%s'", other->GetName(), nmessage);
ps = true;
}


to:

else if (strstr(command,"SAY") != NULL) {
entity_list.NPCMessage(this, false, 400, 0, "%s says, '%s'", other->GetName(), nmessage);
ps = true;
}

This will cause strip the 0 from the end of the npcs name.

Another example, change:

else if (strstr(command,"SHOUT") != NULL) {
entity_list.Message(0, 0, "%s shouts, '%s'", other->GetName(), nmessage);
ps = true;
}
to:

else if (strstr(command,"SHOUT") != NULL) {
entity_list.NPCMessage(this,false,0,13, "%s shouts, '%s'", other->GetName(), nmessage);
ps = true;
}

The 0 in this is what makes this displayed to the whole zone. (Substitute a 0 in for the distance variable to send to the zone). Hope this helps someone. :P -LethalEncounter

steve
12-29-2002, 10:16 PM
Does this revert it back to using just two digits for NPCs? Or just hide the third digit?

EQEmu is going non-standard, using 3 digits. It was stated in a previous thread that EQLive uses 3 now. However, it does not. It only uses 2 digits, even in Planes of Power.

Zafar
12-30-2002, 01:27 AM
I was in South Karana with my mage for the heck of it, putting the beat down on the gnolls and I've seen the gnolls go after my pet and seeing:

A Tesch Mas Gnoll00 says, 'I'll teach you to mess with, yada yada, Gerber00.'

I don't know why ever EQEmu uses or has 3 digits. What is the purpose other than having a bunch of mobs running around in a zone? I never in my life with EQEmuing, seen a server with more than maybe 70-95 of the same mob. Then again, I may have over lookd something somewhere.

Does this revert it back to using just two digits for NPCs? Or just hide the third digit?

EQEmu is going non-standard, using 3 digits. It was stated in a previous thread that EQLive uses 3 now. However, it does not. It only uses 2 digits, even in Planes of Power.

Edgar1898
12-30-2002, 06:04 AM
The above just hides the 0 so that it isnt displayed when an npc says something. Its still there but this just hides it from being displayed.

steve
12-30-2002, 08:21 AM
Ok, thanks! Now what we need is a patch to get rid of the redundant 0.

Zafar, yep, I'm a mage too. I can verify with 200% certainty that EQLive only uses two digits. I'm sure we could have some ex-GM/Guides back this up as well.

Just as you said, there would NOT be over 99 NPCs of the exact same named NPC in a zone. Maybe 99 white bunnies and 99 brown bunnies. But not 200 black bunnies. And it makes sense too, no one wants to see that many hundreds of the exact same mob.

Baron Sprite
12-30-2002, 10:43 AM
EQEMu supports 000.

DeletedUser
01-02-2003, 04:30 AM
Plz cry some more

Edgar1898
01-02-2003, 06:08 AM
Wahhhh :*(