Plugin: MQ2ChuckNorris V1.1

When Chuck Norris asks you, "Could you tell me what time it is," you better tell him "Time for me to die," because that's the only answer that Chuck Norris will accept.
 
Rule #1 - Chuck Norris is ALWAYS right. Rule #2 When Chuck Norris is wrong, refer to Rule #1.
 
Hms... it worked like a charm for a day or two..now i keep crashing whenever i try to do a /chuck ::confused:
 
chokehold said:
Hms... it worked like a charm for a day or two..now i keep crashing whenever i try to do a /chuck ::confused:

Only thing I could think that would cause a crash is something changed/added to the mq2chucknorris.ini. Try redownloading it.
 
Made me Laugh

Two people that were in the raid last night had Chuck Norris spouting off his sayings...

ie: Chuck Norris always knows where carmen SanDiego is...
 
humm

Fry said:
Only thing I could think that would cause a crash is something changed/added to the mq2chucknorris.ini. Try redownloading it.


Fry I am haveing the same probs, donno why, but it crashes me every time i /chuck now.

Jenn
 
Ok.. I found a bug in it that would cause the crash.. I can't test the fix, but if someone wants to let me know if this works, I'd appreciate it. Thanks!!

Code:
// MQ2ChuckNorris.cpp : Informs people about how cool Chuck Norris really is.
//   - Brought to you by MMOBugs.com
//                      
//
// Commands:
//  /chuckpower   - Makes your targeted PC (or self) swell with the power of
//                       Chuck Norris, making them 10x their normal size!
//
//  /chuckant      - Makes your target cower in fear, and shrink at the threat
//                       of being smacked down by Chuck Norris
//
//  /chuckreset    - Returns your target to normal size
//
//  /chuck /<channel>  - Picks a random fact from INI file and splits it out
//
//       Example:  /chuck /gu      - Would spout out a random chuck fact to Guild Chat
//	               /chuck /1       - Would spout out a random chuck fact to channel 1
//                 /chuck /ooc 30  - Would spout out chuck fact 30 (as listed in the INI)



#include "../MQ2Plugin.h"

PreSetup("MQ2ChuckNorris");

// Comment this out to update the offsets/opcodes/structs manually
#define UseMMOBugs True

#ifdef UseMMOBugs
#include "../MQ2MMOBugs.h"
#else
// Offset: 3-15-06
#define SizeFuncOffset  0x4F3210
#endif

class SizeClass
{
    public:
        void SizeFunc(float);
};
 
FUNCTION_AT_ADDRESS(void SizeClass::SizeFunc(float), SizeFuncOffset);


char ChuckFact[MAX_STRING][MAX_STRING];
char ChuckEcho[MAX_STRING][MAX_STRING];
int MaxFacts=0;
int MaxEcho=0;
int ChuckFactLast=0;

VOID LoadArray(VOID)
{
char szTemp[MAX_STRING];
    for (unsigned long i = 1; i < MAX_STRING; i++)
	{
	    sprintf(szTemp, "chuck%i", i);
		GetPrivateProfileString("Chuck",szTemp,NULL,ChuckFact[i],MAX_STRING,INIFileName);
	    if (strlen(ChuckFact[i]) == 0)
		{
			MaxFacts = i-1;
			sprintf(szTemp, "MQ2ChuckNorris: Found %i Chuck Norris Facts in INI file",MaxFacts);
			WriteChatColor(szTemp, CONCOLOR_GREEN);
		    if (MaxFacts <= 0)
			{
				WriteChatColor("No INI file or INI file empty!  Shutting down and unloading plugin", CONCOLOR_RED);
				DoCommand((PSPAWNINFO)pCharSpawn,"/plugin MQ2ChuckNorris unload");
			}
			return;
		}
	}
}

VOID LoadEchoArray(VOID)
{
char szTemp[MAX_STRING];
    for (unsigned long i = 1; i < MAX_STRING; i++)
	{
	    sprintf(szTemp, "echo%i", i);
		GetPrivateProfileString("Echo",szTemp,NULL,ChuckEcho[i],MAX_STRING,INIFileName);
	    if (strlen(ChuckEcho[i]) == 0)
		{
			MaxEcho = i-1;
		    if (MaxEcho <= 0)
			{
				sprintf(ChuckEcho[1], "Chuck Norris round-house kicks you in the face while saying fact");
				MaxEcho = 1;
			}
			return;
		}
	}
}


VOID ChuckStuff(PSPAWNINFO pChar, PCHAR szLine)
{

char szTemp[MAX_STRING];
char szChat[MAX_STRING];
int ChuckFactNum=0;
int ChuckEchoNum=0;
 
   GetArg(szChat,szLine,1);
   GetArg(szTemp,szLine,2);
   if ((strlen(szChat)==0) || ((szChat[0] != '/') && (szChat[0] != ';')))
   {
	   WriteChatColor("MQ2ChuckNorris: You must enter a chat channel (i.e. /gu, /shout, etc)",CONCOLOR_RED);
	   return;
   }
   ChuckFactNum = atoi(szTemp);

   if ((!ChuckFactNum) || (ChuckFactNum > MaxFacts))
   {
	   ChuckFactNum = (rand()%MaxFacts)+1;
	   if (ChuckFactNum == ChuckFactLast)
		   ChuckFactNum++;
	   if (ChuckFactNum >= (MaxFacts+1))
		   ChuckFactNum = (ChuckFactNum-(rand()%MaxFacts));
   }
   ChuckFactLast = ChuckFactNum;
   sprintf(szTemp, "%s %s", szChat, ChuckFact[ChuckFactNum]);
   DoCommand(pChar, szTemp);
   ChuckEchoNum = (rand()%MaxEcho)+1;
   sprintf(szTemp, "%s %i", ChuckEcho[ChuckEchoNum],ChuckFactNum);
   WriteChatColor(szTemp, CONCOLOR_LIGHTBLUE);
}

VOID ChuckPower(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"%s has been given the power of Chuck Norris!", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)40); 
		} 
	} 
} 

VOID ChuckAnt(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"%s has been smacked down to size by Chuck Norris!", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)1); 
		} 
	} 
} 

VOID ChuckReset(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"Chuck Norris has restored %s to normal", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)0); 
		} 
	} 
} 


PLUGIN_API VOID InitializePlugin(VOID)
{
   WriteChatColor("MQ2ChuckNorris - Brought to you by MMOBugs.com",CONCOLOR_YELLOW);
   AddCommand("/chuck", ChuckStuff);
   AddCommand("/chuckpower", ChuckPower);
   AddCommand("/chuckant", ChuckAnt);
   AddCommand("/chuckreset", ChuckReset);
   LoadArray();
   LoadEchoArray();
   srand(time(0));
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
   RemoveCommand("/chuck");
   RemoveCommand("/chuckpower");
   RemoveCommand("/chuckant");
   RemoveCommand("/chuckreset");
}
 

Attachments

  • MQ2ChuckNorris.dll
    104.1 KB · Views: 5
works no crashes. Grats on the update.

On a side note (cuz im pickly) /chuck /group doesnt work have to do /chuck /g or /chuck /gsay!
 
pepper said:
On a side note (cuz im pickly) /chuck /group doesnt work have to do /chuck /g or /chuck /gsay!

It should just use whatever channel you can use for chatting. /g, /ooc, /shout, /auct, /1, /2, /3, /t pepper, /r, ;tell pepper.saryn, etc..

I think that would be fun to start poping off random chuck facts to some random perosn on another server. :)
 
it worked for doing channels like /1 and /tell just fine. Only thing that i seen didnt work was /group. It gave the "Could not parse" message.

I didnt try /shout or /gu|guild so those might not work but probably do. Like i said i was only being picky about it and teasing you :p
 
Teasing me can be hazardous. :) I don't think /group is a valid EQ command.. (Can you type "/group test" and it sends "test" to the group?) I need to log in again some day. /g or /gsay should work, as well as /tell pepper, or /gu, etc.. Then again, I haven't tested any of 'em.. They may all break for all I know. ;)
 
I still sense there are some non-believers out there..

Chuck Norris' Facts

The Power of Chuck Norris
 
Last edited:
Chuck Norris Plugin goes through the same sayings each time you start EQ, it has a pattern. If I do /chuck /gu everytime the first one said is #42 hes the best a man can get.
 
Fry said:
Chuck Norris Plugin goes through the same sayings each time you start EQ, it has a pattern. If I do /chuck /gu everytime the first one said is #42 hes the best a man can get.

Hmmm.. That's really weird.. That tells me that random isn't really random. Let me look at the routine and see if I can randomize the randomizing. :)
 
Here's an update using the internal clock to seed the random number generator.. This should make the random pick really 'random'. :)

Code:
// MQ2ChuckNorris.cpp : Informs people about how cool Chuck Norris really is.
//   - Brought to you by MMOBugs.com
//                      
//
// Commands:
//  /chuckpower <size> - Makes your targeted PC (or self) swell with the power of
//                       Chuck Norris, making them twice their normal size!
//                       Use /chuckpower 0 to return to normal.
//
//  /chuck /<channel>  - Picks a random fact from INI file and splits it out
//
//       Example:  /chuck /gu      - Would spout out a random chuck fact to Guild Chat
//	               /chuck /1       - Would spout out a random chuck fact to channel 1
//                 /chuck /ooc 30  - Would spout out chuck fact 30 (as listed in the INI)



#include "../MQ2Plugin.h"
#include <time.h>

PreSetup("MQ2ChuckNorris");

// Define 4-19-06
#define SizeFuncOffset 0x4F3210

class SizeClass
{
    public:
        void SizeFunc(float);
};
 
FUNCTION_AT_ADDRESS(void SizeClass::SizeFunc(float), SizeFuncOffset);


char ChuckFact[MAX_STRING][MAX_STRING];
char ChuckEcho[MAX_STRING][MAX_STRING];
int MaxFacts=0;
int MaxEcho=0;

VOID LoadArray(VOID)
{
char szTemp[MAX_STRING];
    for (unsigned long i = 1; i < MAX_STRING; i++)
	{
	    sprintf(szTemp, "chuck%i", i);
		GetPrivateProfileString("Chuck",szTemp,NULL,ChuckFact[i],MAX_STRING,INIFileName);
	    if (strlen(ChuckFact[i]) == 0)
		{
			MaxFacts = i-1;
			sprintf(szTemp, "MQ2ChuckNorris: Found %i Chuck Norris Facts in INI file",MaxFacts);
			WriteChatColor(szTemp, CONCOLOR_GREEN);
		    if (MaxFacts <= 0)
			{
				WriteChatColor("No INI file or INI file empty!  Shutting down and unloading plugin", CONCOLOR_RED);
				DoCommand((PSPAWNINFO)pCharSpawn,"/plugin MQ2ChuckNorris unload");
			}
			return;
		}
	}
}

VOID LoadEchoArray(VOID)
{
char szTemp[MAX_STRING];
    for (unsigned long i = 1; i < MAX_STRING; i++)
	{
	    sprintf(szTemp, "echo%i", i);
		GetPrivateProfileString("Echo",szTemp,NULL,ChuckEcho[i],MAX_STRING,INIFileName);
	    if (strlen(ChuckEcho[i]) == 0)
		{
			MaxEcho = i-1;
		    if (MaxEcho <= 0)
			{
				sprintf(ChuckEcho[1], "Chuck Norris round-house kicks you in the face while saying fact");
				MaxEcho = 1;
			}
			return;
		}
	}
}


VOID ChuckStuff(PSPAWNINFO pChar, PCHAR szLine)
{

char szTemp[MAX_STRING];
char szChat[MAX_STRING];
int ChuckFactNum=0;
int ChuckEchoNum=0;

   srand (time(NULL)); // Initilize Random Number Generator
 
   GetArg(szChat,szLine,1);
   GetArg(szTemp,szLine,2);

   if ((strlen(szChat)==0) || ((szChat[0] != '/') && (szChat[0] != ';')))
   {
	   WriteChatColor("MQ2ChuckNorris: You must enter a chat channel (i.e. /gu, /shout, etc)",CONCOLOR_RED);
	   return;
   }
   ChuckFactNum = atoi(szTemp);

   if ((!ChuckFactNum) || (ChuckFactNum > MaxFacts))
      ChuckFactNum = (rand()%MaxFacts)+1;
   sprintf(szTemp, "%s %s", szChat, ChuckFact[ChuckFactNum]);
   DoCommand(pChar, szTemp);
   ChuckEchoNum = (rand()%MaxEcho)+1;
   sprintf(szTemp, "%s %i", ChuckEcho[ChuckEchoNum],ChuckFactNum);
   WriteChatColor(szTemp, CONCOLOR_LIGHTBLUE);
}

VOID ChuckPower(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"%s has been given the power of Chuck Norris!", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)40); 
		} 
	} 
} 

VOID ChuckAnt(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"%s has been smacked down to size by Chuck Norris!", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)1); 
		} 
	} 
} 

VOID ChuckReset(PSPAWNINFO pChar, PCHAR szLine)
{
char szTemp[MAX_STRING];
char szArg[MAX_STRING]={0}; 
GetArg(szArg,szLine,1); 

	if (ppTarget && pTarget) 
	{ 
		PSPAWNINFO Target = (PSPAWNINFO)pTarget; 
		{ 
			sprintf(szTemp,"Chuck Norris has restored %s to normal", Target->DisplayedName);
			WriteChatColor(szTemp, CONCOLOR_YELLOW);
			((SizeClass*)Target)->SizeFunc((float)0); 
		} 
	} 
} 


PLUGIN_API VOID InitializePlugin(VOID)
{
   WriteChatColor("MQ2ChuckNorris - Brought to you by MMOBugs.com",CONCOLOR_YELLOW);
   AddCommand("/chuck", ChuckStuff);
   AddCommand("/chuckpower", ChuckPower);
   AddCommand("/chuckant", ChuckAnt);
   AddCommand("/chuckreset", ChuckReset);
   LoadArray();
   LoadEchoArray();
   srand(time(0));
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
   RemoveCommand("/chuck");
   RemoveCommand("/chuckpower");
   RemoveCommand("/chuckant");
   RemoveCommand("/chuckreset");
}
 

Attachments

  • mq2chucknorris.dll
    104.1 KB · Views: 8
Shards of Dalaya..

Kinda off topic but kinda not. I just thought this was funny. From the EQEmu server Shards of Dalaya's web site..

Wiz said:
Posted: Sun Feb 19, 2006 6:10 am Post subject: List of annoying things that get you jailed

--------------------------------------------------------------------------------

This is a brief list of things that will earn you a jailing sentence or a ban from the forums if you do them/bring them up here or in the in-game global channels. Things on the list are generally jokes done to absolute death, to the point that we never ever want to hear them again. I will be updating this list as new annoying things come along.

This stuff will get you jailed
1) Chuck Norris jokes. Actually, make that mentioning Chuck Norris and any context whatsoever.
.
.
.
 
Id just like to point out, that this is the best plugin... ever!