Beispiel #1
0
        static public void LoadMonsterData()
        {
            MonsterDataDocument = new XmlDocument();
            if (UserSettings.PlayerConfig.HunterPie.Debug.LoadCustomMonsterData)
            {
                try
                {
                    MonsterDataDocument.Load(UserSettings.PlayerConfig.HunterPie.Debug.CustomMonsterData);
                    Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']"));

                    LoadAilments();
                    LoadMonsters();

                    MonsterDataDocument = null;
                    return;
                }
                catch (Exception err)
                {
                    Debugger.Error(err);
                }
            }
            MonsterDataDocument.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HunterPie.Resources/Data/MonsterData.xml"));

            LoadAilments();
            LoadMonsters();

            Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']"));

            // Unload XmlDocument since we don't need it anymore
            MonsterDataDocument = null;
        }
Beispiel #2
0
 private string GetDescription()
 {
     // Custom description for special zones
     switch (ctx.Player.ZoneID)
     {
     case 504:
         return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_TRAINING']"));
     }
     if (ctx.Player.InPeaceZone)
     {
         return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_TOWN']"));
     }
     if (ctx.HuntedMonster == null)
     {
         return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']"));
     }
     else
     {
         if (string.IsNullOrEmpty(ctx.HuntedMonster.Name))
         {
             return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']"));
         }
         return(UserSettings.PlayerConfig.RichPresence.ShowMonsterHealth ? GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']").Replace("{Monster}", ctx.HuntedMonster.Name).Replace("{Health}", $"{(int)(ctx.HuntedMonster.HPPercentage * 100)}%") : GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']").Replace("{Monster}", ctx.HuntedMonster.Name).Replace("({Health})", null));
     }
 }
Beispiel #3
0
        /* Connection */

        public void StartRPC()
        {
            if (isOffline)
            {
                return;
            }

            // Check if connection exists to avoid creating multiple connections
            Instance = new RichPresence();
            Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_CONNECTED']"));
            Instance.Secrets = new Secrets();
            Client           = new DiscordRpcClient(APP_ID, autoEvents: true);

            Client.RegisterUriScheme("582010");

            // Events
            Client.OnReady         += Client_OnReady;
            Client.OnJoinRequested += Client_OnJoinRequested;
            Client.OnJoin          += Client_OnJoin;

            Client.SetSubscription(EventType.JoinRequest | EventType.Join);

            Client.Initialize();
            if (!UserSettings.PlayerConfig.RichPresence.Enabled && isVisible)
            {
                Client?.ClearPresence();
                isVisible = false;
            }
        }
Beispiel #4
0
        private void GetMonsterIDAndName()
        {
            Int64  NamePtr   = Scanner.READ_LONGLONG(this.MonsterAddress + 0x290);
            string MonsterId = Scanner.READ_STRING(NamePtr + 0x0c, 64).Replace("\x00", "");

            if (MonsterId != "")
            {
                try {
                    string ActualID = MonsterId.Split('\\')[4];
                    if (GStrings.MonsterName(ActualID) != null)
                    {
                        if (ActualID != this.ID)
                        {
                            Debugger.Log($"Found new monster #{MonsterNumber} address -> 0x{MonsterAddress:X}");
                        }
                        this.ID   = ActualID;
                        this.Name = GStrings.MonsterName(this.ID);
                    }
                    else
                    {
                        this.ID   = null;
                        this.Name = null;
                    }
                } catch {
                    this.ID   = null;
                    this.Name = null;
                }
            }
            else
            {
                this.ID   = null;
                this.Name = null;
            }
        }
Beispiel #5
0
        public void HandlePresence(object source, EventArgs e)
        {
            if (Instance == null)
            {
                return;
            }

            // Do nothing if RPC is disabled
            if (!isVisible)
            {
                return;
            }

            if (!FailedToRegisterScheme)
            {
                if (ctx.Player.SteamSession != 0 && ctx.Player.InPeaceZone && UserSettings.PlayerConfig.RichPresence.LetPeopleJoinSession)
                {
                    Instance.Secrets.JoinSecret = $"{ctx.Player.SteamSession}/{ctx.Player.SteamID}";
                }
                else
                {
                    Instance.Secrets.JoinSecret = null;
                }
            }

            // Only update RPC if player isn't in loading screen
            switch (ctx.Player.ZoneID)
            {
            case 0:
                Instance.Details = ctx.Player.PlayerAddress == 0 ? GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_MAIN_MENU']") : GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_LOADING_SCREEN']");
                Instance.State   = null;
                GenerateAssets("main-menu", null, null, null);
                Instance.Party = null;
                break;

            default:
                if (ctx.Player.PlayerAddress == 0)
                {
                    Instance.Details = GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_MAIN_MENU']");
                    Instance.State   = null;
                    GenerateAssets("main-menu", null, null, null);
                    Instance.Party = null;
                    break;
                }
                Instance.Details = GetDescription();
                Instance.State   = GetState();
                GenerateAssets(ctx.Player.ZoneName == null ? "main-menu" : $"st{ctx.Player.ZoneID}", ctx.Player.ZoneID == 0 ? null : ctx.Player.ZoneName, ctx.Player.WeaponName == null ? "hunter-rank" : $"weap{ctx.Player.WeaponID}", $"{ctx.Player.Name} | HR: {ctx.Player.Level} | MR: {ctx.Player.MasterRank}");
                if (!ctx.Player.InPeaceZone)
                {
                    MakeParty(ctx.Player.PlayerParty.Size, ctx.Player.PlayerParty.MaxSize, ctx.Player.PlayerParty.PartyHash);
                }
                else
                {
                    MakeParty(ctx.Player.PlayerParty.LobbySize, ctx.Player.PlayerParty.MaxLobbySize, ctx.Player.SteamSession.ToString());
                }
                Instance.Timestamps = NewTimestamp(ctx.Time);
                break;
            }
            Client.SetPresence(Instance);
        }
Beispiel #6
0
        private void GetMonsterIDAndName()
        {
            Int64  NamePtr   = Scanner.READ_LONGLONG(this.MonsterAddress + Address.Offsets.MonsterNamePtr);
            string MonsterId = Scanner.READ_STRING(NamePtr + 0x0c, 64).Replace("\x00", "");

            if (MonsterId != "")
            {
                string[] MonsterID = MonsterId.Split('\\');
                if (MonsterID.Length < 4)
                {
                    this.ID   = null;
                    this.Name = null;
                    return;
                }
                string MonsterModelID = MonsterID[4].Trim('\x00');
                if (MonsterModelID.StartsWith("em") && !MonsterModelID.StartsWith("ems"))
                {
                    if (MonsterModelID != this.ID)
                    {
                        Debugger.Log($"Found new monster ID: {MonsterID[4]} #{MonsterNumber} @ 0x{MonsterAddress:X}");
                    }
                    this.ID   = MonsterModelID;
                    this.Name = GStrings.GetMonsterNameByID(this.ID) ?? "Unknown Monster";
                    return;
                }
            }
            this.ID   = null;
            this.Name = null;
            return;
        }
Beispiel #7
0
        private void GetWeaponId()
        {
            Int64 Address = Memory.Address.BASE + Memory.Address.WEAPON_OFFSET;

            Address    = Scanner.READ_MULTILEVEL_PTR(Address, Memory.Address.Offsets.WeaponOffsets);
            WeaponID   = Scanner.READ_INT(Address + Memory.Address.Offsets.WeaponLastOffset);
            WeaponName = GStrings.WeaponName(WeaponID);
        }
Beispiel #8
0
        private void GetPrimaryMantle()
        {
            Int64 Address  = LEVEL_ADDRESS + 0x34;
            int   mantleId = Scanner.READ_INT(Address);

            PrimaryMantle.SetID(mantleId);
            PrimaryMantle.SetName(GStrings.GetMantleNameByID(mantleId));
        }
Beispiel #9
0
        private void GetSecondaryMantle()
        {
            Int64 Address  = LEVEL_ADDRESS + 0x34 + 0x4;
            int   mantleId = Scanner.READ_INT(Address);

            SecondaryMantle.SetID(mantleId);
            SecondaryMantle.SetName(GStrings.MantleName(mantleId));
        }
Beispiel #10
0
        private void GetWeaponId()
        {
            Int64 Address = Memory.Address.BASE + Memory.Address.WEAPON_OFFSET;

            Address             = Scanner.READ_MULTILEVEL_PTR(Address, Memory.Address.Offsets.WeaponOffsets);
            PlayerStructAddress = Address;
            WeaponID            = Scanner.READ_INT(Address);
            WeaponName          = GStrings.GetWeaponNameByID(WeaponID);
        }
Beispiel #11
0
 public void StartScanning()
 {
     ScanPlayerInfoRef = new ThreadStart(GetPlayerInfo);
     ScanPlayerInfo    = new Thread(ScanPlayerInfoRef)
     {
         Name = "Scanner_Player"
     };
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLAYER_SCANNER_INITIALIZED']"));
     ScanPlayerInfo.Start();
 }
Beispiel #12
0
 public void StartThreadingScan()
 {
     MonsterInfoScanRef = new ThreadStart(ScanMonsterInfo);
     MonsterInfoScan    = new Thread(MonsterInfoScanRef)
     {
         Name = $"Scanner_Monster.{MonsterNumber}"
     };
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_SCANNER_INITIALIZED']").Replace("{MonsterNumber}", MonsterNumber.ToString()));
     MonsterInfoScan.Start();
 }
Beispiel #13
0
 public void StopScanning()
 {
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_GAME_SCANNER_STOP']"));
     UnhookEvents();
     FirstMonster.StopThread();
     SecondMonster.StopThread();
     ThirdMonster.StopThread();
     Player.StopScanning();
     ScanGameThreading.Abort();
     IsActive = false;
 }
Beispiel #14
0
 public void StartScanning()
 {
     StartGameScanner();
     HookEvents();
     Player.StartScanning();
     FirstMonster.StartThreadingScan();
     SecondMonster.StartThreadingScan();
     ThirdMonster.StartThreadingScan();
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_GAME_SCANNER_INITIALIZED']"));
     IsActive = true;
 }
Beispiel #15
0
        private void GetZoneId()
        {
            int ZoneOffset = PlayerSlot == 0 ? 0x95D0 : 0xAB90;
            int zoneId     = Scanner.READ_INT(PlayerSelectedPointer + ZoneOffset);

            if (zoneId != ZoneID)
            {
                this.LastZoneID  = ZoneID;
                this.ZoneID      = zoneId;
                this.inPeaceZone = PeaceZones.Contains(this.ZoneID);
            }
            ZoneName = GStrings.GetStageNameByID(ZoneID);
        }
Beispiel #16
0
        private void Client_OnJoinRequested(object sender, DiscordRPC.Message.JoinRequestMessage args)
        {
            Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOIN_REQUEST']").Replace("{Username}", args.User.ToString()));

            App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => {
                GUI.Widgets.Notification_Widget.DiscordNotify DiscordNotification = new GUI.Widgets.Notification_Widget.DiscordNotify(args);

                DiscordNotification.OnRequestAccepted += OnDiscordRequestAccepted;
                DiscordNotification.OnRequestRejected += OnDiscordRequestRejected;

                DiscordNotification.Show();
            }));
        }
Beispiel #17
0
        private void GetZoneId()
        {
            Int64 Address     = Memory.Address.BASE + Memory.Address.ZONE_OFFSET;
            Int64 ZoneAddress = Scanner.READ_MULTILEVEL_PTR(Address, Memory.Address.Offsets.ZoneOffsets);
            int   zoneId      = Scanner.READ_INT(ZoneAddress + Memory.Address.Offsets.ZoneLastOffset);

            if (zoneId != ZoneID)
            {
                this.LastZoneID  = ZoneID;
                this.ZoneID      = zoneId;
                this.inPeaceZone = PeaceZones.Contains(this.ZoneID);
            }
            ZoneName = GStrings.ZoneName(ZoneID);
        }
Beispiel #18
0
        static public void LoadAbnormalityData()
        {
            AbnormalitiesData = new XmlDocument();
            AbnormalitiesData.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HunterPie.Resources/Data/AbnormalityData.xml"));
            Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_ABNORMALITIES_DATA_LOAD']"));

            LoadHuntingHornAbnormalities();
            LoadPalicoAbnormalities();
            LoadBlightAbnormalities();
            LoadMiscAbnormalities();
            LoadGearAbnormalities();

            // Unload Abnormalities Data since we don't need it anymore
            AbnormalitiesData = null;
        }
Beispiel #19
0
 static public void LoadMonsterData()
 {
     MonsterDataDocument = new XmlDocument();
     if (UserSettings.PlayerConfig.HunterPie.Debug.LoadCustomMonsterData)
     {
         try {
             MonsterDataDocument.Load(UserSettings.PlayerConfig.HunterPie.Debug.CustomMonsterData);
             Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']"));
             return;
         } catch (Exception err) {
             Debugger.Error(err);
         }
     }
     MonsterDataDocument.LoadXml(Resources.MonsterData);
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']"));
 }
Beispiel #20
0
 private string GetState()
 {
     if (ctx.Player.PlayerParty.Size > 1 || ctx.Player.PlayerParty.LobbySize > 1)
     {
         if (ctx.Player.InPeaceZone)
         {
             return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_LOBBY']"));
         }
         else
         {
             return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_PARTY']"));
         }
     }
     else
     {
         return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_SOLO']"));
     }
 }
Beispiel #21
0
        private void GetFertilizers()
        {
            Int64 Address = this.LEVEL_ADDRESS;

            for (int fertCount = 0; fertCount < 4; fertCount++)
            {
                // Calculates memory address
                Int64 FertilizerAddress = Address + Memory.Address.Offsets.FertilizersOffset + (0x10 * fertCount);
                // Read memory
                int    FertilizerId    = Scanner.READ_INT(FertilizerAddress - 0x4);
                string FertilizerName  = GStrings.FertilizerName(FertilizerId);
                int    FertilizerCount = Scanner.READ_INT(FertilizerAddress);
                // update fertilizer data
                Harvest.Box[fertCount].Name   = FertilizerName;
                Harvest.Box[fertCount].ID     = FertilizerId;
                Harvest.Box[fertCount].Amount = FertilizerCount;
            }
            UpdateHarvestBoxCounter(Address + Memory.Address.Offsets.FertilizersOffset + (0x10 * 3));
        }
Beispiel #22
0
 static public void LoadAbnormalityData()
 {
     AbnormalitiesData = new XmlDocument();
     AbnormalitiesData.LoadXml(Resources.AbnormalityData);
     Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_ABNORMALITIES_DATA_LOAD']"));
 }
Beispiel #23
0
 /* Dispose */
 public void Dispose()
 {
     Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_DISCONNECTED']"));
     Dispose(true);
     GC.SuppressFinalize(this);
 }
Beispiel #24
0
 private void Client_OnJoin(object sender, DiscordRPC.Message.JoinMessage args)
 {
     Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOINING']"));
     System.Diagnostics.Process.Start($"steam://joinlobby/582010/{args.Secret}");
     Debugger.Debug($"steam://joinlobby/582010/{args.Secret}");
 }
Beispiel #25
0
 private void Client_OnReady(object sender, DiscordRPC.Message.ReadyMessage args)
 {
     Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_USER_CONNECTED']").Replace("{Username}", args.User.ToString()));
 }