From 8405b8969f205ffae219361dfc03f3b4c680ce73 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Fri, 5 Mar 2021 16:08:30 +0100 Subject: Adding Boss bar (#5025) + Add boss bar Co-authored-by: Tiger Wang --- src/Mobs/EnderDragon.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/Mobs/EnderDragon.cpp') diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp index a3ba5f937..e33fb21f1 100644 --- a/src/Mobs/EnderDragon.cpp +++ b/src/Mobs/EnderDragon.cpp @@ -2,6 +2,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "EnderDragon.h" +#include "../ClientHandle.h" +#include "../CompositeChat.h" @@ -17,6 +19,21 @@ cEnderDragon::cEnderDragon(void) : +bool cEnderDragon::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (!Super::DoTakeDamage(a_TDI)) + { + return false; + } + + m_World->BroadcastBossBarUpdateHealth(*this, GetUniqueID(), GetHealth() / GetMaxHealth()); + return true; +} + + + + + void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer) { // No drops @@ -25,3 +42,11 @@ void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cEnderDragon::SpawnOn(cClientHandle & a_Client) +{ + Super::SpawnOn(a_Client); + + // Red boss bar with no divisions that plays boss music and creates fog: + a_Client.SendBossBarAdd(GetUniqueID(), cCompositeChat("Ender Dragon"), GetHealth() / GetMaxHealth(), BossBarColor::Red, BossBarDivisionType::None, false, true, true); +} -- cgit v1.2.3