TeachersPet
Well-known member
- Joined
- Jul 27, 2005
- RedCents
- 71¢
This is a combination of randomguy's toggling and cronic's better (easier to find the offset) function
12/18: updated offset
Since cronic's requires an offset and mine doesn't, I'll leave this here just in case there's a patch day and no one's able to find the offset for a while. Mine you have to cause the door to open before it works. (Went ahead and added /showdoors into it)
12/18: updated offset
Rich (BB code):
// MQ2Doors.cpp : Defines the entry point for the DLL application.
// MQ2Doors by cronic, uber leet toggle by randomguy_01
#include "../MQ2Plugin.h"
PreSetup("MQ2Doors");
#define EQSwitch__ChangeState 0x482F18
#ifdef EQSwitch__ChangeState
FUNCTION_AT_ADDRESS(void EQSwitch::ChangeState(unsigned char, class EQPlayer *, bool), EQSwitch__ChangeState);
#endif
bool gHidden = false;
BOOL gHideAlways = false;
bool ModDoors(float fMod)
{
if (!pSwitchMgr || gGameState != GAMESTATE_INGAME) return false;
for (unsigned int i = 0; i < ((PDOORTABLE)pSwitchMgr)->NumEntries; i++)
{
PDOOR pDoor = ((PDOORTABLE)pSwitchMgr)->pDoor;
pDoor->DefaultZ += fMod;
pDoor->Z += fMod;
((EQSwitch*)pDoor)->ChangeState(3, 0, 0);
}
return true;
}
void HideDoors()
{
if (gHidden || !ModDoors(-1000000.00f)) return;
gHidden = true;
}
void RevealDoors()
{
if (!gHidden || !ModDoors(1000000.00f)) return;
gHidden = false;
}
void DoorHelp()
{
WriteChatColor("Hide Door Help:");
WriteChatColor("/toggledoors on - Hide the doors in your current zone.");
WriteChatColor("/toggledoors off - Shows all doors and disables the always feature");
WriteChatColor("/toggledoors always - Hides all doors where ever you zone");
}
PLUGIN_API VOID ToggleDoorsCmd(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szArg[MAX_STRING] = {0};
GetArg(szArg, szLine, 1);
if (szArg[0] == 0) DoorHelp();
else if (!strcmp(szArg, "on")) {
HideDoors();
WriteChatColor("Hiding the doors");
}
else if (!strcmp(szArg, "off")) {
gHideAlways = false;
RevealDoors();
WriteChatColor("Revealing the doors");
}
else if (!strcmp(szArg, "always")) {
gHideAlways = true;
WriteChatColor("Hiding doors in all zones after you zone");
}
}
PLUGIN_API VOID OnEndZone(VOID)
{
if (gHideAlways) {
gHidden = false;
HideDoors();
}
else return;
}
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/toggledoors", ToggleDoorsCmd);
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
RemoveCommand("/toggledoors");
RevealDoors();
}
Since cronic's requires an offset and mine doesn't, I'll leave this here just in case there's a patch day and no one's able to find the offset for a while. Mine you have to cause the door to open before it works. (Went ahead and added /showdoors into it)
Rich (BB code):
// MQ2HideDoors by TeachersPet
// Syntax:
// /hidedoors and one click to remove a door until zone!
// /showdoors to bring them back!
#include "../MQ2Plugin.h"
PreSetup("MQ2HideDoors");
bool DoorsHidden = false;
VOID HideDoors(PSPAWNINFO pChar, PCHAR szLine) {
if(!DoorsHidden) {
for(unsigned long i = 0; i < ((PDOORTABLE)pSwitchMgr)->NumEntries; i++) {
((PDOORTABLE)pSwitchMgr)->pDoor->DefaultZ += 10000;
((PDOORTABLE)pSwitchMgr)->pDoor->Z += 10000;
}
}
}
VOID ShowDoors(PSPAWNINFO pChar, PCHAR szLine) {
if(DoorsHidden) {
for(unsigned long i = 0; i < ((PDOORTABLE)pSwitchMgr)->NumEntries; i++) {
((PDOORTABLE)pSwitchMgr)->pDoor->DefaultZ -= 10000;
((PDOORTABLE)pSwitchMgr)->pDoor->Z -= 10000;
}
}
}
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/hidedoors",HideDoors);
AddCOmmand("/showdoors",ShowDoors);
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
RemoveCommand("/hidedoors");
RemoveCommand("/showdoors");
}
Last edited:



