Description: This plugin auto clicks potions when they wear off. It allows you to maintain 2 potions based on Potion belt. Feel free to modify it to be more robust i just kinda threw it together.
Commands:
for example: To keep up Potion Ability X which is in potion belt slot 1 you would type.
/seteffect 1 "Potion Ability X"
/autopotion
Here is the source code:
Commands:
Code:
/autopotion - toggles auto potion on and off
/seteffect # "Effect Name" - Sets the effect to keep up and binds it to potion belt slot #
for example: To keep up Potion Ability X which is in potion belt slot 1 you would type.
/seteffect 1 "Potion Ability X"
/autopotion
Here is the source code:
Code:
#include "../MQ2Plugin.h"
PreSetup("MQ2AutoPotion");
bool on = false;
CHAR buff1[2048] = {0};
CHAR buff2[2048] = {0};
bool casting = false;
int castTimer = 0;
VOID AutoPotion(PSPAWNINFO pChar, PCHAR szLine){
if(on == false){
WriteChatf("AutoPotion: On");
on = true;
} else {
WriteChatf("AutoPotion: Off");
on = false;
}
}
VOID SetPotion(PSPAWNINFO pChar, PCHAR szLine){
CHAR szArg1[MAX_STRING] = {0};
GetArg(szArg1, szLine, 1);
if(!strcmpi(szArg1, "1")){
GetArg(buff1, szLine, 2);
}
if(!strcmpi(szArg1,"2")){
GetArg(buff2, szLine,2);
}
}
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
DebugSpewAlways("Initializing MQ2AutoPotion");
AddCommand("/autopotion",AutoPotion);
AddCommand("/seteffect",SetPotion);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2RonPotion");
RemoveCommand("/autopotion");
RemoveCommand("/seteffect");
}
// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID)
{
bool found = false;
DWORD SID = 0;
PSPELL pSpell = NULL;
int i;
if(castTimer < GetTickCount()){
casting = false;
}
if(on == true && casting == false) {
if(strcmp(buff1,"") != 0) {
pSpell = GetSpellByName(buff1);
for(i=0;i<25;i++){
SID = GetCharInfo2()->Buff[i].SpellID;
if(pSpell->ID == SID) {
found = true;
}
SID = 0;
}
if(found == false){
DoCommand(NULL,"/potionbelt activate 1");
castTimer = GetTickCount()+30000;
casting = true;
return;
}
}
found = false;
pSpell = NULL;
if(strcmp(buff2,"")!=0) {
pSpell = GetSpellByName(buff2);
for(i=0;i<25;i++){
SID = GetCharInfo2()->Buff[i].SpellID;
if(pSpell->ID == SID) {
found = true;
}
SID = 0;
}
if(found == false){
DoCommand(NULL,"/potionbelt activate 2");
casting = true;
castTimer = GetTickCount()+30000;
return;
}
}
}
}
Attachments
Last edited: