• 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

MQ2MovementRecorder

zippzipp

Member
Joined
Nov 17, 2006
RedCents
51¢
This plugin records your movements and allows you to play them back.

Commands are as follows:

/record on <recordname>
/record off
/record delete <recordname>

/playback on <recordname>
/playback off

MQ2MovementRecorder.cpp
Rich (BB code):
///////////////////////////////////////////////////////
//  MQ2MovementRecorder.cpp  by Zippzipp             //
//  created:  20 December 2006                       //
///////////////////////////////////////////////////////


#include "../MQ2Plugin.h"
PreSetup("MQ2MovementRecorder");

int playbackflag = 0;
int recordflag = 0;
int rcount = 0;
CHAR rcountpbVal[MAX_STRING];

CHAR recordname[MAX_STRING];

VOID zRecord(PSPAWNINFO pChar, PCHAR szLine){

	CHAR command[MAX_STRING] = {0};
	CHAR rnBuffer[MAX_STRING] = {0};
	CHAR szMsg[MAX_STRING] = {0};

	GetArg(command,szLine,1);
	if(!strnicmp(command,"off",3)) {
		recordflag = 0;
		sprintf(szMsg,"%d",rcount);
		WritePrivateProfileString(recordname,"rcount",szMsg,INIFileName);
				
		rcount = 0;
		WriteChatColor("Movement Recording Complete",CONCOLOR_YELLOW);
	}else{
		if(!strnicmp(command,"on",3)){
           GetArg(recordname,szLine,2);
		   if(!strnicmp(recordname,"",1))
			   WriteChatColor("You did not specify a record name",CONCOLOR_YELLOW);
		   else{
			    GetPrivateProfileString(recordname,"r0","",rnBuffer,MAX_STRING,INIFileName);
				if(!strnicmp(rnBuffer,"",1)){
					recordflag = 1;
			        WriteChatColor("Recording On",CONCOLOR_YELLOW);
				    WritePrivateProfileString(recordname,"rcount","",INIFileName);
				}else{
					sprintf(szMsg,"Record Name: \'%s\' already exists. Delete it if you wish to overwirte it.",recordname);
					WriteChatColor(szMsg,CONCOLOR_YELLOW);
				}
		   }
		}else{
			if(!strnicmp(command,"delete",6)){
				GetArg(recordname, szLine, 2); 
		        if(!strnicmp(recordname, "", 1)) 
					WriteChatColor("You did not specify a record name",CONCOLOR_YELLOW);
				else{
					GetPrivateProfileString(recordname,"r0","",rnBuffer,MAX_STRING,INIFileName);
					if(!strnicmp(rnBuffer,"", 1)){
						sprintf(szMsg,"Record Name:\'%s\' does not exist.", recordname); 
				        WriteChatColor(szMsg,CONCOLOR_YELLOW);
					}else{
						WritePrivateProfileSection(recordname,"",INIFileName);
					    sprintf(szMsg,"Record Name: \'%s\' Successfully deleted.", recordname); 
				        WriteChatColor(szMsg,CONCOLOR_YELLOW);
					}
				}
		
			}
		}
	}
}

VOID zPlayBack(PSPAWNINFO pChar, PCHAR szLine){
	CHAR command[MAX_STRING] = {0};
	CHAR rnBuffer[MAX_STRING] = {0};
	CHAR szMsg[MAX_STRING] = {0};

	GetArg(command,szLine,1);
	if(!strnicmp(command,"off",3)) {
		recordflag = 0;
		rcount = 0;
		WriteChatColor("Playback Complete",CONCOLOR_YELLOW);
	}else{
		if(!strnicmp(command,"on",3)){
           GetArg(recordname,szLine,2);
		   if(!strnicmp(recordname,"",1))
			   WriteChatColor("You did not specify a record name",CONCOLOR_YELLOW);
		   else{
			    GetPrivateProfileString(recordname,"r0","",rnBuffer,MAX_STRING,INIFileName);
				if(!strnicmp(rnBuffer,"",1)){
					sprintf(szMsg,"Record Name: \'%s\' does not exists.",recordname);
					WriteChatColor(szMsg,CONCOLOR_YELLOW);
				}else{
					playbackflag = 1;
					GetPrivateProfileString(recordname,"rcount","",rcountpbVal,MAX_STRING,INIFileName);
			        WriteChatColor("PlayBack On",CONCOLOR_YELLOW);
				}
		   }
		}
		
	}
}


// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID){
	DebugSpewAlways("Initializing MQ2MovementRecorder");
    AddCommand("/record",zRecord);
	AddCommand("/playback",zPlayBack);
}

// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID){
	DebugSpewAlways("Shutting down MQ2MovementRecorder");
    RemoveCommand("/record");
	RemoveCommand("/playback");
}

// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID){

	CHAR szData[MAX_STRING];
    CHAR szName[MAX_STRING];
	CHAR szLoc[MAX_STRING];

	if(recordflag == 1){
		PSPAWNINFO pCharPulse = GetCharInfo()->pSpawn;
	    
		sprintf(szName,"r%d",rcount);
		sprintf(szData, "%1.2f %1.2f %1.2f %1.2f", pCharPulse->Y, pCharPulse->X, pCharPulse->Z, (float)pCharPulse->Heading);//*0.703125f); 
		WritePrivateProfileString(recordname,szName,szData,INIFileName); 
		rcount++;
	}

	if(playbackflag == 1){
		CHAR x[MAX_STRING];
		CHAR y[MAX_STRING];
		CHAR z[MAX_STRING];
		CHAR head[MAX_STRING];

		sprintf(szName,"r%d",rcount);
		GetPrivateProfileString(recordname,szName,"",szLoc,MAX_STRING,INIFileName);
		GetArg(x, szLoc, 2); 
		GetArg(y, szLoc, 1); 
		GetArg(z, szLoc, 3); 
		GetArg(head, szLoc, 4);
		
		GetCharInfo()->pSpawn->Y = (float)atof(y);
	    GetCharInfo()->pSpawn->X = (float)atof(x);
		GetCharInfo()->pSpawn->Z = (float)atof(z);
		GetCharInfo()->pSpawn->Heading = (float)atof(head);

	    DoCommand(GetCharInfo()->pSpawn,"/keypress forward hold");
		rcount++;
		if(rcount == (int)atoi(rcountpbVal)) {
			playbackflag = 0;
		    rcount = 0;
			WriteChatColor("Playback Complete",CONCOLOR_YELLOW);
			DoCommand(GetCharInfo()->pSpawn,"/keypress back");
		}

	}
	
}

Enjoy!!!

--Zippzipp
 
Will this warp you back to where you started recording when you /playback ?
 
AdvPath allows you to play the path backwards as well as forward. Removing the need to warp.
 
*wishlist 1* the ability to tell it to continue running forward to zone, or to use a door etc at the end of the path :)

*wishlist 2* the ability to list several paths to run one right after the other (excellent combo with item 1).

But great utility either way :)
 
MQ2MovementRecorder

Users who are viewing this thread

Back
Top
Cart