static public void Postfix(ContextActionBreathOfLife __instance) { var tr = Harmony12.Traverse.Create(__instance); var context = tr.Property("Context").GetValue <MechanicsContext>(); var target = tr.Property("Target").GetValue <TargetWrapper>().Unit; bool was_dead = false; if (target.HPLeft <= -(int)((ModifiableValue)target.Stats.Constitution)) { was_dead = true; } if (target.Descriptor.Ensure <UnitPartReceiveBonusCasterLevelHealing>().active() && context.SourceAbility != null && __instance.Value != null) { int dice_count = __instance.Value.DiceCountValue.Calculate(context); var dice = __instance.Value.DiceType; if (dice_count == 0 || dice == DiceType.Zero || context.Params == null) { return; } int bonus_hp = context.Params.CasterLevel; context.TriggerRule <RuleHealDamage>(new RuleHealDamage(target, target, DiceFormula.Zero, bonus_hp)); } if (target.HPLeft > -(int)((ModifiableValue)target.Stats.Constitution) && was_dead) { target.Descriptor.Resurrect(0.0f, false); } }
static public void Postfix(ContextActionBreathOfLife __instance) { var tr = Harmony12.Traverse.Create(__instance); var context = tr.Property("Context").GetValue <MechanicsContext>(); var target = tr.Property("Target").GetValue <TargetWrapper>().Unit; bool was_dead = false; if (target.HPLeft <= -(int)((ModifiableValue)target.Stats.Constitution)) { was_dead = true; } int dice_count = __instance.Value.DiceCountValue.Calculate(context); int bonus_hp = target.Descriptor.Ensure <UnitPartReceiveBonusHpPerDie>().getAmount(context.SourceAbility) * dice_count; if (target.Descriptor.Ensure <UnitPartReceiveBonusCasterLevelHealing>().active() && context.SourceAbility != null && __instance.Value != null) { var dice = __instance.Value.DiceType; if (dice_count == 0 || dice == DiceType.Zero || context.Params == null) { return; } bonus_hp += context.Params.CasterLevel; } if ((target.Get <HarmlessSaves.UnitPartSaveAgainstHarmlessSpells>()?.active()).GetValueOrDefault() && context.SourceAbility?.GetComponent <HarmlessSaves.HarmlessHealSpell>() != null && context.SourceAbility.IsSpell && target.IsAlly(context.MaybeCaster) && target != context.MaybeCaster) { RuleSavingThrow ruleSavingThrow = new RuleSavingThrow(target, context.AssociatedBlueprint.GetComponent <HarmlessSaves.HarmlessHealSpell>().save_type, context.Params.DC); ruleSavingThrow.Reason = (RuleReason)((MechanicsContext)context); if (context.TriggerRule <RuleSavingThrow>(ruleSavingThrow).IsPassed) { bonus_hp /= 2; } } if (bonus_hp > 0) { context.TriggerRule <RuleHealDamage>(new RuleHealDamage(target, target, DiceFormula.Zero, bonus_hp)); } if (target.HPLeft > -(int)((ModifiableValue)target.Stats.Constitution) && was_dead) { target.Descriptor.Resurrect(0.0f, false); } }
static bool Prefix(ContextActionBreathOfLife __instance) { currentHealDice = __instance.Value; return(true); }