Beispiel #1
0
        private void ReadAllGameData()
        {
            try
            {
                if (FF7?.HasExited ?? true)
                {
                    return;
                }

                var  saveMapByteData   = _memoryReader.ReadMemory(Addresses.SaveMapStart);
                byte isBattle          = _memoryReader.ReadMemory(Addresses.ActiveBattleState)?.First() ?? 0;
                var  battleMapByteData = _memoryReader.ReadMemory(Addresses.BattleMapStart);
                var  colors            = _memoryReader.ReadMemory(Addresses.MenuColorAll);

                if (saveMapByteData is null)
                {
                    return;
                }

                SaveMap   = new FF7SaveMap(saveMapByteData, colors);
                BattleMap = new FF7BattleMap(battleMapByteData, isBattle);

                UpdateStatusFromMap(SaveMap, BattleMap);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error Updating Tseng Info");
            }
        }
Beispiel #2
0
        public void UpdateStatusFromMap(FF7SaveMap map, FF7BattleMap battleMap, GameDatabase gameDatabase)
        {
            Gil              = map.LiveGil;
            Location         = map.LiveMapName;
            Party            = new Character[3];
            ActiveBattle     = battleMap.IsActiveBattle;
            ColorTopLeft     = map.WindowColorTopLeft;
            ColorBottomLeft  = map.WindowColorBottomLeft;
            ColorBottomRight = map.WindowColorBottomRight;
            ColorTopRight    = map.WindowColorTopRight;
            TimeActive       = TimeSpan.FromSeconds(map.LiveTotalSeconds).ToString("hh\\:mm\\:ss");

            var characters = map.LiveParty.Select(x => Character.FromCharacterRecord(x, gameDatabase)).ToArray();

            for (var index = 0; index < characters.Length; ++index)
            {
                // Skip empty party
                if (characters[index].Id == FF7Const.Empty)
                {
                    continue;
                }

                var chr = characters[index];

                var effect = characters[index].StatusEffectsValue;

                if (battleMap.IsActiveBattle)
                {
                    BattleActor battleActor = battleMap.Party[index];
                    chr.CurrentHp = battleActor.CurrentHp;
                    chr.MaxHp     = battleActor.MaxHp;
                    chr.CurrentMp = battleActor.CurrentMp;
                    chr.MaxMp     = battleActor.MaxMp;
                    chr.Level     = battleActor.Level;
                    effect        = battleActor.Status;
                    chr.BackRow   = battleActor.IsBackRow;
                }

                var effs = effect.ToString().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
                effs.RemoveAll(x => new[] { "None", "Death" }.Contains(x));
                chr.StatusEffects      = effs.ToArray();
                chr.StatusEffectsValue = effect;
                Party[index]           = chr;
            }
        }
Beispiel #3
0
        private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var saveMapByteData   = MemoryReader.ReadMemory(new IntPtr(Addresses.SaveMapStart), 4342);
                var isBattle          = MemoryReader.ReadMemory(new IntPtr(Addresses.ActiveBattleState), 1).First();
                var battleMapByteData = MemoryReader.ReadMemory(new IntPtr(Addresses.BattleMapStart), 0x750);
                var colors            = MemoryReader.ReadMemory(new IntPtr(Addresses.WindowColorBlockStart), 16);

                SaveMap   = new FF7SaveMap(saveMapByteData);
                BattleMap = new FF7BattleMap(battleMapByteData, isBattle);

                SaveMap.WindowColorTopLeft     = $"{colors[0x2]:X2}{colors[0x1]:X2}{colors[0x0]:X2}";
                SaveMap.WindowColorBottomLeft  = $"{colors[0x6]:X2}{colors[0x5]:X2}{colors[0x4]:X2}";
                SaveMap.WindowColorTopRight    = $"{colors[0xA]:X2}{colors[0x9]:X2}{colors[0x8]:X2}";
                SaveMap.WindowColorBottomRight = $"{colors[0xE]:X2}{colors[0xD]:X2}{colors[0xC]:X2}";

                PartyStatus = ExtractStatusFromMap(SaveMap, BattleMap);
            }
            catch (Exception ex)
            {
                SearchForProcess(ProcessName);
            }
        }
Beispiel #4
0
        public static GameStatus ExtractStatusFromMap(FF7SaveMap map, FF7BattleMap battleMap)
        {
            var time = map.LiveTotalSeconds;

            var t = $"{(time / 3600):00}:{((time % 3600) / 60):00}:{(time % 60):00}";

            var status = new GameStatus()
            {
                Gil              = map.LiveGil,
                Location         = map.LiveMapName,
                Party            = new Models.Character[3],
                ActiveBattle     = battleMap.IsActiveBattle,
                ColorTopLeft     = map.WindowColorTopLeft,
                ColorBottomLeft  = map.WindowColorBottomLeft,
                ColorBottomRight = map.WindowColorBottomRight,
                ColorTopRight    = map.WindowColorTopRight,
                TimeActive       = t
            };
            var party = battleMap.Party;

            var chars = map.LiveParty;

            for (var index = 0; index < chars.Length; ++index)
            {
                // Skip empty party
                if (chars[index].Id == 0xFF)
                {
                    continue;
                }

                var chr = new Models.Character()
                {
                    MaxHp         = chars[index].MaxHp,
                    MaxMp         = chars[index].MaxMp,
                    CurrentHp     = chars[index].CurrentHp,
                    CurrentMp     = chars[index].CurrentMp,
                    Name          = chars[index].Name,
                    Level         = chars[index].Level,
                    Weapon        = WeaponDatabase.FirstOrDefault(w => w.Id == chars[index].Weapon),
                    Armlet        = ArmletDatabase.FirstOrDefault(a => a.Id == chars[index].Armor),
                    Accessory     = AccessoryDatabase.FirstOrDefault(a => a.Id == chars[index].Accessory),
                    WeaponMateria = new Materia[8],
                    ArmletMateria = new Materia[8],
                    Face          = GetFaceForCharacter(chars[index]),
                    BackRow       = !chars[index].AtFront,
                };

                for (var m = 0; m < chars[index].WeaponMateria.Length; ++m)
                {
                    chr.WeaponMateria[m] = MateriaDatabase.FirstOrDefault(x => x.Id == chars[index].WeaponMateria[m]);
                }
                for (var m = 0; m < chars[index].ArmorMateria.Length; ++m)
                {
                    chr.ArmletMateria[m] = MateriaDatabase.FirstOrDefault(x => x.Id == chars[index].ArmorMateria[m]);
                }

                var effect = (StatusEffect)chars[index].Flags;

                if (battleMap.IsActiveBattle)
                {
                    chr.CurrentHp = party[index].CurrentHp;
                    chr.MaxHp     = party[index].MaxHp;
                    chr.CurrentMp = party[index].CurrentMp;
                    chr.MaxMp     = party[index].MaxMp;
                    chr.Level     = party[index].Level;
                    effect        = party[index].Status;
                    chr.BackRow   = party[index].IsBackRow;
                }

                var effs = effect.ToString()
                           .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
                           .ToList();
                effs.RemoveAll(x => new[] { "None", "Death" }.Contains(x));
                chr.StatusEffects   = effs.ToArray();
                status.Party[index] = chr;
            }

            return(status);
        }
Beispiel #5
0
 public void UpdateStatusFromMap(FF7SaveMap map, FF7BattleMap battleMap)
 {
     _partyStatusViewModel.UpdateStatusFromMap(map, battleMap, _gameDatabase);
     _statusHubEmitter.ShowNewPartyStatus(_partyStatusViewModel);
 }