Skip to content

Commit

Permalink
NPCBots: Do not scale controlled creatures for other mods compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer committed Feb 26, 2024
1 parent f135a6a commit c25441c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/AutoBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@ bool isCreatureRelevant(Creature* creature) {
return false;
if (creature->IsNPCBotOrPet())
return false;
if (creature->IsControlledByPlayer())
return false;
//end npcbot

// if this creature isn't assigned to a map, make no changes
Expand Down Expand Up @@ -2160,6 +2162,8 @@ void AddCreatureToMapCreatureList(Creature* creature, bool addToCreatureList = t
return;
if (creature->IsNPCBotOrPet())
return;
if (creature->IsControlledByPlayer())
return;
//end npcbot

// make sure we have a creature and that it's assigned to a map
Expand Down Expand Up @@ -2555,6 +2559,8 @@ void RemoveCreatureFromMapData(Creature* creature)
//npcbot
if (creature->IsNPCBotOrPet())
return;
if (creature->IsControlledByPlayer())
return;
//end npcbot

// get map data
Expand Down Expand Up @@ -3855,7 +3861,7 @@ class AutoBalance_UnitScript : public UnitScript
void ModifyPeriodicDamageAurasTick(Unit* target, Unit* source, uint32& amount, SpellInfo const* spellInfo) override
{
//npcbot
if (source && source->IsNPCBotOrPet())
if (source && (source->IsNPCBotOrPet() || source->IsControlledByPlayer()))
return;
//end npcbot

Expand All @@ -3880,7 +3886,7 @@ class AutoBalance_UnitScript : public UnitScript
void ModifySpellDamageTaken(Unit* target, Unit* source, int32& amount, SpellInfo const* spellInfo) override
{
//npcbot
if (source && source->IsNPCBotOrPet())
if (source && (source->IsNPCBotOrPet() || source->IsControlledByPlayer()))
return;
//end npcbot

Expand All @@ -3905,7 +3911,7 @@ class AutoBalance_UnitScript : public UnitScript
void ModifyMeleeDamage(Unit* target, Unit* source, uint32& amount) override
{
//npcbot
if (source && source->IsNPCBotOrPet())
if (source && (source->IsNPCBotOrPet() || source->IsControlledByPlayer()))
return;
//end npcbot

Expand All @@ -3928,7 +3934,7 @@ class AutoBalance_UnitScript : public UnitScript
void ModifyHealReceived(Unit* target, Unit* source, uint32& amount, SpellInfo const* spellInfo) override
{
//npcbot
if (source && source->IsNPCBotOrPet())
if (source && (source->IsNPCBotOrPet() || source->IsControlledByPlayer()))
return;
//end npcbot

Expand All @@ -3947,7 +3953,7 @@ class AutoBalance_UnitScript : public UnitScript

void OnAuraApply(Unit* unit, Aura* aura) override {
//npcbot
if (aura->GetCaster() && aura->GetCaster()->IsNPCBotOrPet())
if (aura->GetCaster() && (aura->GetCaster()->IsNPCBotOrPet() || aura->GetCaster()->IsControlledByPlayer()))
return;
//end npcbot

Expand Down Expand Up @@ -5223,7 +5229,8 @@ class AutoBalance_AllCreatureScript : public AllCreatureScript
void OnAllCreatureUpdate(Creature* creature, uint32 /*diff*/) override
{
//npcbot
if (!creature || !creature->FindMap() || creature->IsNPCBotOrPet())
if (!creature || !creature->FindMap() || creature->IsNPCBotOrPet() || creature->IsControlledByPlayer())
return;
//end npcbot

// ensure we're in a dungeon with a creature
Expand Down Expand Up @@ -5363,7 +5370,7 @@ class AutoBalance_AllCreatureScript : public AllCreatureScript
// mana
if (creature->getPowerType() == POWER_MANA && creature->GetPower(POWER_MANA) >= 0 && creature->GetMaxPower(POWER_MANA) > 0)
{
float currentManaPercent = creature->GetPower(POWER_MANA) / creature->GetMaxPower(POWER_MANA);
float currentManaPercent = float(creature->GetPower(POWER_MANA)) / creature->GetMaxPower(POWER_MANA);
creature->SetMaxPower(POWER_MANA, origCreatureBaseStats->GenerateMana(creatureTemplate));
creature->SetPower(POWER_MANA, creature->GetMaxPower(POWER_MANA) * currentManaPercent);
}
Expand Down Expand Up @@ -5396,7 +5403,7 @@ class AutoBalance_AllCreatureScript : public AllCreatureScript
void ModifyCreatureAttributes(Creature* creature)
{
//npcbot
if (!creature || !creature->FindMap() || creature->IsNPCBotOrPet())
if (!creature || !creature->FindMap() || creature->IsNPCBotOrPet() || creature->IsControlledByPlayer())
return;
//end npcbot

Expand Down

0 comments on commit c25441c

Please sign in to comment.