So I decided I wanted to try my hand at modifying bot behavior. I want to add in the Cleric's group heals in a moderately intelligent manner. Of course I don't know C++ well at all, so I'm sure I'm missing something obvious in my Frankensteined code.
What I have
almost works, the issue seems to be the targeting. I put in some statements to verify what ID spell the bot is casting, and on who, and those actually come back as expected. The bot says they're casting spell ID whatever (135 on my level 34 bot) on each member that is below my set threshold, (which I find odd behavior too) but the actual spell doesn't hit my bots, although it hits me and their pets. (I have the rule about bot group buffing enabled, though I can't imagine it matters for this?)
I'd appreciate it if someone could take a look at the code I added and give me a push in the right direction. This is in botaispells.cpp, inside switch (iSpellTypes) of AICastSpell at the top of the SpellType_Heal case:
Code:
//Frosef: Special Cleric check for group heals
if (botClass == CLERIC) {
Group *g = this->GetGroup();
if (g){
unsigned short int membersBelowThreshold = 0;
for(int i = 0; i < MAX_GROUP_MEMBERS; i++) {
if(g->members[i] && !g->members[i]->qglobal) {
if ((int8)g->members[i]->GetHPRatio() <= 70){
membersBelowThreshold++;
//this->Say("Member %i (%s) is below threshold\n", i, g->members[i]->GetCleanName());
//If anyone is critically wounded, let's abort the group heal to single target them up
if ((int8)g->members[i]->GetHPRatio() <= 20){
membersBelowThreshold = 0;
break;
}
}
//this->Say("Member %i (%s) is NOT below threshold\n", i, g->members[i]->GetCleanName());
}
}
if (membersBelowThreshold >= 3 && botLevel >= 30){
int healid = 0;
//We have enough wounded to use a group heal, so let's pick it now
if (botLevel >= 69)
healid = 5270;
else if (botLevel >= 64)
healid = 3471;
else if (botLevel >= 57)
healid = 1521;
else if (botLevel >= 52)
healid = 1520;
else if (botLevel >= 45)
healid = 136;
else if (botLevel >= 30)
healid = 135;
if (healid > 0){
this->Say("Trying to group heal with ID %i on %s\n", healid, tar->GetCleanName());
int32 TempDontHealMeBeforeTime = tar->DontHealMeBefore();
castedSpell = CastSpell(healid, tar->GetID(), 10, -1, -1, &TempDontHealMeBeforeTime);
if (castedSpell)
tar->SetDontHealMeBefore(Timer::GetCurrentTime() + 2000);
}
}
}
}
I'm guessing there's something wrong with this line in particular, I just don't know what:
Code:
castedSpell = CastSpell(healid, tar->GetID(), 10, -1, -1, &TempDontHealMeBeforeTime);
I basically ripped off the format from looking at how the #bot ai mez command works, since adding the group heals to the bot's spell list and coding support for that was a whole can of worms I didn't want to get into just yet. I've tried setting the second argument to this->GetID() but it changes nothing.