Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-29-2002, 06:09 PM
Edgar1898
Senior Member
Former EQEmu Developer
Current EQ2Emu Lead Developer
 
Join Date: Dec 2002
Posts: 1,065
Default Getting rid of the 0 in npc names

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:
Code:
void	NPCMessage(Mob* sender, bool skipsender, float dist, int32 type, const char* message, ...);
Add this to entity.cpp:
Code:
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:

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

Code:
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:
Code:
	else if (strstr(command,"SHOUT") != NULL) {
			entity_list.Message(0, 0, "%s shouts, '%s'", other->GetName(), nmessage);
			ps = true;
		}
to:
Code:
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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:32 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3