Quote:
Originally Posted by Kayen
Before we rip my code to shreds I think some basic understanding of the effect is needed and why it is coded like this.
|
No ripping to shreds, just fixing an issue with having a spell effect when there is no AA effect. The buff was being faded and the bonus recalculated a little too early, so the spell effect was lost and that made the whole thing get skipped.
Does something like this meet your needs? It casts any of the AA/item/spell effects and spell 4789 as the original code did, but it doesn't require that there be an AA/item/spell effect present in order to stop a client from dying and applying the Touch of the Divine effect to them.
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.
*/
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);
}
}
SpellOnTarget(4789, this); //Touch of the Divine=4789, an Invulnerability/HoT/Purify effect
SendHPUpdate();
return true;
}
return false;
}