Here's my take on this:
If the divine save check is successful then you're always saved, which sets HP to 1 and casts spell 4789. I didn't look at the spell, but based on the comments by default it's an invulnerability effect and removes detrimental effects, so at least you don't die immediately again.
If there are any additional effects setup in the appropriate AA/item/spell fields, then they are cast in that order until one succeeds and then the rest are skipped. I use the return value from SpellOnTarget to decide if the cast was successful which the original code didn't do. I'm not sure if this is a good idea or not. On the plus side if the spell is bogus or can't be cast on that target then the rest of the effects are still checked, but it might be open to abuse if it is possible to block the spell using blocked buffs to force a lower priority effect to be used.
Anyway, I didn't test this, but it's a thought to how it might look:
Code:
bool Mob::TryDivineSave()
{
/*
How Touch of the Divine AA works:
-Gives chance to avoid death when client is killed.
-Chance is determined by the sum of AA/item/spell chances.
-If the chance is met a divine aura like effect 'Touch of the Divine' is applied to the client removing detrimental spell effects.
-If desired, an additional spell can be triggered from the AA/item/spell effect, generally a heal.
Only one additional effect will be triggered in the order of AA/item/spell. Once an effect has been cast the rest are skipped.
*/
sint32 SuccessChance = aabonuses.DivineSaveChance[0] + itembonuses.DivineSaveChance[0] + spellbonuses.DivineSaveChance[0];
if (SuccessChance && MakeRandomInt(0, 100) <= SuccessChance)
{
SetHP(1);
int16 EffectsToTry[] =
{
aabonuses.DivineSaveChance[1],
itembonuses.DivineSaveChance[1],
spellbonuses.DivineSaveChance[1]
};
//Fade the divine save effect here after saving the old effects off.
//That way, if desired, the effect could apply SE_DivineSave again.
BuffFadeByEffect(SE_DivineSave);
for(size_t i = 0; i < ( sizeof(EffectsToTry) / sizeof(EffectsToTry[0]) ); ++i)
{
if( EffectsToTry[i] && SpellOnTarget(EffectsToTry[i], this) )
{
break;
}
}
SpellOnTarget(4789, this); //Touch of the Divine=4789, an Invulnerability/HoT/Purify effect
SendHPUpdate();
return true;
}
return false;
}
The change is that the additional effect is now completely optional but spell 4789 is always cast, and if no additional effect is available it doesn't prevent the client from being saved. I guess the downside to this is you lose the ability to prevent 4789 from being cast, but if the invulnerability effect is not desired the spell could always be replaced.
Since the additional effect is now optional I think that not restricting it to one effect might be better. What I'm thinking is that maybe you have the AA that gives you a small heal, but you also have a buff or item that provides for a larger heal or different effect. This seems more flexible to me.