示例#1
0
        public ulong GetUInt64(IntPtr address, long offset = 0)
        {
            var value = new byte[8];

            Peek(new IntPtr(address.ToInt64() + offset), value);
            return(BitConverter.TryToUInt32(value, 0));
        }
示例#2
0
 public long GetPlatformUIntFromBytes(byte[] source, int index = 0)
 {
     if (ProcessModel.IsWin64)
     {
         return((long)BitConverter.TryToUInt64(source, index));
     }
     return(BitConverter.TryToUInt32(source, index));
 }
示例#3
0
        public static TargetReadResult GetTargetInfo()
        {
            var result = new TargetReadResult();

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

            try
            {
                var targetAddress = (IntPtr)Scanner.Instance.Locations[Signatures.TargetKey];

                if (targetAddress.ToInt64() > 0)
                {
                    var targetInfoSource = MemoryHandler.Instance.GetByteArray(targetAddress, MemoryHandler.Instance.Structures.TargetInfo.SourceSize);

                    var currentTarget   = MemoryHandler.Instance.GetPlatformIntFromBytes(targetInfoSource, MemoryHandler.Instance.Structures.TargetInfo.Current);
                    var mouseOverTarget = MemoryHandler.Instance.GetPlatformIntFromBytes(targetInfoSource, MemoryHandler.Instance.Structures.TargetInfo.MouseOver);
                    var focusTarget     = MemoryHandler.Instance.GetPlatformIntFromBytes(targetInfoSource, MemoryHandler.Instance.Structures.TargetInfo.Focus);
                    var previousTarget  = MemoryHandler.Instance.GetPlatformIntFromBytes(targetInfoSource, MemoryHandler.Instance.Structures.TargetInfo.Previous);

                    var currentTargetID = BitConverter.TryToUInt32(targetInfoSource, MemoryHandler.Instance.Structures.TargetInfo.CurrentID);

                    if (currentTarget > 0)
                    {
                        try
                        {
                            var entry = GetTargetActorEntityFromSource(currentTarget);
                            currentTargetID = entry.ID;
                            if (entry.IsValid)
                            {
                                result.TargetsFound = true;
                                result.TargetEntity.CurrentTarget = entry;
                            }
                        }
                        catch (Exception ex)
                        {
                            MemoryHandler.Instance.RaiseException(Logger, ex, true);
                        }
                    }
                    if (mouseOverTarget > 0)
                    {
                        try
                        {
                            var entry = GetTargetActorEntityFromSource(mouseOverTarget);
                            if (entry.IsValid)
                            {
                                result.TargetsFound = true;
                                result.TargetEntity.MouseOverTarget = entry;
                            }
                        }
                        catch (Exception ex)
                        {
                            MemoryHandler.Instance.RaiseException(Logger, ex, true);
                        }
                    }
                    if (focusTarget > 0)
                    {
                        try
                        {
                            var entry = GetTargetActorEntityFromSource(focusTarget);
                            if (entry.IsValid)
                            {
                                result.TargetsFound             = true;
                                result.TargetEntity.FocusTarget = entry;
                            }
                        }
                        catch (Exception ex)
                        {
                            MemoryHandler.Instance.RaiseException(Logger, ex, true);
                        }
                    }
                    if (previousTarget > 0)
                    {
                        try
                        {
                            var entry = GetTargetActorEntityFromSource(previousTarget);
                            if (entry.IsValid)
                            {
                                result.TargetsFound = true;
                                result.TargetEntity.PreviousTarget = entry;
                            }
                        }
                        catch (Exception ex)
                        {
                            MemoryHandler.Instance.RaiseException(Logger, ex, true);
                        }
                    }
                    if (currentTargetID > 0)
                    {
                        result.TargetsFound = true;
                        result.TargetEntity.CurrentTargetID = currentTargetID;
                    }
                }
                if (result.TargetEntity.CurrentTargetID > 0)
                {
                    var enmityEntries = new List <EnmityEntry>();

                    try
                    {
                        if (CanGetEnmityEntities())
                        {
                            var enmityCount     = MemoryHandler.Instance.GetInt16(Scanner.Instance.Locations[Signatures.EnmityCountKey]);
                            var enmityStructure = (IntPtr)Scanner.Instance.Locations[Signatures.EnmityMapKey];

                            if (enmityCount > 0 && enmityCount < 16 && enmityStructure.ToInt64() > 0)
                            {
                                for (uint i = 0; i < enmityCount; i++)
                                {
                                    try
                                    {
                                        var address     = new IntPtr(enmityStructure.ToInt64() + i * 72);
                                        var enmityEntry = new EnmityEntry
                                        {
                                            ID     = (uint)MemoryHandler.Instance.GetPlatformInt(address, MemoryHandler.Instance.Structures.EnmityEntry.ID),
                                            Name   = MemoryHandler.Instance.GetString(address + MemoryHandler.Instance.Structures.EnmityEntry.Name),
                                            Enmity = MemoryHandler.Instance.GetUInt32(address + MemoryHandler.Instance.Structures.EnmityEntry.Enmity)
                                        };
                                        if (enmityEntry.ID <= 0)
                                        {
                                            continue;
                                        }
                                        if (string.IsNullOrWhiteSpace(enmityEntry.Name))
                                        {
                                            var pc      = PCWorkerDelegate.GetEntity(enmityEntry.ID);
                                            var npc     = NPCWorkerDelegate.GetEntity(enmityEntry.ID);
                                            var monster = MonsterWorkerDelegate.GetEntity(enmityEntry.ID);
                                            try
                                            {
                                                enmityEntry.Name = (pc ?? npc).Name ?? monster.Name;
                                            }
                                            catch (Exception ex)
                                            {
                                                MemoryHandler.Instance.RaiseException(Logger, ex, true);
                                            }
                                        }
                                        enmityEntries.Add(enmityEntry);
                                    }
                                    catch (Exception ex)
                                    {
                                        MemoryHandler.Instance.RaiseException(Logger, ex, true);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MemoryHandler.Instance.RaiseException(Logger, ex, true);
                    }

                    result.TargetEntity.EnmityEntries = enmityEntries;
                }
            }
            catch (Exception ex)
            {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }

            return(result);
        }
示例#4
0
        public static ActorReadResult GetActors()
        {
            var result = new ActorReadResult();

            if (!Scanner.Instance.Locations.ContainsKey("CHARMAP"))
            {
                return(result);
            }

            try
            {
                #region Ensure Target

                var targetAddress = IntPtr.Zero;

                #endregion

                var endianSize = MemoryHandler.Instance.ProcessModel.IsWin64 ? 8 : 4;

                var limit = MemoryHandler.Instance.Structures.ActorInfo.Size;

                var characterAddressMap = MemoryHandler.Instance.GetByteArray(Scanner.Instance.Locations["CHARMAP"], endianSize * limit);
                var uniqueAddresses     = new Dictionary <IntPtr, IntPtr>();
                var firstAddress        = IntPtr.Zero;

                var firstTime = true;

                for (var i = 0; i < limit; i++)
                {
                    IntPtr characterAddress;

                    if (MemoryHandler.Instance.ProcessModel.IsWin64)
                    {
                        characterAddress = new IntPtr(BitConverter.TryToInt64(characterAddressMap, i * endianSize));
                    }
                    else
                    {
                        characterAddress = new IntPtr(BitConverter.TryToInt32(characterAddressMap, i * endianSize));
                    }
                    if (characterAddress == IntPtr.Zero)
                    {
                        continue;
                    }

                    if (firstTime)
                    {
                        firstAddress = characterAddress;
                        firstTime    = false;
                    }
                    uniqueAddresses[characterAddress] = characterAddress;
                }

                #region ActorEntity Handlers

                result.RemovedMonster = MonsterWorkerDelegate.EntitiesDictionary.Keys.ToDictionary(key => key);
                result.RemovedNPC     = NPCWorkerDelegate.EntitiesDictionary.Keys.ToDictionary(key => key);
                result.RemovedPC      = PCWorkerDelegate.EntitiesDictionary.Keys.ToDictionary(key => key);

                foreach (var kvp in uniqueAddresses)
                {
                    try
                    {
                        var source = MemoryHandler.Instance.GetByteArray(new IntPtr(kvp.Value.ToInt64()), 0x23F0);
                        //var source = MemoryHandler.Instance.GetByteArray(characterAddress, 0x3F40);

                        var         ID       = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.ID);
                        var         NPCID2   = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.NPCID2);
                        var         Type     = (Actor.Type)source[MemoryHandler.Instance.Structures.ActorEntity.Type];
                        ActorEntity existing = null;
                        var         newEntry = false;

                        switch (Type)
                        {
                        case Actor.Type.Monster:
                            if (result.RemovedMonster.ContainsKey(ID))
                            {
                                result.RemovedMonster.Remove(ID);
                                existing = MonsterWorkerDelegate.GetEntity(ID);
                            }
                            else
                            {
                                result.NewMonster.Add(ID);
                                newEntry = true;
                            }
                            break;

                        case Actor.Type.PC:
                            if (result.RemovedPC.ContainsKey(ID))
                            {
                                result.RemovedPC.Remove(ID);
                                existing = PCWorkerDelegate.GetEntity(ID);
                            }
                            else
                            {
                                result.NewPC.Add(ID);
                                newEntry = true;
                            }
                            break;

                        case Actor.Type.NPC:
                        case Actor.Type.Aetheryte:
                        case Actor.Type.EObj:
                            if (result.RemovedNPC.ContainsKey(NPCID2))
                            {
                                result.RemovedNPC.Remove(NPCID2);
                                existing = NPCWorkerDelegate.GetEntity(NPCID2);
                            }
                            else
                            {
                                result.NewNPC.Add(NPCID2);
                                newEntry = true;
                            }
                            break;

                        default:
                            if (result.RemovedNPC.ContainsKey(ID))
                            {
                                result.RemovedNPC.Remove(ID);
                                existing = NPCWorkerDelegate.GetEntity(ID);
                            }
                            else
                            {
                                result.NewNPC.Add(ID);
                                newEntry = true;
                            }
                            break;
                        }

                        var isFirstEntry = kvp.Value.ToInt64() == firstAddress.ToInt64();

                        var entry = ActorEntityHelper.ResolveActorFromBytes(source, isFirstEntry, existing);

                        #region Ensure Map & Zone

                        EnsureMapAndZone(entry);

                        #endregion

                        if (isFirstEntry)
                        {
                            if (targetAddress.ToInt64() > 0)
                            {
                                var targetInfoSource = MemoryHandler.Instance.GetByteArray(targetAddress, 128);
                                entry.TargetID = (int)BitConverter.TryToUInt32(targetInfoSource, MemoryHandler.Instance.Structures.ActorEntity.ID);
                            }
                        }
                        if (!entry.IsValid)
                        {
                            result.NewMonster.Remove(entry.ID);
                            result.NewMonster.Remove(entry.NPCID2);
                            result.NewNPC.Remove(entry.ID);
                            result.NewNPC.Remove(entry.NPCID2);
                            result.NewPC.Remove(entry.ID);
                            result.NewPC.Remove(entry.NPCID2);
                            continue;
                        }
                        if (existing != null)
                        {
                            continue;
                        }

                        if (newEntry)
                        {
                            switch (entry.Type)
                            {
                            case Actor.Type.Monster:
                                MonsterWorkerDelegate.EnsureEntity(entry.ID, entry);
                                break;

                            case Actor.Type.PC:
                                PCWorkerDelegate.EnsureEntity(entry.ID, entry);
                                break;

                            case Actor.Type.Aetheryte:
                            case Actor.Type.EObj:
                            case Actor.Type.NPC:
                                NPCWorkerDelegate.EnsureEntity(entry.NPCID2, entry);
                                break;

                            default:
                                NPCWorkerDelegate.EnsureEntity(entry.ID, entry);
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MemoryHandler.Instance.RaiseException(Logger, ex, true);
                    }
                }

                try
                {
                    // REMOVE OLD MONSTERS FROM LIVE CURRENT DICTIONARY
                    foreach (var kvp in result.RemovedMonster)
                    {
                        MonsterWorkerDelegate.RemoveEntity(kvp.Key);
                    }

                    // REMOVE OLD NPC'S FROM LIVE CURRENT DICTIONARY
                    foreach (var kvp in result.RemovedNPC)
                    {
                        NPCWorkerDelegate.RemoveEntity(kvp.Key);
                    }

                    // REMOVE OLD PC'S FROM LIVE CURRENT DICTIONARY
                    foreach (var kvp in result.RemovedPC)
                    {
                        PCWorkerDelegate.RemoveEntity(kvp.Key);
                    }
                }
                catch (Exception ex)
                {
                    MemoryHandler.Instance.RaiseException(Logger, ex, true);
                }

                MemoryHandler.Instance.ScanCount++;

                #endregion
            }
            catch (Exception ex)
            {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }

            return(result);
        }
示例#5
0
        public static PartyInfoReadResult GetPartyMembers()
        {
            var result = new PartyInfoReadResult();

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

            var PartyInfoMap  = (IntPtr)Scanner.Instance.Locations[Signatures.PartyMapKey];
            var PartyCountMap = Scanner.Instance.Locations[Signatures.PartyCountKey];

            try
            {
                var partyCount = MemoryHandler.Instance.GetByte(PartyCountMap);

                if (partyCount > 1 && partyCount < 9)
                {
                    for (uint i = 0; i < partyCount; i++)
                    {
                        var         size     = (uint)MemoryHandler.Instance.Structures.PartyInfo.Size;
                        var         address  = PartyInfoMap.ToInt64() + i * size;
                        var         source   = MemoryHandler.Instance.GetByteArray(new IntPtr(address), (int)size);
                        var         ID       = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.PartyEntity.ID);
                        ActorEntity existing = null;
                        if (result.RemovedParty.ContainsKey(ID))
                        {
                            result.RemovedParty.Remove(ID);
                            if (MonsterWorkerDelegate.EntitiesDictionary.ContainsKey(ID))
                            {
                                existing = MonsterWorkerDelegate.GetEntity(ID);
                            }
                            if (PCWorkerDelegate.EntitiesDictionary.ContainsKey(ID))
                            {
                                existing = PCWorkerDelegate.GetEntity(ID);
                            }
                        }
                        else
                        {
                            result.NewParty.Add(ID);
                        }
                        var entry = PartyEntityHelper.ResolvePartyMemberFromBytes(source, existing);
                        if (!entry.IsValid)
                        {
                            continue;
                        }
                        if (existing != null)
                        {
                            continue;
                        }
                        PartyInfoWorkerDelegate.EnsureEntity(entry.ID, entry);
                    }
                }
                else if (partyCount == 0 || partyCount == 1)
                {
                    var entry = PartyEntityHelper.ResolvePartyMemberFromBytes(new byte[0], PCWorkerDelegate.CurrentUser);
                    if (entry.IsValid)
                    {
                        var exists = false;
                        if (result.RemovedParty.ContainsKey(entry.ID))
                        {
                            result.RemovedParty.Remove(entry.ID);
                            exists = true;
                        }
                        else
                        {
                            result.NewParty.Add(entry.ID);
                        }
                        if (!exists)
                        {
                            PartyInfoWorkerDelegate.EnsureEntity(entry.ID, entry);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }

            try
            {
                // REMOVE OLD PARTY MEMBERS FROM LIVE CURRENT DICTIONARY
                foreach (var kvp in result.RemovedParty)
                {
                    PartyInfoWorkerDelegate.RemoveEntity(kvp.Key);
                }
            }
            catch (Exception ex)
            {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }

            return(result);
        }
示例#6
0
        public static PartyEntity ResolvePartyMemberFromBytes(byte[] source, ActorEntity actorEntity = null)
        {
            if (actorEntity != null)
            {
                var entry = new PartyEntity
                {
                    X             = actorEntity.X,
                    Y             = actorEntity.Y,
                    Z             = actorEntity.Z,
                    Coordinate    = actorEntity.Coordinate,
                    ID            = actorEntity.ID,
                    UUID          = actorEntity.UUID,
                    Name          = actorEntity.Name,
                    Job           = actorEntity.Job,
                    Level         = actorEntity.Level,
                    HPCurrent     = actorEntity.HPCurrent,
                    HPMax         = actorEntity.HPMax,
                    MPCurrent     = actorEntity.MPCurrent,
                    MPMax         = actorEntity.MPMax,
                    StatusEntries = actorEntity.StatusEntries
                };
                CleanXPValue(ref entry);
                return(entry);
            }
            else
            {
                var defaultStatusEffectOffset = MemoryHandler.Instance.Structures.PartyEntity.DefaultStatusEffectOffset;
                var entry = new PartyEntity();
                try
                {
                    entry.X          = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.PartyEntity.X);
                    entry.Z          = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.PartyEntity.Z);
                    entry.Y          = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.PartyEntity.Y);
                    entry.Coordinate = new Coordinate(entry.X, entry.Z, entry.Z);
                    entry.ID         = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.PartyEntity.ID);
                    entry.UUID       = Guid.NewGuid()
                                       .ToString();
                    entry.Name      = MemoryHandler.Instance.GetStringFromBytes(source, MemoryHandler.Instance.Structures.PartyEntity.Name);
                    entry.JobID     = source[MemoryHandler.Instance.Structures.PartyEntity.Job];
                    entry.Job       = (Actor.Job)entry.JobID;
                    entry.Level     = source[MemoryHandler.Instance.Structures.PartyEntity.Level];
                    entry.HPCurrent = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.PartyEntity.HPCurrent);
                    entry.HPMax     = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.PartyEntity.HPMax);
                    entry.MPCurrent = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.PartyEntity.MPCurrent);
                    entry.MPMax     = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.PartyEntity.MPMax);
                    const int limit = 15;
                    entry.StatusEntries = new List <StatusEntry>();
                    const int statusSize     = 12;
                    var       statusesSource = new byte[limit * statusSize];

                    Buffer.BlockCopy(source, defaultStatusEffectOffset, statusesSource, 0, limit * 12);
                    for (var i = 0; i < limit; i++)
                    {
                        var statusSource = new byte[statusSize];
                        Buffer.BlockCopy(statusesSource, i * statusSize, statusSource, 0, statusSize);
                        var statusEntry = new StatusEntry
                        {
                            TargetName = entry.Name,
                            StatusID   = BitConverter.TryToInt16(statusSource, MemoryHandler.Instance.Structures.StatusEntry.StatusID),
                            Stacks     = statusSource[MemoryHandler.Instance.Structures.StatusEntry.Stacks],
                            Duration   = BitConverter.TryToSingle(statusSource, MemoryHandler.Instance.Structures.StatusEntry.Duration),
                            CasterID   = BitConverter.TryToUInt32(statusSource, MemoryHandler.Instance.Structures.StatusEntry.CasterID)
                        };
                        try
                        {
                            var pc      = PCWorkerDelegate.GetEntity(statusEntry.CasterID);
                            var npc     = NPCWorkerDelegate.GetEntity(statusEntry.CasterID);
                            var monster = MonsterWorkerDelegate.GetEntity(statusEntry.CasterID);
                            statusEntry.SourceEntity = (pc ?? npc) ?? monster;
                        }
                        catch (Exception ex)
                        {
                            MemoryHandler.Instance.RaiseException(Logger, ex, true);
                        }
                        try
                        {
                            if (statusEntry.StatusID > 0)
                            {
                                var statusInfo = StatusEffectHelper.StatusInfo((uint)statusEntry.StatusID);
                                statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                                var statusKey = statusInfo.Name.English;
                                switch (MemoryHandler.Instance.GameLanguage)
                                {
                                case "French":
                                    statusKey = statusInfo.Name.French;
                                    break;

                                case "Japanese":
                                    statusKey = statusInfo.Name.Japanese;
                                    break;

                                case "German":
                                    statusKey = statusInfo.Name.German;
                                    break;

                                case "Chinese":
                                    statusKey = statusInfo.Name.Chinese;
                                    break;

                                case "Korean":
                                    statusKey = statusInfo.Name.Korean;
                                    break;
                                }
                                statusEntry.StatusName = statusKey;
                            }
                        }
                        catch (Exception)
                        {
                            statusEntry.StatusName = "UNKNOWN";
                        }
                        if (statusEntry.IsValid())
                        {
                            entry.StatusEntries.Add(statusEntry);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MemoryHandler.Instance.RaiseException(Logger, ex, true);
                }
                CleanXPValue(ref entry);
                return(entry);
            }
        }
示例#7
0
        public static ActorEntity ResolveActorFromBytes(byte[] source, bool isCurrentUser = false, ActorEntity entry = null)
        {
            entry = entry ?? new ActorEntity();
            var defaultBaseOffset         = MemoryHandler.Instance.Structures.ActorEntity.DefaultBaseOffset;
            var defaultStatOffset         = MemoryHandler.Instance.Structures.ActorEntity.DefaultStatOffset;
            var defaultStatusEffectOffset = MemoryHandler.Instance.Structures.ActorEntity.DefaultStatusEffectOffset;

            try
            {
                entry.MapTerritory = 0;
                entry.MapIndex     = 0;
                entry.MapID        = 0;
                entry.TargetID     = 0;
                entry.Name         = MemoryHandler.Instance.GetStringFromBytes(source, MemoryHandler.Instance.Structures.ActorEntity.Name);
                entry.ID           = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.ID);
                entry.UUID         = string.IsNullOrEmpty(entry.UUID) ? Guid.NewGuid()
                                     .ToString() : entry.UUID;
                entry.NPCID1       = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.NPCID1);
                entry.NPCID2       = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.NPCID2);
                entry.OwnerID      = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.OwnerID);
                entry.TypeID       = source[MemoryHandler.Instance.Structures.ActorEntity.Type];
                entry.Type         = (Actor.Type)entry.TypeID;
                entry.TargetTypeID = source[MemoryHandler.Instance.Structures.ActorEntity.TargetType];
                entry.TargetType   = (Actor.TargetType)entry.TargetTypeID;

                entry.GatheringStatus = source[MemoryHandler.Instance.Structures.ActorEntity.GatheringStatus];
                entry.Distance        = source[MemoryHandler.Instance.Structures.ActorEntity.Distance];

                entry.X                  = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.X + defaultBaseOffset);
                entry.Z                  = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.Z + defaultBaseOffset);
                entry.Y                  = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.Y + defaultBaseOffset);
                entry.Heading            = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.Heading + defaultBaseOffset);
                entry.HitBoxRadius       = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.HitBoxRadius + defaultBaseOffset);
                entry.Fate               = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.Fate + defaultBaseOffset); // ??
                entry.GatheringInvisible = source[MemoryHandler.Instance.Structures.ActorEntity.GatheringInvisible];                                 // ??
                entry.ModelID            = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.ModelID);
                entry.ActionStatusID     = source[MemoryHandler.Instance.Structures.ActorEntity.ActionStatus];
                entry.ActionStatus       = (Actor.ActionStatus)entry.ActionStatusID;

                // 0x17D - 0 = Green name, 4 = non-agro (yellow name)
                entry.IsGM   = BitConverter.TryToBoolean(source, MemoryHandler.Instance.Structures.ActorEntity.IsGM); // ?
                entry.IconID = source[MemoryHandler.Instance.Structures.ActorEntity.Icon];
                entry.Icon   = (Actor.Icon)entry.IconID;

                entry.StatusID = source[MemoryHandler.Instance.Structures.ActorEntity.Status];
                entry.Status   = (Actor.Status)entry.StatusID;

                entry.ClaimedByID = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.ClaimedByID);
                var targetID   = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.TargetID);
                var pcTargetID = targetID;

                entry.JobID            = source[MemoryHandler.Instance.Structures.ActorEntity.Job + defaultStatOffset];
                entry.Job              = (Actor.Job)entry.JobID;
                entry.Level            = source[MemoryHandler.Instance.Structures.ActorEntity.Level + defaultStatOffset];
                entry.GrandCompany     = source[MemoryHandler.Instance.Structures.ActorEntity.GrandCompany + defaultStatOffset];
                entry.GrandCompanyRank = source[MemoryHandler.Instance.Structures.ActorEntity.GrandCompanyRank + defaultStatOffset];
                entry.Title            = source[MemoryHandler.Instance.Structures.ActorEntity.Title + defaultStatOffset];
                entry.HPCurrent        = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.ActorEntity.HPCurrent + defaultStatOffset);
                entry.HPMax            = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.ActorEntity.HPMax + defaultStatOffset);
                entry.MPCurrent        = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.ActorEntity.MPCurrent + defaultStatOffset);
                entry.MPMax            = BitConverter.TryToInt32(source, MemoryHandler.Instance.Structures.ActorEntity.MPMax + defaultStatOffset);
                entry.TPCurrent        = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.TPCurrent + defaultStatOffset);
                entry.TPMax            = 1000;
                entry.GPCurrent        = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.GPCurrent + defaultStatOffset);
                entry.GPMax            = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.GPMax + defaultStatOffset);
                entry.CPCurrent        = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.CPCurrent + defaultStatOffset);
                entry.CPMax            = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.CPMax + defaultStatOffset);
                //entry.Race = source[0x2578]; // ??
                //entry.Sex = (Actor.Sex) source[0x2579]; //?
                entry.CombatFlags     = source[MemoryHandler.Instance.Structures.ActorEntity.CombatFlags];
                entry.DifficultyRank  = source[MemoryHandler.Instance.Structures.ActorEntity.DifficultyRank];
                entry.CastingID       = BitConverter.TryToInt16(source, MemoryHandler.Instance.Structures.ActorEntity.CastingID);        // 0x2C94);
                entry.CastingTargetID = BitConverter.TryToUInt32(source, MemoryHandler.Instance.Structures.ActorEntity.CastingTargetID); // 0x2CA0);
                entry.CastingProgress = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.CastingProgress); // 0x2CC4);
                entry.CastingTime     = BitConverter.TryToSingle(source, MemoryHandler.Instance.Structures.ActorEntity.CastingTime);     // 0x2DA8);
                entry.Coordinate      = new Coordinate(entry.X, entry.Z, entry.Y);
                if (targetID > 0)
                {
                    entry.TargetID = (int)targetID;
                }
                else
                {
                    if (pcTargetID > 0)
                    {
                        entry.TargetID = (int)pcTargetID;
                    }
                }
                if (entry.CastingTargetID == 3758096384)
                {
                    entry.CastingTargetID = 0;
                }
                entry.MapIndex = 0;
                var limit = 60;
                switch (entry.Type)
                {
                case Actor.Type.PC:
                    limit = 30;
                    break;
                }
                entry.StatusEntries = new List <StatusEntry>();
                const int statusSize     = 12;
                var       statusesSource = new byte[limit * statusSize];

                Buffer.BlockCopy(source, defaultStatusEffectOffset, statusesSource, 0, limit * statusSize);
                for (var i = 0; i < limit; i++)
                {
                    var statusSource = new byte[statusSize];
                    Buffer.BlockCopy(statusesSource, i * statusSize, statusSource, 0, statusSize);
                    var statusEntry = new StatusEntry
                    {
                        TargetEntity = entry,
                        TargetName   = entry.Name,
                        StatusID     = BitConverter.TryToInt16(statusSource, MemoryHandler.Instance.Structures.StatusEntry.StatusID),
                        Stacks       = statusSource[MemoryHandler.Instance.Structures.StatusEntry.Stacks],
                        Duration     = BitConverter.TryToSingle(statusSource, MemoryHandler.Instance.Structures.StatusEntry.Duration),
                        CasterID     = BitConverter.TryToUInt32(statusSource, MemoryHandler.Instance.Structures.StatusEntry.CasterID)
                    };
                    try
                    {
                        var pc      = PCWorkerDelegate.GetEntity(statusEntry.CasterID);
                        var npc     = NPCWorkerDelegate.GetEntity(statusEntry.CasterID);
                        var monster = MonsterWorkerDelegate.GetEntity(statusEntry.CasterID);
                        statusEntry.SourceEntity = (pc ?? npc) ?? monster;
                    }
                    catch (Exception ex)
                    {
                        MemoryHandler.Instance.RaiseException(Logger, ex, true);
                    }
                    try
                    {
                        var statusInfo = StatusEffectHelper.StatusInfo((uint)statusEntry.StatusID);
                        if (statusInfo != null)
                        {
                            statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                            var statusKey = statusInfo.Name.English;
                            switch (MemoryHandler.Instance.GameLanguage)
                            {
                            case "French":
                                statusKey = statusInfo.Name.French;
                                break;

                            case "Japanese":
                                statusKey = statusInfo.Name.Japanese;
                                break;

                            case "German":
                                statusKey = statusInfo.Name.German;
                                break;

                            case "Chinese":
                                statusKey = statusInfo.Name.Chinese;
                                break;

                            case "Korean":
                                statusKey = statusInfo.Name.Korean;
                                break;
                            }
                            statusEntry.StatusName = statusKey;
                        }
                    }
                    catch (Exception)
                    {
                        statusEntry.StatusName = "UNKNOWN";
                    }
                    if (statusEntry.IsValid())
                    {
                        entry.StatusEntries.Add(statusEntry);
                    }
                }
            }
            catch (Exception ex)
            {
                MemoryHandler.Instance.RaiseException(Logger, ex, true);
            }
            CleanXPValue(ref entry);

            if (isCurrentUser)
            {
                PCWorkerDelegate.CurrentUser = entry;
            }
            return(entry);
        }