mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
Consolidate AttemptForcedCastSpell
This commit is contained in:
+36
-85
@@ -10954,7 +10954,7 @@ bool Bot::AttemptForcedCastSpell(Mob* tar, uint16 spell_id, bool is_disc) {
|
|||||||
tar = this;
|
tar = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((IsCharmSpell(spell_id) || IsPetSpell(spell_id) && HasPet())) {
|
if ((IsCharmSpell(spell_id) || (IsPetSpell(spell_id) && HasPet()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10963,19 +10963,16 @@ bool Bot::AttemptForcedCastSpell(Mob* tar, uint16 spell_id, bool is_disc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsBeneficialSpell(spell_id)) {
|
if (IsBeneficialSpell(spell_id)) {
|
||||||
if (
|
bool invalid_beneficial_target =
|
||||||
(tar->IsNPC() && !tar->GetOwner()) ||
|
(tar->IsNPC() && !tar->GetOwner()) ||
|
||||||
(tar->GetOwner() && tar->GetOwner()->IsOfClientBot() && !GetBotOwner()->IsInGroupOrRaid(tar->GetOwner())) ||
|
(tar->GetOwner() && tar->GetOwner()->IsOfClientBot() && !GetBotOwner()->IsInGroupOrRaid(tar->GetOwner())) ||
|
||||||
(tar->IsOfClientBot() && !GetBotOwner()->IsInGroupOrRaid(tar))
|
(tar->IsOfClientBot() && !GetBotOwner()->IsInGroupOrRaid(tar));
|
||||||
) {
|
|
||||||
|
if (invalid_beneficial_target) {
|
||||||
GetBotOwner()->Message(
|
GetBotOwner()->Message(
|
||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
fmt::format(
|
fmt::format("[{}] is an invalid target. Only players or their pet in your group or raid are eligible targets.", tar->GetCleanName()).c_str()
|
||||||
"[{}] is an invalid target. Only players or their pet in your group or raid are eligible targets."
|
|
||||||
, tar->GetCleanName()
|
|
||||||
).c_str()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10983,32 +10980,17 @@ bool Bot::AttemptForcedCastSpell(Mob* tar, uint16 spell_id, bool is_disc) {
|
|||||||
if (IsDetrimentalSpell(spell_id) && (!GetBotOwner()->IsAttackAllowed(tar) || !IsAttackAllowed(tar))) {
|
if (IsDetrimentalSpell(spell_id) && (!GetBotOwner()->IsAttackAllowed(tar) || !IsAttackAllowed(tar))) {
|
||||||
GetBotOwner()->Message(
|
GetBotOwner()->Message(
|
||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
fmt::format(
|
fmt::format("{} says, 'I cannot attack [{}]'.", GetCleanName(), tar->GetCleanName()).c_str()
|
||||||
"{} says, 'I cannot attack [{}]'.",
|
|
||||||
GetCleanName(),
|
|
||||||
tar->GetCleanName()
|
|
||||||
).c_str()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_disc) {
|
if (!is_disc && !CheckSpellRecastTimer(spell_id)) {
|
||||||
if (!CheckSpellRecastTimer(spell_id)) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (!IsInGroupOrRaid(tar, true) &&
|
||||||
!IsInGroupOrRaid(tar, true) &&
|
(!RuleB(Bots, EnableBotTGB) || (IsGroupSpell(spell_id) && !IsTGBCompatibleSpell(spell_id)))) {
|
||||||
(
|
|
||||||
!RuleB(Bots, EnableBotTGB) ||
|
|
||||||
(
|
|
||||||
IsGroupSpell(spell_id) &&
|
|
||||||
!IsTGBCompatibleSpell(spell_id)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11019,12 +11001,8 @@ bool Bot::AttemptForcedCastSpell(Mob* tar, uint16 spell_id, bool is_disc) {
|
|||||||
if (!CastChecks(spell_id, tar, UINT16_MAX)) {
|
if (!CastChecks(spell_id, tar, UINT16_MAX)) {
|
||||||
GetBotOwner()->Message(
|
GetBotOwner()->Message(
|
||||||
Chat::Red,
|
Chat::Red,
|
||||||
fmt::format(
|
fmt::format("{} says, 'Ability failed to cast. This could be due to range, mana, immune, target type, etc.'", GetBotOwner()->GetCleanName()).c_str()
|
||||||
"{} says, 'Ability failed to cast. This could be due to this to any number of things: range, mana, immune, target type, etc.'",
|
|
||||||
GetBotOwner()->GetCleanName()
|
|
||||||
).c_str()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11038,62 +11016,35 @@ bool Bot::AttemptForcedCastSpell(Mob* tar, uint16 spell_id, bool is_disc) {
|
|||||||
tar->GetCleanName()
|
tar->GetCleanName()
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
InterruptSpell();
|
InterruptSpell();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CastSpell(spell_id, tar->GetID())) {
|
if (!CastSpell(spell_id, tar->GetID())) {
|
||||||
BotGroupSay(
|
return false;
|
||||||
this,
|
|
||||||
fmt::format(
|
|
||||||
"Casting {} on {}.",
|
|
||||||
GetSpellName(spell_id),
|
|
||||||
(tar == this ? "myself" : tar->GetCleanName())
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
|
|
||||||
int timer_duration = 0;
|
|
||||||
|
|
||||||
if (!is_disc) {
|
|
||||||
timer_duration = CalcBuffDuration(tar, this, spell_id);
|
|
||||||
|
|
||||||
if (timer_duration) {
|
|
||||||
timer_duration = GetActSpellDuration(spell_id, timer_duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timer_duration < 0) {
|
|
||||||
timer_duration = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (spell.recast_time > 0) {
|
|
||||||
timer_duration = spell.recast_time / 1000;
|
|
||||||
auto focus = GetFocusEffect(focusReduceRecastTime, spell_id);
|
|
||||||
|
|
||||||
if (focus > timer_duration) {
|
|
||||||
timer_duration = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timer_duration -= focus;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timer_duration > 0) {
|
|
||||||
timer_duration = timer_duration * 1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_disc) {
|
|
||||||
SetSpellRecastTimer(spell_id, timer_duration);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SetDisciplineReuseTimer(spell_id, timer_duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
BotGroupSay(
|
||||||
|
this,
|
||||||
|
fmt::format(
|
||||||
|
"Casting {} on {}.",
|
||||||
|
GetSpellName(spell_id),
|
||||||
|
(tar == this ? "myself" : tar->GetCleanName())
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
int timer_duration = 0;
|
||||||
|
|
||||||
|
if (!is_disc) {
|
||||||
|
timer_duration = CalcBuffDuration(tar, this, spell_id);
|
||||||
|
timer_duration = std::max(0, GetActSpellDuration(spell_id, timer_duration));
|
||||||
|
SetSpellRecastTimer(spell_id, timer_duration);
|
||||||
|
}
|
||||||
|
else if (spell.recast_time > 0) {
|
||||||
|
timer_duration = std::max(0, int(spell.recast_time / 1000 - GetFocusEffect(focusReduceRecastTime, spell_id)));
|
||||||
|
SetDisciplineReuseTimer(spell_id, timer_duration * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 Bot::GetParentSpellType(uint16 spell_type) {
|
uint16 Bot::GetParentSpellType(uint16 spell_type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user