Пример #1
0
 public PlayerStruct(PlayerStruct player, byte status)
 {
     WeaponUnsheathed  = player.WeaponUnsheathed;
     InCombat          = player.InCombat;
     CastingPercentage = player.CastingPercentage;
     HPCurrent         = player.HPCurrent;
     HPMax             = player.HPMax;
     MPCurrent         = player.MPCurrent;
     MPMax             = player.MPMax;
     CPCurrent         = player.CPCurrent;
     CPMax             = player.CPMax;
     GPCurrent         = player.GPCurrent;
     GPMax             = player.GPMax;
     JobType           = player.JobType;
     Status            = (OnlineStatus)status;
     LevelProgression  = player.LevelProgression;
 }
Пример #2
0
        private async Task ReaderTask()
        {
            while (true)
            {
                if (read)
                {
                    try
                    {
                        var actions = Reader.GetActions();
                        if (actions.ActionContainers.Any())
                        {
                            lock (GameState.Actions)
                            {
                                GameState.Actions.Clear();
                                GameState.Actions.AddRange(actions.ActionContainers.SelectMany(t => t.ActionItems.Select(f => new ActionStructure(f))));
                            }
                        }
                        var player      = Reader.GetCurrentPlayer();
                        var actors      = Reader.GetActors();
                        var playerActor = actors.CurrentPCs.FirstOrDefault(t => t.Value.Name == player.CurrentPlayer.Name).Value;
                        var playerObj   = new PlayerStruct(player, playerActor);
                        if (!Scanner.Instance.IsScanning && playerActor != null)
                        {
                            var characterAddressMap = MemoryHandler.Instance.GetByteArray(Scanner.Instance.Locations[Signatures.CharacterMapKey], 8 * 480);
                            var uniqueAddresses     = new Dictionary <IntPtr, IntPtr>();
                            for (var i = 0; i < 480; i++)
                            {
                                var characterAddress = new IntPtr(TryBitConverter.TryToInt64(characterAddressMap, i * 8));

                                if (characterAddress == IntPtr.Zero)
                                {
                                    continue;
                                }

                                uniqueAddresses[characterAddress] = characterAddress;
                            }
                            foreach (var(key, address) in uniqueAddresses)
                            {
                                try
                                {
                                    var    characterAddress = new IntPtr(address.ToInt64());
                                    byte[] source           = MemoryHandler.Instance.GetByteArray(characterAddress, 9200);
                                    var    ID   = TryBitConverter.TryToUInt32(source, 116);
                                    var    Type = (Actor.Type)source[140];
                                    var    set  = false;
                                    switch (Type)
                                    {
                                    case Actor.Type.PC:
                                        if (playerActor.ID == ID)
                                        {
                                            playerObj = new PlayerStruct(playerObj, source[6366]);
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                    if (set)
                                    {
                                        break;
                                    }
                                }
                                catch (Exception)
                                {
                                    //
                                }
                            }
                        }
                        GameState.Player = playerObj;
                        //TODO add in party when there is a way to sort based on the ingame sort
                        //var party = Reader.GetPartyMembers();
                        //var partyActors = party.PartyMembers.Select(t => actors.CurrentPCs[t.Key]).ToList();
                        //gsiJObject["party"] = JToken.Parse(JsonConvert.SerializeObject(partyActors, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));
                        MemoryRead?.Invoke();
                    }
                    catch (Exception e)
                    {
                        Global.logger.Error(e, "[FFXIVPlugin] Memory reading failed");
                    }
                    await Task.Delay(TimeSpan.FromMilliseconds(5));
                }
                else
                {
                    await Task.Delay(TimeSpan.FromSeconds(2));
                }
            }
        }