MQ2Cobalt v1.0.0
Created By: Cobalt
Purpose: First plugin ever written and updated over the years. Nothing new here, but some people wanted the ability to zone to a taget in zone.
Usage: /zone <zonename/targetname> <zonetype> <zonereason> <y> <x> <z>
/warp <s/t/y> <x> <z>
/fade
/gate
It's a bit more technical to use. Reason = 0, Type = 1 for succor 0 for specified coords.
I'll updated it if anyone needs anything put into it. But there's nothing new from other plugins, cept target zoning and exposing reason/type. Enjoy.
Use at your own risk!
Created By: Cobalt
Purpose: First plugin ever written and updated over the years. Nothing new here, but some people wanted the ability to zone to a taget in zone.
Usage: /zone <zonename/targetname> <zonetype> <zonereason> <y> <x> <z>
/warp <s/t/y> <x> <z>
/fade
/gate
It's a bit more technical to use. Reason = 0, Type = 1 for succor 0 for specified coords.
I'll updated it if anyone needs anything put into it. But there's nothing new from other plugins, cept target zoning and exposing reason/type. Enjoy.
Use at your own risk!
Rich (BB code):
/***************************
FLOAT SafeYLoc;
FLOAT SafeXLoc;
FLOAT SafeZLoc;
***************************/
#include "../MQ2Plugin.h"
PreSetup("MQ2Cobalt");
#define LocalCEverQuest__DoTheZone 0x4C6D60
#undef CDisplay__MoveLocalPlayerToSafeCoords
#define CDisplay__MoveLocalPlayerToSafeCoords 0x4580D0
//0x457E10
DWORD MLPTSC = CDisplay__MoveLocalPlayerToSafeCoords;
class LocalCEverQuest;
class LocalCEverQuest
{
public:
__declspec(dllexport) char * LocalCEverQuest::DoTheZone(int,char *,int,int,float,float,float,int);
};
#ifdef LocalCEverQuest__DoTheZone
FUNCTION_AT_ADDRESS(char * LocalCEverQuest::DoTheZone(int,char *,int,int,float,float,float,int),LocalCEverQuest__DoTheZone);
#endif
LocalCEverQuest **ppLEQ;
#define pLEQ (*ppLEQ)
VOID CZone(PSPAWNINFO pChar, PCHAR szLine);
VOID CFade(PSPAWNINFO pChar, PCHAR szLine);
VOID CGate(PSPAWNINFO pChar, PCHAR szLine);
bool g_bZoneChange = false;
int g_iZoneDest = 0;
int g_iZoneDestType = 0;
int g_iZoneReason = 0;
float g_fLocY = 0;
float g_fLocX = 0;
float g_fLocZ = 0;
int g_iHeading = 0;
VOID CZone(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szBuffer[MAX_STRING] = {0};
CHAR szArg1[MAX_STRING] ={0};
CHAR szZoneDestType[MAX_STRING]={0};
CHAR szZoneReason[MAX_STRING]={0};
CHAR szLocX[MAX_STRING]={0};
CHAR szLocY[MAX_STRING]={0};
CHAR szLocZ[MAX_STRING]={0};
GetArg(szArg1,szLine,1);
GetArg(szZoneDestType,szLine,2);
GetArg(szZoneReason,szLine,3);
GetArg(szLocY,szLine,4);
GetArg(szLocX,szLine,5);
GetArg(szLocZ,szLine,6);
g_iZoneDest = GetZoneID(szArg1);
g_iZoneDestType = atoi(szZoneDestType);
g_iZoneReason = atoi(szZoneReason);
g_iHeading = (int)pChar->Heading;
g_bZoneChange = true;
g_fLocX = (float)atof(szLocX);
g_fLocY = (float)atof(szLocY);
g_fLocZ = (float)atof(szLocZ);
if (g_iZoneDest == -1)
{
PSPAWNINFO psTarget = NULL;
Target(pChar, szArg1);
if (ppTarget && pTarget)
{
psTarget = (PSPAWNINFO)pTarget;
}
if (psTarget)
{
g_fLocX = psTarget->X;
g_fLocY = psTarget->Y;
g_fLocZ = psTarget->Z;
g_iZoneDest = pChar->Zone;
if (g_iZoneDest == -1)
{
g_bZoneChange = false;
WriteChatColor("Invalid Zone or Target Name...",CONCOLOR_YELLOW);
return;
}
}
if (!psTarget)
{
g_bZoneChange = false;
WriteChatColor("Invalid Zone or Target Name...",CONCOLOR_YELLOW);
return;
}
}
}
VOID CWarp(PSPAWNINFO pChar,PCHAR szLine)
{
CHAR szBuffer[MAX_STRING] = {0};
PZONEINFO TheZone = (PZONEINFO) pZoneInfo;
FLOAT OldSafeCoords[3];
CHAR Arg1[MAX_STRING] = {0};
CHAR Arg2[MAX_STRING] = {0};
CHAR Arg3[MAX_STRING] = {0};
if (szLine[0] == 0)
{
WriteChatColor("Not a valid warp.", CONCOLOR_RED);
return;
}
GetArg(Arg1, szLine, 1, false);
GetArg(Arg2, szLine, 2, false);
GetArg(Arg3, szLine, 3, false);
OldSafeCoords[0] = TheZone->SafeYLoc;
OldSafeCoords[1] = TheZone->SafeXLoc;
OldSafeCoords[2] = TheZone->SafeZLoc;
if (!strcmpi(Arg1, "s") || !strcmpi(Arg1, "safe") || !strcmpi(Arg1, "succor"))
{
sprintf(szBuffer, "Succor Point Warp (%.0f, %.0f, %.0f).", TheZone->SafeYLoc, TheZone->SafeXLoc, TheZone->SafeZLoc);
}
else if ((!strcmpi(Arg1, "t") || !strcmpi(Arg1, "target")) && pTarget)
{
TheZone->SafeYLoc = ((PSPAWNINFO)pTarget)->Y;
TheZone->SafeXLoc = ((PSPAWNINFO)pTarget)->X;
TheZone->SafeZLoc = ((PSPAWNINFO)pTarget)->Z;
sprintf(szBuffer, "Target Warp: %s (%.0f, %.0f, %.0f).", ((PSPAWNINFO)pTarget)->Name, TheZone->SafeYLoc, TheZone->SafeXLoc, TheZone->SafeZLoc);
}
else if (*Arg1 && *Arg2 && *Arg3)
{
TheZone->SafeYLoc = (float)atof(Arg1);
TheZone->SafeXLoc = (float)atof(Arg2);
TheZone->SafeZLoc = (float)atof(Arg3);
sprintf(szBuffer, "Transporting you to the location you specified (%.0f, %.0f, %.0f).", TheZone->SafeYLoc, TheZone->SafeXLoc, TheZone->SafeZLoc);
}
WriteChatColor(szBuffer, CONCOLOR_YELLOW);
__asm {
call dword ptr [MLPTSC];
}
TheZone->SafeYLoc = OldSafeCoords[0];
TheZone->SafeXLoc = OldSafeCoords[1];
TheZone->SafeZLoc = OldSafeCoords[2];
}
VOID CGate(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szMsg[MAX_STRING] = {0};
PCHARINFO2 pChar2 = GetCharInfo2();
sprintf(szMsg,"Gating...");
WriteChatColor(szMsg,USERCOLOR_DEFAULT);
g_iZoneDest = pChar2->ZoneBoundID;
g_iZoneDestType = 0;
g_iZoneReason = 11;
g_fLocY = pChar2->ZoneBoundY;
g_fLocX = pChar2->ZoneBoundX;
g_fLocZ = pChar2->ZoneBoundZ;
g_iHeading = 0;
g_bZoneChange = true;
return;
}
VOID CFade(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szMsg[MAX_STRING] = {0};
if (pChar->Instance != 0)
{
g_iZoneDest = *((int *)(&(pChar->Instance)-1));
}
else
{
g_iZoneDest = pChar->Zone;
}
sprintf(szMsg,"Fading...");
WriteChatColor(szMsg,USERCOLOR_DEFAULT);
g_iZoneDestType = 0;
g_iZoneReason = 0;
g_fLocY = pChar->Y;
g_fLocX = pChar->X;
g_fLocZ = pChar->Z;
g_iHeading = (int)pChar->Heading;
g_bZoneChange = true;
return;
}
PLUGIN_API VOID OnPulse(VOID)
{
CHAR szBuffer[MAX_STRING] = {0};
char szJunk[100]="test";
if(g_bZoneChange)
{
g_bZoneChange=false;
sprintf(szBuffer,"Zone ID: %d Type: %d Reason: %d X: %.00f Y: %.00f Z: %.00f Heading: %d", g_iZoneDest, g_iZoneDestType, g_iZoneReason, g_fLocX, g_fLocY, g_fLocZ, g_iHeading);
WriteChatColor(szBuffer,USERCOLOR_DEFAULT);
pLEQ->DoTheZone(g_iZoneDest,szJunk,g_iZoneDestType,g_iZoneReason,g_fLocY,g_fLocX,g_fLocZ,g_iHeading);
}
return;
}
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
DebugSpewAlways("Initializing MQ2Cobalt");
ppLEQ=(LocalCEverQuest**)pinstCEverQuest;
AddCommand("/zone",CZone);
AddCommand("/gate",CGate);
AddCommand("/fade",CFade);
AddCommand("/warp",CWarp);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2Cobalt");
RemoveCommand("/zone");
RemoveCommand("/gate");
RemoveCommand("/fade");
RemoveCommand("/warp");
}


