public static ActorEntity ResolveActorFromBytes(byte[] source, bool isCurrentUser = false) { 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[0x8E]; entry.GatheringStatus = 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[0x17E]; //0x18E]; entry.ClaimedByID = BitConverter.ToUInt32(source, 0x180); // 0x1A0); var targetID = BitConverter.ToUInt32(source, 0x188); // 0x1A8); var 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); 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, 0x28B8, 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); if (isCurrentUser) { PCWorkerDelegate.CurrentUser = entry; } entry.CurrentUser = PCWorkerDelegate.CurrentUser; return(entry); }
/// <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); }
public static ActorEntity ResolveActorFromBytes(byte[] source, bool isCurrentUser = false, ActorEntity entry = null) { entry = 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, 0x7C); 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[0x91]; var defaultBaseOffset = MemoryHandler.Instance.ProcessModel.IsWin64 ? 0x10 : 0; entry.X = BitConverter.ToSingle(source, 0xA0 + defaultBaseOffset); entry.Z = BitConverter.ToSingle(source, 0xA4 + defaultBaseOffset); entry.Y = BitConverter.ToSingle(source, 0xA8 + defaultBaseOffset); entry.Heading = BitConverter.ToSingle(source, 0xB0 + defaultBaseOffset); entry.HitBoxRadius = BitConverter.ToSingle(source, 0xC0 + defaultBaseOffset); entry.Fate = BitConverter.ToUInt32(source, 0xE4 + defaultBaseOffset); // ?? entry.GatheringInvisible = source[0x11C]; // ?? entry.ModelID = BitConverter.ToUInt32(source, 0x174); entry.ActionStatus = (Actor.ActionStatus)source[0x17C]; // 0x17D - 0 = Green name, 4 = non-agro (yellow name) 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); var defaultStatOffset = MemoryHandler.Instance.ProcessModel.IsWin64 ? 0x230 : 0; entry.Job = (Actor.Job)source[0x14C0 + defaultStatOffset]; // 0x17C0]; entry.Level = source[0x14C1 + defaultStatOffset]; // 0x17C1]; entry.GrandCompany = source[0x14C3 + defaultStatOffset]; // 0x17C3]; entry.GrandCompanyRank = source[0x14C4 + defaultStatOffset]; //0x17C4]; entry.Title = source[0x1546 + defaultStatOffset]; //0x17C6]; entry.HPCurrent = BitConverter.ToInt32(source, 0x14C8 + defaultStatOffset); // 0x17C8); entry.HPMax = BitConverter.ToInt32(source, 0x14CC + defaultStatOffset); // 0x17CC); entry.MPCurrent = BitConverter.ToInt32(source, 0x14D0 + defaultStatOffset); // 0x17D0); entry.MPMax = BitConverter.ToInt32(source, 0x14D4 + defaultStatOffset); // 0x17D4); entry.TPCurrent = BitConverter.ToInt16(source, 0x14D8 + defaultStatOffset); // 0x17D8); entry.TPMax = 1000; entry.GPCurrent = BitConverter.ToInt16(source, 0x14DA + defaultStatOffset); // 0x17DA); entry.GPMax = BitConverter.ToInt16(source, 0x14DC + defaultStatOffset); // 0x17DC); entry.CPCurrent = BitConverter.ToInt16(source, 0x14DE + defaultStatOffset); // 0x17DE); entry.CPMax = BitConverter.ToInt16(source, 0x14E0 + defaultStatOffset); // 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: var defaultStatusEffectOffset = MemoryHandler.Instance.ProcessModel.IsWin64 ? 0x3740 : 0x2878; 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 { 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.GetNPCEntity(statusEntry.CasterID); var npc = NPCWorkerDelegate.GetNPCEntity(statusEntry.CasterID); var monster = MonsterWorkerDelegate.GetNPCEntity(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); }
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); } }
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.IsCasting = BitConverter.TryToBoolean(source, MemoryHandler.Instance.Structures.ActorEntity.IsCasting1) && BitConverter.TryToBoolean(source, MemoryHandler.Instance.Structures.ActorEntity.IsCasting2); // 0x2C90); 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); }
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); } }