public static ActorEntity ResolveActorFromBytes(byte[] source)
 {
     var entry = new ActorEntity();
     try
     {
         entry.MapIndex = 0;
         entry.TargetID = 0;
         entry.Name = MemoryHandler.Instance.GetStringFromBytes(source, 48);
         entry.ID = BitConverter.ToUInt32(source, 0x74);
         entry.NPCID1 = BitConverter.ToUInt32(source, 0x78);
         entry.NPCID2 = BitConverter.ToUInt32(source, 0x80);
         entry.OwnerID = BitConverter.ToUInt32(source, 0x84);
         entry.Type = (Actor.Type) source[0x8A];
         entry.TargetType = (Actor.TargetType) source[0x8C];
         entry.Distance = source[0x8D];
         entry.GatheringStatus = source[0x8E];
         entry.X = BitConverter.ToSingle(source, 0xA0);
         entry.Z = BitConverter.ToSingle(source, 0xA4);
         entry.Y = BitConverter.ToSingle(source, 0xA8);
         entry.Heading = BitConverter.ToSingle(source, 0xB0);
         entry.Fate = BitConverter.ToUInt32(source, 0xE4); // ??
         entry.GatheringInvisible = source[0x11C]; // ??
         entry.ModelID = BitConverter.ToUInt32(source, 0x184);
         entry.ActionStatus = (Actor.ActionStatus) source[0x18C];
         entry.IsGM = BitConverter.ToBoolean(source, 0x193); // ?
         entry.Icon = (Actor.Icon) source[0x19C];
         entry.Status = (Actor.Status) source[0x19E];
         entry.ClaimedByID = BitConverter.ToUInt32(source, 0x1A0);
         var targetID = BitConverter.ToUInt32(source, 0x1A8);
         var pcTargetID = BitConverter.ToUInt32(source, 0xAA8);
         entry.Job = (Actor.Job) source[0x17C0];
         entry.Level = source[0x17C1];
         entry.GrandCompany = source[0x17C3];
         entry.GrandCompanyRank = source[0x17C4];
         entry.Title = source[0x17C6];
         entry.HPCurrent = BitConverter.ToInt32(source, 0x17C8);
         entry.HPMax = BitConverter.ToInt32(source, 0x17CC);
         entry.MPCurrent = BitConverter.ToInt32(source, 0x17D0);
         entry.MPMax = BitConverter.ToInt32(source, 0x17D4);
         entry.TPCurrent = BitConverter.ToInt16(source, 0x17D8);
         entry.TPMax = 1000;
         entry.GPCurrent = BitConverter.ToInt16(source, 0x17DA);
         entry.GPMax = BitConverter.ToInt16(source, 0x17DC);
         entry.CPCurrent = BitConverter.ToInt16(source, 0x17DE);
         entry.CPMax = BitConverter.ToInt16(source, 0x17E0);
         entry.Race = source[0x2E58]; // ??
         entry.Sex = (Actor.Sex) source[0x2E59]; //?
         entry.IsCasting = BitConverter.ToBoolean(source, 0x32C0);
         entry.CastingID = BitConverter.ToInt16(source, 0x32C4);
         entry.CastingTargetID = BitConverter.ToUInt32(source, 0x32D0);
         entry.CastingProgress = BitConverter.ToSingle(source, 0x32F4);
         entry.CastingTime = BitConverter.ToSingle(source, 0x33D8);
         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, 0x3148, 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.ToInt16(statusSource, 0x0),
                 Duration = BitConverter.ToSingle(statusSource, 0x4),
                 CasterID = BitConverter.ToUInt32(statusSource, 0x8)
             };
             try
             {
                 var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                 statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                 var statusKey = "";
                 switch (Settings.Default.GameLanguage)
                 {
                     case "English":
                         statusKey = statusInfo.Name.English;
                         break;
                     case "French":
                         statusKey = statusInfo.Name.French;
                         break;
                     case "German":
                         statusKey = statusInfo.Name.German;
                         break;
                     case "Japanese":
                         statusKey = statusInfo.Name.Japanese;
                         break;
                 }
                 statusEntry.StatusName = statusKey;
             }
             catch (Exception ex)
             {
                 statusEntry.StatusName = "UNKNOWN";
             }
             if (statusEntry.IsValid())
             {
                 entry.StatusEntries.Add(statusEntry);
             }
         }
     }
     catch (Exception ex)
     {
     }
     CleanXPValue(ref entry);
     return entry;
 }
Exemple #2
0
 /// <summary>
 /// </summary>
 /// <param name="sender"> </param>
 /// <param name="e"> </param>
 private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
 {
     if (_isScanning)
     {
         return;
     }
     _isScanning = true;
     double refresh = 1000;
     if (Double.TryParse(Settings.Default.PartyInfoWorkerRefresh.ToString(CultureInfo.InvariantCulture), out refresh))
     {
         _scanTimer.Interval = refresh;
     }
     Func<bool> scannerWorker = delegate
     {
         if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("CHARMAP"))
         {
             if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("PARTYMAP"))
             {
                 if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("PARTYCOUNT"))
                 {
                     PartyInfoMap = MemoryHandler.Instance.SigScanner.Locations["PARTYMAP"];
                     PartyCountMap = MemoryHandler.Instance.SigScanner.Locations["PARTYCOUNT"];
                     try
                     {
                         var partyEntities = new List<PartyEntity>();
                         var partyCount = MemoryHandler.Instance.GetByte(PartyCountMap);
                         if (partyCount > 0 && partyCount < 9)
                         {
                             for (uint i = 0; i < partyCount; i++)
                             {
                                 uint size;
                                 switch (Settings.Default.GameLanguage)
                                 {
                                     case "Chinese":
                                         size = 594;
                                         break;
                                     default:
                                         size = 544;
                                         break;
                                 }
                                 var address = PartyInfoMap + (i * size);
                                 var actor = MemoryHandler.Instance.GetStructure<Structures.PartyMember>(address);
                                 var entry = new PartyEntity
                                 {
                                     Name = MemoryHandler.Instance.GetString(address, 32),
                                     ID = actor.ID,
                                     Coordinate = new Coordinate(actor.X, actor.Z, actor.Y),
                                     X = actor.X,
                                     Z = actor.Z,
                                     Y = actor.Y,
                                     Level = actor.Level,
                                     HPCurrent = actor.HPCurrent,
                                     HPMax = actor.HPMax,
                                     MPCurrent = actor.MPCurrent,
                                     MPMax = actor.MPMax,
                                     Job = actor.Job
                                 };
                                 if (entry.HPMax == 0)
                                 {
                                     entry.HPMax = 1;
                                 }
                                 foreach (var status in actor.Statuses)
                                 {
                                     var statusEntry = new StatusEntry
                                     {
                                         TargetName = entry.Name,
                                         StatusID = status.StatusID,
                                         Duration = status.Duration,
                                         CasterID = status.CasterID
                                     };
                                     try
                                     {
                                         var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                                         statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                                         var statusKey = statusInfo.Name.English;
                                         switch (Settings.Default.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;
                                         }
                                         statusEntry.StatusName = statusKey;
                                     }
                                     catch (Exception ex)
                                     {
                                         statusEntry.StatusName = "UNKNOWN";
                                     }
                                     if (statusEntry.IsValid())
                                     {
                                         entry.StatusEntries.Add(statusEntry);
                                     }
                                 }
                                 if (entry.IsValid)
                                 {
                                     partyEntities.Add(entry);
                                 }
                             }
                         }
                         AppContextHelper.Instance.RaiseNewPartyEntries(partyEntities);
                     }
                     catch (Exception ex)
                     {
                     }
                 }
             }
         }
         _isScanning = false;
         return true;
     };
     scannerWorker.BeginInvoke(delegate { }, scannerWorker);
 }
Exemple #3
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,
             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 entry = new PartyEntity();
         try
         {
             switch (Settings.Default.GameLanguage)
             {
                 case "Chinese":
                 default:
                     entry.X = BitConverter.ToSingle(source, 0x0);
                     entry.Z = BitConverter.ToSingle(source, 0x4);
                     entry.Y = BitConverter.ToSingle(source, 0x8);
                     entry.Coordinate = new Coordinate(entry.X, entry.Z, entry.Z);
                     entry.ID = BitConverter.ToUInt32(source, 0x10);
                     entry.Name = MemoryHandler.Instance.GetStringFromBytes(source, 0x20);
                     entry.Job = (Actor.Job) source[0x61];
                     entry.Level = source[0x63];
                     entry.HPCurrent = BitConverter.ToInt32(source, 0x68);
                     entry.HPMax = BitConverter.ToInt32(source, 0x6C);
                     entry.MPCurrent = BitConverter.ToInt16(source, 0x70);
                     entry.MPMax = BitConverter.ToInt16(source, 0x72);
                     break;
             }
             const int limit = 15;
             entry.StatusEntries = new List<StatusEntry>();
             const int statusSize = 12;
             var statusesSource = new byte[limit * statusSize];
             switch (Settings.Default.GameLanguage)
             {
                 case "Chinese":
                 default:
                     var defaultStatusEffectOffset = MemoryHandler.Instance.ProcessModel.IsWin64 ? 0x88 : 0x80;
                     Buffer.BlockCopy(source, defaultStatusEffectOffset, statusesSource, 0, limit * 12);
                     break;
             }
             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.ToInt16(statusSource, 0x0),
                     Stacks = statusSource[0x2],
                     Duration = BitConverter.ToSingle(statusSource, 0x4),
                     CasterID = BitConverter.ToUInt32(statusSource, 0x8)
                 };
                 try
                 {
                     var pc = PCWorkerDelegate.GetNPCEntity(statusEntry.CasterID);
                     var npc = NPCWorkerDelegate.GetNPCEntity(statusEntry.CasterID);
                     var monster = MonsterWorkerDelegate.GetNPCEntity(statusEntry.CasterID);
                     statusEntry.SourceEntity = (pc ?? npc) ?? monster;
                 }
                 catch (Exception ex)
                 {
                 }
                 try
                 {
                     if (statusEntry.StatusID > 0)
                     {
                         var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                         statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                         var statusKey = statusInfo.Name.English;
                         switch (Settings.Default.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;
                         }
                         statusEntry.StatusName = statusKey;
                     }
                 }
                 catch (Exception ex)
                 {
                     statusEntry.StatusName = "UNKNOWN";
                 }
                 if (statusEntry.IsValid())
                 {
                     entry.StatusEntries.Add(statusEntry);
                 }
             }
         }
         catch (Exception ex)
         {
         }
         CleanXPValue(ref entry);
         return entry;
     }
 }
        public void NewPartyMemberStatusEntry(StatusEntry statusEntry, uint partyMemberId)
        {
            try
            {
                var partyMemberStatusEntry = new PartyMemberStatusEntry
                {
                    CasterId = statusEntry.CasterID,
                    Duration = statusEntry.Duration,
                    EncounterId = EncounterId,
                    PartyMemberId = partyMemberId,
                    StatusId = statusEntry.StatusID,
                    StatusName = statusEntry.StatusName,
                    TargetName = statusEntry.TargetName,
                    TimeOffset = Convert.ToUInt32(EncounterTimer.ElapsedMilliseconds)
                };

                _sqLiteConnection.InsertAsync(partyMemberStatusEntry)
                                 .ContinueWith(t => LogHelper.Log(Logger, "Status " + partyMemberStatusEntry.StatusName + " (" + partyMemberStatusEntry.StatusId + ") for party member " + partyMemberId + " captured for encounter " + EncounterId + ".", LogLevel.Trace));

                partyMemberStatusEntries.Add(partyMemberStatusEntry);
            }
            catch (Exception ex)
            {
                LogHelper.Log(Logger, ex, LogLevel.Error);
            }
        }
 private static PartyEntity GetPartyEntity(uint address, Structures.PartyMember partyMember, ActorEntity currentUser = null)
 {
     var actor = currentUser ?? (dynamic) partyMember;
     try
     {
         var entry = new PartyEntity
         {
             ID = actor.ID,
             X = actor.X,
             Z = actor.Z,
             Y = actor.Y,
             Level = actor.Level,
             HPCurrent = actor.HPCurrent,
             HPMax = actor.HPMax,
             MPCurrent = actor.MPCurrent,
             MPMax = actor.MPMax,
             Job = actor.Job
         };
         if (entry.HPMax == 0)
         {
             entry.HPMax = 1;
         }
         if (currentUser == null)
         {
             entry.Name = MemoryHandler.Instance.GetString(address, 32);
             entry.Coordinate = new Coordinate(actor.X, actor.Z, actor.Y);
             foreach (var status in actor.Statuses)
             {
                 var statusEntry = new StatusEntry
                 {
                     TargetName = entry.Name,
                     StatusID = status.StatusID,
                     Duration = status.Duration,
                     CasterID = status.CasterID
                 };
                 try
                 {
                     var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                     statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                     var statusKey = statusInfo.Name.English;
                     switch (Settings.Default.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;
                     }
                     statusEntry.StatusName = statusKey;
                 }
                 catch (Exception ex)
                 {
                     statusEntry.StatusName = "UNKNOWN";
                 }
                 if (statusEntry.IsValid())
                 {
                     entry.StatusEntries.Add(statusEntry);
                 }
             }
         }
         else
         {
             entry.Name = actor.Name;
             entry.Coordinate = actor.Coordinate;
             entry.StatusEntries = actor.StatusEntries;
         }
         return entry;
     }
     catch (Exception ex)
     {
     }
     return new PartyEntity();
 }
Exemple #6
0
        public static ActorEntity ResolveActorFromBytes(byte[] source, bool isCurrentUser = false)
        {
            var entry = new ActorEntity();
            try
            {
                uint targetID;
                uint pcTargetID;
                entry.MapIndex = 0;
                entry.TargetID = 0;
                switch (Settings.Default.GameLanguage)
                {
                    case "Chinese":
                        entry.Name = MemoryHandler.Instance.GetStringFromBytes(source, 48);
                        entry.ID = BitConverter.ToUInt32(source, 0x74);
                        entry.NPCID1 = BitConverter.ToUInt32(source, 0x78);
                        entry.NPCID2 = BitConverter.ToUInt32(source, 0x80);
                        entry.OwnerID = BitConverter.ToUInt32(source, 0x84);
                        entry.Type = (Actor.Type) source[0x8A];
                        entry.TargetType = (Actor.TargetType) source[0x8C];
                        entry.GatheringStatus = source[0x8E];
                        entry.Distance = source[0x8F];
                        entry.X = BitConverter.ToSingle(source, 0xA0);
                        entry.Z = BitConverter.ToSingle(source, 0xA4);
                        entry.Y = BitConverter.ToSingle(source, 0xA8);
                        entry.Heading = BitConverter.ToSingle(source, 0xB0);
                        entry.Fate = BitConverter.ToUInt32(source, 0xE4); // ??
                        entry.GatheringInvisible = source[0x11C]; // ??
                        entry.ModelID = BitConverter.ToUInt32(source, 0x174);
                        entry.ActionStatus = (Actor.ActionStatus) source[0x17C];
                        entry.IsGM = BitConverter.ToBoolean(source, 0x183); // ?
                        entry.Icon = (Actor.Icon) source[0x18C];
                        entry.Status = (Actor.Status) source[0x18E];
                        entry.ClaimedByID = BitConverter.ToUInt32(source, 0x1A0);
                        targetID = BitConverter.ToUInt32(source, 0x1A8);
                        pcTargetID = BitConverter.ToUInt32(source, 0xAA8);
                        entry.Job = (Actor.Job) source[0x17C0];
                        entry.Level = source[0x17C1];
                        entry.GrandCompany = source[0x17C3];
                        entry.GrandCompanyRank = source[0x17C4];
                        entry.Title = source[0x17C6];
                        entry.HPCurrent = BitConverter.ToInt32(source, 0x17C8);
                        entry.HPMax = BitConverter.ToInt32(source, 0x17CC);
                        entry.MPCurrent = BitConverter.ToInt32(source, 0x17D0);
                        entry.MPMax = BitConverter.ToInt32(source, 0x17D4);
                        entry.TPCurrent = BitConverter.ToInt16(source, 0x17D8);
                        entry.TPMax = 1000;
                        entry.GPCurrent = BitConverter.ToInt16(source, 0x17DA);
                        entry.GPMax = BitConverter.ToInt16(source, 0x17DC);
                        entry.CPCurrent = BitConverter.ToInt16(source, 0x17DE);
                        entry.CPMax = BitConverter.ToInt16(source, 0x17E0);
                        entry.Race = source[0x2E58]; // ??
                        entry.Sex = (Actor.Sex) source[0x2E59]; //?
                        entry.IsCasting = BitConverter.ToBoolean(source, 0x32E0);
                        entry.CastingID = BitConverter.ToInt16(source, 0x32E4);
                        entry.CastingTargetID = BitConverter.ToUInt32(source, 0x32F0);
                        entry.CastingProgress = BitConverter.ToSingle(source, 0x3314);
                        entry.CastingTime = BitConverter.ToSingle(source, 0x33F8);
                        entry.Coordinate = new Coordinate(entry.X, entry.Z, entry.Y);
                        break;
                    default:
                        entry.Name = MemoryHandler.Instance.GetStringFromBytes(source, 48);
                        entry.ID = BitConverter.ToUInt32(source, 0x74);
                        entry.NPCID1 = BitConverter.ToUInt32(source, 0x78);
                        entry.NPCID2 = BitConverter.ToUInt32(source, 0x80);
                        entry.OwnerID = BitConverter.ToUInt32(source, 0x84);
                        entry.Type = (Actor.Type) source[0x8A];
                        entry.TargetType = (Actor.TargetType) source[0x8C];
                        entry.GatheringStatus = source[0x8F];
                        entry.Distance = source[0x90];
                        entry.X = BitConverter.ToSingle(source, 0xA0);
                        entry.Z = BitConverter.ToSingle(source, 0xA4);
                        entry.Y = BitConverter.ToSingle(source, 0xA8);
                        entry.Heading = BitConverter.ToSingle(source, 0xB0);
                        entry.Fate = BitConverter.ToUInt32(source, 0xE4); // ??
                        entry.GatheringInvisible = source[0x11C]; // ??
                        entry.ModelID = BitConverter.ToUInt32(source, 0x174);
                        entry.ActionStatus = (Actor.ActionStatus) source[0x17C];
                        entry.IsGM = BitConverter.ToBoolean(source, 0x183); // ?
                        entry.Icon = (Actor.Icon) source[0x18C];
                        entry.Status = (Actor.Status) source[0x17E]; //0x18E];
                        entry.ClaimedByID = BitConverter.ToUInt32(source, 0x180); // 0x1A0);
                        targetID = BitConverter.ToUInt32(source, 0x188); // 0x1A8);
                        pcTargetID = BitConverter.ToUInt32(source, 0x938); // 0xAA8);
                        entry.Job = (Actor.Job) source[0x1540]; // 0x17C0];
                        entry.Level = source[0x1541]; // 0x17C1];
                        entry.GrandCompany = source[0x1543]; // 0x17C3];
                        entry.GrandCompanyRank = source[0x1544]; //0x17C4];
                        entry.Title = source[0x1546]; //0x17C6];
                        entry.HPCurrent = BitConverter.ToInt32(source, 0x1548); // 0x17C8);
                        entry.HPMax = BitConverter.ToInt32(source, 0x154C); // 0x17CC);
                        entry.MPCurrent = BitConverter.ToInt32(source, 0x1550); // 0x17D0);
                        entry.MPMax = BitConverter.ToInt32(source, 0x1554); // 0x17D4);
                        entry.TPCurrent = BitConverter.ToInt16(source, 0x1558); // 0x17D8);
                        entry.TPMax = 1000;
                        entry.GPCurrent = BitConverter.ToInt16(source, 0x155A); // 0x17DA);
                        entry.GPMax = BitConverter.ToInt16(source, 0x155C); // 0x17DC);
                        entry.CPCurrent = BitConverter.ToInt16(source, 0x155E); // 0x17DE);
                        entry.CPMax = BitConverter.ToInt16(source, 0x1560); // 0x17E0);
                        entry.Race = source[0x2808]; // ??
                        entry.Sex = (Actor.Sex) source[0x2809]; //?
                        entry.IsCasting = BitConverter.ToBoolean(source, 0x2A30); // 0x2C90);
                        entry.CastingID = BitConverter.ToInt16(source, 0x2A34); // 0x2C94);
                        entry.CastingTargetID = BitConverter.ToUInt32(source, 0x2A40); // 0x2CA0);
                        entry.CastingProgress = BitConverter.ToSingle(source, 0x2A64); // 0x2CC4);
                        entry.CastingTime = BitConverter.ToSingle(source, 0x2A68); // 0x2DA8);
                        entry.Coordinate = new Coordinate(entry.X, entry.Z, entry.Y);
                        break;
                }
                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];
                switch (Settings.Default.GameLanguage)
                {
                    case "Chinese":
                        Buffer.BlockCopy(source, 0x3168, statusesSource, 0, limit * 12);
                        break;
                    default:
                        Buffer.BlockCopy(source, 0x28BC, statusesSource, 0, limit * 12);
                        break;
                }
                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.ToInt16(statusSource, 0x0),
                        Stacks = statusSource[0x2],
                        Duration = BitConverter.ToSingle(statusSource, 0x4),
                        CasterID = BitConverter.ToUInt32(statusSource, 0x8)
                    };
                    try
                    {
                        var pc = PCWorkerDelegate.GetUniqueNPCEntities()
                                                 .FirstOrDefault(a => a.ID == statusEntry.CasterID);
                        var npc = NPCWorkerDelegate.GetUniqueNPCEntities()
                                                   .FirstOrDefault(a => a.NPCID2 == statusEntry.CasterID);
                        var monster = MonsterWorkerDelegate.GetUniqueNPCEntities()
                                                           .FirstOrDefault(a => a.ID == statusEntry.CasterID);
                        statusEntry.SourceEntity = (pc ?? npc) ?? monster;
                    }
                    catch (Exception ex)
                    {
                    }
                    try
                    {
                        var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
                        statusEntry.IsCompanyAction = statusInfo.CompanyAction;
                        var statusKey = statusInfo.Name.English;
                        switch (Settings.Default.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;
                        }
                        statusEntry.StatusName = statusKey;
                    }
                    catch (Exception ex)
                    {
                        statusEntry.StatusName = "UNKNOWN";
                    }
                    if (statusEntry.IsValid())
                    {
                        entry.StatusEntries.Add(statusEntry);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            CleanXPValue(ref entry);

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