//////////////////////////////////////////////////////////
//	Author: Drammel										//
//	Date: 5/15/2009										//
//	Name: clf_cr_soul									//
//	Description: Gratns a bonus to the Crusader's will	//
//	based on the Crusader's CHA modifier.				//
//////////////////////////////////////////////////////////

void IndomitableSoul()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);

	SetLocalInt(oToB, "IndSoulActive", 1);
	SetLocalInt(oPC, "IndSoulActive", 1);

	if (!GetHasFeat(FEAT_DIVINE_GRACE, oPC) && !GetHasFeat(FEAT_PRESTIGE_DARK_BLESSING, oPC))
	{
		int nCha = GetAbilityModifier(ABILITY_CHARISMA, oPC);

		if (nCha > 0)
		{
			effect eSoul = EffectSavingThrowIncrease(SAVING_THROW_WILL, nCha);
			eSoul = SupernaturalEffect(eSoul);

			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSoul, oPC, 6.0f);
		}
	}

	DelayCommand(6.0f, IndomitableSoul());
}

void main()
{
	object oPC = OBJECT_SELF;
	string sToB = GetName(oPC) + "tob";
	object oToB = GetObjectByTagAndType(sToB, OBJECT_TYPE_ITEM, 1);

	if ((GetLocalInt(oToB, "IndSoulActive") == 1) || (GetLocalInt(oPC, "IndSoulActive") == 1))
	{
		return; // Prevents duplicate checks.
	}
	else if ((GetLocalInt(oToB, "IndSoulActive") == 0) && (GetLocalInt(oPC, "IndSoulActive") == 0)) //If oToB isn't valid it still returns zero.
	{
		IndomitableSoul();
	}
}