View Single Post
  #1  
Old 10-22-2002, 01:20 AM
Xarslik
Hill Giant
 
Join Date: Oct 2002
Location: System.Web
Posts: 107
Default WesQuests.cpp Utils, Changes, Etc

Going to edit this post as I add more changes etc.

I was bored, and I noticed when using the quest functions SAY, SHOUT, EMOTE etc... NPCs name's have 0 appended to them.
This is due to the fact that EQLive only uses 2 digits for their NPC numbering (eg. a_shadow_wolf01), while EQEmu uses 3 (a_shadow_wolf001). Therefore when processed, I'm assuming the EQClient automatically removes 2 digits from the end of the name. However, because of EQEmu's 3, you're left with "a shadow wolf0 says, "Hi there, Soandso!". Anyway, I added the following code snippets to WesQuests.cpp and client.h that effectively remove any 0's through 9's and replace them with a null character.

client.h
I added this after the "char * strreplace" line, in the public section of class Client.
Code:
char * stripNumFromStr( const char* strToStrip );
WesQuests.cpp
I added this after the method "Client::strreplace".
(Originally it was editing the NPC's actual Name, which is very very bad. Changed it to store it in a static char once I found out the max length for a name)
Code:
char* Client::stripNumFromStr ( const char* strToStrip )
{
	static char tempStr[30];
	strcpy(tempStr, strToStrip);
	int a;
	for(a=0;a<strlen(strToStrip);a++)
	{
		if(tempStr[a] >= 48 && tempStr[a] <= 57)
			tempStr[a] = '\0';
	}

	return tempStr;
}
WesQuests.cpp
Now simply wrap the "this->target->GetName()" call inside a call to stripNumFromStr.

Here is SAY (modified):
Code:
entity_list.Message(0, MT_Say, "%s says, %s", [b]stripNumFromStr( this->target->GetName() )[/b], nmessage);
Here is EMOTE (modified):
Code:
entity_list.Message(0, MT_Emote, "%s %s", stripNumFromStr( this->target->GetName() ), nmessage);
Here is SHOUT (modified):
Code:
entity_list.Message(0, MT_Shout, "%s shouts, %s", stripNumFromStr( this->target->GetName() ), nmessage);
(NOTE: I noticed that including the apostrophe's surrounding what the mob is saying\shouting, causes some kind of problem with the EntityList::Message function. The message will appear with a line break before the last apostrophe. To remedy this, I removed them and in my qst file added them manually. So instead of SAY:Hail, %CHARNAME%. I'd have SAY:'Hail, %CHARNAME%.')
__________________
~ Xarslik
[ Xarslik's Arena Challenge Server ]
Reply With Quote