Exemple #1
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.PlayerInfoWorkerRefresh.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("PLAYERINFO"))
             {
                 PlayerInfoMap = MemoryHandler.Instance.SigScanner.Locations["PLAYERINFO"];
                 if (PlayerInfoMap <= 6496)
                 {
                     return false;
                 }
                 try
                 {
                     short enmityCount;
                     uint enmityStructure;
                     switch (Settings.Default.GameLanguage)
                     {
                         case "Chinese":
                             enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 5688);
                             enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 3384;
                             break;
                         default:
                             enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] - 0x1C590); // 116032
                             enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] - 0x1CE94; // 118340;
                             break;
                     }
                     var enmityEntries = new List<EnmityEntry>();
                     if (enmityCount > 0 && enmityCount < 32 && enmityStructure > 0)
                     {
                         for (uint i = 0; i < enmityCount; i++)
                         {
                             var address = enmityStructure + (i * 72);
                             var enmityEntry = new EnmityEntry
                             {
                                 ID = (uint) MemoryHandler.Instance.GetInt32(address),
                                 Name = MemoryHandler.Instance.GetString(address + 4),
                                 Enmity = (uint) MemoryHandler.Instance.GetInt16(address + 72)
                             };
                             if (enmityEntry.ID > 0)
                             {
                                 enmityEntries.Add(enmityEntry);
                             }
                         }
                     }
                     var source = MemoryHandler.Instance.GetByteArray(PlayerInfoMap, 0x256);
                     try
                     {
                         var entry = PlayerEntityHelper.ResolvePlayerFromBytes(source);
                         entry.EnmityEntries = enmityEntries;
                         var notify = false;
                         if (LastPlayerEntity == null)
                         {
                             LastPlayerEntity = entry;
                             notify = true;
                         }
                         else
                         {
                             var hash1 = JsonConvert.SerializeObject(LastPlayerEntity)
                                                    .GetHashCode();
                             var hash2 = JsonConvert.SerializeObject(entry)
                                                    .GetHashCode();
                             if (!hash1.Equals(hash2))
                             {
                                 LastPlayerEntity = entry;
                                 notify = true;
                             }
                         }
                         if (notify)
                         {
                             AppContextHelper.Instance.RaiseNewPlayerEntity(entry);
                         }
                     }
                     catch (Exception ex)
                     {
                     }
                 }
                 catch (Exception ex)
                 {
                 }
             }
             else
             {
                 try
                 {
                     switch (Settings.Default.GameLanguage)
                     {
                         case "Chinese":
                             PlayerInfoMap = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 5724;
                             break;
                         default:
                             PlayerInfoMap = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] - 115996;
                             break;
                     }
                     MemoryHandler.Instance.SigScanner.Locations.Add("PLAYERINFO", PlayerInfoMap);
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
         _isScanning = false;
         return true;
     };
     scannerWorker.BeginInvoke(delegate { }, scannerWorker);
 }
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 = 100;
     if (Double.TryParse(Settings.Default.TargetWorkerRefresh.ToString(CultureInfo.InvariantCulture), out refresh))
     {
         _scanTimer.Interval = refresh;
     }
     Func<bool> scannerWorker = delegate
     {
         if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("GAMEMAIN"))
         {
             if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("CHARMAP"))
             {
                 try
                 {
                     uint targetHateStructure;
                     switch (Settings.Default.GameLanguage)
                     {
                         case "Chinese":
                             targetHateStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 1136;
                             break;
                         default:
                             targetHateStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] - 120664;
                             break;
                     }
                     var enmityEntries = new List<EnmityEntry>();
                     var targetEntity = new TargetEntity();
                     if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("TARGET"))
                     {
                         var targetAddress = MemoryHandler.Instance.SigScanner.Locations["TARGET"];
                         var somethingFound = false;
                         if (targetAddress > 0)
                         {
                             //var targetInfo = MemoryHandler.Instance.GetStructure<Structures.Target>(targetAddress);
                             uint currentTarget;
                             uint mouseOverTarget;
                             uint focusTarget;
                             uint previousTarget;
                             uint currentTargetID;
                             var targetInfoSource = MemoryHandler.Instance.GetByteArray(targetAddress, 128);
                             switch (Settings.Default.GameLanguage)
                             {
                                 case "Chinese":
                                     currentTarget = BitConverter.ToUInt32(targetInfoSource, 0x0);
                                     mouseOverTarget = BitConverter.ToUInt32(targetInfoSource, 0xC);
                                     focusTarget = BitConverter.ToUInt32(targetInfoSource, 0x3C);
                                     previousTarget = BitConverter.ToUInt32(targetInfoSource, 0x48);
                                     currentTargetID = BitConverter.ToUInt32(targetInfoSource, 0x5C);
                                     break;
                                 default:
                                     currentTarget = BitConverter.ToUInt32(targetInfoSource, 0x0);
                                     mouseOverTarget = BitConverter.ToUInt32(targetInfoSource, 0xC);
                                     focusTarget = BitConverter.ToUInt32(targetInfoSource, 0x3C);
                                     previousTarget = BitConverter.ToUInt32(targetInfoSource, 0x48);
                                     currentTargetID = BitConverter.ToUInt32(targetInfoSource, 0x5C);
                                     break;
                             }
                             if (currentTarget > 0)
                             {
                                 try
                                 {
                                     var source = MemoryHandler.Instance.GetByteArray(currentTarget, 0x3F40);
                                     var entry = ActorEntityHelper.ResolveActorFromBytes(source);
                                     if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("MAP"))
                                     {
                                         try
                                         {
                                             entry.MapIndex = MemoryHandler.Instance.GetUInt32(MemoryHandler.Instance.SigScanner.Locations["MAP"]);
                                         }
                                         catch (Exception ex)
                                         {
                                         }
                                     }
                                     if (entry.IsValid)
                                     {
                                         somethingFound = true;
                                         targetEntity.CurrentTarget = entry;
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                 }
                             }
                             if (mouseOverTarget > 0)
                             {
                                 try
                                 {
                                     var source = MemoryHandler.Instance.GetByteArray(mouseOverTarget, 0x3F40);
                                     var entry = ActorEntityHelper.ResolveActorFromBytes(source);
                                     if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("MAP"))
                                     {
                                         try
                                         {
                                             entry.MapIndex = MemoryHandler.Instance.GetUInt32(MemoryHandler.Instance.SigScanner.Locations["MAP"]);
                                         }
                                         catch (Exception ex)
                                         {
                                         }
                                     }
                                     if (entry.IsValid)
                                     {
                                         somethingFound = true;
                                         targetEntity.MouseOverTarget = entry;
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                 }
                             }
                             if (focusTarget > 0)
                             {
                                 var source = MemoryHandler.Instance.GetByteArray(focusTarget, 0x3F40);
                                 var entry = ActorEntityHelper.ResolveActorFromBytes(source);
                                 if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("MAP"))
                                 {
                                     try
                                     {
                                         entry.MapIndex = MemoryHandler.Instance.GetUInt32(MemoryHandler.Instance.SigScanner.Locations["MAP"]);
                                     }
                                     catch (Exception ex)
                                     {
                                     }
                                 }
                                 if (entry.IsValid)
                                 {
                                     somethingFound = true;
                                     targetEntity.FocusTarget = entry;
                                 }
                             }
                             if (previousTarget > 0)
                             {
                                 try
                                 {
                                     var source = MemoryHandler.Instance.GetByteArray(previousTarget, 0x3F40);
                                     var entry = ActorEntityHelper.ResolveActorFromBytes(source);
                                     if (MemoryHandler.Instance.SigScanner.Locations.ContainsKey("MAP"))
                                     {
                                         try
                                         {
                                             entry.MapIndex = MemoryHandler.Instance.GetUInt32(MemoryHandler.Instance.SigScanner.Locations["MAP"]);
                                         }
                                         catch (Exception ex)
                                         {
                                         }
                                     }
                                     if (entry.IsValid)
                                     {
                                         somethingFound = true;
                                         targetEntity.PreviousTarget = entry;
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                 }
                             }
                             if (currentTargetID > 0)
                             {
                                 somethingFound = true;
                                 targetEntity.CurrentTargetID = currentTargetID;
                             }
                         }
                         if (targetEntity.CurrentTargetID > 0)
                         {
                             for (uint i = 0; i < 16; i++)
                             {
                                 var address = targetHateStructure + (i * 72);
                                 var enmityEntry = new EnmityEntry
                                 {
                                     ID = (uint) MemoryHandler.Instance.GetInt32(address),
                                     Enmity = (uint) MemoryHandler.Instance.GetInt32(address, 4)
                                 };
                                 if (enmityEntry.ID <= 0)
                                 {
                                     continue;
                                 }
                                 if (PCWorkerDelegate.GetUniqueNPCEntities()
                                                         .Any(a => a.ID == enmityEntry.ID))
                                 {
                                     enmityEntry.Name = PCWorkerDelegate.GetUniqueNPCEntities()
                                                                        .First(a => a.ID == enmityEntry.ID)
                                                                        .Name;
                                 }
                                 if (String.IsNullOrWhiteSpace(enmityEntry.Name))
                                 {
                                     if (NPCWorkerDelegate.GetUniqueNPCEntities()
                                                              .Any(a => a.NPCID2 == enmityEntry.ID))
                                     {
                                         enmityEntry.Name = NPCWorkerDelegate.GetUniqueNPCEntities()
                                                                             .First(a => a.NPCID2 == enmityEntry.ID)
                                                                             .Name;
                                     }
                                 }
                                 if (String.IsNullOrWhiteSpace(enmityEntry.Name))
                                 {
                                     if (MonsterWorkerDelegate.GetUniqueNPCEntities()
                                                                  .Any(a => a.ID == enmityEntry.ID))
                                     {
                                         enmityEntry.Name = MonsterWorkerDelegate.GetUniqueNPCEntities()
                                                                                 .First(a => a.ID == enmityEntry.ID)
                                                                                 .Name;
                                     }
                                 }
                                 enmityEntries.Add(enmityEntry);
                             }
                         }
                         targetEntity.EnmityEntries = enmityEntries;
                         if (somethingFound)
                         {
                             AppContextHelper.Instance.RaiseNewTargetEntity(targetEntity);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
         _isScanning = false;
         return true;
     };
     scannerWorker.BeginInvoke(delegate { }, scannerWorker);
 }
 /// <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.PlayerInfoWorkerRefresh.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("PLAYERINFO"))
             {
                 PlayerInfoMap = MemoryHandler.Instance.SigScanner.Locations["PLAYERINFO"];
                 if (PlayerInfoMap <= 6496)
                 {
                     return false;
                 }
                 try
                 {
                     var enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 5688);
                     var enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 3384;
                     var enmityEntries = new List<EnmityEntry>();
                     if (enmityCount > 0 && enmityCount < 32 && enmityStructure > 0)
                     {
                         for (uint i = 0; i < enmityCount; i++)
                         {
                             var address = enmityStructure + (i * 72);
                             var enmityEntry = new EnmityEntry
                             {
                                 Name = MemoryHandler.Instance.GetString(address),
                                 ID = (uint) MemoryHandler.Instance.GetInt32(address + 64),
                                 Enmity = (uint) MemoryHandler.Instance.GetInt16(address + 68)
                             };
                             if (enmityEntry.ID > 0)
                             {
                                 enmityEntries.Add(enmityEntry);
                             }
                         }
                     }
                     var playerInfo = MemoryHandler.Instance.GetStructure<Structures.PlayerInfo>(PlayerInfoMap);
                     var playerEntity = new PlayerEntity
                     {
                         Name = MemoryHandler.Instance.GetString(PlayerInfoMap, 1),
                         EnmityEntries = enmityEntries,
                         Accuracy = playerInfo.Accuracy,
                         ACN = playerInfo.ACN,
                         ACN_CurrentEXP = playerInfo.ACN_CurrentEXP,
                         ALC = playerInfo.ALC,
                         ARC = playerInfo.ARC,
                         ARC_CurrentEXP = playerInfo.ARC_CurrentEXP,
                         ARM = playerInfo.ARM,
                         ARM_CurrentEXP = playerInfo.ARM_CurrentEXP,
                         AttackMagicPotency = playerInfo.AttackMagicPotency,
                         AttackPower = playerInfo.AttackPower,
                         BTN = playerInfo.BTN,
                         BTN_CurrentEXP = playerInfo.BTN_CurrentEXP,
                         BSM = playerInfo.BSM,
                         BSM_CurrentEXP = playerInfo.BSM_CurrentEXP,
                         BaseDexterity = playerInfo.BaseDexterity,
                         BaseIntelligence = playerInfo.BaseIntelligence,
                         BaseMind = playerInfo.BaseMind,
                         BasePiety = playerInfo.BasePiety,
                         BaseStrength = playerInfo.BaseStrength,
                         BaseVitality = playerInfo.BaseVitality,
                         CNJ = playerInfo.CNJ,
                         CNJ_CurrentEXP = playerInfo.CNJ_CurrentEXP,
                         CPMax = playerInfo.CPMax,
                         CPT = playerInfo.CPT,
                         CPT_CurrentEXP = playerInfo.CPT_CurrentEXP,
                         CUL = playerInfo.CUL,
                         CUL_CurrentEXP = playerInfo.CUL_CurrentEXP,
                         Control = playerInfo.Control,
                         Craftmanship = playerInfo.Craftmanship,
                         CriticalHitRate = playerInfo.CriticalHitRate,
                         Defense = playerInfo.Defense,
                         Determination = playerInfo.Determination,
                         Dexterity = playerInfo.Dexterity,
                         FSH = playerInfo.FSH,
                         FSH_CurrentEXP = playerInfo.FSH_CurrentEXP,
                         FireResistance = playerInfo.FireResistance,
                         GLD = playerInfo.GLD,
                         GLD_CurrentEXP = playerInfo.GLD_CurrentEXP,
                         GPMax = playerInfo.GPMax,
                         GSM = playerInfo.GSM,
                         GSM_CurrentEXP = playerInfo.GSM_CurrentEXP,
                         Gathering = playerInfo.Gathering,
                         HPMax = playerInfo.HPMax,
                         HealingMagicPotency = playerInfo.HealingMagicPotency,
                         IceResistance = playerInfo.IceResistance,
                         Intelligence = playerInfo.Intelligence,
                         JobID = playerInfo.JobID,
                         LNC = playerInfo.LNC,
                         LNC_CurrentEXP = playerInfo.LNC_CurrentEXP,
                         LTW = playerInfo.LTW,
                         LTW_CurrentEXP = playerInfo.LTW_CurrentEXP,
                         LightningResistance = playerInfo.LightningResistance,
                         MIN = playerInfo.MIN,
                         MIN_CurrentEXP = playerInfo.MIN_CurrentEXP,
                         MPMax = playerInfo.MPMax,
                         MRD = playerInfo.MRD,
                         MRD_CurrentEXP = playerInfo.MRD_CurrentEXP,
                         MagicDefense = playerInfo.MagicDefense,
                         Mind = playerInfo.Mind,
                         PGL = playerInfo.PGL,
                         PGL_CurrentEXP = playerInfo.PGL_CurrentEXP,
                         Parry = playerInfo.Parry,
                         Perception = playerInfo.Perception,
                         PiercingResistance = playerInfo.PiercingResistance,
                         Piety = playerInfo.Piety,
                         SkillSpeed = playerInfo.SkillSpeed,
                         SlashingResistance = playerInfo.SlashingResistance,
                         SpellSpeed = playerInfo.SpellSpeed,
                         Strength = playerInfo.Strength,
                         THM = playerInfo.THM,
                         THM_CurrentEXP = playerInfo.THM_CurrentEXP,
                         TPMax = playerInfo.TPMax,
                         Vitality = playerInfo.Vitality,
                         WVR = playerInfo.WVR,
                         WVR_CurrentEXP = playerInfo.WVR_CurrentEXP,
                         WaterResistance = playerInfo.WaterResistance,
                         WindResistance = playerInfo.WindResistance
                     };
                     playerEntity.Job = (Actor.Job) playerEntity.JobID;
                     var notify = false;
                     if (LastPlayerEntity == null)
                     {
                         LastPlayerEntity = playerEntity;
                         notify = true;
                     }
                     else
                     {
                         var hash1 = JsonConvert.SerializeObject(LastPlayerEntity)
                                                .GetHashCode();
                         var hash2 = JsonConvert.SerializeObject(playerEntity)
                                                .GetHashCode();
                         if (!hash1.Equals(hash2))
                         {
                             LastPlayerEntity = playerEntity;
                             notify = true;
                         }
                     }
                     if (notify)
                     {
                         AppContextHelper.Instance.RaiseNewPlayerEntity(playerEntity);
                     }
                 }
                 catch (Exception ex)
                 {
                 }
             }
             else
             {
                 try
                 {
                     PlayerInfoMap = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 5724;
                     MemoryHandler.Instance.SigScanner.Locations.Add("PLAYERINFO", PlayerInfoMap);
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
         _isScanning = false;
         return true;
     };
     scannerWorker.BeginInvoke(delegate { }, scannerWorker);
 }