Plugin: MQ2Rez

thez

Rhymes well with Pez
Joined
Oct 25, 2006
Messages
966
Reaction score
0
Points
0
Location
Santa Cruz
So...after looking at MQ2Autorez, I decided to take it upon myself to finish what dewey had started and make the next step to have it autoloot as well as take the rez.

Commands:
Code:
/rez               -> displays settings
/rez accept on|off -> Toggle auto-accepting rezbox
/rez spawn  on|off -> Toggles going to bind point after death
/rez pct # -> Autoaccepts rezes only if they are higher than # percent
/rez loot on|off -> Toggle looting corpse when opened and when rezzed
/rez command on|off -> Toggle use of a command after looting out corpse
/rez setcommand "mycommand" -> Set the command that you want. 
/rez help

The "mycommand" must be formatted like this: "/memset group" or "/multiline ; /sit ; /memset group ; /mac rezbuffs" etc.

Code:
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
// Project: MQ2Rez.cpp
// Author: TheZ, made from an amalgamation of dewey and s0rcier's code
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

#include "../MQ2Plugin.h"
PreSetup("MQ2Rez");
#include <map>

long       SetBOOL(long Cur, PCHAR Val, PCHAR Sec="", PCHAR Key="");
long       SetLONG(long Cur, PCHAR Val, PCHAR Sec="", PCHAR Key="", bool ZeroIsOff=false);
void       WinClick(CXWnd *Wnd, PCHAR ScreenID, PCHAR ClickNotification, DWORD KeyState=0);
int        AutoRezPct     = 0;        // Take Rez %
int        ClickWait      = 0;
int        LootWait       = 0;
DWORD      Initialized    = false;             // Plugin Initialized?
long       LootMeHandle   = false;    // LootMe Handle?
long       AutoRezAccept  = false;    // Take Rez box?
long       AutoRezSpawn   = false;    // Let respawn window time out or port to bind.
long       RezDone        = false;
long       RezClicked     = false;
long       RezCommandOn   = false;
char       szCommand[MAX_STRING];

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

void WinClick(CXWnd *Wnd, PCHAR ScreenID, PCHAR ClickNotification, DWORD KeyState) {
  if(Wnd) if(CXWnd *Child=Wnd->GetChildItem(ScreenID)) {
    BOOL KeyboardFlags[4];
    *(DWORD*)&KeyboardFlags=*(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags;
    *(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=KeyState;
    SendWndClick2(Child,ClickNotification);
    *(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=*(DWORD*)&KeyboardFlags;
  }
}

long SetLONG(long Cur,PCHAR Val, PCHAR Sec, PCHAR Key, bool ZeroIsOff,long Maxi) {
  char ToStr[16]; char Buffer[128]; long Result=atol(Val);
  if(Result && Result>Maxi) Result=Maxi; itoa(Result,ToStr,10);
  if(Sec[0] && Key[0]) WritePrivateProfileString(Sec,Key,ToStr,INIFileName);
  sprintf(Buffer,"%s::%s (\ag%s\ax)",Sec,Key,(ZeroIsOff && !Result)?"\aroff":ToStr);
  WriteChatColor(Buffer);
  return Result;
}

long SetBOOL(long Cur, PCHAR Val, PCHAR Sec, PCHAR Key) {
  char buffer[128]; long result=0;
  if(!strnicmp(Val,"false",5) || !strnicmp(Val,"off",3) || !strnicmp(Val,"0",1))    result=0;
  else if(!strnicmp(Val,"true",4) || !strnicmp(Val,"on",2) || !strnicmp(Val,"1",1)) result=1;
  else result=(!Cur)&1;
  if(Sec[0] && Key[0]) WritePrivateProfileString(Sec,Key,result?"1":"0",INIFileName);
  sprintf(buffer,"%s::%s (%s)",Sec,Key,result?"\agon\ax":"\agoff\ax");
  WriteChatColor(buffer);
  return result;
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

BOOL IsWindowOpen(PCHAR WindowName){
   PCSIDLWND pWnd=(PCSIDLWND)FindMQ2Window(WindowName);
   if (!pWnd) return false;
   return (BOOL)pWnd->Show;
}

int ExpRezBox() {
   CXWnd *Child;
   CXWnd *pWnd;
   char InputCXStr[128],*p,CasterName[32];
   int v, i;

   pWnd=(CXWnd *)FindMQ2Window("ConfirmationDialogBox");
   if(pWnd) {
      if (((PCSIDLWND)(pWnd))->Show==0) return -1;
      Child=pWnd->GetChildItem("cd_textoutput");
      if(Child) {
         ZeroMemory(InputCXStr,sizeof(InputCXStr));
         GetCXStr(Child->SidlText,InputCXStr,sizeof(InputCXStr));
         p = strstr(InputCXStr,"attempting to return you");
		 if (p) {
			 for (i=0; i <= sizeof(InputCXStr); i++ ) {
				 if (InputCXStr[i] == ' ') break;
				 CasterName[i] = InputCXStr[i];
			 }
			 WriteChatf("Accepting Rez from %s", CasterName);
			 return 0;
		 }
         p = strstr(InputCXStr,"(");
         if (!p) return -1;
         v = atoi(p+1);
         p = strstr(p,"percent");
         if (!p) return -1;
		 for (i=0; i <= sizeof(InputCXStr); i++ ) {
			if (InputCXStr[i] == ' ') break;
			CasterName[i] = InputCXStr[i];
		 }
		 WriteChatf("Accepting Rez from %s", CasterName);
         return v;
      }
   }
   return -1;
}
void AutoRezCommand(PSPAWNINFO pCHAR, PCHAR zLine) {
   bool ShowInfo=false;
   bool NeedHelp=false;
  char Parm1[MAX_STRING];
  char Parm2[MAX_STRING];
  GetArg(Parm1,zLine,1);
  GetArg(Parm2,zLine,2);

  if(!stricmp("help",Parm1)) NeedHelp=true;
//Accept rez?
  else if(!stricmp("accept",Parm1) && (!stricmp("on",Parm2)))
     AutoRezAccept=SetBOOL(AutoRezAccept ,Parm2 ,"MQ2Rez","Accept");
  else if(!stricmp("accept",Parm1) && (!stricmp("off",Parm2)))
     AutoRezAccept=SetBOOL(AutoRezAccept ,Parm2,"MQ2Rez","Accept");
//What percent?
  else if(!stricmp("pct",Parm1)) {
     WritePrivateProfileString("MQ2Rez","RezPct",Parm2,INIFileName);
     AutoRezPct=atoi(Parm2);
  }
//Should I spawn first?
  else if(!stricmp("spawn",Parm1) && (!stricmp("on",Parm2)))
     AutoRezSpawn=SetBOOL(AutoRezSpawn ,Parm2 ,"MQ2Rez","Spawn");
  else if(!stricmp("spawn",Parm1) && (!stricmp("off",Parm2)))
     AutoRezSpawn=SetBOOL(AutoRezSpawn ,Parm2,"MQ2Rez","Spawn");
//Should I loot my corpse?
  else if(!stricmp("loot",Parm1) && (!stricmp("on",Parm2)))
        LootMeHandle=SetBOOL(LootMeHandle ,Parm2 ,"MQ2Rez","Active");
  else if(!stricmp("loot",Parm1) && !stricmp("off",Parm2))
        LootMeHandle=SetBOOL(LootMeHandle ,Parm2,"MQ2Rez","Active");
//Do I want a command executed after being rezed?
  else if(!stricmp("command",Parm1) && !stricmp("on",Parm2))
        RezCommandOn=SetBOOL(RezCommandOn ,Parm2,"MQ2Rez","RezCommandOn");
  else if(!stricmp("command",Parm1) && !stricmp("off",Parm2))
        RezCommandOn=SetBOOL(RezCommandOn ,Parm2,"MQ2Rez","RezCommandOn");
//What command should I execute?
 else if(!stricmp("setcommand",Parm1)) {
      WritePrivateProfileString("MQ2Rez","Command Line",Parm2,INIFileName);
      WriteChatf("Command set to: \ag%s\ax",Parm2);
  }
//Help??
  else if(!stricmp("",Parm1))
  {
     ShowInfo=TRUE;
     NeedHelp=TRUE;
  }
  if(NeedHelp) {
   WriteChatColor("Usage:");
   WriteChatColor("/rez -> displays settings");
   WriteChatColor("/rez accept on|off -> Toggle auto-accepting rezbox");
   WriteChatColor("/rez spawn  on|off -> Toggles going to bind point after death");
   WriteChatColor("/rez pct # -> Autoaccepts rezes only if they are higher than # percent");
   WriteChatColor("/rez loot on|off -> Toggle looting corpse when opened and when rezzed");
   WriteChatColor("/rez command on|off -> Toggle use of a command after looting out corpse");
   WriteChatColor("/rez setcommand mycommand -> Set the command that you want.");
   WriteChatColor("/rez help");
  }
  if (ShowInfo)
  {
     WriteChatf("MQ2Rez Accept(\ag%s\ax).",(AutoRezAccept?"on":"off"));
     WriteChatf("MQ2Rez Spawn(\ag%s\ax).",(AutoRezSpawn?"on":"off"));
     WriteChatf("MQ2Rez Loot(\ag%s\ax).",(LootMeHandle?"on":"off"));
     WriteChatf("MQ2Rez AcceptPct(\ag%d\ax).",AutoRezPct);
     WriteChatf("MQ2Rez Command(\ag%s\ax).",(RezCommandOn?"on":"off"));
     WriteChatf("Command line set to: \ag%s\ax",szCommand);
  }
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

PLUGIN_API VOID SetGameState(DWORD GameState) {
  if(GameState==GAMESTATE_INGAME && !Initialized) {
      Initialized=true;
      sprintf(INIFileName,"%s\\%s_%s.ini",gszINIPath,EQADDR_SERVERNAME,GetCharInfo()->Name);
      LootMeHandle =GetPrivateProfileInt("MQ2Rez","Active" ,0,INIFileName);
      AutoRezAccept=GetPrivateProfileInt("MQ2Rez","Accept" ,0,INIFileName);
      AutoRezSpawn =GetPrivateProfileInt("MQ2Rez","Spawn"  ,0,INIFileName);
      AutoRezPct   =GetPrivateProfileInt("MQ2Rez","RezPct" ,0,INIFileName);
      RezCommandOn =GetPrivateProfileInt("MQ2Rez","RezCommandOn" ,0,INIFileName);
      GetPrivateProfileString("MQ2Rez","Command Line","DISABLED",szCommand,MAX_STRING,INIFileName);
      if(!strcmp(szCommand,"DISABLED")) RezCommandOn = false;
  } else if(GameState!=GAMESTATE_LOGGINGIN && Initialized) {
      LootMeHandle=0;
      Initialized=0;
  }
}

PLUGIN_API VOID InitializePlugin() {
  AddCommand("/rez",AutoRezCommand);
}

PLUGIN_API VOID ShutdownPlugin() {
  RemoveCommand("/rez");
}

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//

PLUGIN_API VOID OnPulse() {
    if (AutoRezSpawn && IsWindowOpen("RespawnWnd")) {
        WinClick(FindMQ2Window("RespawnWnd"),"RW_SelectButton","leftmouseup",1);
        return;
    }
    if (AutoRezAccept && ExpRezBox()>=AutoRezPct){
        WriteChatColor("Accepting Rez now");
        DoCommand(GetCharInfo()->pSpawn,"/notify ConfirmationDialogBox Yes_Button leftmouseup");
        RezClicked = true;
    }
    if (RezClicked && ClickWait>35) {
        DoCommand(GetCharInfo()->pSpawn,"/squelch /notify RespawnWnd RW_OptionsList listselect 2");
        DoCommand(GetCharInfo()->pSpawn,"/squelch /notify RespawnWnd RW_SelectButton leftmouseup");
        ClickWait=0;
        RezClicked=false;
        RezDone = true;
        return;
    } else if(RezClicked) {
        ClickWait++;
        return;
    }

    if (RezDone && LootWait>35) {
        DoCommand(GetCharInfo()->pSpawn,"/target mycorpse");
        DoCommand(GetCharInfo()->pSpawn,"/corpse");
        if(LootMeHandle)DoCommand(GetCharInfo()->pSpawn,"/lootall");
        LootWait=0;
        RezDone=false;
        if(RezCommandOn)HideDoCommand(GetCharInfo()->pSpawn, szCommand, FromPlugin);
        return;
    } else if(RezDone) {
        LootWait++;
        return;
    }
}
 
Last edited:
rezme Q

there was a rezme mac running arround the other day I tried to use it but, didn't have soemthing right does this do the same thing? If not, How is the best way to get the rezme mac to work?
 
This should do the /rezzme stuff perfectly...but if you have the alias done according to my post there, then it might not work correctly. Try going into your macroquest.ini and deleting the alias.

Made a bunch of changes to the plugin, as well. Everything should be working right.

Changes:
-Condensed all of the rez stuff into the "/rez" command with options as listed above.
-Added in the requested change to have a minimum rez level

DLL has been updated as well. Please let me know if you have any problems.
 
what plugins do i need to run cause i can't get these to run. i tried /plugin mq2rez , plugin mq2 rezzme, i tried /mac rez, /rez /mac rezzme. what am i doing wrong?
 
Download the DLL into your MacroQuest2 folder, do "/plugin mq2rez", then the command "/rez help" should work.

Fry.
 
maybe it is just me but, i can't get the plugin to upload
 
Had a small error with the looting because of a line...fixed in the source and the DLL.
 
--Update...added /rez silent to remove the spam while looting items off of a corpse. This keeps only the Accepting, Opening, and Closing messages.
 
I need some people to test out a new version of this code that includes a feature which allows you to set a command to be executed once your corpse has been looted. Please send me a PM if you are able.
 
commands don't work, /rez just does nothing, tried /rez help, /rez accept on, ect. Loads ok
 
BUMP...new version posted that allows you to define a command or series of commands to be executed after you have looted your corpse. Using the /rezzme command will now cause the plugin to loot your corpse like a regular rez if looting is enabled.

Enjoy!

The format for the new command is as follows:
Code:
/rez command on|off -> Toggle use of a command after looting out corpse

/rez setcommand "mycommand" -> Set the command that you want.

The "mycommand" must be formatted like this: "/memset group" or "/multiline ; /sit ; /memset group ; /mac rezbuffs" etc. If you can't get that to work, the command can be manually set in the INI file, too.
 
Small update to the code. The "/rez" command which shows you the commands / settings will now show you your OnRez command, when you change the command it should echo, and I changed the way the command is done a small bit, which might help some people that have been having problems.
 
just want to confirm before I try this later, the /rezzme command will pop you right back up and loot corpse, without exp, but will still allow for an exp rez afterwards, correct?
 
Yes. When you loot out a corpse that hasn't has a rez, it won't fade until the rez timer is up.