Compare commits

..

8 Commits

Author SHA1 Message Date
avirar
23d9931f65
Resolved crash in BGStatusAction (#1656)
* Prevent race condition and server crash

* Updated other direct packet handling lines to queue packets instead
2025-09-28 00:01:24 +02:00
kadeshar
05d3a44481
Merge pull request #1651 from Tierisch/shaman_fix
Fix SetTotemAction - add `isUseful` and get array size instead of pointer size
2025-09-27 23:08:18 +02:00
bash
662e7f1b0b
Update ShamanActions.cpp 2025-09-27 23:00:24 +02:00
kadeshar
0547ce5cf7 - Code optimalizations 2025-09-27 20:57:10 +02:00
Crow
f5a6194808
Fixed some comments in the config (#1668) 2025-09-27 20:31:06 +02:00
kadeshar
01f0b71a17 - Code refactoring 2025-09-25 20:31:42 +02:00
Spargel
f35e39e19c Removing unnecessary variable 2025-09-22 03:00:29 -05:00
Spargel
ca0dafd67b Fix SetTotemAction
Add isUseful and check array size instead of pointer size
2025-09-21 21:21:09 -05:00
4 changed files with 32 additions and 17 deletions

View File

@ -519,7 +519,7 @@ AiPlayerbot.AutoGearScoreLimit = 0
# "taxi" (bots may use all flight paths, though they will not actually learn them) # "taxi" (bots may use all flight paths, though they will not actually learn them)
# "raid" (bots use cheats implemented into raid strategies) # "raid" (bots use cheats implemented into raid strategies)
# To use multiple cheats, separate them by commas below (e.g., to enable all, use "gold,health,mana,power,raid,taxi") # To use multiple cheats, separate them by commas below (e.g., to enable all, use "gold,health,mana,power,raid,taxi")
# Default: taxi and raid are enabled # Default: food, taxi, and raid are enabled
AiPlayerbot.BotCheats = "food,taxi,raid" AiPlayerbot.BotCheats = "food,taxi,raid"
# #
@ -1603,10 +1603,10 @@ AiPlayerbot.PremadeSpecLink.11.6.80 = 05320021--230033312031500531353013251
# #
# #
# Applies a permanent buff to all bots simulating effects of spells, flasks, food, runes, etc. # Applies automatically refreshing buffs to bots simulating effects of spells, flasks, food, runes, etc.
# Requires sending the command "nc +worldbuff" in chat to a bot (or a group of bots) to enable # Requires sending the command "nc +worldbuff" in chat to a bot (or a group of bots) to enable
# Each entry in the matrix should be formatted as follows: Entry:FactionID,ClassID,SpecID,MinimumLevel,MaximumLevel:SpellID1,SpellID2,etc.; # Each entry in the matrix should be formatted as follows: Entry:FactionID,ClassID,SpecID,MinimumLevel,MaximumLevel:SpellID1,SpellID2,etc.;
# Use 0 for any field to make it agnostic (e.g., 0 for FactionID means the entry will apply buffs to either faction) # FactionID may be set to 0 for the entry to apply buffs to bots of either faction
# The default entries create a cross-faction list of level 80 buffs for each implemented pve spec from the "Premade Specs" section # The default entries create a cross-faction list of level 80 buffs for each implemented pve spec from the "Premade Specs" section
# The default entries may be deleted or modified, and new custom entries may be added # The default entries may be deleted or modified, and new custom entries may be added

View File

@ -688,7 +688,7 @@ bool BGLeaveAction::Execute(Event event)
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
packet << type << unk2 << (uint32)_bgTypeId << unk << uint8(0); packet << type << unk2 << (uint32)_bgTypeId << unk << uint8(0);
bot->GetSession()->HandleBattleFieldPortOpcode(packet); bot->GetSession()->QueuePacket(new WorldPacket(packet));
if (IsRandomBot) if (IsRandomBot)
botAI->SetMaster(nullptr); botAI->SetMaster(nullptr);
@ -917,7 +917,7 @@ bool BGStatusAction::Execute(Event event)
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
packet << type << unk2 << (uint32)_bgTypeId << unk << action; packet << type << unk2 << (uint32)_bgTypeId << unk << action;
bot->GetSession()->HandleBattleFieldPortOpcode(packet); bot->GetSession()->QueuePacket(new WorldPacket(packet));
botAI->ResetStrategies(false); botAI->ResetStrategies(false);
if (!bot->GetBattleground()) if (!bot->GetBattleground())
@ -972,7 +972,7 @@ bool BGStatusAction::Execute(Event event)
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
action = 0; action = 0;
packet << type << unk2 << (uint32)_bgTypeId << unk << action; packet << type << unk2 << (uint32)_bgTypeId << unk << action;
bot->GetSession()->HandleBattleFieldPortOpcode(packet); bot->GetSession()->QueuePacket(new WorldPacket(packet));
botAI->ResetStrategies(!IsRandomBot); botAI->ResetStrategies(!IsRandomBot);
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0); botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
@ -1039,7 +1039,7 @@ bool BGStatusAction::Execute(Event event)
WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20);
packet << type << unk2 << (uint32)_bgTypeId << unk << action; packet << type << unk2 << (uint32)_bgTypeId << unk << action;
bot->GetSession()->HandleBattleFieldPortOpcode(packet); bot->GetSession()->QueuePacket(new WorldPacket(packet));
botAI->ResetStrategies(false); botAI->ResetStrategies(false);
if (!bot->GetBattleground()) if (!bot->GetBattleground())

View File

@ -93,19 +93,26 @@ bool CastSpiritWalkAction::Execute(Event event)
bool SetTotemAction::Execute(Event event) bool SetTotemAction::Execute(Event event)
{ {
size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); const size_t spellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
if (spellIdsCount == 0)
return false; // early return
uint32 totemSpell = 0; uint32 totemSpell = 0;
for (int i = spellIdsCount - 1; i >= 0; --i)
// Iterate backwards to prioritize the highest-rank totem spell the bot knows
for (size_t i = spellIdsCount; i-- > 0;)
{ {
if (bot->HasSpell(totemSpellIds[i])) const uint32 spellId = totemSpellIds[i];
if (bot->HasSpell(spellId))
{ {
totemSpell = totemSpellIds[i]; totemSpell = spellId;
break; break;
} }
} }
if (!totemSpell)
if (totemSpell == 0)
return false; return false;
bot->addActionButton(actionButtonId, totemSpell, ACTION_BUTTON_SPELL); bot->addActionButton(actionButtonId, totemSpell, ACTION_BUTTON_SPELL);
return true; return true;
} }

View File

@ -424,6 +424,7 @@ bool SetTotemTrigger::IsActive()
{ {
if (!bot->HasSpell(SPELL_CALL_OF_THE_ELEMENTS)) if (!bot->HasSpell(SPELL_CALL_OF_THE_ELEMENTS))
return false; return false;
if (!bot->HasSpell(requiredSpellId)) if (!bot->HasSpell(requiredSpellId))
return false; return false;
@ -431,13 +432,20 @@ bool SetTotemTrigger::IsActive()
if (!button || button->GetType() != ACTION_BUTTON_SPELL || button->GetAction() == 0) if (!button || button->GetType() != ACTION_BUTTON_SPELL || button->GetAction() == 0)
return true; return true;
size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32); const size_t totemSpellIdsCount = sizeof(totemSpellIds) / sizeof(uint32);
for (size_t i = 0; i < totemSpellIdsCount; ++i) if (totemSpellIdsCount == 0)
{ {
if (button->GetAction() == totemSpellIds[i]) return false;
}
for (int i = (int)totemSpellIdsCount - 1; i >= 0; --i)
{
const uint32 spellId = totemSpellIds[i];
if (bot->HasSpell(spellId))
{ {
return false; return button->GetAction() != spellId;
} }
} }
return true;
return false;
} }