Skip to content

Commit 3cb6cb3

Browse files
committed
Force SetDeviceType in SwSh and BDSP bot initialization.
1 parent 313e1a8 commit 3cb6cb3

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

SysBot.Pokemon/BDSP/PokeRoutineExecutor8BS.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public async Task InitializeHardware(IBotStateSettings settings, CancellationTok
130130
await SetScreen(ScreenState.Off, token).ConfigureAwait(false);
131131
}
132132

133+
await SetDeviceType(HidDeviceType.FullKey3, token).ConfigureAwait(false);
133134
Log("Setting BDSP-specific hid waits.");
134135
await Connection.SendAsync(SwitchCommand.Configure(SwitchConfigureParameter.keySleepTime, 50), token).ConfigureAwait(false);
135136
await Connection.SendAsync(SwitchCommand.Configure(SwitchConfigureParameter.pollRate, 50), token).ConfigureAwait(false);

SysBot.Pokemon/LGPE/BotEncounter/Encounter7BSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public class Encounter7BSettings : IBotStateSettings
2020
[Category(Encounter), Description("Set the fortune teller nature. All the wild and stationary Pokémon will have this nature. Ignored if random.")]
2121
public PKHeX.Core.Nature SetFortuneTellerNature { get; set; } = PKHeX.Core.Nature.Random;
2222

23+
[Category(Encounter), Description("Set the Lure type. The Lure will be reactivated once the effect ends. Only useful for LiveStatsChecking. Ignored if None.")]
24+
public Lure SetLure { get; set; } = Lure.None;
25+
26+
2327
private int _completedWild;
2428
private int _completedLegend;
2529

SysBot.Pokemon/LGPE/BotEncounter/EncounterBot7B.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public EncounterBot7B(PokeBotState cfg, PokeBotHub<PK8> hub) : base(cfg)
3333
public override async Task MainLoop(CancellationToken token)
3434
{
3535
Log("Identifying trainer data of the host console.");
36-
var sav = await IdentifyTrainer(token).ConfigureAwait(false);
36+
await IdentifyTrainer(token).ConfigureAwait(false);
3737
await InitializeHardware(Settings, token).ConfigureAwait(false);
3838

3939
try
@@ -65,13 +65,23 @@ private async Task DoLiveStatsChecking(CancellationToken token)
6565
{
6666
while (!token.IsCancellationRequested)
6767
{
68-
if (Settings.SetFortuneTellerNature is not Nature.Random && !await IsNatureTellerEnabled(token).ConfigureAwait(false))
68+
//Force the Fortune Teller Nature value, value is reset at the end of the day
69+
if (Settings.SetFortuneTellerNature != Nature.Random &&
70+
(!await IsNatureTellerEnabled(token).ConfigureAwait(false) || await ReadWildNature(token).ConfigureAwait(false) != Settings.SetFortuneTellerNature))
6971
{
7072
await EnableNatureTeller(token).ConfigureAwait(false);
7173
await EditWildNature(Settings.SetFortuneTellerNature, token).ConfigureAwait(false);
7274
Log($"Fortune Teller enabled, Nature set to {await ReadWildNature(token).ConfigureAwait(false)}.");
7375
}
7476

77+
//Check Lure Type
78+
if (await ReadLureType(token).ConfigureAwait(false) != Settings.SetLure)
79+
await EditLureType((uint)Settings.SetLure, token).ConfigureAwait(false);
80+
81+
//Check Lure Steps
82+
if (Settings.SetLure != Lure.None && await ReadLureCounter(token).ConfigureAwait(false) < 20)
83+
await EditLureCounter(100, token).ConfigureAwait(false);
84+
7585
while (await IsInCatchScreen(token).ConfigureAwait(false) || await IsGiftFound(token).ConfigureAwait(false) || await IsInBattle(token).ConfigureAwait(false) || await IsInTrade(token).ConfigureAwait(false))
7686
await Task.Delay(1_000, token).ConfigureAwait(false);
7787

SysBot.Pokemon/LGPE/BotOverworld/BotOverworld7B.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,20 @@ private async Task Overworld(CancellationToken token, bool birds = false)
118118
if (await CountMilliseconds(Hub.Config, token).ConfigureAwait(false) > 0 || !searchforshiny)
119119
{
120120
//Force the Fortune Teller Nature value, value is reset at the end of the day
121-
if (Settings.SetFortuneTellerNature != Nature.Random && !await IsNatureTellerEnabled(token).ConfigureAwait(false))
121+
if (Settings.SetFortuneTellerNature != Nature.Random &&
122+
(!await IsNatureTellerEnabled(token).ConfigureAwait(false) || await ReadWildNature(token).ConfigureAwait(false) != Settings.SetFortuneTellerNature))
122123
{
123124
await EnableNatureTeller(token).ConfigureAwait(false);
124125
await EditWildNature(Settings.SetFortuneTellerNature, token).ConfigureAwait(false);
125126
Log($"Fortune Teller enabled, Nature set to {await ReadWildNature(token).ConfigureAwait(false)}.");
126127
}
127128

128129
//Check Lure Type
129-
if (await ReadLureType(token).ConfigureAwait(false) != Hub.Config.LGPE_OverworldScan.SetLure)
130-
await EditLureType((uint)Hub.Config.LGPE_OverworldScan.SetLure, token).ConfigureAwait(false);
130+
if (await ReadLureType(token).ConfigureAwait(false) != Settings.SetLure)
131+
await EditLureType((uint)Settings.SetLure, token).ConfigureAwait(false);
131132

132133
//Check Lure Steps
133-
if (Hub.Config.LGPE_OverworldScan.SetLure != Lure.None && await ReadLureCounter(token).ConfigureAwait(false) < 20)
134+
if (Settings.SetLure != Lure.None && await ReadLureCounter(token).ConfigureAwait(false) < 20)
134135
await EditLureCounter(100, token).ConfigureAwait(false);
135136

136137
//PG Movements. The routine need to continue and check the overworld spawns, cannot be stuck at changing stick position.

SysBot.Pokemon/SWSH/BotEncounter/EncounterBotLair.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private async Task InnerLoop(CancellationToken token)
100100
await Task.Delay(2_000, token).ConfigureAwait(false);
101101

102102
//Select Solo Adventure
103-
await Click(DDOWN, 0_800, token).ConfigureAwait(false);
103+
await Click(DDOWN, 1_800, token).ConfigureAwait(false);
104104
await Click(A, 1_000, token).ConfigureAwait(false);
105105

106106
//MAIN LOOP

SysBot.Pokemon/SWSH/PokeRoutineExecutor8.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public async Task InitializeHardware(IBotStateSettings settings, CancellationTok
104104
Log("Turning off screen.");
105105
await SetScreen(ScreenState.Off, token).ConfigureAwait(false);
106106
}
107+
await SetDeviceType(HidDeviceType.FullKey3, token).ConfigureAwait(false);
107108
}
108109

109110
public async Task CleanExit(IBotStateSettings settings, CancellationToken token)

0 commit comments

Comments
 (0)