Пример #1
0
        public static byte[] Create(N3Message messageBody)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(null);
            }

            int localDynelInstance = N3EngineClient_t.GetClientInst(pEngine);

            messageBody.Identity = new Identity(IdentityType.SimpleChar, localDynelInstance);

            var message = new Message
            {
                Body   = messageBody,
                Header = new Header
                {
                    MessageId  = BitConverter.ToUInt16(new byte[] { 0xFF, 0xFF }, 0),
                    PacketType = messageBody.PacketType,
                    Unknown    = 0x0001,
                    Sender     = localDynelInstance,
                    Receiver   = 0x02
                }
            };

            using (MemoryStream stream = new MemoryStream())
            {
                _serializer.Serialize(stream, message);
                return(stream.ToArray());
            }
        }
Пример #2
0
        private static unsafe List <TeamMember> GetMemberList()
        {
            List <TeamMember> teamMembers = new List <TeamMember>();

            if (!IsInTeam)
            {
                return(teamMembers);
            }

            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(teamMembers);
            }


            for (int i = 0; i < (IsRaid ? 6 : 1); i++)
            {
                StdObjVector *pMemberList = N3EngineClientAnarchy_t.GetTeamMemberList(pEngine, i);

                if (pMemberList == null)
                {
                    continue;
                }

                foreach (IntPtr pMember in pMemberList->ToList())
                {
                    teamMembers.Add(new TeamMember(pMember, i));
                }
            }

            return(teamMembers);
        }
Пример #3
0
        public static void UseItem(Identity identity, bool unknown = false)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine != IntPtr.Zero)
            {
                N3EngineClientAnarchy_t.UseItem(pEngine, ref identity, unknown);
            }
        }
Пример #4
0
        public static void UseItemOnCharacter(Identity source, Identity target)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine != IntPtr.Zero)
            {
                N3EngineClientAnarchy_t.UseItemOnCharacter(pEngine, ref source, ref target);
            }
        }
Пример #5
0
        public static bool HasPerk(int perkId)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                throw new NullReferenceException("Could not get N3Engine instance");
            }

            return(N3EngineClientAnarchy_t.HasPerk(pEngine, perkId));
        }
Пример #6
0
        private static bool GetIsRaid()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            return(N3EngineClientAnarchy_t.IsInRaidTeam(pEngine));
        }
Пример #7
0
        public float GetAttackRange()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(0f);
            }

            return(N3EngineClientAnarchy_t.GetAttackRange(pEngine));
        }
Пример #8
0
        private static LocalPlayer GetLocalPlayer()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(null);
            }

            IntPtr pLocalPlayer = N3EngineClient_t.GetClientControlDynel(pEngine);

            return(pLocalPlayer == IntPtr.Zero ? null : new LocalPlayer(pLocalPlayer));
        }
Пример #9
0
        public void Attack(Identity target)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return;
            }

            N3EngineClientAnarchy_t.DefaultAttack(pEngine, &target, true);

            _nextAttack = Time.NormalTime + AttackAttemptDelay;
        }
Пример #10
0
        public bool IsInTeam()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            Identity identity = Identity;

            return(N3EngineClientAnarchy_t.IsInTeam(pEngine, &identity));
        }
Пример #11
0
        private unsafe float GetTotalTime()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
                return(0);

            fixed(Identity *pIdentity = &Identity)
            fixed(Identity * pOwner = &Owner)
            {
                return(N3EngineClientAnarchy_t.GetBuffTotalTime(pEngine, pIdentity, pOwner) / 100f);
            }
        }
Пример #12
0
        private Buff[] GetBuffs()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(new Buff[0]);
            }

            Identity identity = Identity;

            return(N3EngineClientAnarchy_t.GetNanoTemplateInfoList(pEngine, &identity)->ToList().Select(x => new Buff(Identity, (*(NanoTemplateInfoMemStruct *)x).Identity)).ToArray());
        }
Пример #13
0
        public static string GetName(Identity identity)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(null);
            }

            Identity garbage = new Identity();

            return(Utils.UnsafePointerToString(N3EngineClientAnarchy_t.GetName(pEngine, ref identity, ref garbage)));
        }
Пример #14
0
        private bool GetIsAvailable()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            Identity identity = Identity;

            return(N3EngineClientAnarchy_t.GetSpecialActionState(pEngine, ref identity) == SpecialActionState.Ready);
        }
Пример #15
0
        private unsafe bool GetIsLeader()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            Identity identity = Identity;

            return(N3EngineClientAnarchy_t.IsTeamLeader(pEngine, &identity));
        }
Пример #16
0
        private bool GetIsOpen()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            Identity identity = Identity;
            IntPtr   pItems   = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref identity);

            return(pItems != IntPtr.Zero);
        }
Пример #17
0
        public static unsafe List <Item> GetContainerItems(Identity identity)
        {
            List <Item> items = new List <Item>();

            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(items);
            }

            IntPtr pInvList = N3EngineClientAnarchy_t.GetContainerInventoryList(pEngine, &identity);

            if (pInvList == IntPtr.Zero)
            {
                return(items);
            }

            IntPtr pItems = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref identity);

            if (pItems == IntPtr.Zero)
            {
                return(items);
            }

            List <IntPtr> containerInvList = (*(StdObjList *)pInvList).ToList();

            int i = 0;

            foreach (IntPtr pItem in (*(StdStructVector *)pItems).ToList(sizeof(IntPtr)))
            {
                IntPtr pActualItem = *(IntPtr *)pItem;

                if (pActualItem != IntPtr.Zero)
                {
                    try
                    {
                        int      lowId          = (*(ItemMemStruct *)pActualItem).LowId;
                        int      highId         = (*(ItemMemStruct *)pActualItem).HighId;
                        int      ql             = (*(ItemMemStruct *)pActualItem).QualityLevel;
                        Identity unqiueIdentity = (*(ItemMemStruct *)pActualItem).UniqueIdentity;
                        Identity slot           = *((Identity *)(containerInvList[i] + 0x8));
                        items.Add(new Item(lowId, highId, ql, unqiueIdentity, slot));
                    } catch {}
                    i++;
                }
            }
            return(items);
        }
Пример #18
0
        private unsafe void TeamViewModule_SlotJoinTeamRequestFailed_Hook(IntPtr pThis, ref Identity identity)
        {
            try
            {
                IntPtr pEngine = N3Engine_t.GetInstance();

                if (pEngine == IntPtr.Zero)
                {
                    return;
                }

                N3EngineClientAnarchy_t.TeamJoinRequest(pEngine, ref identity, true);
            }
            catch (Exception) { }
        }
Пример #19
0
        internal unsafe DummyItem(Identity identity)
        {
            Identity none    = Identity.None;
            IntPtr   pEngine = N3Engine_t.GetInstance();
            IntPtr   pItem   = N3EngineClientAnarchy_t.GetItemByTemplate(pEngine, identity, &none);

            if (pItem == IntPtr.Zero)
            {
                throw new Exception($"DummyItem::DummyItem - Unable to locate item {identity}");
            }

            Pointer  = pItem;
            Identity = (*(MemStruct *)pItem).Identity;
            Name     = Utils.UnsafePointerToString((*(MemStruct *)pItem).Name);
        }
Пример #20
0
        public static unsafe bool CreateDummyItemID(int lowId, int highId, int ql, out Identity dummyItemId)
        {
            ACGItem itemInfo = new ACGItem
            {
                LowId  = lowId,
                HighId = highId,
                QL     = ql
            };

            IntPtr pEngine = N3Engine_t.GetInstance();

            fixed(Identity *pDummyItemId = &dummyItemId)
            {
                return(N3EngineClientAnarchy_t.CreateDummyItemID(pEngine, pDummyItemId, &itemInfo));
            }
        }
Пример #21
0
        public void StopAttack()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return;
            }

            N3EngineClientAnarchy_t.StopAttack(pEngine);

            if (Pets.Length > 0)
            {
                Pets.Follow();
            }
        }
Пример #22
0
        public bool IsAvailable()
        {
            if (Time.NormalTime < _nextAttack)
            {
                return(false);
            }

            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            //Why is this inverted lol?
            return(!N3EngineClientAnarchy_t.IsSecondarySpecialAttackAvailable(pEngine, _stat));
        }
Пример #23
0
        public unsafe bool UseOn(Identity target)
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(false);
            }

            bool successful = N3EngineClientAnarchy_t.SecondarySpecialAttack(pEngine, &target, _stat);

            if (successful)
            {
                _nextAttack = Time.NormalTime + ATTACK_DELAY_BUFFER;
            }

            return(successful);
        }
Пример #24
0
        private static unsafe List <Perk> GetFullPerkMap()
        {
            List <Perk> perks = new List <Perk>();

            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(perks);
            }

            foreach (PerkMemStruct perkMemStruct in N3EngineClientAnarchy_t.GetFullPerkMap(pEngine)->ToList <PerkMemStruct>())
            {
                Perk perk = new Perk(perkMemStruct.Instance, perkMemStruct.TemplateInstance,
                                     perkMemStruct.PrerequisitePerkInstance, perkMemStruct.PerkType, perkMemStruct.AllowedProfessions,
                                     perkMemStruct.ActionInstance, perkMemStruct.RequiredExperience);

                perks.Add(perk);
            }

            // I'm not doing the following in the Perk constructor because we need the full perk
            // map to do it and querying the entire perk map again in the constructor is too expensive

            string currentName  = "NoName";
            int    currentLevel = 1;

            foreach (Perk perk in perks.OrderBy(perk => perk.Instance))
            {
                if (perk.Name != currentName)
                {
                    currentName  = perk.Name;
                    currentLevel = 1;
                }

                perk.Level = currentLevel;

                currentLevel++;
            }

            return(perks);
        }
Пример #25
0
        internal unsafe DummyItem(int lowId, int highId, int ql)
        {
            Identity none    = Identity.None;
            IntPtr   pEngine = N3Engine_t.GetInstance();

            if (!CreateDummyItemID(lowId, highId, ql, out Identity dummyItemId))
            {
                throw new Exception($"Failed to create dummy item. LowId: {lowId}\tLowId: {highId}\tLowId: {ql}");
            }

            IntPtr pItem = N3EngineClientAnarchy_t.GetItemByTemplate(pEngine, dummyItemId, &none);

            if (pItem == IntPtr.Zero)
            {
                throw new Exception($"DummyItem::DummyItem - Unable to locate item. LowId: {lowId}\tLowId: {highId}\tLowId: {ql}");
            }

            Pointer  = pItem;
            Identity = (*(MemStruct *)pItem).Identity;
            Name     = Utils.UnsafePointerToString((*(MemStruct *)pItem).Name);
        }
Пример #26
0
        //Must be called from game loop!
        private static void ChangeMovement(MovementAction action)
        {
            if (action == MovementAction.LeaveSit)
            {
                Network.Send(new CharacterActionMessage()
                {
                    Action = CharacterActionType.StandUp
                });
            }
            else
            {
                IntPtr pEngine = N3Engine_t.GetInstance();

                if (pEngine == IntPtr.Zero)
                {
                    return;
                }

                N3EngineClientAnarchy_t.MovementChanged(pEngine, action, 0, 0, true);
            }
        }
Пример #27
0
        public unsafe bool Use(SimpleChar target, bool setTarget = false, bool packetOnly = false)
        {
            if (target == null)
            {
                target = DynelManager.LocalPlayer;
            }

            if (setTarget)
            {
                target.Target();
            }

            if (packetOnly)
            {
                Network.Send(new CharacterActionMessage()
                {
                    Action     = CharacterActionType.UsePerk,
                    Target     = target.Identity,
                    Parameter1 = Identity.Instance,
                    Parameter2 = (int)Hash
                });

                EnqueuePendingPerk(this);

                return(true);
            }
            else
            {
                IntPtr pEngine = N3Engine_t.GetInstance();

                if (pEngine == IntPtr.Zero)
                {
                    return(false);
                }

                Identity identity = Identity;
                return(N3EngineClientAnarchy_t.PerformSpecialAction(pEngine, ref identity));
            }
        }
Пример #28
0
        public static unsafe void SetTarget(Identity target, bool packetOnly = false)
        {
            if (!packetOnly)
            {
                TargetingModule_t.SetTarget(ref target, false);

                IntPtr pEngine = N3Engine_t.GetInstance();

                if (pEngine == IntPtr.Zero)
                {
                    return;
                }

                N3EngineClientAnarchy_t.SelectedTarget(pEngine, ref target);
            }
            else
            {
                Network.Send(new LookAtMessage()
                {
                    Target = target
                });
            }
        }
Пример #29
0
        private static unsafe List <PerkAction> GetPerkActions()
        {
            List <PerkAction> perks   = new List <PerkAction>();
            IntPtr            pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
            {
                return(perks);
            }

            foreach (IntPtr pAction in N3EngineClientAnarchy_t.GetSpecialActionList(pEngine)->ToList())
            {
                SpecialActionMemStruct specialAction = *(SpecialActionMemStruct *)pAction;

                if (specialAction.Identity.Type != IdentityType.PerkHash)
                {
                    continue;
                }

                perks.Add(new PerkAction(specialAction.TemplateIdentity, specialAction.Identity.Instance));
            }

            return(perks.OrderBy(perk => perk.Identity.Instance).ToList());
        }
Пример #30
0
        public bool Remove()
        {
            IntPtr pEngine = N3Engine_t.GetInstance();

            if (pEngine == IntPtr.Zero)
                return(false); }