Combine GatherGroupSpellTargets and GatherSpellTargets

This commit is contained in:
nytmyr
2024-12-20 09:50:07 -06:00
parent da5cb9c936
commit 665d7e3641
3 changed files with 26 additions and 111 deletions
+15 -84
View File
@@ -6007,12 +6007,7 @@ bool Bot::DoFinishedSpellSingleTarget(uint16 spell_id, Mob* spellTarget, EQ::spe
if (!noGroupSpell) { if (!noGroupSpell) {
std::vector<Mob*> v; std::vector<Mob*> v;
if (RuleB(Bots, RaidBuffing)) { v = GatherSpellTargets(RuleB(Bots, RaidBuffing));
v = GatherSpellTargets(true);
}
else {
v = GatherGroupSpellTargets();
}
for (Mob* m : v) { for (Mob* m : v) {
if (IsEffectInSpell(thespell, SE_AbsorbMagicAtt) || IsEffectInSpell(thespell, SE_Rune)) { if (IsEffectInSpell(thespell, SE_AbsorbMagicAtt) || IsEffectInSpell(thespell, SE_Rune)) {
@@ -6072,7 +6067,7 @@ bool Bot::DoFinishedSpellGroupTarget(uint16 spell_id, Mob* spellTarget, EQ::spel
v = GatherSpellTargets(true); v = GatherSpellTargets(true);
} }
else { else {
v = GatherGroupSpellTargets(spellTarget); v = GatherSpellTargets(false, spellTarget);
} }
for (Mob* m : v) { for (Mob* m : v) {
@@ -9287,74 +9282,11 @@ void Bot::DoItemClick(const EQ::ItemData *item, uint16 slot_id)
uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][Stance::AEBurn][cntHSND] = { 0 }; uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][Stance::AEBurn][cntHSND] = { 0 };
std::vector<Mob*> Bot::GatherGroupSpellTargets(Mob* target, bool noClients, bool noBots) { std::vector<Mob*> Bot::GatherSpellTargets(bool entireRaid, Mob* target, bool noClients, bool noBots, bool noPets) {
std::vector<Mob*> valid_spell_targets; std::vector<Mob*> valid_spell_targets;
if (IsRaidGrouped()) { if (IsRaidGrouped()) {
if (auto raid = entity_list.GetRaidByBotName(GetName())) { if (auto raid = GetRaid()) {
std::vector<RaidMember> raidGroupMembers;
if (target) {
auto raidGroup = raid->GetGroup(target->GetName());
if (raidGroup != RAID_GROUPLESS) {
raidGroupMembers = raid->GetRaidGroupMembers(raidGroup);
}
else {
return valid_spell_targets;
}
}
else {
auto raidGroup = raid->GetGroup(GetName());
if (raidGroup != RAID_GROUPLESS) {
raidGroupMembers = raid->GetRaidGroupMembers(raidGroup);
}
else {
return valid_spell_targets;
}
}
for (const auto& m : raidGroupMembers) {
if (
m.member && m.group_number != RAID_GROUPLESS &&
(
(m.member->IsClient() && !noClients) ||
(m.member->IsBot() && !noBots)
)
) {
valid_spell_targets.emplace_back(m.member);
}
}
}
}
else if (IsGrouped()) {
Group* group = GetGroup();
if (group) {
for (const auto& m : group->members) {
if (
m &&
(
(m->IsClient() && !noClients) ||
(m->IsBot() && !noBots)
)
) {
valid_spell_targets.emplace_back(m);
}
}
}
}
else {
valid_spell_targets.emplace_back(this);
}
return valid_spell_targets;
}
std::vector<Mob*> Bot::GatherSpellTargets(bool entireRaid, bool noClients, bool noBots, bool noPets) {
std::vector<Mob*> valid_spell_targets;
if (IsRaidGrouped()) {
if (auto raid = entity_list.GetRaidByBotName(GetName())) {
if (entireRaid) { if (entireRaid) {
for (const auto& m : raid->members) { for (const auto& m : raid->members) {
if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) { if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) {
@@ -9363,7 +9295,14 @@ std::vector<Mob*> Bot::GatherSpellTargets(bool entireRaid, bool noClients, bool
} }
} }
else { else {
std::vector<RaidMember> raidGroup = raid->GetRaidGroupMembers(raid->GetGroup(GetName())); std::vector<RaidMember> raidGroup;
if (target) {
raidGroup = raid->GetRaidGroupMembers(raid->GetGroup(target->GetName()));
}
else {
raidGroup = raid->GetRaidGroupMembers(raid->GetGroup(GetName()));
}
for (const auto& m : raidGroup) { for (const auto& m : raidGroup) {
if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) { if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) {
@@ -9375,6 +9314,7 @@ std::vector<Mob*> Bot::GatherSpellTargets(bool entireRaid, bool noClients, bool
} }
else if (IsGrouped()) { else if (IsGrouped()) {
Group* group = GetGroup(); Group* group = GetGroup();
if (group) { if (group) {
for (const auto& m : group->members) { for (const auto& m : group->members) {
if (m && ((m->IsClient() && !noClients) || (m->IsBot() && !noBots))) { if (m && ((m->IsClient() && !noClients) || (m->IsBot() && !noBots))) {
@@ -9832,23 +9772,14 @@ bool Bot::BotHasEnoughMana(uint16 spell_id) {
} }
bool Bot::IsTargetAlreadyReceivingSpell(Mob* tar, uint16 spell_id) { bool Bot::IsTargetAlreadyReceivingSpell(Mob* tar, uint16 spell_id) {
if (!tar || !spell_id) { if (!tar || !spell_id) {
return true; return true;
} }
if (IsNPC() && CastToNPC()->GetSwarmOwner()) {
return true;
}
std::vector<Mob*> v; std::vector<Mob*> v;
uint16 targetID = tar->GetID();
if (RuleB(Bots, CrossRaidBuffingAndHealing)) { v = GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
v = GatherSpellTargets(true);
}
else {
v = GatherGroupSpellTargets();
}
for (Mob* m : v) { for (Mob* m : v) {
if ( if (
+1 -2
View File
@@ -455,8 +455,7 @@ public:
{ return Mob::Attack(other, Hand, FromRiposte, IsStrikethrough, IsFromSpell, opts); } { return Mob::Attack(other, Hand, FromRiposte, IsStrikethrough, IsFromSpell, opts); }
void DoAttackRounds(Mob* target, int hand); void DoAttackRounds(Mob* target, int hand);
std::vector<Mob*> GatherGroupSpellTargets(Mob* target = nullptr, bool noClients = false, bool noBots = false); std::vector<Mob*> GatherSpellTargets(bool entireRaid = false, Mob* target = nullptr, bool noClients = false, bool noBots = false, bool noPets = false);
std::vector<Mob*> GatherSpellTargets(bool entireRaid = false, bool noClients = false, bool noBots = false, bool noPets = false);
bool PrecastChecks(Mob* tar, uint16 spellType); bool PrecastChecks(Mob* tar, uint16 spellType);
bool CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechecks = false, bool AECheck = false); bool CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechecks = false, bool AECheck = false);
+6 -21
View File
@@ -350,7 +350,7 @@ bool Bot::BotCastCure(Mob* tar, uint8 botClass, BotSpell& botSpell, uint16 spell
).c_str() ).c_str()
); );
const std::vector<Mob*> v = GatherGroupSpellTargets(tar); const std::vector<Mob*> v = GatherSpellTargets(false, tar);
if (!IsCommandedSpell()) { if (!IsCommandedSpell()) {
@@ -533,7 +533,7 @@ bool Bot::BotCastHeal(Mob* tar, uint8 botClass, BotSpell& botSpell, uint16 spell
); );
if (botClass != Class::Bard) { if (botClass != Class::Bard) {
const std::vector<Mob*> v = GatherGroupSpellTargets(tar); const std::vector<Mob*> v = GatherSpellTargets(false, tar);
if (!IsCommandedSpell()) { if (!IsCommandedSpell()) {
for (Mob* m : v) { for (Mob* m : v) {
@@ -1264,12 +1264,7 @@ BotSpell Bot::GetBestBotSpellForGroupHeal(Bot* botCaster, Mob* tar, uint16 spell
std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_CurrentHP); std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_CurrentHP);
std::vector<Mob*> v; std::vector<Mob*> v;
if (RuleB(Bots, CrossRaidBuffingAndHealing)) { v = botCaster->GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
v = botCaster->GatherSpellTargets(true);
}
else {
v = botCaster->GatherGroupSpellTargets();
}
int targetCount = 0; int targetCount = 0;
@@ -1313,12 +1308,7 @@ BotSpell Bot::GetBestBotSpellForGroupHealOverTime(Bot* botCaster, Mob* tar, uint
std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_HealOverTime); std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_HealOverTime);
std::vector<Mob*> v; std::vector<Mob*> v;
if (RuleB(Bots, CrossRaidBuffingAndHealing)) { v = botCaster->GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
v = botCaster->GatherSpellTargets(true);
}
else {
v = botCaster->GatherGroupSpellTargets();
}
int targetCount = 0; int targetCount = 0;
@@ -1362,12 +1352,7 @@ BotSpell Bot::GetBestBotSpellForGroupCompleteHeal(Bot* botCaster, Mob* tar, uint
std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_CompleteHeal); std::list<BotSpell> botSpellList = GetBotSpellsForSpellEffect(botCaster, spellType, SE_CompleteHeal);
std::vector<Mob*> v; std::vector<Mob*> v;
if (RuleB(Bots, CrossRaidBuffingAndHealing)) { v = botCaster->GatherSpellTargets(RuleB(Bots, CrossRaidBuffingAndHealing));
v = botCaster->GatherSpellTargets(true);
}
else {
v = botCaster->GatherGroupSpellTargets();
}
int targetCount = 0; int targetCount = 0;
@@ -1970,7 +1955,7 @@ BotSpell Bot::GetBestBotSpellForCure(Bot* botCaster, Mob* tar, uint16 spellType)
std::list<BotSpell_wPriority> botSpellListItr = GetPrioritizedBotSpellsBySpellType(botCaster, spellType, tar); std::list<BotSpell_wPriority> botSpellListItr = GetPrioritizedBotSpellsBySpellType(botCaster, spellType, tar);
if (IsGroupBotSpellType(spellType)) { if (IsGroupBotSpellType(spellType)) {
const std::vector<Mob*> v = botCaster->GatherGroupSpellTargets(tar); const std::vector<Mob*> v = botCaster->GatherSpellTargets(false, tar);
int countNeedsCured = 0; int countNeedsCured = 0;
uint16 countPoisoned = 0; uint16 countPoisoned = 0;
uint16 countDiseased = 0; uint16 countDiseased = 0;