Esempio n. 1
0
            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,
                });
Esempio n. 2
0
            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());
            }
Esempio n. 3
0
            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) !,
                });
Esempio n. 4
0
            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,
                });