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 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 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) !, });
public OnSpellCast() { Caster = NWScript.OBJECT_SELF.ToNwObject <NwGameObject>(); Spell = NwSpell.FromSpellId(NWScript.GetSpellId()) !; Harmful = NWScript.GetLastSpellHarmful().ToBool(); TargetObject = NWScript.GetSpellTargetObject().ToNwObject <NwGameObject>(); TargetLocation = NWScript.GetSpellTargetLocation(); SpellCastClass = NwClass.FromClassId(NWScript.GetLastSpellCastClass()); Item = NWScript.GetSpellCastItem().ToNwObject <NwItem>(); SaveDC = NWScript.GetSpellSaveDC(); MetaMagicFeat = (MetaMagic)NWScript.GetMetaMagicFeat(); }
private static int OnSetMemorizedSpellSlot(void *pCreatureStats, byte nMultiClass, byte nSpellSlot, uint nSpellId, byte nDomainLevel, byte nMetaType, int bFromClient) { CNWSCreatureStats creatureStats = CNWSCreatureStats.FromPointer(pCreatureStats); OnSpellSlotMemorize eventData = ProcessEvent(new OnSpellSlotMemorize { Creature = creatureStats.m_pBaseCreature.ToNwObject <NwCreature>() !, ClassIndex = nMultiClass, SlotIndex = nSpellSlot, Spell = NwSpell.FromSpellId((int)nSpellId) !, Domain = (Domain)nDomainLevel, MetaMagic = (MetaMagic)nMetaType, FromClient = bFromClient.ToBool(), });
private static void OnSpellCastAndImpact(void *pObject, int nSpellId, Vector3 targetPosition, uint oidTarget, byte nMultiClass, uint itemObj, int bSpellCountered, int bCounteringSpell, byte projectilePathType, int bInstantSpell) { CNWSObject gameObject = CNWSObject.FromPointer(pObject); OnSpellCast eventData = null !; VirtualMachine.ExecuteInScriptContext(() => { eventData = ProcessEvent(new OnSpellCast { Caster = gameObject.ToNwObject <NwGameObject>() !, Spell = NwSpell.FromSpellId(nSpellId) !, TargetPosition = targetPosition, TargetObject = oidTarget.ToNwObject <NwGameObject>() !, ClassIndex = nMultiClass, Item = itemObj.ToNwObject <NwItem>() !, SpellCountered = bSpellCountered.ToBool(), CounteringSpell = bCounteringSpell.ToBool(), ProjectilePathType = (ProjectilePathType)projectilePathType, IsInstantSpell = bInstantSpell.ToBool(), MetaMagic = (MetaMagic)NWScript.GetMetaMagicFeat(), }, false); });