private static int OnAddCastSpellActions(void *pCreature, uint nSpellId, int nMultiClass, int nDomainLevel, int nMetaType, int bSpontaneousCast, Vector3 vTargetLocation, uint oidTarget, int bAreaTarget, int bAddToFront, int bFake, byte nProjectilePathType, int bInstant, int bAllowPolymorphedCast, int nFeat, byte nCasterLevel) { CNWSCreature creature = CNWSCreature.FromPointer(pCreature); OnSpellAction eventData = new OnSpellAction { Caster = creature.ToNwObject <NwCreature>() !, Spell = NwSpell.FromSpellId((int)nSpellId) !, ClassIndex = nMultiClass, Domain = (Domain)nDomainLevel, MetaMagic = (MetaMagic)nMetaType, IsSpontaneous = bSpontaneousCast.ToBool(), TargetPosition = vTargetLocation, TargetObject = oidTarget.ToNwObject <NwGameObject>() !, IsAreaTarget = bAreaTarget.ToBool(), IsFake = bFake.ToBool(), ProjectilePath = (ProjectilePathType)nProjectilePathType, IsInstant = bInstant.ToBool(), Feat = NwFeat.FromFeatId(nFeat) !, CasterLevel = nCasterLevel, }; eventData.Result = new Lazy <bool>(() => !eventData.PreventSpellCast && Hook.CallOriginal(pCreature, nSpellId, nMultiClass, nDomainLevel, nMetaType, bSpontaneousCast, vTargetLocation, oidTarget, bAreaTarget, bAddToFront, bFake, nProjectilePathType, bInstant, bAllowPolymorphedCast, nFeat, nCasterLevel).ToBool()); ProcessEvent(eventData); return(eventData.Result.Value.ToInt()); }
private static int OnEffectApplied(void *pEffectListHandler, void *pObject, void *pEffect, int bLoadingGame) { if (pEffect == null) { return(Hook.CallOriginal(pEffectListHandler, pObject, null, bLoadingGame)); } CGameEffect effect = CGameEffect.FromPointer(pEffect); if (effect.m_nType != (int)EffectTrueType.VisualEffect || effect.m_nNumIntegers == 0 || effect.m_nParamInteger[0] != 292 && effect.m_nParamInteger[0] != 293) { return(Hook.CallOriginal(pEffectListHandler, pObject, pEffect, bLoadingGame)); } CNWSObject gameObject = CNWSObject.FromPointer(pObject); ProcessEvent(new OnSpellInterrupt { InterruptedCaster = gameObject.ToNwObject <NwGameObject>() !, Spell = NwSpell.FromSpellId((int)gameObject.m_nLastSpellId) !, ClassIndex = gameObject.m_nLastSpellCastMulticlass, Feat = NwFeat.FromFeatId(gameObject.m_nLastSpellCastFeat) !, Domain = (Domain)gameObject.m_nLastDomainLevel, Spontaneous = gameObject.m_bLastSpellCastSpontaneous.ToBool(), MetaMagic = (MetaMagic)gameObject.m_nLastSpellCastMetaType, });
private static void OnBroadcastSpellCast(void *pCreature, uint nSpellId, byte nMultiClass, ushort nFeat) { CNWSCreature creature = CNWSCreature.FromPointer(pCreature); OnSpellBroadcast eventData = ProcessEvent(new OnSpellBroadcast { Caster = creature.ToNwObject <NwCreature>() !, Spell = NwSpell.FromSpellId((int)nSpellId) !, ClassIndex = nMultiClass, Feat = NwFeat.FromFeatId(nFeat) !, });
private static int OnCreatureUseFeat(void *pCreature, ushort nFeat, ushort nSubFeat, uint oidTarget, uint oidArea, void *pTargetPos) { CNWSCreature creature = CNWSCreature.FromPointer(pCreature); OnUseFeat eventData = ProcessEvent(new OnUseFeat { Creature = creature.ToNwObject <NwCreature>() !, Feat = NwFeat.FromFeatId(nFeat) !, SubFeatId = nSubFeat, TargetObject = oidTarget.ToNwObject <NwGameObject>() !, TargetArea = oidArea.ToNwObject <NwArea>() !, TargetPosition = pTargetPos != null ? Marshal.PtrToStructure <Vector3>((IntPtr)pTargetPos) : Vector3.Zero, });
public void GetFeatRemainingUsesReturnsValidValue() { Location startLocation = NwModule.Instance.StartingLocation; NwCreature?creature = NwCreature.Create(StandardResRef.Creature.tanarukk, startLocation); Assert.That(creature, Is.Not.Null, "Creature was null after creation."); Assert.That(creature !.IsValid, Is.True, "Creature was invalid after creation."); createdTestObjects.Add(creature); NwFeat?feat = NwFeat.FromFeatType(Feat.BarbarianRage); Assert.That(creature.GetFeatRemainingUses(feat !), Is.EqualTo(1)); }
private static int OnApplyDisarm(void *pEffectHandler, void *pObject, void *pEffect, int bLoadingGame) { CNWSObject gameObject = CNWSObject.FromPointer(pObject); CGameEffect gameEffect = CGameEffect.FromPointer(pEffect); OnDisarmWeapon eventData = new OnDisarmWeapon { DisarmedObject = gameObject.ToNwObject <NwGameObject>() !, DisarmedBy = gameEffect.m_oidCreator.ToNwObject <NwGameObject>() !, Feat = gameEffect.GetInteger(0) == 1 ? NwFeat.FromFeatType(API.Feat.ImprovedDisarm) ! : NwFeat.FromFeatType(API.Feat.Disarm) !, }; eventData.Result = new Lazy <bool>(() => !eventData.PreventDisarm && Hook.CallOriginal(pEffectHandler, pObject, pEffect, bLoadingGame).ToBool()); ProcessEvent(eventData); return(eventData.Result.Value.ToInt()); } }
public void SetFeatRemainingUsesCorrectlyUpdatesState(byte uses) { Location startLocation = NwModule.Instance.StartingLocation; NwCreature?creature = NwCreature.Create(StandardResRef.Creature.tanarukk, startLocation); Assert.That(creature, Is.Not.Null, "Creature was null after creation."); Assert.That(creature !.IsValid, Is.True, "Creature was invalid after creation."); createdTestObjects.Add(creature); NwFeat?feat = NwFeat.FromFeatType(Feat.BarbarianRage); Assert.That(feat, Is.Not.Null, "Could not get feat."); creature.SetFeatRemainingUses(feat !, uses); Assert.That(creature.GetFeatRemainingUses(feat !), Is.EqualTo(Math.Min(uses, creature.GetFeatTotalUses(feat !))), "Remaining feat uses was not updated after being set."); Assert.That(creature.HasFeatPrepared(feat !), Is.EqualTo(uses > 0), "Creature incorrectly assumes the feat is/is not available."); }
public static Talent ToTalent(this NwFeat feat) { return(feat); }
/// <summary> /// Adds the specified feat as a weapon specialization feat for the specified base item type. /// </summary> /// <param name="baseItem">The base item type to be mapped.</param> /// <param name="feat">The feat to map to the base item.</param> public void AddWeaponSpecializationFeat(NwBaseItem baseItem, NwFeat feat) { weaponSpecializationMap.AddElement(baseItem.Id, feat.Id); }
/// <summary> /// Adds the specified feat as a weapon of choice feat for the specified base item type. /// </summary> /// <param name="baseItem">The base item type to be mapped.</param> /// <param name="feat">The feat to map to the base item.</param> public void AddWeaponOfChoiceFeat(NwBaseItem baseItem, NwFeat feat) { weaponOfChoiceMap.AddElement(baseItem.Id, feat.Id); }
/// <summary> /// Adds the specified feat as an improved critical feat for the specified base item type. /// </summary> /// <param name="baseItem">The base item type to be mapped.</param> /// <param name="feat">The feat to map to the base item.</param> public void AddWeaponImprovedCriticalFeat(NwBaseItem baseItem, NwFeat feat) { weaponImprovedCriticalMap.AddElement(baseItem.Id, feat.Id); }
/// <summary> /// Adds the specified feat as a weapon focus feat for the specified base item type. /// </summary> /// <param name="baseItem">The base item type to be mapped.</param> /// <param name="feat">The feat to map to the base item.</param> public void AddWeaponFocusFeat(NwBaseItem baseItem, NwFeat feat) { weaponFocusMap.AddElement(baseItem.Id, feat.Id); }
/// <summary> /// Adds the specified feat as an epic overwhelming critical feat for the specified base item type. /// </summary> /// <param name="baseItem">The base item type to be mapped.</param> /// <param name="feat">The feat to map to the base item.</param> public void AddEpicWeaponOverwhelmingCriticalFeat(NwBaseItem baseItem, NwFeat feat) { epicWeaponOverwhelmingCriticalMap.AddElement(baseItem.Id, feat.Id); }