// Nokos By: Stigmatine
// Updated 2004.09.23
/*
Instructions: Leave your character in a safe spot (zone line) somwhere where he is not in the path of other mobs, cause even though you "leave" your body , your original self can be attacked still, even though you can /nokos off and will zap you too current location. But leave yourself in a safe place type /nokos on, and then roam free of aggro anywhere you wanna go no mobs will attack, you may not con any mob or attack anything whlie in nokos mode, to undo just type /nokos off, and all mobs will again like/dislike you as they normally would and you may once again attack and con. Enjoy!!.
*/
#include "../MQ2Plugin.h"
PreSetup("MQ2NoKos");
VOID SumCorpseCmd (PSPAWNINFO pChar, PCHAR szLine);
VOID SendMovementPacket (FLOAT x, FLOAT y, FLOAT z);
DWORD SpawnID;
void SetID(PSPAWNINFO pChar, PCHAR szLine)
{
if(!strcmp(szLine,"on"))
{
pTarget = NULL;
SpawnID = GetCharInfo()->pSpawn->SpawnID;
GetCharInfo()->pSpawn->SpawnID = 0;
WriteChatColor("NoKos mode is now set to ON.",CONCOLOR_GREEN);
}
if(!strcmp(szLine,"off"))
{
pTarget = NULL;
GetCharInfo()->pSpawn->SpawnID = SpawnID;
WriteChatColor("NoKos mode is now set to OFF.",CONCOLOR_RED);
}
else
{
WriteChatColor("Invalid Syntax. Usage:",COLOR_LIGHTGREY);
WriteChatColor("/nokos on",COLOR_LIGHTGREY);
WriteChatColor("/nokos off",COLOR_LIGHTGREY);
}
}
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
// Add commands
AddCommand("/nokos",SetID);
AddCommand("/sumcorpse",SumCorpseCmd);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
// Remove Commands
RemoveCommand("/nokos");
RemoveCommand("/sumcorpse");
}
VOID SumCorpseCmd(PSPAWNINFO pChar, PCHAR szLine)
{
if (!pTarget || !ppTarget) return;
PSPAWNINFO Target = (PSPAWNINFO)pTarget;
if (Target->Type != SPAWN_CORPSE) return;
SendMovementPacket(Target->X, Target->Y, Target->Z);
SendEQMessage(864, Target->Name, 152);
SendMovementPacket(pChar->X, pChar->Y, pChar->Z);
SendEQMessage(865, "", 0);
}
void SendMovementPacket(FLOAT x, FLOAT y, FLOAT z)
{
// type == 39
typedef struct _MOVEPKT {
WORD SpawnID;
FLOAT Z;
FLOAT Y;
FLOAT SpeedY;
FLOAT X;
FLOAT SpeedZ;
FLOAT SpeedX;
DWORD Turning;
} MOVEPKT, *PMOVEPKT; // 0x1E
PSPAWNINFO Me = GetCharInfo()->pSpawn;
MOVEPKT Packet;
Packet.SpawnID = (WORD)Me->SpawnID;
Packet.X = x;
Packet.Y = y;
Packet.Z = z;
Packet.SpeedX = 0;
Packet.SpeedY = 0;
Packet.SpeedZ = 0;
Packet.Turning = Me->pActorInfo->LastPacketHeadingTurning;
SendEQMessage(39, &Packet, sizeof(Packet));
}