Skip to content

Commit

Permalink
NPCBots: Revert (mostly) pet temporary unsummoning. Increase timed su…
Browse files Browse the repository at this point in the history
…mmons duration for free bots
  • Loading branch information
trickerer committed Aug 13, 2024
1 parent 872c62d commit 1f850c2
Show file tree
Hide file tree
Showing 19 changed files with 11 additions and 162 deletions.
91 changes: 3 additions & 88 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15789,108 +15789,24 @@ void bot_ai::KilledUnit(Unit* u)
}
}

void bot_ai::UnsummonCreature(Creature* creature, bool save)
void bot_ai::UnsummonCreature(Creature* creature, bool /*save*/)
{
if (creature)
{
bot_pet_ai* petai = creature->GetBotPetAI();

if (save && !petai)
{
LOG_WARN("npcbots", "bot_ai::Unsummon: Trying to save creature {} (id: {}) which isn't a bot pet! Unsummoning instead.", creature->GetName(), creature->GetEntry());
save = false;
}

if (!save)
{
if (!creature->FindMap() || !creature->IsInWorld())
{
Map* newmap = nullptr;
if (!IAmFree() && master->IsInWorld())
{
newmap = master->GetMap();
creature->Relocate(master);
}
else
{
newmap = ASSERT_NOTNULL(sMapMgr->FindMap(1, 0));
creature->Relocate(5470.f, -3800.f, 1611.f); // Hyjal
}

if (creature->FindMap())
creature->ResetMap();
creature->SetMap(newmap);
newmap->AddToMap(creature);
}

ASSERT_NOTNULL(creature->ToTempSummon())->UnSummon();
return;
}

if (petai)
if (bot_pet_ai* petai = creature->GetBotPetAI())
{
petai->KillEvents(true);
petai->canUpdate = false;
}

creature->m_Events.KillAllEvents(false);
Map* petmap = creature->FindMap();
if (petmap)
{
if (creature->IsInWorld())
{
creature->RemoveFromWorld();
creature->BotStopMovement();
creature->RemoveAurasByType(SPELL_AURA_MOD_STUN);
creature->RemoveAurasByType(SPELL_AURA_MOD_FEAR);
creature->RemoveAurasByType(SPELL_AURA_MOD_CONFUSE);
creature->RemoveAurasByType(SPELL_AURA_MOD_ROOT);
creature->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED);
creature->InterruptNonMeleeSpells(true);
creature->RemoveAllGameObjects();
creature->CombatStop();
creature->ClearComboPoints();
creature->ClearComboPointHolders();
}

if (creature->IsInGrid())
petmap->RemoveFromMap(creature, false);
}
ASSERT_NOTNULL(creature->ToTempSummon())->UnSummon();
}
}
void bot_ai::UnsummonPet(bool save)
{
UnsummonCreature(botPet, save);
}

void bot_ai::ResummonCreature(Creature* creature)
{
if (creature)
{
if (creature->FindMap())
creature->ResetMap();
creature->SetMap(me->GetMap());

Position pos;
bot_pet_ai* petai = creature->GetBotPetAI();
if (petai)
petai->CalculatePetsOwnerFollowPosition(pos);
else
pos.Relocate(me);

creature->Relocate(pos);
if (!creature->IsInGrid())
me->GetMap()->AddToMap(creature);

if (petai)
petai->canUpdate = true;
}
}
void bot_ai::ResummonPet()
{
ResummonCreature(botPet);
}

void bot_ai::MoveInLineOfSight(Unit* /*u*/)
{
}
Expand Down Expand Up @@ -18496,7 +18412,6 @@ bool bot_ai::FinishTeleport(bool reset)
this->Reset();
//bot->SetAI(oldAI);
//me->IsAIEnabled = true;
ResummonAll();
canUpdate = true;
outdoorsTimer = 0;

Expand Down
10 changes: 0 additions & 10 deletions src/server/game/AI/NpcBots/bot_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,6 @@ class bot_ai : public CreatureAI
UnsummonCreature(c, save);
}

virtual void ResummonAll() {}
void ResummonCreature(Creature* creature);
void ResummonPet();
template<typename C>
void ResummonCreatures(C const& container)
{
for (auto c : container)
ResummonCreature(c);
}

virtual void OnBotDamageTaken(Unit* /*attacker*/, uint32 /*damage*/, CleanDamage const* /*cleanDamage*/, DamageEffectType /*damagetype*/, SpellInfo const* /*spellInfo*/) {}
virtual void OnBotDamageDealt(Unit* /*victim*/, uint32 /*damage*/, CleanDamage const* /*cleanDamage*/, DamageEffectType /*damagetype*/, SpellInfo const* /*spellInfo*/) {}
virtual void OnBotDispelDealt(Unit* /*dispelled*/, uint8 /*num*/) {}
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_archmage_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ class archmage_bot : public CreatureScript
botPet = nullptr;
}

void ResummonAll() override
{
ResummonPet();
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_crypt_lord_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,6 @@ class crypt_lord_bot : public CreatureScript
}
}

void ResummonAll() override
{
ResummonCreatures(_minions);
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_dark_ranger_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,6 @@ class dark_ranger_bot : public CreatureScript
_minions.erase(summon);
}

void ResummonAll() override
{
ResummonCreatures(_minions);
}

float GetSpellAttackRange(bool longRange) const override
{
return longRange ? CalcSpellMaxRange(BLACK_ARROW_1) - 5.f : 15.f;
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_death_knight_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,11 +1720,6 @@ class death_knight_bot : public CreatureScript
}
}

void ResummonAll() override
{
ResummonPet();
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_dreadlord_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,6 @@ class dreadlord_bot : public CreatureScript
botPet = nullptr;
}

void ResummonAll() override
{
ResummonPet();
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_hunter_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,11 +1931,6 @@ class hunter_bot : public CreatureScript
}
}

void ResummonAll() override
{
ResummonPet();
}

float GetSpellAttackRange(bool longRange) const override
{
return longRange ? CalcSpellMaxRange(AUTO_SHOT_1) : 25.f;
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_mage_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,11 +1594,6 @@ class mage_bot : public CreatureScript
botPet = nullptr;
}

void ResummonAll() override
{
ResummonPet();
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_necromancer_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ class necromancer_bot : public CreatureScript
_minions.erase(summon);
}

void ResummonAll() override
{
ResummonCreatures(_minions);
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_priest_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1754,11 +1754,6 @@ class priest_bot : public CreatureScript
botPet = nullptr;
}

void ResummonAll() override
{
ResummonPet();
}

uint32 GetAIMiscValue(uint32 data) const override
{
switch (data)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_sea_witch_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,6 @@ class sea_witch_bot : public CreatureScript
_minions.erase(summon);
}

void ResummonAll() override
{
ResummonCreatures(_minions);
}

float GetSpellAttackRange(bool longRange) const override
{
return longRange ? CalcSpellMaxRange(FROST_ARROW_1) - 6.f : CalcSpellMaxRange(FROST_ARROW_1) - 15.f;
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/AI/NpcBots/bot_warlock_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1818,11 +1818,6 @@ class warlock_bot : public CreatureScript
}
}

void ResummonAll() override
{
ResummonPet();
}

float GetSpellAttackRange(bool longRange) const override
{
return longRange ? CalcSpellMaxRange(SHADOW_BOLT_1) : 20.f;
Expand Down
1 change: 0 additions & 1 deletion src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,6 @@ void BotMgr::_teleportBot(Creature* bot, Map* newMap, float x, float y, float z,
botai->Reset();
botai->SetIsDuringTeleport(false);
botai->ResetContestedPvP();
botai->ResummonAll();

if (newMap->IsBattleground())
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bpet_archmage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class archmage_pet_bot : public CreatureScript

void UpdateAI(uint32 diff) override
{
if ((liveTimer += diff) >= uint32(IAmFree() ? (1 * HOUR * IN_MILLISECONDS) : ELEMENTAL_DURATION))
if ((liveTimer += diff) >= ELEMENTAL_DURATION * (IAmFree() ? 60u : 1u))
{
canUpdate = false;
me->setDeathState(DeathState::JustDied);
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/AI/NpcBots/bpet_dark_ranger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum DarkRangerPetSpecial
{
SPELL_GENERATE_THREAT = 23604, //reduce threat
THREAT_BASE = 5,
MINION_DURATION = 160000
MINION_DURATION = 80000
};

class dark_ranger_pet_bot : public CreatureScript
Expand Down Expand Up @@ -69,7 +69,7 @@ class dark_ranger_pet_bot : public CreatureScript

void UpdateAI(uint32 diff) override
{
if ((liveTimer += diff) >= MINION_DURATION)
if ((liveTimer += diff) >= MINION_DURATION * (IAmFree() ? 5u : 1u))
{
canUpdate = false;
me->setDeathState(DeathState::JustDied);
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/AI/NpcBots/bpet_dreadlord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum DreadlordPetSpecial
{
IMMOLATION_DAMAGE = 35959,

INFERNAL_DURATION = 180000 - 2000 //3 min
INFERNAL_DURATION = 180000 //3 min
};

class dreadlord_pet_bot : public CreatureScript
Expand Down Expand Up @@ -59,7 +59,7 @@ class dreadlord_pet_bot : public CreatureScript

void UpdateAI(uint32 diff) override
{
if ((liveTimer += diff) >= INFERNAL_DURATION)
if ((liveTimer += diff) >= INFERNAL_DURATION * (IAmFree() ? 20u : 1u) - 2000u)
{
canUpdate = false;
me->setDeathState(DeathState::JustDied);
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/AI/NpcBots/bpet_mage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum MagePetBaseSpells

enum MagePetSpecial
{
ELEMENTAL_DURATION = 90000
ELEMENTAL_DURATION = 45000
};

class mage_pet_bot : public CreatureScript
Expand Down Expand Up @@ -75,7 +75,7 @@ class mage_pet_bot : public CreatureScript

void UpdateAI(uint32 diff) override
{
if ((liveTimer += diff) >= uint32(IAmFree() ? (1 * HOUR * IN_MILLISECONDS) : ELEMENTAL_DURATION))
if ((liveTimer += diff) >= ELEMENTAL_DURATION * (IAmFree() ? 80u : 1u))
{
canUpdate = false;
me->ToTempSummon()->UnSummon(1);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bpet_necromancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum NecromancerPetPassives
enum NecromancerPetSpecial
{
THREAT_BASE = 5,
MINION_DURATION = 130000
MINION_DURATION = 65000
};

class necromancer_pet_bot : public CreatureScript
Expand Down

0 comments on commit 1f850c2

Please sign in to comment.