Updated bot casting roles to not refresh with every spell cast (oversight in recent casting chances commit)

This commit is contained in:
Uleat 2017-02-24 04:48:33 -05:00
parent 72ed770037
commit 3383f65ff7
5 changed files with 147 additions and 59 deletions

View File

@ -176,6 +176,9 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
if (GetClass() == ROGUE) if (GetClass() == ROGUE)
evade_timer.Start(); evade_timer.Start();
m_CastingRoles.GroupHealer = false;
m_CastingRoles.GroupSlower = false;
GenerateBaseStats(); GenerateBaseStats();
if (!botdb.LoadTimers(this) && bot_owner) if (!botdb.LoadTimers(this) && bot_owner)
@ -6835,66 +6838,116 @@ bool Bot::IsBotCasterCombatRange(Mob *target) {
return result; return result;
} }
bool Bot::IsGroupPrimaryHealer() { void Bot::UpdateGroupCastingRoles(const Group* group, bool disband)
bool result = false; {
uint8 botclass = GetClass(); if (!group)
if(HasGroup()) { return;
Group *g = GetGroup();
switch(botclass) { for (auto iter : group->members) {
case CLERIC: { if (!iter)
result = true; continue;
break;
} if (iter->IsBot()) {
case DRUID: { iter->CastToBot()->SetGroupHealer(false);
result = GroupHasClericClass(g) ? false : true; iter->CastToBot()->SetGroupSlower(false);
break;
}
case SHAMAN: {
result = (GroupHasClericClass(g) || GroupHasDruidClass(g)) ? false : true;
break;
}
case PALADIN:
case RANGER:
case BEASTLORD: {
result = GroupHasPriestClass(g) ? false : true;
break;
}
default: {
result = false;
break;
}
} }
} }
return result; if (disband)
} return;
bool Bot::IsGroupPrimarySlower() { Mob* healer = nullptr;
bool result = false; Mob* slower = nullptr;
uint8 botclass = GetClass();
if(HasGroup()) { for (auto iter : group->members) {
Group *g = GetGroup(); if (!iter)
switch(botclass) { continue;
case SHAMAN: {
result = true; switch (iter->GetClass()) {
break; case CLERIC:
} if (!healer)
case ENCHANTER: { healer = iter;
result = GroupHasShamanClass(g) ? false : true; else
break; switch (healer->GetClass()) {
} case CLERIC:
case BEASTLORD: { break;
result = (GroupHasShamanClass(g) || GroupHasEnchanterClass(g)) ? false : true; default:
break; healer = iter;
} }
default: {
result = false; break;
break; case DRUID:
} if (!healer)
healer = iter;
else
switch (healer->GetClass()) {
case CLERIC:
case DRUID:
break;
default:
healer = iter;
}
break;
case SHAMAN:
if (!healer)
healer = iter;
else
switch (healer->GetClass()) {
case CLERIC:
case DRUID:
case SHAMAN:
break;
default:
healer = iter;
}
break;
case PALADIN:
case RANGER:
case BEASTLORD:
if (!healer)
healer = iter;
break;
default:
break;
}
switch (iter->GetClass()) {
case SHAMAN:
if (!slower)
slower = iter;
else
switch (slower->GetClass()) {
case SHAMAN:
break;
default:
slower = iter;
}
break;
case ENCHANTER:
if (!slower)
slower = iter;
else
switch (slower->GetClass()) {
case SHAMAN:
case ENCHANTER:
break;
default:
slower = iter;
}
break;
case BEASTLORD:
if (!slower)
slower = iter;
break;
default:
break;
} }
} }
return result; if (healer && healer->IsBot())
healer->CastToBot()->SetGroupHealer();
if (slower && slower->IsBot())
slower->CastToBot()->SetGroupSlower();
} }
bool Bot::CanHeal() { bool Bot::CanHeal() {

View File

@ -132,7 +132,8 @@ enum SpellTypeIndex {
MaxSpellTypes MaxSpellTypes
}; };
enum BotCastingChanceConditional : uint8 { nHS = 0, pH, pS, pHS, cntHS }; // negative Healer/Slower, positive Healer, postive Slower, positive Healer/Slower // negative Healer/Slower, positive Healer, postive Slower, positive Healer/Slower
enum BotCastingChanceConditional : uint8 { nHS = 0, pH, pS, pHS, cntHS = 4 };
class Bot : public NPC { class Bot : public NPC {
@ -475,8 +476,11 @@ public:
BotRoleType GetBotRole() { return _botRole; } BotRoleType GetBotRole() { return _botRole; }
BotStanceType GetBotStance() { return _botStance; } BotStanceType GetBotStance() { return _botStance; }
uint8 GetChanceToCastBySpellType(uint32 spellType); uint8 GetChanceToCastBySpellType(uint32 spellType);
bool IsGroupPrimaryHealer();
bool IsGroupPrimarySlower(); bool IsGroupHealer() { return m_CastingRoles.GroupHealer; }
bool IsGroupSlower() { return m_CastingRoles.GroupSlower; }
static void UpdateGroupCastingRoles(const Group* group, bool disband = false);
bool IsBotCaster() { return IsCasterClass(GetClass()); } bool IsBotCaster() { return IsCasterClass(GetClass()); }
bool IsBotINTCaster() { return IsINTCasterClass(GetClass()); } bool IsBotINTCaster() { return IsINTCasterClass(GetClass()); }
bool IsBotWISCaster() { return IsWISCasterClass(GetClass()); } bool IsBotWISCaster() { return IsWISCasterClass(GetClass()); }
@ -640,6 +644,10 @@ protected:
virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0); virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0);
virtual float GetMaxMeleeRangeToTarget(Mob* target); virtual float GetMaxMeleeRangeToTarget(Mob* target);
BotCastingRoles& GetCastingRoles() { return m_CastingRoles; }
void SetGroupHealer(bool flag = true) { m_CastingRoles.GroupHealer = flag; }
void SetGroupSlower(bool flag = true) { m_CastingRoles.GroupSlower = flag; }
private: private:
// Class Members // Class Members
uint32 _botID; uint32 _botID;
@ -679,6 +687,8 @@ private:
Timer evade_timer; Timer evade_timer;
BotCastingRoles m_CastingRoles;
std::shared_ptr<HealRotation> m_member_of_heal_rotation; std::shared_ptr<HealRotation> m_member_of_heal_rotation;
std::map<uint32, BotAA> botAAs; std::map<uint32, BotAA> botAAs;

View File

@ -60,6 +60,11 @@ struct BotSpell_wPriority : public BotSpell {
uint8 Priority; uint8 Priority;
}; };
struct BotCastingRoles {
bool GroupHealer;
bool GroupSlower;
};
struct BotAA { struct BotAA {
uint32 aa_id; uint32 aa_id;
uint8 req_level; uint8 req_level;

View File

@ -108,7 +108,7 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) {
bool isPrimaryHealer = false; bool isPrimaryHealer = false;
if(HasGroup()) { if(HasGroup()) {
isPrimaryHealer = IsGroupPrimaryHealer(); isPrimaryHealer = IsGroupHealer();
} }
if(hpr < 95 || (tar->IsClient() && (hpr < 95)) || (botClass == BARD)) { if(hpr < 95 || (tar->IsClient() && (hpr < 95)) || (botClass == BARD)) {
@ -2590,9 +2590,9 @@ uint8 Bot::GetChanceToCastBySpellType(uint32 spellType)
uint8 type_index = nHS; uint8 type_index = nHS;
if (HasGroup()) { if (HasGroup()) {
if (IsGroupPrimaryHealer()) if (IsGroupHealer())
type_index |= pH; type_index |= pH;
if (IsGroupPrimarySlower()) if (IsGroupSlower())
type_index |= pS; type_index |= pS;
} }

View File

@ -347,6 +347,10 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
safe_delete(outapp); safe_delete(outapp);
#ifdef BOTS
Bot::UpdateGroupCastingRoles(this);
#endif
return true; return true;
} }
@ -481,6 +485,10 @@ bool Group::UpdatePlayer(Mob* update){
if (update->IsClient() && !mentoree && mentoree_name.length() && !mentoree_name.compare(update->GetName())) if (update->IsClient() && !mentoree && mentoree_name.length() && !mentoree_name.compare(update->GetName()))
mentoree = update->CastToClient(); mentoree = update->CastToClient();
#ifdef BOTS
Bot::UpdateGroupCastingRoles(this);
#endif
return updateSuccess; return updateSuccess;
} }
@ -513,6 +521,10 @@ void Group::MemberZoned(Mob* removemob) {
if (removemob->IsClient() && removemob == mentoree) if (removemob->IsClient() && removemob == mentoree)
mentoree = nullptr; mentoree = nullptr;
#ifdef BOTS
Bot::UpdateGroupCastingRoles(this);
#endif
} }
void Group::SendGroupJoinOOZ(Mob* NewMember) { void Group::SendGroupJoinOOZ(Mob* NewMember) {
@ -721,6 +733,10 @@ bool Group::DelMember(Mob* oldmember, bool ignoresender)
ClearAllNPCMarks(); ClearAllNPCMarks();
} }
#ifdef BOTS
Bot::UpdateGroupCastingRoles(this);
#endif
return true; return true;
} }
@ -864,6 +880,10 @@ uint32 Group::GetTotalGroupDamage(Mob* other) {
} }
void Group::DisbandGroup(bool joinraid) { void Group::DisbandGroup(bool joinraid) {
#ifdef BOTS
Bot::UpdateGroupCastingRoles(this, true);
#endif
auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate_Struct)); auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate_Struct));
GroupUpdate_Struct* gu = (GroupUpdate_Struct*) outapp->pBuffer; GroupUpdate_Struct* gu = (GroupUpdate_Struct*) outapp->pBuffer;