mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-26 11:27:17 +00:00
Implement AAs and harmtouch/layonhands to ^cast --- fix IsValidSpellRange
This commit is contained in:
+2
-2
@@ -9739,7 +9739,7 @@ bool Bot::CanCastSpellType(uint16 spellType, uint16 spell_id, Mob* tar) {
|
|||||||
case BotSpellTypes::Invisibility:
|
case BotSpellTypes::Invisibility:
|
||||||
case BotSpellTypes::MovementSpeed:
|
case BotSpellTypes::MovementSpeed:
|
||||||
case BotSpellTypes::SendHome:
|
case BotSpellTypes::SendHome:
|
||||||
if (
|
if ( // TODO bot rewrite - fix this, missing other target types (43 for example)
|
||||||
!(
|
!(
|
||||||
spells[spell_id].target_type == ST_Target ||
|
spells[spell_id].target_type == ST_Target ||
|
||||||
spells[spell_id].target_type == ST_Pet ||
|
spells[spell_id].target_type == ST_Pet ||
|
||||||
@@ -9748,7 +9748,7 @@ bool Bot::CanCastSpellType(uint16 spellType, uint16 spell_id, Mob* tar) {
|
|||||||
spells[spell_id].target_type == ST_GroupTeleport
|
spells[spell_id].target_type == ST_GroupTeleport
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
LogBotPreChecks("{} says, 'Cancelling cast of {} on {} due to target_type checks.'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName()); //deleteme
|
LogBotPreChecks("{} says, 'Cancelling cast of {} on {} due to target_type checks. Using {}'", GetCleanName(), GetSpellName(spell_id), tar->GetCleanName(), GetSpellTargetType(spell_id)); //deleteme
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,6 +402,7 @@ public:
|
|||||||
// AI Methods
|
// AI Methods
|
||||||
bool AICastSpell(Mob* tar, uint8 iChance, uint16 spellType, uint16 subTargetType = UINT16_MAX, uint16 subType = UINT16_MAX);
|
bool AICastSpell(Mob* tar, uint8 iChance, uint16 spellType, uint16 subTargetType = UINT16_MAX, uint16 subType = UINT16_MAX);
|
||||||
bool AttemptAICastSpell(uint16 spellType);
|
bool AttemptAICastSpell(uint16 spellType);
|
||||||
|
bool AttemptAACastSpell(Mob* tar, uint16 spell_id, AA::Rank* rank);
|
||||||
bool AI_EngagedCastCheck() override;
|
bool AI_EngagedCastCheck() override;
|
||||||
bool AI_PursueCastCheck() override;
|
bool AI_PursueCastCheck() override;
|
||||||
bool AI_IdleCastCheck() override;
|
bool AI_IdleCastCheck() override;
|
||||||
@@ -478,6 +479,7 @@ public:
|
|||||||
void LoadDefaultBotSettings();
|
void LoadDefaultBotSettings();
|
||||||
void SetBotSpellRecastTimer(uint16 spellType, Mob* spelltar, bool preCast = false);
|
void SetBotSpellRecastTimer(uint16 spellType, Mob* spelltar, bool preCast = false);
|
||||||
BotSpell GetSpellByHealType(uint16 spellType, Mob* tar);
|
BotSpell GetSpellByHealType(uint16 spellType, Mob* tar);
|
||||||
|
uint16 GetSpellByAA(int id, AA::Rank* &rank);
|
||||||
|
|
||||||
std::string GetBotSpellCategoryName(uint8 setting_type);
|
std::string GetBotSpellCategoryName(uint8 setting_type);
|
||||||
std::string GetBotSettingCategoryName(uint8 setting_type);
|
std::string GetBotSettingCategoryName(uint8 setting_type);
|
||||||
|
|||||||
+84
-20
@@ -11,7 +11,13 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
std::vector<std::string> notes =
|
std::vector<std::string> notes =
|
||||||
{
|
{
|
||||||
"- This will interrupt any spell currently being cast by bots told to use the command.",
|
"- This will interrupt any spell currently being cast by bots told to use the command.",
|
||||||
"- Bots will still check to see if they have the spell in their spell list, whether the target is immune, spell is allowed and all other sanity checks for spells"
|
"- Bots will still check to see if they have the spell in their spell list, whether the target is immune, spell is allowed and all other sanity checks for spells",
|
||||||
|
fmt::format(
|
||||||
|
"- You can use {} aa # to cast any clickable AA or specifically {} harmtouch / {} layonhands"
|
||||||
|
, sep->arg[0]
|
||||||
|
, sep->arg[0]
|
||||||
|
, sep->arg[0]
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::string> example_format =
|
std::vector<std::string> example_format =
|
||||||
@@ -29,12 +35,12 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
{
|
{
|
||||||
"To tell everyone to Nuke the target:",
|
"To tell everyone to Nuke the target:",
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} spawned",
|
"{} {}",
|
||||||
sep->arg[0],
|
sep->arg[0],
|
||||||
c->GetSpellTypeShortNameByID(BotSpellTypes::Nuke)
|
c->GetSpellTypeShortNameByID(BotSpellTypes::Nuke)
|
||||||
),
|
),
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} spawned",
|
"{} {}",
|
||||||
sep->arg[0],
|
sep->arg[0],
|
||||||
BotSpellTypes::Nuke
|
BotSpellTypes::Nuke
|
||||||
)
|
)
|
||||||
@@ -57,16 +63,14 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
};
|
};
|
||||||
std::vector<std::string> examples_three =
|
std::vector<std::string> examples_three =
|
||||||
{
|
{
|
||||||
"To tell Clrbot to resurrect the targeted corpse:",
|
"To tell Skbot to Harm Touch the target:",
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} byname Clrbot",
|
"{} aa 6000 byname Skbot",
|
||||||
sep->arg[0],
|
sep->arg[0]
|
||||||
c->GetSpellTypeShortNameByID(BotSpellTypes::Resurrect)
|
|
||||||
),
|
),
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} byname Clrbot",
|
"{} harmtouch byname Skbot",
|
||||||
sep->arg[0],
|
sep->arg[0]
|
||||||
BotSpellTypes::Resurrect
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,6 +124,11 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
std::string arg1 = sep->arg[1];
|
std::string arg1 = sep->arg[1];
|
||||||
std::string arg2 = sep->arg[2];
|
std::string arg2 = sep->arg[2];
|
||||||
|
|
||||||
|
//AA help
|
||||||
|
if (!arg1.compare("aa") && !arg2.compare("help")) {
|
||||||
|
c->Message(Chat::Yellow, "Enter the ID of an AA to attempt to cast.", sep->arg[0]);
|
||||||
|
}
|
||||||
|
|
||||||
//Commanded type help prompts
|
//Commanded type help prompts
|
||||||
if (!arg2.compare("help")) {
|
if (!arg2.compare("help")) {
|
||||||
c->Message(Chat::Yellow, "You can also use [single], [group], [ae]. Ex: ^cast movementspeed group.", sep->arg[0]);
|
c->Message(Chat::Yellow, "You can also use [single], [group], [ae]. Ex: ^cast movementspeed group.", sep->arg[0]);
|
||||||
@@ -174,8 +183,32 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ab_arg = 2;
|
int ab_arg = 2;
|
||||||
uint16 spellType = 0;
|
uint16 spellType = UINT16_MAX;
|
||||||
|
uint16 subType = UINT16_MAX;
|
||||||
|
uint16 subTargetType = UINT16_MAX;
|
||||||
|
bool aaType = false;
|
||||||
|
int aaID = 0;
|
||||||
|
|
||||||
|
if (!arg1.compare("aa") || !arg1.compare("harmtouch") || !arg1.compare("layonhands")) {
|
||||||
|
if (!arg1.compare("harmtouch")) {
|
||||||
|
aaID = zone->GetAlternateAdvancementAbilityByRank(aaHarmTouch)->id;
|
||||||
|
}
|
||||||
|
else if (!arg1.compare("layonhands")) {
|
||||||
|
aaID = zone->GetAlternateAdvancementAbilityByRank(aaLayonHands)->id;
|
||||||
|
}
|
||||||
|
else if (!sep->IsNumber(2) || !zone->GetAlternateAdvancementAbility(Strings::ToInt(arg2))) {
|
||||||
|
c->Message(Chat::Yellow, "You must enter an AA ID.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
++ab_arg;
|
||||||
|
aaID = Strings::ToInt(arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
aaType = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aaType) {
|
||||||
// String/Int type checks
|
// String/Int type checks
|
||||||
if (sep->IsNumber(1)) {
|
if (sep->IsNumber(1)) {
|
||||||
spellType = atoi(sep->arg[1]);
|
spellType = atoi(sep->arg[1]);
|
||||||
@@ -248,8 +281,7 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string argString = sep->arg[ab_arg];
|
std::string argString = sep->arg[ab_arg];
|
||||||
uint16 subType = UINT16_MAX;
|
|
||||||
uint16 subTargetType = UINT16_MAX;
|
|
||||||
|
|
||||||
if (!argString.compare("shrink")) {
|
if (!argString.compare("shrink")) {
|
||||||
subType = CommandedSubTypes::Shrink;
|
subType = CommandedSubTypes::Shrink;
|
||||||
@@ -306,12 +338,13 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
c->Message(Chat::Yellow, "Pet type heals and buffs are not supported, use the regular spell type.");
|
c->Message(Chat::Yellow, "Pet type heals and buffs are not supported, use the regular spell type.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Mob* tar = c->GetTarget();
|
Mob* tar = c->GetTarget();
|
||||||
//LogTestDebug("{}: 'Attempting {} [{}-{}] on {}'", __LINE__, c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (tar ? tar->GetCleanName() : "NOBODY")); //deleteme
|
//LogTestDebug("{}: 'Attempting {} [{}-{}] on {}'", __LINE__, c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (tar ? tar->GetCleanName() : "NOBODY")); //deleteme
|
||||||
|
|
||||||
if (!tar) {
|
if (!tar) {
|
||||||
if (spellType != BotSpellTypes::Escape && spellType != BotSpellTypes::Pet) {
|
if (!aaType && spellType != BotSpellTypes::Escape && spellType != BotSpellTypes::Pet) {
|
||||||
c->Message(Chat::Yellow, "You need a target for that.");
|
c->Message(Chat::Yellow, "You need a target for that.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,10 +389,11 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
|
|
||||||
if (IsBotSpellTypeBeneficial(spellType)) {
|
if (IsBotSpellTypeBeneficial(spellType)) {
|
||||||
if (
|
if (
|
||||||
(!tar->IsOfClientBot() && !(tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot())) ||
|
(tar->IsNPC() && !tar->GetOwner()) ||
|
||||||
((tar->IsOfClientBot() && !c->IsInGroupOrRaid(tar)) || (tar->GetOwner() && tar->GetOwner()->IsOfClientBot() && !c->IsInGroupOrRaid(tar->GetOwner())))
|
(tar->GetOwner() && tar->GetOwner()->IsOfClientBot() && !c->IsInGroupOrRaid(tar->GetOwner())) ||
|
||||||
|
(tar->IsOfClientBot() && !c->IsInGroupOrRaid(tar))
|
||||||
) {
|
) {
|
||||||
c->Message(Chat::Yellow, "[%s] is an invalid target. Only players in your group or raid are eligible targets.", tar->GetCleanName());
|
c->Message(Chat::Yellow, "[%s] is an invalid target. Only players or their pet in your group or raid are eligible targets.", tar->GetCleanName());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -408,6 +442,8 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mob* newTar = tar;
|
Mob* newTar = tar;
|
||||||
|
|
||||||
|
if (!aaType) {
|
||||||
//LogTestDebug("{}: {} says, 'Attempting {} [{}-{}] on {}'", __LINE__, bot_iter->GetCleanName(), c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (newTar ? newTar->GetCleanName() : "NOBODY")); //deleteme
|
//LogTestDebug("{}: {} says, 'Attempting {} [{}-{}] on {}'", __LINE__, bot_iter->GetCleanName(), c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (newTar ? newTar->GetCleanName() : "NOBODY")); //deleteme
|
||||||
if (!SpellTypeRequiresTarget(spellType, bot_iter->GetClass())) {
|
if (!SpellTypeRequiresTarget(spellType, bot_iter->GetClass())) {
|
||||||
newTar = bot_iter;
|
newTar = bot_iter;
|
||||||
@@ -436,9 +472,31 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aaType) {
|
||||||
|
if (!bot_iter->GetAA(zone->GetAlternateAdvancementAbility(aaID)->first_rank_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogTestDebug("{}: {} says, 'aaID is {}'", __LINE__, bot_iter->GetCleanName(), aaID); //deleteme
|
||||||
|
AA::Rank* tempRank = nullptr;
|
||||||
|
AA::Rank*& rank = tempRank;
|
||||||
|
uint16 spell_id = bot_iter->GetSpellByAA(aaID, rank);
|
||||||
|
|
||||||
|
if (!IsValidSpell(spell_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bot_iter->AttemptAACastSpell(tar, spell_id, rank)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSuccess = true;
|
||||||
|
++successCount;
|
||||||
|
}
|
||||||
|
else {
|
||||||
LogTestDebug("{}: {} says, 'Attempting {} [{}-{}] on {}'", __LINE__, bot_iter->GetCleanName(), c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (newTar ? newTar->GetCleanName() : "NOBODY")); //deleteme
|
LogTestDebug("{}: {} says, 'Attempting {} [{}-{}] on {}'", __LINE__, bot_iter->GetCleanName(), c->GetSpellTypeNameByID(spellType), (subType != UINT16_MAX ? c->GetSubTypeNameByID(subType) : "Standard"), (subTargetType != UINT16_MAX ? c->GetSubTypeNameByID(subTargetType) : "Standard"), (newTar ? newTar->GetCleanName() : "NOBODY")); //deleteme
|
||||||
|
|
||||||
bot_iter->SetCommandedSpell(true);
|
bot_iter->SetCommandedSpell(true);
|
||||||
|
|
||||||
if (bot_iter->AICastSpell(newTar, 100, spellType, subTargetType, subType)) {
|
if (bot_iter->AICastSpell(newTar, 100, spellType, subTargetType, subType)) {
|
||||||
@@ -449,8 +507,14 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
isSuccess = true;
|
isSuccess = true;
|
||||||
++successCount;
|
++successCount;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
bot_iter->GetBotOwner()->Message(Chat::Red, "%s says, 'Ability failed to cast. This could be due to this to any number of things: range, mana, immune, etc.'", bot_iter->GetCleanName());
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bot_iter->SetCommandedSpell(false);
|
bot_iter->SetCommandedSpell(false);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -460,7 +524,7 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"No bots are capable of casting [{}] on {}.",
|
"No bots are capable of casting [{}] on {}.",
|
||||||
c->GetSpellTypeNameByID(spellType),
|
(!aaType ? c->GetSpellTypeNameByID(spellType) : zone->GetAAName(zone->GetAlternateAdvancementAbility(aaID)->first_rank_id)),
|
||||||
tar ? tar->GetCleanName() : "your target"
|
tar ? tar->GetCleanName() : "your target"
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
@@ -471,7 +535,7 @@ void bot_command_cast(Client* c, const Seperator* sep)
|
|||||||
"{} {} [{}]{}",
|
"{} {} [{}]{}",
|
||||||
((successCount == 1 && firstFound) ? firstFound->GetCleanName() : (fmt::format("{}", successCount).c_str())),
|
((successCount == 1 && firstFound) ? firstFound->GetCleanName() : (fmt::format("{}", successCount).c_str())),
|
||||||
((successCount == 1 && firstFound) ? "casted" : "of your bots casted"),
|
((successCount == 1 && firstFound) ? "casted" : "of your bots casted"),
|
||||||
c->GetSpellTypeNameByID(spellType),
|
(!aaType ? c->GetSpellTypeNameByID(spellType) : zone->GetAAName(zone->GetAlternateAdvancementAbility(aaID)->first_rank_id)),
|
||||||
tar ? (fmt::format(" on {}.", tar->GetCleanName()).c_str()) : "."
|
tar ? (fmt::format(" on {}.", tar->GetCleanName()).c_str()) : "."
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -2566,7 +2566,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
range = GetActSpellRange(spell_id, range);
|
range = GetActSpellRange(spell_id, range);
|
||||||
if(IsClient() && IsIllusionSpell(spell_id) && (HasProjectIllusion())){
|
if(IsOfClientBot() && IsIllusionSpell(spell_id) && (HasProjectIllusion())){
|
||||||
range = 100;
|
range = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user