View Full Version : TrinityCore-Multi Trinity Core shared boss health

09-19-2016, 10:22 PM
I'm writing a custom script and I have problems with shared boss hp. Basicaly I do not know how to make 2 npcs share health. So if someone is willing to help me it would be awesome :).

09-20-2016, 02:39 PM
Sharing health in itself may not be completely trivial thing because the NPCs can have different debuffs applied to them and both in practice need to keep a separate health pool.
You should try different approaches for where you keep the actual health they have or how you manage what is the real health of the NPCs.

Here is one example:
You need to create the NPCs with the same health.
Then make an CreatureScript for them in C++.
Then in the script you should make the creatures know each other in one way or another. For example by storing the guids in the instance script or by making the creatures know each other's database guids
or by making them know each other's entries so they can make a search etc etc etc.
Then use the damage hook: void OnDamage(Unit* /*attacker*/, Unit* /*victim*/, uint32& /*damage*/) { }
and in it you can search for the NPCs and damage both of them with the given damage. Also it might be a good idea to do something like:

A, B = GetCreatures()
hp = std::min(A:GetHealth(), B:GetHealth())
Or similar to ensure they have the same health. - Note that Im unsure how such would work when one of the NPCs dies for example.

10-20-2016, 08:34 PM
Take a look at Illidari Council's code, I believe it gets the guids of the 4 NPCs, stores them and shares damage (damage / 4) between them. This is the part you should be looking at to get an idea how to do it:

void DamageTaken(Unit* done_by, uint32 &damage) override
if (done_by == me)

damage /= 4;
for (uint8 i = 0; i < 4; ++i)
if (Creature* unit = ObjectAccessor::GetCreature(*me, Council[i]))
if (unit != me && damage < unit->GetHealth())