• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

MQ2Tswitch

Joined
Feb 24, 2005
RedCents
2,154¢
**Source Updated Should fix Crashing problems**

This plugin allows you to click doors/switches from anywhere in the zone. Removed source from BB code and attached my .cpp file.
 
Last edited:
Brilliant!

Now if only I could remember how Phazor made his replace doors with bags plugin, I could recode it and put it here.
 
If anyone else is crashing let me know and I'll work on it some more it was working for this cpu that I compiled on it as well as my other 2 cpus and I tested on my brother's laptop aswell.
 
This is the compiling error I get from VC 6.0 :

F:\Program Files\MQ2\mq2TSwitch\MQ2TSwitch.cpp(13) : warning C4005: 'PKT_UPDATE_POSITION' : macro redefinition
F:\Program Files\MQ2\mq2TSwitch\../MQ2Main/MQ2Internal.h(344) : see previous definition of 'PKT_UPDATE_POSITION'
Linking...
Creating library ../Release/mq2TSwitch.lib and object ../Release/mq2TSwitch.exp

mq2TSwitch.dll - 0 error(s), 1 warning(s)

Will try it in game now on one of my trial accounts.
 
Either delete out the #define PKT_UPDATE_POSITION 0 that the mq2 devs added, or about the #define in the .cpp add this
Rich (BB code):
#ifdef PKT_UPDATE_POSITION
#undef PKT_UPDATE_POSITION
#endif

I'll put that in the .cpp and update zip later today.
 
Here is a compiled MQ2switch all I did was take out the movement packet sending, so for
this one you have to be in range of the door/switch. Made the command for this one /switchopen instead of /tswitch incase you want to use both at the sametime. This gives
you the option of when you want to send movement packet or not. Works great for clicking the FH rock, DoN Instance zoneins/zoneouts, etc..
 
I changed the source some, anybody want to compile it and test it for me a bit? It should work just the same as before minus crash issues, but im going to bed I'll mess with it tomorrow.


Rich (BB code):
/* A Tone Plugin :p
Odessa assisted in a crash fix.
Usage: /switch door#
Basically this plugin allows you to open/click any switch or door in the zone
from any location in the zone. Works great for zoning into instances like the
DoN mission ports and also clickin PoK books.

I took the Movement packet from Cronic's Csum, so credit goes to him for that.
*/
#include "../MQ2Plugin.h"
#ifdef PKT_UPDATE_POSITION
#undef PKT_UPDATE_POSITION
#endif


#define OP_ClickSwitch		 0x43B
#define PKT_UPDATE_POSITION  0x14CB
#pragma warning(disable:4273) // inconsistent dll linkage warning

PreSetup("MQ2switch");

VOID ClickSwitchCmd(PSPAWNINFO pChar, PCHAR szLine)
{
	CHAR szSwitch[MAX_STRING] = {0};
	CHAR szMsg[MAX_STRING] = {0};
	PCHARINFO pCharInfo;
	PCHARINFO pCharInfo;
    PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr;
    DWORD Count;
	BYTE ID=-1;
	pDoorTarget = NULL;

    GetArg(szSwitch,szLine,1);
	if ((pCharInfo = GetCharInfo())==NULL)
		return;

	if (strlen(szSwitch)==0) {
		MacroError("SwitchOpen:: Usage: /tswitch <Door #>");
		MacroError("SwitchOpen:: Use /doors to see a list of all doors/switches in zone and their respective number.");
		return;
	}

    ID = atoi(szSwitch);
	for (Count=0; Count<pDoorTable->NumEntries; Count++) {
		if (pDoorTable->pDoor[Count]->ID == ID) {
			strcpy(DoorEnviroTarget.Name, pDoorTable->pDoor[Count]->Name);
            DoorEnviroTarget.Y = pDoorTable->pDoor[Count]->Y;
            DoorEnviroTarget.X = pDoorTable->pDoor[Count]->X;
            DoorEnviroTarget.Z = pDoorTable->pDoor[Count]->Z;
            DoorEnviroTarget.Heading = pDoorTable->pDoor[Count]->Heading;
			DoorEnviroTarget.Type = SPAWN_NPC;
			DoorEnviroTarget.HPCurrent = 1;
			DoorEnviroTarget.HPMax = 1;
			DoorEnviroTarget.pActorInfo = &EnviroActor;
            pDoorTarget = pDoorTable->pDoor[Count];
            break;
         }
    }

	if (pDoorTarget==NULL) {
		sprintf(szMsg,"Couldn't find door '%s'.",szLine);
		WriteChatColor(szMsg,CONCOLOR_RED);
		return;
	}

	//setup switch packet
    struct _ClickSwitchPacket {
	DWORD SwitchID;
	DWORD unk0x4; // always 0
	DWORD unk0x8; // always -1
	DWORD SpawnID;
	} S; // 0x10


	// setup move packet
	// Cronic's Packet
	struct _MOVEPKT {
	/*0000*/ unsigned short SpawnID;
	/*0002*/ unsigned short TimeStamp;
	/*0004*/ float Y;
	/*0008*/ float DeltaZ;
	/*0012*/ float DeltaY;
	/*0016*/ float DeltaX;
	/*0020*/ int Animation:10;
	/*0020*/ int DeltaHeading:10;
	/*0020*/ int padding0020:12;
	/*0024*/ float X;
	/*0028*/ float Z;
	/*0032*/ int Heading:12;
	/*0032*/ int padding1_0032:10;
	/*0032*/ int padding2_0032:10;
	} P; // 36

	// init move packet
	ZeroMemory(&P, sizeof(P));
	P.SpawnID = (unsigned short)pChar->SpawnID;
	P.Heading = (unsigned int)(pChar->Heading * 4);

	// jump to
	P.Z = pDoorTarget->Z;
	P.Y = pDoorTarget->Y;
	P.X = pDoorTarget->X;
	SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));



PSPAWNINFO Me = GetCharInfo()->pSpawn;



	S.SwitchID = (DWORD)atoi(szSwitch);
	S.unk0x4 = (DWORD)0;
	S.unk0x8 = (DWORD)-1;
	S.SpawnID = (DWORD)Me->SpawnID;

	SendEQMessage(OP_ClickSwitch, &S, sizeof(S));

	sprintf(szMsg,"SwitchOpen:: Opened Switch/Door: %s ",szSwitch);
	WriteChatColor(szMsg,USERCOLOR_DEFAULT);

	// jump back
	P.Z = pChar->Z;
	P.Y = pChar->Y;
	P.X = pChar->X;
	SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));
}

PLUGIN_API VOID InitializePlugin(VOID)
{
	AddCommand("/switch", ClickSwitchCmd);
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
	RemoveCommand("/switch");
}
 
Last edited:
Just discovered that you need to target the door before calling /tswitch. CTD if the door is not targeted. Easy enough to consider, just caught me by surprise and thought others might appreciate advance notice.

Also, /doortarget ### appears to want the name of the door as a parameter, not the number, while /tswitch ### wants the number. Be sure to note both when you are doing your research and macro preparation.

....or I may have overlooked the obvious and will be quickly corrected :).

Regardless, I like this one. Thanks!!
 
TeachersPet said:
Brilliant!

Now if only I could remember how Phazor made his replace doors with bags plugin, I could recode it and put it here.

Hehe, would be kinda funny to replace a door with a bag =P
 
The code is incorrect since you have to have a door targeted and the number after /switch doesn't do anything. If the door is not targeted you will CTD.
Here's fixed plugin which will actually get the proper door.

Rich (BB code):
/* A Tone Plugin :p
Usage: /switch door#
Basically this plugin allows you to open/click any switch or door in the zone
from any location in the zone. Works great for zoning into instances like the
DoN mission ports and also clickin PoK books.

I took the Movement packet from Cronic's Csum, so credit goes to him for that.
*/
#include "../MQ2Plugin.h"
#ifdef PKT_UPDATE_POSITION
#undef PKT_UPDATE_POSITION
#endif


#define OP_ClickSwitch		 0x43B
#define PKT_UPDATE_POSITION  0x14CB
#pragma warning(disable:4273) // inconsistent dll linkage warning

PreSetup("MQ2switch");

VOID ClickSwitchCmd(PSPAWNINFO pChar, PCHAR szLine)
{
	CHAR szSwitch[MAX_STRING] = {0};
	CHAR szMsg[MAX_STRING] = {0};
	PCHARINFO pCharInfo;
    PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr;
    DWORD Count;
	BYTE ID=-1;
	pDoorTarget = NULL;

    GetArg(szSwitch,szLine,1);
	if ((pCharInfo = GetCharInfo())==NULL)
		return;

	if (strlen(szSwitch)==0) {
		MacroError("SwitchOpen:: Usage: /switch <Door #>");
		MacroError("SwitchOpen:: Use /doors to see a list of all doors/switches in zone and their respective number.");
		return;
	}

    ID = atoi(szSwitch);
	for (Count=0; Count<pDoorTable->NumEntries; Count++) {
		if (pDoorTable->pDoor[Count]->ID == ID) {
			strcpy(DoorEnviroTarget.Name, pDoorTable->pDoor[Count]->Name);
            DoorEnviroTarget.Y = pDoorTable->pDoor[Count]->Y;
            DoorEnviroTarget.X = pDoorTable->pDoor[Count]->X;
            DoorEnviroTarget.Z = pDoorTable->pDoor[Count]->Z;
            DoorEnviroTarget.Heading = pDoorTable->pDoor[Count]->Heading;
			DoorEnviroTarget.Type = SPAWN_NPC;
			DoorEnviroTarget.HPCurrent = 1;
			DoorEnviroTarget.HPMax = 1;
			DoorEnviroTarget.pActorInfo = &EnviroActor;
            pDoorTarget = pDoorTable->pDoor[Count];
            break;
         }
    }

	if (pDoorTarget==NULL) {
		sprintf(szMsg,"Couldn't find door '%s'.",szLine);
		WriteChatColor(szMsg,CONCOLOR_RED);
		return;
	}

	//setup switch packet
    struct _ClickSwitchPacket {
	DWORD SwitchID;
	DWORD unk0x4; // always 0
	DWORD unk0x8; // always -1
	DWORD SpawnID;
	} S; // 0x10


	// setup move packet
	// Cronic's Packet
	struct _MOVEPKT {
	/*0000*/ unsigned short SpawnID;
	/*0002*/ unsigned short TimeStamp;
	/*0004*/ float Y;
	/*0008*/ float DeltaZ;
	/*0012*/ float DeltaY;
	/*0016*/ float DeltaX;
	/*0020*/ int Animation:10;
	/*0020*/ int DeltaHeading:10;
	/*0020*/ int padding0020:12;
	/*0024*/ float X;
	/*0028*/ float Z;
	/*0032*/ int Heading:12;
	/*0032*/ int padding1_0032:10;
	/*0032*/ int padding2_0032:10;
	} P; // 36

	// init move packet
	ZeroMemory(&P, sizeof(P));
	P.SpawnID = (unsigned short)pChar->SpawnID;
	P.Heading = (unsigned int)(pChar->Heading * 4);

	// jump to
	P.Z = pDoorTarget->Z;
	P.Y = pDoorTarget->Y;
	P.X = pDoorTarget->X;
	SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));



PSPAWNINFO Me = GetCharInfo()->pSpawn;



	S.SwitchID = (DWORD)atoi(szSwitch);
	S.unk0x4 = (DWORD)0;
	S.unk0x8 = (DWORD)-1;
	S.SpawnID = (DWORD)Me->SpawnID;

	SendEQMessage(OP_ClickSwitch, &S, sizeof(S));

	sprintf(szMsg,"SwitchOpen:: Opened Switch/Door: %s ",szSwitch);
	WriteChatColor(szMsg,USERCOLOR_DEFAULT);

	// jump back
	P.Z = pChar->Z;
	P.Y = pChar->Y;
	P.X = pChar->X;
	SendEQMessage(PKT_UPDATE_POSITION, &P, sizeof(P));
}

PLUGIN_API VOID InitializePlugin(VOID)
{
	AddCommand("/switch", ClickSwitchCmd);
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
	RemoveCommand("/switch");
}
 
Last edited:
Seksi :P Thanks for the correction I've been busy, and I can tell you havin fun with packets :P
 
this is still incorrect :)
logic seems perfectly fine but it doesn't work one some spawns, it does not send a proper movement packet and you get can't reach target.
I am trying to figure out why that is.
 
That's what originally happened when I made it that's why I made it so you had to target I think I dunno this plugin is older. Hopefully we can get it working so you can just do /switch # without working about /doort and stuff.
 
/bump

Any luck on a fix for the latest patch? I'd look at it myself but I'm lazy :/
 
I wasn't clear, I meant for the new mq2 zip where you no longer actually get a door on your target (though it's still handled by mq2 in some way). I suppose I'll probably just roll back to the previous mq2 version of the door target code, but I haven't looked at it close enough to see if there's a simple change to the plugin that would make it work.
 
cbsro said:
I wasn't clear, I meant for the new mq2 zip where you no longer actually get a door on your target (though it's still handled by mq2 in some way). I suppose I'll probably just roll back to the previous mq2 version of the door target code, but I haven't looked at it close enough to see if there's a simple change to the plugin that would make it work.

no idea what you are talking about, /doors gives you door number, just do /switch door# and that's it, it works.
 
odessa said:
no idea what you are talking about, /doors gives you door number, just do /switch door# and that's it, it works.

In the most version I was using, you had to (1) /doortarget by name (or manually target), then (2) /tswitch by door number. I could not simply /tswitch by door number: the door had to be targeted first.

This behavior was reported and verified by others. The issue appeared to be left at "to be looked at" for a comprehensive solution. If a revised version was posted, I missed it as I had already coded macros to utilize the two-step process. Others appear to be in a similar position.

***
see Tone's comment on 11/11
***
 
Last edited:
I have no use for mq2pok, read the thread once when it first came up but not after that. I just assumed if you were successful in making the switch open without targetting you'd post it here or a new thread. Thanks though :)
 
cbsro said:
I have no use for mq2pok, read the thread once when it first came up but not after that. I just assumed if you were successful in making the switch open without targetting you'd post it here or a new thread. Thanks though :)

mq2pok has an incorrect thread title and I can't edit it.
there's no mq2pok, there's only mq2switch :)
 
Yes I see that now lol. Only explaining why I didn't keep up with that thread.
 
MQ2Tswitch

Users who are viewing this thread

Back
Top
Cart