mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
Fix for bot wizard repeating familiar casting when pet is dead and buff is active
This commit is contained in:
parent
8f67df1f4f
commit
9adfe5b9ff
19
zone/bot.cpp
19
zone/bot.cpp
@ -1635,6 +1635,19 @@ bool Bot::LoadPet()
|
||||
if (!bot_owner)
|
||||
return false;
|
||||
|
||||
if (GetClass() == WIZARD) {
|
||||
auto buffs_max = GetMaxBuffSlots();
|
||||
auto my_buffs = GetBuffs();
|
||||
if (buffs_max && my_buffs) {
|
||||
for (int index = 0; index < buffs_max; ++index) {
|
||||
if (IsEffectInSpell(my_buffs[index].spellid, SE_Familiar)) {
|
||||
MakePet(my_buffs[index].spellid, spells[my_buffs[index].spellid].teleport_zone);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string error_message;
|
||||
|
||||
uint32 pet_index = 0;
|
||||
@ -1649,7 +1662,7 @@ bool Bot::LoadPet()
|
||||
if (!botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id)) {
|
||||
bot_owner->Message(13, "%s for %s's pet", BotDatabase::fail::LoadPetSpellID(), GetCleanName());
|
||||
}
|
||||
if (!saved_pet_spell_id || saved_pet_spell_id > SPDAT_RECORDS) {
|
||||
if (!IsValidSpell(saved_pet_spell_id)) {
|
||||
bot_owner->Message(13, "Invalid spell id for %s's pet", GetCleanName());
|
||||
DeletePet();
|
||||
return false;
|
||||
@ -1693,11 +1706,11 @@ bool Bot::LoadPet()
|
||||
|
||||
bool Bot::SavePet()
|
||||
{
|
||||
if (!GetPet() /*|| dead*/)
|
||||
if (!GetPet() || GetPet()->IsFamiliar() /*|| dead*/)
|
||||
return true;
|
||||
|
||||
NPC *pet_inst = GetPet()->CastToNPC();
|
||||
if (pet_inst->IsFamiliar() || !pet_inst->GetPetSpellID() || pet_inst->GetPetSpellID() > SPDAT_RECORDS)
|
||||
if (!pet_inst->GetPetSpellID() || !IsValidSpell(pet_inst->GetPetSpellID()))
|
||||
return false;
|
||||
|
||||
auto bot_owner = GetBotOwner();
|
||||
|
||||
@ -557,10 +557,35 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) {
|
||||
case SpellType_Pet: {
|
||||
//keep mobs from recasting pets when they have them.
|
||||
if (!IsPet() && !GetPetID() && !IsBotCharmer()) {
|
||||
if(botClass == MAGICIAN)
|
||||
botSpell = GetBestBotMagicianPetSpell(this);
|
||||
else
|
||||
if (botClass == WIZARD) {
|
||||
auto buffs_max = GetMaxBuffSlots();
|
||||
auto my_buffs = GetBuffs();
|
||||
int familiar_buff_slot = -1;
|
||||
if (buffs_max && my_buffs) {
|
||||
for (int index = 0; index < buffs_max; ++index) {
|
||||
if (IsEffectInSpell(my_buffs[index].spellid, SE_Familiar)) {
|
||||
MakePet(my_buffs[index].spellid, spells[my_buffs[index].spellid].teleport_zone);
|
||||
familiar_buff_slot = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GetPetID())
|
||||
break;
|
||||
|
||||
if (familiar_buff_slot >= 0) {
|
||||
BuffFadeBySlot(familiar_buff_slot);
|
||||
break;
|
||||
}
|
||||
|
||||
botSpell = GetFirstBotSpellBySpellType(this, SpellType_Pet);
|
||||
}
|
||||
else if (botClass == MAGICIAN) {
|
||||
botSpell = GetBestBotMagicianPetSpell(this);
|
||||
}
|
||||
else {
|
||||
botSpell = GetFirstBotSpellBySpellType(this, SpellType_Pet);
|
||||
}
|
||||
|
||||
if(botSpell.SpellId == 0)
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user