Skip to content

Commit

Permalink
NPCBots v5.4.195a. Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer committed May 20, 2024
1 parent 56be2b4 commit b889b12
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 92 deletions.
108 changes: 57 additions & 51 deletions AC/NPCBots.patch
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
src/server/game/AI/CreatureAI.h | 5 +
src/server/game/AI/NpcBots/bot_Events.h | 74 +
src/server/game/AI/NpcBots/bot_GridNotifiers.h | 1408 ++
src/server/game/AI/NpcBots/bot_ai.cpp | 19934 +++++++++++++++++++
src/server/game/AI/NpcBots/bot_ai.cpp | 19937 +++++++++++++++++++
src/server/game/AI/NpcBots/bot_ai.h | 809 +
src/server/game/AI/NpcBots/bot_archmage_ai.cpp | 417 +
src/server/game/AI/NpcBots/bot_bm_ai.cpp | 962 +
Expand Down Expand Up @@ -103,7 +103,7 @@
src/server/game/AI/NpcBots/botgearscore.h | 16 +
src/server/game/AI/NpcBots/botgiver.cpp | 287 +
src/server/game/AI/NpcBots/botgossip.h | 141 +
src/server/game/AI/NpcBots/botmgr.cpp | 2981 +++
src/server/game/AI/NpcBots/botmgr.cpp | 2982 +++
src/server/game/AI/NpcBots/botmgr.h | 346 +
src/server/game/AI/NpcBots/botspell.cpp | 1899 ++
src/server/game/AI/NpcBots/botspell.h | 317 +
Expand Down Expand Up @@ -157,7 +157,7 @@
src/server/game/Entities/Totem/Totem.cpp | 25 +
src/server/game/Entities/Transport/Transport.cpp | 11 +
src/server/game/Entities/Unit/StatSystem.cpp | 56 +
src/server/game/Entities/Unit/Unit.cpp | 1515 +-
src/server/game/Entities/Unit/Unit.cpp | 1517 +-
src/server/game/Entities/Unit/Unit.h | 67 +-
src/server/game/Entities/Vehicle/Vehicle.cpp | 44 +
src/server/game/Entities/Vehicle/Vehicle.h | 6 +
Expand Down Expand Up @@ -215,7 +215,7 @@
src/server/shared/DataStores/DBCStructure.h | 6 +-
src/server/shared/DataStores/DBCfmt.h | 2 +-
src/server/shared/SharedDefines.h | 23 +
217 files changed, 94146 insertions(+), 73 deletions(-)
217 files changed, 94152 insertions(+), 73 deletions(-)
create mode 100644 data/sql/Bots/locales/deDE/npc_text_locale.sql
create mode 100644 data/sql/Bots/locales/esES/npc_text_locale.sql
create mode 100644 data/sql/Bots/locales/esMX/npc_text_locale.sql
Expand Down Expand Up @@ -12881,7 +12881,7 @@ index 0000000000..ad440f8312
+UPDATE `npc_text` SET `text0_0`='You exceed max npcbots for your level (%u)' WHERE (`ID`='70532');
diff --git a/data/sql/custom/db_world/2024_03_19_00_npc_text.sql b/data/sql/custom/db_world/2024_03_19_00_npc_text.sql
new file mode 100644
index 0000000000..d69d525675
index 0000000000..c0904d4f71
--- /dev/null
+++ b/data/sql/custom/db_world/2024_03_19_00_npc_text.sql
@@ -0,0 +1,17 @@
Expand All @@ -12895,7 +12895,7 @@ index 0000000000..d69d525675
+(70675,'Stormwind','-1'),
+(70676,'Ironforge','-1'),
+(70677,'Darnassus','-1'),
+(70678,'Exordar','-1'),
+(70678,'Exodar','-1'),
+(70679,'Orgrimmar','-1'),
+(70680,'Undercity','-1'),
+(70681,'Thunder Bluff','-1'),
Expand Down Expand Up @@ -15102,10 +15102,10 @@ index 0000000000..fdda703289
+#endif
diff --git a/src/server/game/AI/NpcBots/bot_ai.cpp b/src/server/game/AI/NpcBots/bot_ai.cpp
new file mode 100644
index 0000000000..dd06908628
index 0000000000..a3bb09c27d
--- /dev/null
+++ b/src/server/game/AI/NpcBots/bot_ai.cpp
@@ -0,0 +1,19934 @@
@@ -0,0 +1,19937 @@
+#include "Battleground.h"
+#include "BattlegroundAB.h"
+#include "BattlegroundAV.h"
Expand Down Expand Up @@ -15728,8 +15728,11 @@ index 0000000000..dd06908628
+ me->ReplaceAllUnitFlags2(UnitFlags2(me->GetCreatureTemplate()->unit_flags2));
+ }
+
+ if (resetType == BOTAI_RESET_DISMISS && !IsTempBot())
+ if ((resetType == BOTAI_RESET_DISMISS || resetType == BOTAI_RESET_LOGOUT) && !IsTempBot())
+ {
+ EnableAllSpells();
+ InitRoles();
+ }
+
+ //me->IsAIEnabled = true;
+ canUpdate = true;
Expand Down Expand Up @@ -75104,10 +75107,10 @@ index 0000000000..96bb60f9db
+#endif //BOTGOSSIP_H
diff --git a/src/server/game/AI/NpcBots/botmgr.cpp b/src/server/game/AI/NpcBots/botmgr.cpp
new file mode 100644
index 0000000000..8352a166fa
index 0000000000..18f6cedf4c
--- /dev/null
+++ b/src/server/game/AI/NpcBots/botmgr.cpp
@@ -0,0 +1,2981 @@
@@ -0,0 +1,2982 @@
+#include "Battleground.h"
+#include "BattlegroundMgr.h"
+#include "bot_ai.h"
Expand Down Expand Up @@ -76627,6 +76630,7 @@ index 0000000000..8352a166fa
+ bot->GetBotAI()->UnsummonAll();
+ bot->AttackStop();
+ bot->CombatStopWithPets(true);
+ bot->getHostileRefMgr().deleteReferences();
+
+ //bot->SetOwnerGUID(ObjectGuid::Empty);
+ //_owner->m_Controlled.erase(bot);
Expand Down Expand Up @@ -92950,7 +92954,7 @@ index f2191b39ef..2baa223ecb 100644
float totalPct = addTotalPct ? GetModifierValue(unitMod, TOTAL_PCT) : 1.0f;
float dmgMultiplier = GetCreatureTemplate()->DamageModifier; // = DamageModifier * _GetDamageMod(rank);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 9cc2e85e31..b7f44a43cf 100644
index 9cc2e85e31..6163dee1b7 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -72,6 +72,11 @@
Expand Down Expand Up @@ -94948,37 +94952,39 @@ index 9cc2e85e31..b7f44a43cf 100644
}
}

@@ -19051,6 +20204,14 @@ bool Unit::IsInPartyWith(Unit const* unit) const
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) ||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup()))
@@ -19042,6 +20195,15 @@ bool Unit::IsInPartyWith(Unit const* unit) const
if (u1 == u2)
return true;

+ //npcbot
+ else if (u1->IsPlayer() && u2->IsNPCBot())
+ return u1->ToPlayer()->GetBotMgr()->GetBot(u2->GetGUID()) || (u1->ToPlayer()->GetGroup() && u2->ToCreature()->GetBotGroup() && u1->ToPlayer()->GetSubGroup() == u2->ToCreature()->GetSubGroup());
+ else if (u2->IsPlayer() && u1->IsNPCBot())
+ return u2->ToPlayer()->GetBotMgr()->GetBot(u1->GetGUID()) || (u2->ToPlayer()->GetGroup() && u1->ToCreature()->GetBotGroup() && u2->ToPlayer()->GetSubGroup() == u1->ToCreature()->GetSubGroup());
+ else if (u1->IsNPCBot() && u2->IsNPCBot() && u1->ToCreature()->GetBotGroup() && u1->ToCreature()->GetBotGroup() == u2->ToCreature()->GetBotGroup())
+ Player const* pla = u1->IsPlayer() ? u1->ToPlayer() : u2->IsPlayer() ? u2->ToPlayer() : nullptr;
+ Creature const* bot = u1->IsNPCBot() ? u1->ToCreature() : u2->IsNPCBot() ? u2->ToCreature() : nullptr;
+ if (pla && bot)
+ return (pla->GetGroup() && pla->GetGroup() == bot->GetBotGroup()) ? pla->GetSubGroup() == bot->GetSubGroup() : !!pla->GetBotMgr()->GetBot(bot->GetGUID());
+ if (u1->IsNPCBot() && u2->IsNPCBot() && u1->ToCreature()->GetBotGroup() && u1->ToCreature()->GetBotGroup() == u2->ToCreature()->GetBotGroup())
+ return u1->ToCreature()->GetSubGroup() == u2->ToCreature()->GetSubGroup();
+ //end npcbot
else
return false;
}
@@ -19073,6 +20234,14 @@ bool Unit::IsInRaidWith(Unit const* unit) const
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) ||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
+
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer());
// Xinef: we assume that npcs with the same faction are in party
@@ -19065,6 +20227,15 @@ bool Unit::IsInRaidWith(Unit const* unit) const
if (u1 == u2)
return true;

+ //npcbot
+ else if (u1->IsPlayer() && u2->IsNPCBot())
+ return u1->ToPlayer()->GetBotMgr()->GetBot(u2->GetGUID()) || (u1->ToPlayer()->GetGroup() && u1->ToPlayer()->GetGroup() == u2->ToCreature()->GetBotGroup());
+ else if (u2->IsPlayer() && u1->IsNPCBot())
+ return u2->ToPlayer()->GetBotMgr()->GetBot(u1->GetGUID()) || (u2->ToPlayer()->GetGroup() && u2->ToPlayer()->GetGroup() == u1->ToCreature()->GetBotGroup());
+ else if (u1->IsNPCBot() && u2->IsNPCBot() && u1->ToCreature()->GetBotGroup())
+ Player const* pla = u1->IsPlayer() ? u1->ToPlayer() : u2->IsPlayer() ? u2->ToPlayer() : nullptr;
+ Creature const* bot = u1->IsNPCBot() ? u1->ToCreature() : u2->IsNPCBot() ? u2->ToCreature() : nullptr;
+ if (pla && bot)
+ return (pla->GetGroup() && pla->GetGroup() == bot->GetBotGroup()) ? true : !!pla->GetBotMgr()->GetBot(bot->GetGUID());
+ if (u1->IsNPCBot() && u2->IsNPCBot() && u1->ToCreature()->GetBotGroup())
+ return u1->ToCreature()->GetBotGroup() == u2->ToCreature()->GetBotGroup();
+ //end npcbot
else
return false;
}
@@ -19084,9 +20253,21 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
+
if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER)
return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer());
// Xinef: we assume that npcs with the same faction are in party
@@ -19084,9 +20255,21 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
if (owner->GetTypeId() == TYPEID_PLAYER)
group = owner->ToPlayer()->GetGroup();

Expand All @@ -95000,7 +95006,7 @@ index 9cc2e85e31..b7f44a43cf 100644

for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
@@ -19106,6 +20287,14 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
@@ -19106,6 +20289,14 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
}
}
}
Expand All @@ -95015,7 +95021,7 @@ index 9cc2e85e31..b7f44a43cf 100644
}
else
{
@@ -19118,6 +20307,18 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
@@ -19118,6 +20309,18 @@ void Unit::GetPartyMembers(std::list<Unit*>& TagUnitMap)
if (pet->IsGuardian() && pet->IsAlive())
TagUnitMap.push_back(pet);
}
Expand All @@ -95034,7 +95040,7 @@ index 9cc2e85e31..b7f44a43cf 100644
}
}

@@ -19130,6 +20331,10 @@ Aura* Unit::AddAura(uint32 spellId, Unit* target)
@@ -19130,6 +20333,10 @@ Aura* Unit::AddAura(uint32 spellId, Unit* target)
if (!spellInfo)
return nullptr;

Expand All @@ -95045,7 +95051,7 @@ index 9cc2e85e31..b7f44a43cf 100644
if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR2_ALLOW_DEAD_TARGET))
return nullptr;

@@ -19185,6 +20390,13 @@ void Unit::SendPlaySpellImpact(ObjectGuid guid, uint32 id)
@@ -19185,6 +20392,13 @@ void Unit::SendPlaySpellImpact(ObjectGuid guid, uint32 id)
SendMessageToSet(&data, true);
}

Expand All @@ -95059,7 +95065,7 @@ index 9cc2e85e31..b7f44a43cf 100644
void Unit::ApplyResilience(Unit const* victim, float* crit, int32* damage, bool isCrit, CombatRating type)
{
// player mounted on multi-passenger mount is also classified as vehicle
@@ -19249,6 +20461,11 @@ void Unit::ApplyResilience(Unit const* victim, float* crit, int32* damage, bool
@@ -19249,6 +20463,11 @@ void Unit::ApplyResilience(Unit const* victim, float* crit, int32* damage, bool
float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
{
SpellInfo const* spellInfo = spellId ? sSpellMgr->GetSpellInfo(spellId) : nullptr;
Expand All @@ -95071,7 +95077,7 @@ index 9cc2e85e31..b7f44a43cf 100644
if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR7_NO_ATTACK_MISS))
{
return 0.0f;
@@ -19257,6 +20474,16 @@ float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, i
@@ -19257,6 +20476,16 @@ float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, i
//calculate miss chance
float missChance = victim->GetUnitMissChance(attType);

Expand All @@ -95088,7 +95094,7 @@ index 9cc2e85e31..b7f44a43cf 100644
// Check if dual wielding, add additional miss penalty - when mainhand has on next swing spell, offhand doesnt suffer penalty
if (!spellId && (attType != RANGED_ATTACK) && haveOffhandWeapon() && (!m_currentSpells[CURRENT_MELEE_SPELL] || !m_currentSpells[CURRENT_MELEE_SPELL]->IsNextMeleeSwingSpell()))
{
@@ -19371,6 +20598,11 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
@@ -19371,6 +20600,11 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
}
}

Expand All @@ -95100,7 +95106,7 @@ index 9cc2e85e31..b7f44a43cf 100644
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
{
if (m_SummonSlot[i])
@@ -19444,6 +20676,10 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const
@@ -19444,6 +20678,10 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const
{
if (Player const* player = ToPlayer())
return player->GetRatingBonusValue(cr);
Expand All @@ -95111,7 +95117,7 @@ index 9cc2e85e31..b7f44a43cf 100644
// Player's pet get resilience from owner
else if (IsPet() && GetOwner())
if (Player* owner = GetOwner()->ToPlayer())
@@ -19645,6 +20881,183 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const
@@ -19645,6 +20883,183 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const
break;
}
}
Expand Down Expand Up @@ -95295,7 +95301,7 @@ index 9cc2e85e31..b7f44a43cf 100644

uint32 modelid = 0;
SpellShapeshiftEntry const* formEntry = sSpellShapeshiftStore.LookupEntry(form);
@@ -20236,6 +21649,10 @@ bool Unit::CanSwim() const
@@ -20236,6 +21651,10 @@ bool Unit::CanSwim() const
return false;
if (HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT))
return true;
Expand All @@ -95306,7 +95312,7 @@ index 9cc2e85e31..b7f44a43cf 100644
return HasUnitFlag(UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
}

@@ -20319,6 +21736,11 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
@@ -20319,6 +21738,11 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
UpdateObjectVisibility(false);
}

Expand All @@ -95318,7 +95324,7 @@ index 9cc2e85e31..b7f44a43cf 100644
return (relocated || turn);
}

@@ -20459,6 +21881,19 @@ void Unit::StopAttackFaction(uint32 faction_id)
@@ -20459,6 +21883,19 @@ void Unit::StopAttackFaction(uint32 faction_id)

for (ControlSet::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
(*itr)->StopAttackFaction(faction_id);
Expand All @@ -95338,7 +95344,7 @@ index 9cc2e85e31..b7f44a43cf 100644
}

void Unit::StopAttackingInvalidTarget()
@@ -21057,6 +22492,10 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
@@ -21057,6 +22494,10 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)

if (plr && plr->IsInSameRaidWith(target))
visibleFlag |= UF_FLAG_PARTY_MEMBER;
Expand All @@ -95349,7 +95355,7 @@ index 9cc2e85e31..b7f44a43cf 100644

uint64 cacheKey = static_cast<uint64>(visibleFlag) << 8 | updateType;

@@ -21294,6 +22733,17 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi
@@ -21294,6 +22735,17 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi
{
valuesUpdateBuf.put(posPointers.UnitFieldBytes2Pos, (m_uint32Values[UNIT_FIELD_BYTES_2] & 0xFFFFF2FF)); // clear UNIT_BYTE2_FLAG_PVP, UNIT_BYTE2_FLAG_FFA_PVP, UNIT_BYTE2_FLAG_SANCTUARY
}
Expand All @@ -95367,7 +95373,7 @@ index 9cc2e85e31..b7f44a43cf 100644
}

// UNIT_FIELD_FACTIONTEMPLATE
@@ -21312,6 +22762,15 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi
@@ -21312,6 +22764,15 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi
{
valuesUpdateBuf.put(posPointers.UnitFieldFactionTemplatePos, uint32(target->GetFaction()));
}
Expand All @@ -95383,7 +95389,7 @@ index 9cc2e85e31..b7f44a43cf 100644
}

sScriptMgr->OnPatchValuesUpdate(this, valuesUpdateBuf, posPointers, target);
@@ -21632,6 +23091,52 @@ bool Unit::IsInDisallowedMountForm() const
@@ -21632,6 +23093,52 @@ bool Unit::IsInDisallowedMountForm() const
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion AC/SQL/updates/world/2024_03_19_00_npc_text.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INSERT INTO `npc_text` (`ID`,`text0_0`,`VerifiedBuild`) VALUES
(70675,'Stormwind','-1'),
(70676,'Ironforge','-1'),
(70677,'Darnassus','-1'),
(70678,'Exordar','-1'),
(70678,'Exodar','-1'),
(70679,'Orgrimmar','-1'),
(70680,'Undercity','-1'),
(70681,'Thunder Bluff','-1'),
Expand Down
Loading

0 comments on commit b889b12

Please sign in to comment.