I threw this together to address my cleric bot nuking til oom during fights then having no mana to heal, and my char (a wizard) getting haste buffs and such which would make me wait longer between fights.
Code:
Index: zone/mob.h
===================================================================
--- zone/mob.h (revision 187)
+++ zone/mob.h (working copy)
@@ -45,6 +45,10 @@
#define APPEAR_HEIGHT 0x001d
#define APPEAR_HP_TIC 0x0011
+#define ARCHETYPE_HYBRID 1
+#define ARCHETYPE_CASTER 2
+#define ARCHETYPE_MELEE 3
+
#define CON_GREEN 2
#define CON_LIGHTBLUE 18
#define CON_BLUE 4
@@ -655,6 +659,7 @@
// neotokyo: moved from client to use in NPC too
char GetCasterClass() const;
+ uint8 GetArchetype() const;
virtual sint32 CalcMaxMana();
inline virtual sint16 GetAC() const { return AC + itembonuses.AC + spellbonuses.AC; } // Quagmire - this is NOT the right math
Index: zone/botspellsai.cpp
===================================================================
--- zone/botspellsai.cpp (revision 187)
+++ zone/botspellsai.cpp (working copy)
@@ -253,6 +253,29 @@
continue;
}
+ switch(tar->GetArchetype())
+ {
+ case ARCHETYPE_CASTER:
+ //TODO: probably more caster specific spell effects in here
+ if(IsEffectInSpell(selectedBotSpell.SpellId, SE_AttackSpeed) || IsEffectInSpell(selectedBotSpell.SpellId, SE_ATK) ||
+ IsEffectInSpell(selectedBotSpell.SpellId, SE_STR) || IsEffectInSpell(selectedBotSpell.SpellId, SE_ReverseDS))
+ {
+ continue;
+ }
+ break;
+ case ARCHETYPE_MELEE:
+ //TODO: Include mana regen (breeze/clarity/etc), I don't know what spell effect it is
+ if(IsEffectInSpell(selectedBotSpell.SpellId, SE_IncreaseSpellHaste))
+ {
+ continue;
+ }
+ break;
+ case ARCHETYPE_HYBRID:
+ //Hybrids get all buffs
+ default:
+ break;
+ }
+
if(CheckSpellRecastTimers(this, itr->SpellIndex))
{
@@ -297,6 +320,12 @@
checked_los = true;
}
+ if(botClass == CLERIC && this->GetManaRatio() <= 50.0f)
+ {
+ //If we're at 50% mana or below, don't nuke as a cleric
+ break;
+ }
+
if(botClass == MAGICIAN || botClass == SHADOWKNIGHT || botClass == NECROMANCER || botClass == PALADIN || botClass == RANGER || botClass == DRUID || botClass == CLERIC) {
if(tar->GetBodyType() == BT_Undead || tar->GetBodyType() == BT_SummonedUndead || tar->GetBodyType() == BT_Vampire)
botSpell = GetBestBotSpellForNukeByTargetType(this, ST_Undead);
Index: zone/mob.cpp
===================================================================
--- zone/mob.cpp (revision 187)
+++ zone/mob.cpp (working copy)
@@ -663,6 +663,53 @@
}
}
+uint8 Mob::GetArchetype() const {
+ switch(class_)
+ {
+ case PALADIN:
+ case RANGER:
+ case SHADOWKNIGHT:
+ case BARD:
+ case BEASTLORD:
+ case PALADINGM:
+ case RANGERGM:
+ case SHADOWKNIGHTGM:
+ case BARDGM:
+ case BEASTLORDGM:
+ return ARCHETYPE_HYBRID;
+ break;
+ case CLERIC:
+ case DRUID:
+ case SHAMAN:
+ case NECROMANCER:
+ case WIZARD:
+ case MAGICIAN:
+ case ENCHANTER:
+ case CLERICGM:
+ case DRUIDGM:
+ case SHAMANGM:
+ case NECROMANCERGM:
+ case WIZARDGM:
+ case MAGICIANGM:
+ case ENCHANTERGM:
+ return ARCHETYPE_CASTER;
+ break;
+ case WARRIOR:
+ case MONK:
+ case ROGUE:
+ case BERSERKER:
+ case WARRIORGM:
+ case MONKGM:
+ case ROGUEGM:
+ case BERSERKERGM:
+ return ARCHETYPE_MELEE;
+ break;
+ default:
+ return ARCHETYPE_HYBRID;
+ break;
+ }
+}
+
void Mob::CreateSpawnPacket(EQApplicationPacket* app, Mob* ForWho) {
app->SetOpcode(OP_NewSpawn);
app->size = sizeof(NewSpawn_Struct);
This diff is against r1886, with some small modifications (I don't think any affect this diff, but correct me if you find otherwise).
It makes clerics stop nuking if they are at 50% mana or below. It also adds Mob::GetArchetype() which returns ARCHETYPE_MELEE, ARCHETYPE_CASTER, or ARCHETYPE_HYBRID. Bots will check against a list of spell effects before buffing the target to avoid giving unneeded buffs (eg clarity to a melee, or haste to a caster) to the char.
Right now I only implemented SE_AttackSpeed, SE_Atk, SE_STR, and SE_ReverseDS for casters, and SE_IncreaseSpellHaste for melees. Hybrids get all buffs.
I am hoping someone who knows more about the different spell effects could fill in the other buffs.
Possible future improvements: make the cleric sit and med if it's safe instead of just standing there when they're below 50% mana.