• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->

Question - Is this a viable code? (1 Viewer)

Joined
Mar 26, 2011
RedCents
1,667¢
Chatbot abuse (-50 redcents)
I am messing around with code some and was wondering if this would even work?


#include "MQ2Main.h"
#include <map>
#include <vector>

#define PLUGIN_NAME "ClericAutoHealer"
#define INI_FILE "ClericAutoHealer.ini"

// Define your spell and ability IDs here
const int HEAL_SPELL_ID = 1234;
const int BUFF_SPELL_ID = 5678;
const int DISPEL_SPELL_ID = 9012;
const int AA_ABILITY_ID = 8765;
const int MIN_LEVEL = 1; // Minimum character level
const int MAX_LEVEL = 115; // Maximum character level

const int MAX_DEBUFFS = 30; // Maximum number of debuff slots

// Define your plugin settings structure
struct AutoHealerSettings {
std::vector<int> buffSpellIDs;
std::map<int, std::vector<int>> spellsByLevel;
std::map<int, std::vector<int>> aaAbilitiesByLevel;
int healThreshold;
int emergencyHealThreshold;
int buffAggroThreshold;
bool prioritizeBuffing;
bool autoRebuff;
bool dispelDebuffs;
bool useAAAbility;
int maxTargets;
};

AutoHealerSettings settings;

void ReadSettings() {
// Read settings from the INI file
// Load buffSpellIDs, spellsByLevel, aaAbilitiesByLevel, and other settings
}

void SaveSettings() {
// Save settings to the INI file
}

bool HasHarmfulDebuffs() {
return SpellDebuffCount();
}

bool ShouldBuff() {
for (const int buffID : settings.buffSpellIDs) {
if (!GetCharInfo2()->Buff[buffID].pSpell) {
return true;
}
}
return false;
}

void DispelHarmfulDebuffs() {
for (int i = 0; i < MAX_DEBUFFS; i++) {
if (GetSpellDebuff(i)) {
CastSpellByID(DISPEL_SPELL_ID);
// You can add additional logic here
}
}
}

void CastBuffSpell() {
for (const int buffID : settings.buffSpellIDs) {
if (!GetCharInfo2()->Buff[buffID].pSpell) {
CastSpellByID(buffID);
// You can add additional logic here
}
}
}

bool AutoHeal(PSPAWNINFO pChar, PCHAR szLine) {
int characterLevel = GetCharInfo2()->Level;
if (characterLevel < MIN_LEVEL || characterLevel > MAX_LEVEL) {
WriteChatf("[%s] Character level is out of range.", PLUGIN_NAME);
return false;
}

const std::vector<int>& spellsToCast = settings.spellsByLevel[characterLevel];
const std::vector<int>& aaAbilitiesToUse = settings.aaAbilitiesByLevel[characterLevel];

bool hasDebuffs = HasHarmfulDebuffs();

if (GetCharInfo2()->HPCurrent < settings.emergencyHealThreshold) {
CastSpellByID(HEAL_SPELL_ID);
}
else if (GetCharInfo2()->HPCurrent < settings.healThreshold) {
CastSpellByID(HEAL_SPELL_ID);
}
else if (settings.prioritizeBuffing && InCombat()) {
if (CheckBuffAggro()) {
CastSpellByID(BUFF_SPELL_ID);
}
}
else if (settings.useAAAbility) {
UseAAAbilityByID(AA_ABILITY_ID);
}
else if (settings.dispelDebuffs && hasDebuffs) {
DispelHarmfulDebuffs();
}
else if (ShouldBuff()) {
CastBuffSpell();
}

// Add more logic for other conditions and priorities

return false; // Returning false to allow other plugins to process this event
}

PLUGIN_API void InitializePlugin() {
ReadSettings();

// Other initialization code

AddCommand("/reloadsettings", PluginCommand);
AddMQ2Data("AutoHealer", AutoHeal);
}

PLUGIN_API void ShutdownPlugin() {
SaveSettings();

// Other shutdown code
}

bool PluginCommand(PSPAWNINFO pChar, PCHAR szLine) {
if (_stricmp(szLine, "reloadsettings") == 0) {
ReadSettings();
WriteChatf("[%s] Settings reloaded.", PLUGIN_NAME);
return true;
}
return false;
}
 
Kinda figured it would receive a harsh critique, not a fine. But yes it was an attempt to see if it could come up with a viable working code. Didnt mean to violate any rules just was wondering if the code was worth going any further with
 
Question - Is this a viable code?

Users who are viewing this thread

Back
Top