Make boss stuck at 1 hp until it meets some condition

I’m looking foward to fix Viscidius on AQ40.

Right now the only function i thought was possible to make it stuck at 1 hp until it meets certain condition is

void DamageTaken(Unit* attacker, uint32& damage) override

making the damage = 0; when i want to make it immune to damage

but is not working. any suggestion?