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:
The "mycommand" must be formatted like this: "/memset group" or "/multiline ; /sit ; /memset group ; /mac rezbuffs" etc.
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: