PDA

View Full Version : Cleric Group Heals


Frosef
04-24-2010, 01:06 AM
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:

//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:

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.

Frosef
04-25-2010, 09:40 AM
So, small update, even though I didn't change any code I noticed the group heals were working properly on another character.

My guess is Wizard Familiars are screwing things up somehow, as my original test party is my 36 Ogre Warrior, Gnome Cleric bot, and 4 Gnome Wizards bots. (I thought it'd be a fun gimmick to run around with a crew of Wizards blowing everything up)

When I logged in my level 70 character this morning, his level 70 Cleric bot used Word of Vivification successfully. That party is myself (Erudite Magician) and my bots: Dwarf Cleric, Barbarian Warrior, Erudite Enchanter, Barbarian Shaman, Erudite Wizard. (no Familiar, my DB doesn't have data for the level 70 one so I deleted it from the Wizard bot spell list to prevent him from continuously trying to summon it)

Just to double check, I logged back in on the Wizard bot party and confirmed bot-casted group heals bug out and refuse to hit the bots still.

I'll fiddle it with some more later on and report back. Probably will try casting the bot to a client before issuing the call to the cast function, or comment out the Wizard's check to summon a pet and see if it's really the familiars blocking the spell.