However it apparently isn't as simple a task as I thought it would be. I'm at a bit of a loss as to why it's not working, probably due to my lack of C++ knowledge. If anyone can tell me what I'm doing wrong I'd appreciate it.
It runs through all the code without any issues, other than the final pSwitch->UseSwitch() doesn't seem to do anything...
Code: Select all
bool MQ2SwitchType::GETMETHOD()
{
#define pPtr ((PDOOR)VarPtr.Ptr)
if (!VarPtr.Ptr)
return false;
PMQ2TYPEMETHOD pMethod=MQ2SwitchType::FindMethod(Method);
if (!pMethod)
{
return false;
}
if (!pMethod)
return false;
switch (static_cast<SwitchMethods>(pMethod->ID))
{
case Toggle:
PSPAWNINFO pChar = GetCharInfo()->pSpawn;
if (pPtr)
{
if (pPtr->Name[0] != 0)
{
if (GetDistance(pChar->X, pChar->Y, pPtr->X, pPtr->Y)<20.0f)
{
EQSwitch *pSwitch = (EQSwitch *) pPtr->pSwitch;
srand(static_cast<unsigned int>(time(0)));
int randclickY = rand() % 5;
int randclickX = rand() % 5;
int randclickZ = rand() % 5;
PSWITCHCLICK pClick = new SWITCHCLICK;
if (pClick)
{
pClick->Y = pPtr->Y + randclickY;
pClick->X = pPtr->X + randclickX;
pClick->Z = pPtr->Z + randclickZ;
randclickY = rand() % 5;
randclickX = rand() % 5;
randclickZ = rand() % 5;
pClick->Y1 = pPtr->Y + randclickY;
pClick->X1 = pPtr->X + randclickX;
pClick->Z1 = pPtr->Z + randclickZ;
pSwitch->UseSwitch(GetCharInfo()->pSpawn->SpawnID, 0xFFFFFFFF, 0, DWORD(pClick));
delete pClick;
}
if (pTarget == reinterpret_cast<EQPlayer*>(pPtr))
{
pTarget = NULL;
}
return true;
}
WriteChatf("You are too far away from the door, please move closer before issuing the toggle switch command");
}
else
{
WriteChatf("No door by that ID");
}
}
break;
}
return false;
#undef pPtr
}
