// MQ2BuffBlock.cpp : Defines the entry point for the DLL application.
//
// PLUGIN_API is only to be used for callbacks. All existing callbacks at this time
// are shown below. Remove the ones your plugin does not use. Always use Initialize
// and Shutdown for setup and cleanup, do NOT do it in DllMain.
#include "../MQ2Plugin.h"
#define pCharInfo GetCharInfo()
int pulse = 0;
VOID BuffBlock(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szKeyNameBuffer[MAX_STRING] = {0};
CHAR szBuffName[MAX_STRING] = {0};
CHAR szMsg[MAX_STRING] = {0};
CHAR Arg1[MAX_STRING] = {0};
GetArg(Arg1,szLine,1);
if (!(stricmp(strlwr(Arg1),"list"))){
for (int i=0;i<99;i++){
sprintf(szKeyNameBuffer,"buff%d",i+1);
GetPrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,"notfound",szBuffName,MAX_STRING,INIFileName);
if (strstr(szBuffName,"notfound")) {
break;
}
WriteChatColor(szBuffName,USERCOLOR_CHAT_CHANNEL);
}
return;
}
for (int i=0;i<99;i++) {
sprintf(szKeyNameBuffer,"buff%d",i+1);
GetPrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,"notfound",szBuffName,MAX_STRING,INIFileName);
if (strstr(szBuffName,"notfound")) {
break;
}
if (!stricmp(Arg1,szBuffName)){
sprintf(szMsg,"%s already being blocked.",szBuffName);
WriteChatColor(szMsg,USERCOLOR_CHAT_CHANNEL);
return;
}
}
WritePrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,strlwr(Arg1),INIFileName);
sprintf(szMsg,"%s is now being blocked",Arg1);
WriteChatColor(szMsg,USERCOLOR_CHAT_CHANNEL);
}
VOID BuffUnblock(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szKeyNameBuffer[MAX_STRING] = {0};
CHAR szBuffName[MAX_STRING] = {0};
CHAR szMsg[MAX_STRING] = {0};
CHAR Arg1[MAX_STRING] = {0};
GetArg(Arg1,szLine,1);
for (int i=0;i<99;i++) {
sprintf(szKeyNameBuffer,"buff%d",i+1);
GetPrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,"notfound",szBuffName,MAX_STRING,INIFileName);
if (strstr(szBuffName,"notfound")) {
break;
}
if (!stricmp(Arg1,szBuffName)) {
WritePrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,NULL,INIFileName);
sprintf(szMsg,"%s is no longer being blocked",Arg1);
WriteChatColor(szMsg,USERCOLOR_CHAT_CHANNEL);
break;
}
}
}
PreSetup("MQ2BuffBlock");
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
DebugSpewAlways("Initializing MQ2BuffBlock");
AddCommand("/block",BuffBlock);
AddCommand("/unblock",BuffUnblock);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2BuffBlock");
RemoveCommand("/block");
RemoveCommand("/unblock");
// Remove commands, macro parameters, hooks, etc.
// RemoveMQ2Benchmark(bmMyBenchmark);
// RemoveParm("$myparm(x)");
// RemoveCommand("/mycommand");
// RemoveXMLFile("MQUI_MyXMLFile.xml");
}
// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID)
{
if (!pCharInfo || gGameState!=GAMESTATE_INGAME) return;
if(pulse >= 20)
{
pulse = 0;
DWORD bf;
CHAR szKeyNameBuffer[MAX_STRING] = {0};
CHAR szBuffName[MAX_STRING] = {0};
CHAR szTemp[MAX_STRING] = {0};
for (bf = 0; bf<15; bf++)
{
if(PSPELL pSpell=GetSpellByID(GetCharInfo2()->Buff[bf].SpellID)) //if(pCharInfo->Buff[bf].SpellID != 0xFFFFFFFF)
{
for (int i=0;i<99;i++) {
sprintf(szKeyNameBuffer,"buff%d",i+1);
GetPrivateProfileString(GetCharInfo()->Name,szKeyNameBuffer,"notfound",szBuffName,MAX_STRING,INIFileName);
if (strstr(szBuffName,"notfound")) {
break;
}
if (!stricmp(szBuffName,pSpell->Name)){ //if (!stricmp(szBuffName,GetSpellNameByID(pCharInfo->Buff[bf].SpellID))){
sprintf(szTemp,"Buff%d",bf);
SendWndClick("BuffWindow",szTemp,"leftmouseup");
}
}
}
}
}
pulse = pulse++;
}