static bool Prefix(UnitUseAbility __instance, ref bool __result) { if ((__instance?.Spell?.Caster?.Get <UnitPartDoNoProvekeAooOnSpellCast>()?.active()).GetValueOrDefault()) { __result = true; return(false); } return(true); }
static void Postfix(UnitUseAbility __instance) { if (IsInCombat() && __instance.Executor.IsInCombat && CastingTimeOfFullRoundSpell != 1f) { float castTime = __instance.GetCastTime(); if (castTime >= 6f) { __instance.SetCastTime(castTime * CastingTimeOfFullRoundSpell); } } }
// ReSharper disable once UnusedMember.Local private static void Postfix(UnitUseAbility __instance) { var caster = __instance.Executor; var bondedComponent = Main.GetBondedItemComponentForCaster(caster.Descriptor); if (bondedComponent != null && bondedComponent.ownerItem != null && bondedComponent.ownerItem.Wielder != caster.Descriptor) { Main.AddBattleLogMessage( Main.L10NFormat(caster, "craftMagicItems-logMessage-not-wielding-bonded-item", bondedComponent.ownerItem.Name), new L10NString("craftMagicItems-bonded-item-glossary")); // Concentration checks have no way of overriding the DC, so contrive some fake damage to give a DC of 20 + spell level. var ruleDamage = new RuleDealDamage(caster, caster, null); Main.Accessors.SetRuleDealDamageDamage(ruleDamage, 20); __instance.MakeConcentrationCheck(ruleDamage); } }
static public bool Prefix(UnitUseAbility __instance, UnitCommand.CommandType commandType, ref AbilityData spell, TargetWrapper target) { //base ctor /*this.Type = commandType; * this.Target = target; * this.Cutscene = (ElementsContext.GetData<CutsceneParametersContext.ContextData>() != null);*/ //modify spell if (spell == null) { return(true); } if (spell.Spellbook == null) { return(true); } if (spell.Spellbook.Blueprint.CharacterClass != ArcanistClass.arcanist) { return(true); } UnitDescriptor unit = spell.Caster; bool hadMetamagic = spell.MetamagicData != null; bool hadMetamixing = unit.Buffs.HasFact(Metamixing.buff); //An arcanist can't combine prepared metamagic and spontaneous metamagic, if she doesn't have //the Metamixing exploit. if (hadMetamagic && !hadMetamixing) { return(true); } //UnityModManager.Logger.Log($"spell {spell.Name} has metamagic {(spell.MetamagicData!=null?spell.MetamagicData.MetamagicMask:0)}"); MetamagicBuilder builder = new MetamagicBuilder(spell.Spellbook, spell); Dictionary <Metamagic, Feature> meta_feat = new Dictionary <Metamagic, Feature>(); foreach (var ft in builder.SpellMetamagicFeatures) { AddMetamagicFeat comp = ft.Get <AddMetamagicFeat>(); if (comp == null) { continue; } Metamagic metaId = comp.Metamagic; meta_feat[metaId] = ft; } bool flag = false; foreach (var kv in SponMetamagic.buffDict) { Metamagic metaId = (Metamagic)(kv.Key.first); int HeightenLevel = kv.Key.second; if (!meta_feat.ContainsKey(metaId)) { continue; } BlueprintBuff buff = kv.Value; if (!unit.HasFact(buff)) { continue; } //If the arcanist has the Metamixing exploit, she can add ONE //metamagic feat to a prepared spell, without using extra time to cast. //(regardless if the spell had metamagic feats when prepared) if (metaId == Metamagic.Heighten) { int originalLevel = spell.Spellbook.GetSpellLevel(spell.Blueprint); if (HeightenLevel <= originalLevel) { continue; } builder.AddHeightenMetamagic(meta_feat[metaId], HeightenLevel - originalLevel); unit.RemoveFact(buff); flag = true; if (hadMetamixing) { unit.Resources.Spend(ArcaneReservoir.resource, 1); break; } } else { builder.AddMetamagic(meta_feat[metaId]); unit.RemoveFact(buff); flag = true; if (hadMetamixing) { unit.Resources.Spend(ArcaneReservoir.resource, 1); break; } } } if (flag && !hadMetamixing) { unit.AddBuff(SponMetamagic.flagBuff, unit.Unit); } //fix ConvertedFrom. this is used in checking if a subspell is existed in memorized spells. //if spell is a subspell, spell.IsAvailableInSpellbook will use its m_ConvertedFrom(which is its master spell) //to get the return value. var newSpell = builder.ResultAbilityData; newSpell.ConvertedFrom = spell.ConvertedFrom; spell = newSpell; //UnityModManager.Logger.Log($"new spell {spell.Name} has metamagic {(spell.MetamagicData != null ? spell.MetamagicData.MetamagicMask : 0)}"); return(true); }
public static void SetCastTime(this UnitUseAbility unitUseAbility, float value) { unitUseAbility.SetFieldValue("m_CastTime", value); }
public static float GetCastTime(this UnitUseAbility unitUseAbility) { return(unitUseAbility.GetFieldValue <UnitUseAbility, float>("m_CastTime")); }
static public void Prefix(UnitUseAbility __instance) { Main.logger.Log($"DUA, use ability {__instance.Spell.Name}"); }