View Single Post
  #8  
Old 12-23-2012, 02:38 PM
Hateborne
Hill Giant
 
Join Date: May 2010
Posts: 125
Exclamation

Quote:
Originally Posted by lerxst2112 View Post
Attach debugger, add a breakpoint inside the TryDivineSave function and where it calculates the bonus effect, then trace through and see where it goes wrong.
Did just that and the answer was staring right in my face. The buff cannot fade BEFORE you check for it. The problem I ran into after moving the BuffFadeByEffect was it casting up to 4 effects. This got...interesting.

I added in a basic check to allow only one effect to go off. The only immediate note is that only ONE effect is allowed to go off, AAXP -> items -> spell.

(Should I be submitting as a diff instead?)


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 AA value. (base1)
	-Spell can be triggered from divine save (base2) in this case a Heal
	Note: Heal value does not and should not increase from more levels of this AA.
	-If chance is met, a heal is done and a divine aura like effect 'Touch of the Divine'
	is applied to the client. Determintal spell effects are removed.
	*/
	sint16 SuccessChance = aabonuses.DivineSaveChance[0] + itembonuses.DivineSaveChance[0] + spellbonuses.DivineSaveChance[0];

	if (SuccessChance)
	{
		if (MakeRandomInt(0, 100) <= SuccessChance)
		{
			int32 HealAmt = 0;
			// boolean to check if a single effect has gone off
			bool beenSaved = false;
			//Touch of the Divine=4789, an Invulnerability/HoT/Purify effect hard coded to trigger if spell effect is defined from base2.
			if (aabonuses.DivineSaveChance[1] || itembonuses.DivineSaveChance[1] || spellbonuses.DivineSaveChance[1]) {
			
				SetHP(1);

				/* will check aaxp, items, and then spells (in that priority order)
					if a line procs, any below it are ignored.
				*/
				if (aabonuses.DivineSaveChance[1] && (beenSaved == false))
				{
					SpellOnTarget(aabonuses.DivineSaveChance[1], this);
					beenSaved = true;
				}

				if (itembonuses.DivineSaveChance[1] && (beenSaved == false))
				{
					SpellOnTarget(itembonuses.DivineSaveChance[1], this);
					beenSaved = true;
				}

				if (spellbonuses.DivineSaveChance[1] && (beenSaved == false))
				{
					SpellOnTarget(spellbonuses.DivineSaveChance[1], this);
					beenSaved = true;
				}

				// this was moved INSIDE the check as it always failed when spell was removed AND THEN check took place
				BuffFadeByEffect(SE_DivineSave);

				// if nothing went off or all were blank triggers, make sure we save the player
				if (beenSaved == false)
				{
					SpellOnTarget(4789, this);
				}

				SendHPUpdate();
				return true;
			}
		}
	}
	return false;
}

-Hate
Reply With Quote