コード例 #1
0
        public KeyValuePair <uint, (string, bool)> GetCurrentPlayer()
        {
            var result = new KeyValuePair <uint, (string, bool)>();

            if (!CanGetPlayerInfo() || !MemoryHandler.IsAttached)
            {
                return(result);
            }

            var playerInfoMap = (IntPtr)Scanner.Locations[Signatures.PlayerInformationKey];

            if (playerInfoMap.ToInt64() <= 6496)
            {
                return(result);
            }

            try
            {
                var source          = MemoryHandler.GetByteArray(playerInfoMap, MemoryHandler.Structures.CurrentPlayer.SourceSize);
                var actorId         = SBitConverter.TryToUInt32(source, MemoryHandler.Structures.CurrentPlayer.ID);
                var playerName      = MemoryHandler.GetStringFromBytes(source, MemoryHandler.Structures.CurrentPlayer.Name);
                var isCurrentlyBard = source[MemoryHandler.Structures.CurrentPlayer.JobID] == 0x17;

                if (ActorIdTools.RangeOkay(actorId) && !string.IsNullOrEmpty(playerName))
                {
                    result = new KeyValuePair <uint, (string, bool)>(actorId, (playerName, isCurrentlyBard));
                }
            }
            catch (Exception ex) {
                MemoryHandler?.RaiseException(ex);
            }
            return(result);
        }
コード例 #2
0
        public SortedDictionary <uint, string> GetPartyMembers()
        {
            var result = new SortedDictionary <uint, string>();

            if (!CanGetPartyMembers() || !MemoryHandler.IsAttached)
            {
                return(result);
            }

            var partyInfoMap  = (IntPtr)Scanner.Locations[Signatures.PartyMapKey];
            var partyCountMap = Scanner.Locations[Signatures.PartyCountKey];

            try {
                var partyCount = MemoryHandler.GetByte(partyCountMap);
                var sourceSize = MemoryHandler.Structures.PartyMember.SourceSize;

                if (partyCount > 1 && partyCount < 9)
                {
                    for (uint i = 0; i < partyCount; i++)
                    {
                        var address = partyInfoMap.ToInt64() + i * (uint)sourceSize;
                        var source  = MemoryHandler.GetByteArray(new IntPtr(address), sourceSize);

                        var actorId    = SBitConverter.TryToUInt32(source, MemoryHandler.Structures.PartyMember.ID);
                        var playerName = MemoryHandler.GetStringFromBytes(source, MemoryHandler.Structures.PartyMember.Name);
                        if (ActorIdTools.RangeOkay(actorId) && !string.IsNullOrEmpty(playerName))
                        {
                            result[actorId] = playerName;
                        }
                    }
                }
                if (result.Count == 1)
                {
                    result.Clear();
                }
            }
            catch (Exception ex) {
                MemoryHandler?.RaiseException(ex);
            }

            return(result);
        }