Jump to content

[11032][Patch] Automatic SetInCombatWithZone for Raid bosses


Schmoozerd

Recommended Posts

What bug does the patch fix? What features does the patch add?

Add automatic SetInCombatWithZone for Raidbosses,

either - depending on check of InstanceData (v1, 2, 3) or - depending on creature_template.flags_extra (v4)

For which repository revision was the patch created?

10986 - v4 on 11030

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

no

Who has been writing this patch? Please include either forum user names or email addresses.

me

Basic Idea:

When a RaidBoss enters combat, he uses SetInCombatWithZone.

To allow exceptions of this general rule, I added a new virtual function to InstanceData, such that the scripting library is able to control this behaviour.

Here are four different ways - they have different default behaviour.

1) The 'agressive way: http://paste2.org/p/1184405 (default: raid bosses go into combat with zone)

This way provides this feature also without scripting library, but needs to adjust (very reasonable I think) the SetInCombatWithZone function to prevent unexpected behaviour.

2) A moderate way: http://paste2.org/p/1184408 (default: raid bosses go into combat with zone, _if_ the map is scripted)

This way needs rather fast exceptions for bosses that shouldn't behave this way, however it can be changed to a better default behaviour, if we add for this case the change in SetInCombatWithZone(), too

3) A conservative way: http://paste2.org/p/1184411 (default: raid bosses go into combat with zone, _if_ the map is scripted AND the script returns true)

This way must explicit add a raid to allow this behaviour, hence should be bug-free "out of the box" (when scripted), however this would require (pointless) return true for the instances..

I personally think way 1) is the best choice, because this is the generic behaviour that should be modelled, also if this _might_ have a bug temporarily(until scripted proper) for older instances.

However I looked over raids and their bosses and didn't see any possible bug for this solution.

--

4) New version, using some flags_extra (thanks to NF for the idea)

diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index a7d62a9..d37e575 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1985,7 +1985,7 @@ void Creature::SetInCombatWithZone()
            if (pPlayer->isGameMaster())
                continue;

-            if (pPlayer->isAlive())
+            if (pPlayer->isAlive() && !IsFriendlyTo(pPlayer))
            {
                pPlayer->SetInCombatWith(this);
                AddThreat(pPlayer);
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 95076db..563ccb5 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -52,6 +52,7 @@ enum CreatureFlagsExtra
    CREATURE_FLAG_EXTRA_NO_XP_AT_KILL   = 0x00000040,       // creature kill not provide XP
    CREATURE_FLAG_EXTRA_INVISIBLE       = 0x00000080,       // creature is always invisible for player (mostly trigger creatures)
    CREATURE_FLAG_EXTRA_NOT_TAUNTABLE   = 0x00000100,       // creature is immune to taunt auras and effect attack me
+    CREATURE_FLAG_EXTRA_AGGRO_ZONE      = 0x00000200,       // creature sets itself in combat with zone on aggro
};

// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 3a42cbf..bf04237 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -7711,11 +7711,17 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
        if (getStandState() == UNIT_STAND_STATE_CUSTOM)
            SetStandState(UNIT_STAND_STATE_STAND);

-        if (((Creature*)this)->AI())
-            ((Creature*)this)->AI()->EnterCombat(enemy);
+        Creature* pCreature = (Creature*)this;
+
+        if (pCreature->AI())
+            pCreature->AI()->EnterCombat(enemy);
+
+        // Some bosses are set into combat with zone
+        if (GetMap()->IsDungeon() && pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE)
+            pCreature->SetInCombatWithZone();

        if (InstanceData* mapInstance = GetInstanceData())
-            mapInstance->OnCreatureEnterCombat((Creature*)this);
+            mapInstance->OnCreatureEnterCombat(pCreature);
    }
}

Testing ie MoltenCore with: UPDATE creature_template SET flags_extra = flags_extra | 512 WHERE entry IN (12098, 12056, 12057, 12264, 12118, 11982, 11988, 12259, 12018);

Link to comment
Share on other sites

Thank you for the idea, bump with it.

Also added the IsFriendlyTo check (in better way as suggested by vladimir) to SetInCombatWithZone to prevent possible bugs (in _very_ rare case that a boss turns friendly by script, should before SetTheCombatInZone, and enters combat with some other NPCs :P)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use