From cd3cd9ef1a7899377b2deb65f7fc2ba85c55e9a2 Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:09:51 -0600 Subject: [PATCH] commanded spell fixes. All should be working now minus depart --- zone/bot.cpp | 75 ++++++++++++++++++++++---------------- zone/bot_commands/cast.cpp | 6 --- zone/botspellsai.cpp | 9 ++--- 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 53b7d181b..3e95c30a8 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9372,12 +9372,12 @@ bool Bot::PrecastChecks(Mob* tar, uint16 spellType) { } bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechecks, bool AECheck) { - if (!tar) { - LogBotPreChecksDetail("{} says, 'Cancelling cast due to CastChecks !tar.'", GetCleanName()); //deleteme - return false; - } - if (doPrechecks) { + if (!tar) { + LogBotPreChecksDetail("{} says, 'Cancelling cast due to CastChecks !tar.'", GetCleanName()); //deleteme + return false; + } + if (spells[spell_id].target_type == ST_Self && tar != this) { if (IsEffectInSpell(spell_id, SE_SummonCorpse) && RuleB(Bots, AllowCommandedSummonCorpse)) { //tar = this; @@ -9393,7 +9393,7 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec } } - LogBotPreChecksDetail("{} says, 'Running [{}] CastChecks on [{}].'", GetCleanName(), GetSpellTypeNameByID(spellType), tar->GetCleanName()); //deleteme + LogBotPreChecksDetail("{} says, 'Running [{}] CastChecks on [{}].'", GetCleanName(), GetSpellTypeNameByID(spellType), (tar ? tar->GetCleanName() : "nobody")); //deleteme if (!IsValidSpell(spell_id)) { LogBotPreChecksDetail("{} says, 'Cancelling cast due to !IsValidSpell.'", GetCleanName()); //deleteme @@ -9401,26 +9401,17 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec } if (IsFeared() || IsSilenced() || IsAmnesiad()) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to Incapacitated.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to Incapacitated.'", GetCleanName(), GetSpellName(spell_id), (tar ? tar->GetCleanName() : "nobody")); //deleteme return false; } if ((IsStunned() || IsMezzed() || DivineAura()) && !IsCastNotStandingSpell(spell_id)) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to !IsCastNotStandingSpell.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme - return false; - } - - if ( - spells[spell_id].target_type == ST_Self - && tar != this && - (spellType != BotSpellTypes::SummonCorpse || RuleB(Bots, AllowCommandedSummonCorpse)) - ) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to ST_Self.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to !IsCastNotStandingSpell.'", GetCleanName(), GetSpellName(spell_id), (tar ? tar->GetCleanName() : "nobody")); //deleteme return false; } if (IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to !CanDoCombat.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to !CanDoCombat.'", GetCleanName(), GetSpellName(spell_id), (tar ? tar->GetCleanName() : "nobody")); //deleteme return false; } @@ -9439,11 +9430,6 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec return false; } - if (this == tar && IsSacrificeSpell(spell_id)) { - LogBotPreChecks("{} says, 'Cancelling cast of {} due to IsSacrificeSpell.'", GetCleanName(), GetSpellName(spell_id)); //deleteme - return false; - } - if (spells[spell_id].caster_requirement_id && !PassCastRestriction(spells[spell_id].caster_requirement_id)) { LogBotPreChecks("{} says, 'Cancelling cast of {} due to !PassCastRestriction.'", GetCleanName(), GetSpellName(spell_id)); //deleteme return false; @@ -9495,11 +9481,39 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec return false; } + if (SpellTypeRequiresTarget(spellType) && !tar) { + LogBotPreChecksDetail("{} says, 'Cancelling cast due to CastChecks !tar.'", GetCleanName()); //deleteme + return false; + } + + if ( + spells[spell_id].target_type == ST_Self + && tar != this && + (spellType != BotSpellTypes::SummonCorpse || RuleB(Bots, AllowCommandedSummonCorpse)) + ) { + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to ST_Self.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + return false; + } + + if (this == tar && IsSacrificeSpell(spell_id)) { + LogBotPreChecks("{} says, 'Cancelling cast of {} due to IsSacrificeSpell.'", GetCleanName(), GetSpellName(spell_id)); //deleteme + return false; + } + if (!AECheck && !IsValidSpellRange(spell_id, tar)) { LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to IsValidSpellRange.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme return false; } + LogBotPreChecksDetail("{} says, 'Doing CanCastSpellType checks of {} on {}.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + if (!CanCastSpellType(spellType, spell_id, tar)) { + return false; + } + + if (IsCommandedSpell()) { //stop checks here for commanded spells + return true; + } + if (!IsValidTargetType(spell_id, GetSpellTargetType(spell_id), tar->GetBodyType())) { LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to IsValidTargetType.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme return false; @@ -9515,13 +9529,13 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec return false; } - if (!DoResistCheckBySpellType(tar, spell_id, spellType)) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to DoResistCheckBySpellType.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + if (!IsCommandedSpell() && !IsTaunting() && GetSpellTypeAggroCheck(spellType) && HasOrMayGetAggro(IsSitting(), spell_id) && !tar->IsFleeing()) { + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to HasOrMayGetAggro.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme return false; } - if (!IsCommandedSpell() && !IsTaunting() && GetSpellTypeAggroCheck(spellType) && HasOrMayGetAggro(IsSitting(), spell_id) && !tar->IsFleeing()) { - LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to HasOrMayGetAggro.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme + if (!DoResistCheckBySpellType(tar, spell_id, spellType)) { + LogBotPreChecksDetail("{} says, 'Cancelling cast of {} on {} due to DoResistCheckBySpellType.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme return false; } @@ -9538,11 +9552,6 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec return false; } - LogBotPreChecksDetail("{} says, 'Doing CanCastSpellType checks of {} on {}.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme - if (!CanCastSpellType(spellType, spell_id, tar)) { - return false; - } - return true; } @@ -11378,6 +11387,8 @@ bool Bot::HasValidAETarget(Bot* botCaster, uint16 spell_id, uint16 spellType, Mo if (!m->IsNPC()) { continue; } + + break; default: break; } diff --git a/zone/bot_commands/cast.cpp b/zone/bot_commands/cast.cpp index fb7f97209..ef5074e89 100644 --- a/zone/bot_commands/cast.cpp +++ b/zone/bot_commands/cast.cpp @@ -403,12 +403,6 @@ void bot_command_cast(Client* c, const Seperator* sep) continue; } - /* - TODO bot rewrite - - FIX: Depart - Group Cures, Precombat - NEED TO CHECK: precombat - */ if (bot_iter->GetBotStance() == Stance::Passive || bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsSilenced() || bot_iter->IsAmnesiad() || bot_iter->GetHP() < 0) { continue; } diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 35cec06d1..a86b8e6c8 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1042,14 +1042,11 @@ std::list Bot::GetPrioritizedBotSpellsBySpellType(Bot* botCa IsGroupSpell(botSpellList[i].spellid) && !IsTGBCompatibleSpell(botSpellList[i].spellid) && !botCaster->IsInGroupOrRaid(tar, true) - ) { + ) { continue; } - - if ( - (!botCaster->IsCommandedSpell() || (botCaster->IsCommandedSpell() && SpellTypeRequiresCastChecks(spellType))) && - (!IsPBAESpell(botSpellList[i].spellid) && !botCaster->CastChecks(botSpellList[i].spellid, tar, spellType, false, IsAEBotSpellType(spellType))) - ) { + if (spellType == debugSpellType) { LogTestDebugDetail("{} - #{}: [{} #{}] - {} says, '{} #{} - Passed TGB checks.'", __FILE__, __LINE__, botCaster->GetSpellTypeNameByID(spellType), spellType, botCaster->GetCleanName(), spells[botSpellList[i].spellid].name, botSpellList[i].spellid); }; //deleteme + if (!IsPBAESpell(botSpellList[i].spellid) && !botCaster->CastChecks(botSpellList[i].spellid, tar, spellType, false, IsAEBotSpellType(spellType))) { continue; }