TeachersPet
Well-known member
- Joined
- Jul 27, 2005
- RedCents
- 71¢
TurkReno's Assist had problems so I made this one. It also does a distance check so if you're within range of doing an assist it doesn't warp you. Let me know if you have any problems.
Minor Update (10 minutes after initial post)
- There is no need to use a structure for OP_Assist, thank you to randomguy_01 for pointing that out ^_^
Minor Update (10 minutes after initial post)
- There is no need to use a structure for OP_Assist, thank you to randomguy_01 for pointing that out ^_^
Rich (BB code):
/*
MQ2WorkingAssist
By: TeachersPet
This removes distance restrictions on /assist by moving you
to 10,000 units below your target and back to your previous
location as soon as assist has fired.
I'd like to thank those who made this possible,
- Abyss for his MovePkt structure
- TurkReno for making a non-working version of this
- Whoever made the Assist structure in TurkReno's version
- The Lord Our God
- My Agent
- The Staff at Gold's Gym in West Hollywood
- Calvin Klein
- Whoever invented Astroglide
- Oh yeah, that guy Pythagorus for right triangle functions
*/
#include "../MQ2Plugin.h"
#include <math.h>
PreSetup("MQ2WorkingAssist");
// ******************** Packet Defines ********************
#ifdef PKT_UPDATE_POSITION
#undef PKT_UPDATE_POSITION
#endif
#define PKT_UPDATE_POSITION 0x178A // 06-16-06
#define OP_ASSIST 0x1C3C // 06-16-06
// Abyss's MOVEPKT structure
// (Because I'm too lazy to make one myself)
typedef struct _MOVEPKT {
unsigned short SpawnID;
unsigned short TimeStamp;
unsigned Heading:12;
unsigned Padding0004:20;
float DeltaY;
int Animation:10;
unsigned Padding0012:22;
float DeltaX;
float Y;
int DeltaHeading:10;
int Padding0024:6;
int unknown0026:2;
float DeltaZ;
float Z;
float X;
} MovePkt;
// ********************* End Defines **********************
VOID PacketMoveLoc(float Y, float X, float Z) {
MovePkt Move;
Move.SpawnID = (unsigned short)GetCharInfo()->pSpawn->SpawnID;
Move.Heading = (unsigned int)(GetCharInfo()->pSpawn->Heading * 4);
Move.Y = Y;
Move.X = X;
Move.Z = Z;
SendEQMessage(PKT_UPDATE_POSITION, &Move, sizeof(Move));
}
float oldY;
float oldX;
float oldZ;
bool WaitAssist = false;
VOID AssistTarget(PSPAWNINFO pChar, PCHAR szLine) {
char szOutput[MAX_STRING] = {0};
if(szLine[1]) {
pTarget = NULL;
Target(GetCharInfo()->pSpawn,szLine);
}
PSPAWNINFO Targ = (PSPAWNINFO)pTarget;
if(Targ) {
sprintf(szOutput,"Assisting %s",Targ->Name);
WriteChatColor(szOutput,USERCOLOR_DEFAULT);
pTarget = NULL;
// Tells OnPulse you're waiting for assist to fire
// Check if out of range of assisting
float myY = GetCharInfo()->pSpawn->Y;
float myX = GetCharInfo()->pSpawn->X;
float myZ = GetCharInfo()->pSpawn->Z;
float dist;
dist = sqrt(pow(sqrt(pow((myX - Targ->X),2) + pow((myY - Targ->Y),2)),2) + pow((myZ - Targ->Z),2));
if(dist > 200) {
// Save Old Locations
oldY = myY;
oldX = myX;
oldZ = myZ;
PacketMoveLoc(Targ->Y,Targ->X,(Targ->Z) - 25);
WaitAssist = true;
}
SendEQMessage(OP_ASSIST, &Targ->SpawnID, 4);
}
}
int WaitAssistCount = 0;
PLUGIN_API VOID OnPulse(VOID) {
if(WaitAssist) {
PSPAWNINFO Target = (PSPAWNINFO)pTarget;
if(Target) {
PacketMoveLoc(oldY,oldX,oldZ);
WaitAssist = false;
WaitAssistCount = 0;
}
WaitAssistCount++;
if(WaitAssistCount >= 1000) {
WaitAssistCount = 0;
WaitAssist = false;
}
}
}
PLUGIN_API VOID InitializePlugin(VOID) {
AddCommand("/assist",AssistTarget);
}
PLUGIN_API VOID ShutdownPlugin(VOID) {
RemoveCommand("/assist");
}
Last edited:


