private static bool PrivateIsFailure(IMagicalInteraction interaction, OccultTypes testType, out bool fail, out bool epicFailure) { fail = false; epicFailure = false; if (!OccultTypeHelper.HasType(interaction.Actor, testType)) return false; switch (testType) { case OccultTypes.Witch: SpellcastingSkill spellcasting = interaction.Actor.SkillManager.GetElement(SkillNames.Spellcasting) as SpellcastingSkill; MagicWand wand = MagicWand.GetWandToUse(interaction.Actor, spellcasting); if (wand != null) { fail = RandomUtil.RandomChance(wand.SuccessChance(interaction.Actor, interaction.SpellLevel, spellcasting.SkillLevel)); if (!fail) { epicFailure = RandomUtil.RandomChance(wand.EpicFailChance(interaction.Actor)); } } break; case OccultTypes.Fairy: if (interaction.SpellLevel <= interaction.Actor.SkillManager.GetSkillLevel(SkillNames.FairyMagic)) { fail = true; } break; case OccultTypes.Genie: case OccultTypes.Unicorn: return false; } return fail; }
protected virtual bool SetupAnimation(T ths, MagicControl control, bool twoPerson) { if (mWand is MagicHands) { ths.SetParameter("noWand", true); } else { ths.SetParameter("noWand", false); } ths.SetActor("wand", mWand); ths.SetParameter("isSkilled", control.GetSkillLevel(ths.Actor.SimDescription) >= MagicWand.kExpertLevel); IMagicalInteraction interaction = ths as IMagicalInteraction; if (interaction != null) { ths.AddOneShotScriptEventHandler(0x65, interaction.ShowSuccessVfx); ths.AddOneShotScriptEventHandler(0x66, interaction.ShowFailVfx); ths.AddOneShotScriptEventHandler(0x67, interaction.ShowEpicFailVfx); } return(true); }
public static bool IsFailure(IMagicalInteraction interaction, OccultTypes intended, out bool epicFailure) { bool fail = false; epicFailure = false; if (intended != OccultTypes.None) { if (PrivateIsFailure(interaction, intended, out fail, out epicFailure)) { return fail; } } foreach (OccultTypes type in sMagicOccult) { if (type == intended) continue; if (PrivateIsFailure(interaction, type, out fail, out epicFailure)) { return fail; } } return fail; }
public static bool IsFailure(IMagicalInteraction interaction, OccultTypes intended, out bool epicFailure) { bool fail = false; epicFailure = false; if (intended != OccultTypes.None) { if (PrivateIsFailure(interaction, intended, out fail, out epicFailure)) { return(fail); } } foreach (OccultTypes type in sMagicOccult) { if (type == intended) { continue; } if (PrivateIsFailure(interaction, type, out fail, out epicFailure)) { return(fail); } } return(fail); }
public static bool Run(IMagicalInteraction ths, OccultTypes intendedType) { bool succeeded = true; if (!ths.OnPreFailureCheck()) { return(false); } bool epicFailure; ths.SpellCastingSucceeded = MagicPointControl.IsFailure(ths, intendedType, out epicFailure); if (!ths.SpellCastingSucceeded) { ths.SpellCastingEpiclyFailed = epicFailure; } ths.StandardEntry(); ths.BeginCommodityUpdates(); try { if (!ths.OnPostFailureCheck()) { return(false); } MagicPointControl.UsePoints(ths.Actor, ths.SpellPoints, intendedType); if (ths.SpellCastingSucceeded) { ths.OnSpellSuccess(); } else if ((ths.EpicFailureAllowed()) && (ths.SpellCastingEpiclyFailed)) { succeeded = false; ths.OnSpellEpicFailure(); } else { succeeded = false; ths.OnSpellFailure(); } EventTracker.SendEvent(EventTypeId.kCastSpell, ths.Actor); } finally { ths.EndCommodityUpdates(succeeded); ths.StandardExit(); } return(succeeded); }
public static bool Run(IMagicalInteraction ths, OccultTypes intendedType) { bool succeeded = true; if (!ths.OnPreFailureCheck()) return false; bool epicFailure; ths.SpellCastingSucceeded = MagicPointControl.IsFailure(ths, intendedType, out epicFailure); if (!ths.SpellCastingSucceeded) { ths.SpellCastingEpiclyFailed = epicFailure; } ths.StandardEntry(); ths.BeginCommodityUpdates(); try { if (!ths.OnPostFailureCheck()) return false; MagicPointControl.UsePoints(ths.Actor, ths.SpellPoints, intendedType); if (ths.SpellCastingSucceeded) { ths.OnSpellSuccess(); } else if ((ths.EpicFailureAllowed()) && (ths.SpellCastingEpiclyFailed)) { succeeded = false; ths.OnSpellEpicFailure(); } else { succeeded = false; ths.OnSpellFailure(); } EventTracker.SendEvent(EventTypeId.kCastSpell, ths.Actor); } finally { ths.EndCommodityUpdates(succeeded); ths.StandardExit(); } return succeeded; }
private static bool PrivateIsFailure(IMagicalInteraction interaction, OccultTypes testType, out bool fail, out bool epicFailure) { fail = false; epicFailure = false; if (!OccultTypeHelper.HasType(interaction.Actor, testType)) { return(false); } switch (testType) { case OccultTypes.Witch: SpellcastingSkill spellcasting = interaction.Actor.SkillManager.GetElement(SkillNames.Spellcasting) as SpellcastingSkill; MagicWand wand = MagicWand.GetWandToUse(interaction.Actor, spellcasting); if (wand != null) { fail = RandomUtil.RandomChance(wand.SuccessChance(interaction.Actor, interaction.SpellLevel, spellcasting.SkillLevel)); if (!fail) { epicFailure = RandomUtil.RandomChance(wand.EpicFailChance(interaction.Actor)); } } break; case OccultTypes.Fairy: if (interaction.SpellLevel <= interaction.Actor.SkillManager.GetSkillLevel(SkillNames.FairyMagic)) { fail = true; } break; case OccultTypes.Genie: case OccultTypes.Unicorn: return(false); } return(fail); }
public static bool IsFailure(IMagicalInteraction interaction, OccultTypes preferredType) { bool epicFailure = false; return IsFailure(interaction, preferredType, out epicFailure); }
public static bool IsFailure(IMagicalInteraction interaction, OccultTypes preferredType) { bool epicFailure = false; return(IsFailure(interaction, preferredType, out epicFailure)); }