//private static void OnNewPlayerEntity(object sender, PlayerEntityEvent playerEntityEvent)
 //{
 //    // delegate event from player info from ram, not required to subsribe
 //    // this is for YOU and includes all your stats and your agro list with hate values as %
 //    // this updates 10x a second and only sends data when the newly read data is differen than what was previously sent
 //    if (sender == null)
 //    {
 //        return;
 //    }
 //    var playerEntity = playerEntityEvent.PlayerEntity;
 //}
 private static void OnNewTargetEntity(object sender, TargetEntityEvent targetEntityEvent)
 {
     // delegate event from target info from ram, not required to subsribe
     // this includes the full entities for current, previous, mouseover, focus targets (if 0+ are found)
     // it also includes a list of upto 16 targets that currently have hate on the currently targeted monster
     // these hate values are realtime and change based on the action used
     // this updates 10x a second and only sends data when the newly read data is differen than what was previously sent
     if (sender == null)
     {
         return;
     }
     var targetEntity = targetEntityEvent.TargetEntity;
     var emptyEntity = new TargetEntity();
     // assign empty entity
     EnmityWidgetViewModel.Instance.TargetEntity = emptyEntity;
     FocusTargetWidgetViewModel.Instance.TargetEntity = emptyEntity;
     CurrentTargetWidgetViewModel.Instance.TargetEntity = emptyEntity;
     // assign default current/focus target info
     EnmityWidgetViewModel.Instance.EnmityTargetIsValid = false;
     EnmityWidgetViewModel.Instance.EnmityTargetHPPercent = 0;
     EnmityWidgetViewModel.Instance.EnmityTargetDistance = 0;
     FocusTargetWidgetViewModel.Instance.FocusTargetIsValid = false;
     FocusTargetWidgetViewModel.Instance.FocusTargetHPPercent = 0;
     FocusTargetWidgetViewModel.Instance.FocusTargetDistance = 0;
     CurrentTargetWidgetViewModel.Instance.CurrentTargetIsValid = false;
     CurrentTargetWidgetViewModel.Instance.CurrentTargetHPPercent = 0;
     CurrentTargetWidgetViewModel.Instance.CurrentTargetDistance = 0;
     // if valid assign actual current target info
     if (targetEntity.CurrentTarget != null && targetEntity.CurrentTarget.IsValid && Settings.Default.ShowEnmityWidgetOnLoad)
     {
         EnmityWidgetViewModel.Instance.TargetEntity = targetEntity;
         EnmityWidgetViewModel.Instance.EnmityTargetIsValid = true;
         EnmityWidgetViewModel.Instance.EnmityTargetHPPercent = (double) targetEntity.CurrentTarget.HPPercent;
         try
         {
             EnmityWidgetViewModel.Instance.EnmityTargetDistance = XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(targetEntity.CurrentTarget);
         }
         catch (Exception ex)
         {
         }
     }
     // if valid assign actual current target info
     if (targetEntity.CurrentTarget != null && targetEntity.CurrentTarget.IsValid && Settings.Default.ShowCurrentTargetWidgetOnLoad)
     {
         CurrentTargetWidgetViewModel.Instance.TargetEntity = targetEntity;
         CurrentTargetWidgetViewModel.Instance.CurrentTargetIsValid = true;
         CurrentTargetWidgetViewModel.Instance.CurrentTargetHPPercent = (double) targetEntity.CurrentTarget.HPPercent;
         try
         {
             CurrentTargetWidgetViewModel.Instance.CurrentTargetDistance = XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(targetEntity.CurrentTarget);
         }
         catch (Exception ex)
         {
         }
     }
     // if valid assign actual focus target info
     if (targetEntity.FocusTarget != null && targetEntity.FocusTarget.IsValid && Settings.Default.ShowFocusTargetWidgetOnLoad)
     {
         FocusTargetWidgetViewModel.Instance.TargetEntity = targetEntity;
         FocusTargetWidgetViewModel.Instance.FocusTargetIsValid = true;
         FocusTargetWidgetViewModel.Instance.FocusTargetHPPercent = (double) targetEntity.FocusTarget.HPPercent;
         try
         {
             FocusTargetWidgetViewModel.Instance.FocusTargetDistance = XIVInfoViewModel.Instance.CurrentUser.GetDistanceTo(targetEntity.FocusTarget);
         }
         catch (Exception ex)
         {
         }
     }
 }
Example #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);
 }
Example #3
0
 public virtual void RaiseNewTargetEntity(TargetEntity e)
 {
     var targetEntityEvent = new TargetEntityEvent(this, e);
     var handler = NewTargetEntity;
     if (handler != null)
     {
         handler(this, targetEntityEvent);
     }
 }
Example #4
0
 public void RaiseNewTargetEntity(TargetEntity targetEntity)
 {
     // THIRD PARTY
     PluginHost.Instance.RaiseNewTargetEntity(targetEntity);
 }
 public TargetEntityEvent(object sender, TargetEntity targetEntity)
 {
     Sender = sender;
     TargetEntity = targetEntity;
 }