Skip to content

Commit

Permalink
Mega Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SSinist3r committed Aug 21, 2020
1 parent 160f310 commit f67c0ea
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 42 deletions.
56 changes: 37 additions & 19 deletions SSinProtocol/Battle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public Battle(string playerName, string[] data)
OpponentHealth = Convert.ToInt32(data[1]);
CurrentHealth = OpponentHealth;
OpponentLevel = Convert.ToInt32(data[2]);
SelectedPokemonIndex = Convert.ToInt32(data[3]) - 1;
BattleText = data[4];
IsShiny = (data[5] != "0");
IsWild = data[6] == string.Empty && data[8] == string.Empty;
TrainerName = data[6];
IsPvp = data[7] == string.Empty;
SelectedPokemonIndex = Convert.ToInt32(data[4]) - 1;
BattleText = data[5];
IsShiny = (data[6] != "0");
IsWild = data[7] == string.Empty && data[9] == string.Empty;
TrainerName = data[7];
IsPvp = data[8] == string.Empty;
PokemonCount = 1;
if (data[8] != string.Empty)
if (data[9] != string.Empty)
{
PokemonCount = Convert.ToInt32(data[8]);
}
OpponentGender = data[9];
OpponentStatus = data[10];
AlreadyCaught = (data[11] == "1");
AlternateForm = int.Parse(data[12]);
OpponentGender = data[10];
OpponentStatus = data[11];
AlreadyCaught = (data[12] == "1");
AlternateForm = int.Parse(data[13]);
}

public bool ProcessMessage(List<Pokemon> team, string message)
Expand Down Expand Up @@ -126,14 +126,14 @@ public bool ProcessMessage(List<Pokemon> team, string message)

int pokemonId = Convert.ToInt32(data[2]);
int level = Convert.ToInt32(data[3]);
bool isShiny = data[4] == "1";
int maxHealth = Convert.ToInt32(data[5]);
int currentHealth = Convert.ToInt32(data[6]);
int index = Convert.ToInt32(data[7]) - 1;
string status = data[8];
string gender = data[9];
bool alreadyCaught = (data[10] == "1");
string alternateForm = data[11];
bool isShiny = data[5] == "1";
int maxHealth = Convert.ToInt32(data[6]);
int currentHealth = Convert.ToInt32(data[7]);
int index = Convert.ToInt32(data[8]) - 1;
string status = data[9];
string gender = data[10];
bool alreadyCaught = (data[11] == "1");
string alternateForm = data[12];

if (data[1] == _playerName)
{
Expand Down Expand Up @@ -198,6 +198,24 @@ public bool ProcessMessage(List<Pokemon> team, string message)
return true;
}

if (message.StartsWith("W:"))
{
// --------------------------------
return true;
}

if (message.StartsWith("U:"))
{
// --------------------------------
return true;
}

if (message.StartsWith("EXP:"))
{
// --------------------------------
return true;
}

if (message.Contains("$CantRun") || message.Contains("$NoSwitch"))
{
IsTrapped = true;
Expand Down
46 changes: 29 additions & 17 deletions SSinProtocol/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public class GameClient
public event Action ActivePokemonChanged;
public event Action OpponentChanged;

private const string Version = "Mega";
private const string Version = "Mega_v2";

private GameConnection _connection;
private DateTime _lastMovement;
Expand Down Expand Up @@ -273,7 +273,7 @@ public void SendPokedexRequest()
{
try
{
SendPacket("p|.|l|0");
SendPacket("p|.|1|0");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -566,19 +566,19 @@ public void SendUseItem(int id, int pokemon = 0)
string toSend = "*|.|" + id;
if (pokemon != 0)
{
toSend += "|.|" + pokemon;
toSend += "|.|" + Team[pokemon - 1].DatabaseId;
}
SendPacket(toSend);
}

public void SendGiveItem(int pokemonUid, int itemId)
public void SendGiveItem(int databaseId, int itemId)
{
SendMessage("/giveitem " + pokemonUid + "," + itemId);
SendPacket("<|.|" + databaseId + "|" + itemId);
}

public void SendTakeItem(int pokemonUid)
public void SendTakeItem(int databaseId)
{
SendMessage("/takeitem " + pokemonUid);
SendPacket(">|.|" + databaseId);
}

public void LearnMove(int pokemonUid, int moveToForgetUid)
Expand All @@ -589,7 +589,7 @@ public void LearnMove(int pokemonUid, int moveToForgetUid)

private void SendLearnMove(int pokemonUid, int moveToForgetUid)
{
SendPacket("^|.|" + pokemonUid + "|.|" + moveToForgetUid);
SendPacket("^|.|" + (pokemonUid) + "|.|" + moveToForgetUid);
}

private void SendMovePokemonToPC(int pokemonUid)
Expand Down Expand Up @@ -839,15 +839,15 @@ public void UseItem(int id, int pokemonUid = 0)
}
else if (!_battleTimeout.IsActive && IsInBattle && item.Scope == 2)
{
SendAttack("item" + id + ":" + pokemonUid);
SendAttack("item" + id + ":" + Team[pokemonUid - 1].DatabaseId);
_battleTimeout.Set();
}
}
}

public bool GiveItemToPokemon(int pokemonUid, int itemId)
public bool GiveItemToPokemon(int databaseId, int itemId)
{
if (!(pokemonUid >= 1 && pokemonUid <= Team.Count))
if (!(databaseId >= 1 && databaseId <= Team.Count))
{
return false;
}
Expand All @@ -860,22 +860,22 @@ public bool GiveItemToPokemon(int pokemonUid, int itemId)
&& (item.Scope == 2 || item.Scope == 3 || item.Scope == 9 || item.Scope == 13
|| item.Scope == 14 || item.Scope == 5 || item.Scope == 12 || item.Scope == 6))
{
SendGiveItem(pokemonUid, itemId);
SendGiveItem(Team[databaseId - 1].DatabaseId, itemId);
_itemUseTimeout.Set();
return true;
}
return false;
}

public bool TakeItemFromPokemon(int pokemonUid)
public bool TakeItemFromPokemon(int databaseId)
{
if (!(pokemonUid >= 1 && pokemonUid <= Team.Count))
if (!(databaseId >= 1 && databaseId <= Team.Count))
{
return false;
}
if (!_itemUseTimeout.IsActive && Team[pokemonUid - 1].ItemHeld != "")
if (!_itemUseTimeout.IsActive && Team[databaseId - 1].ItemHeld != "")
{
SendTakeItem(pokemonUid);
SendTakeItem(Team[databaseId - 1].DatabaseId);
_itemUseTimeout.Set();
return true;
}
Expand Down Expand Up @@ -1172,7 +1172,17 @@ private void SendTalkToNpc(int npcId)
private void SendDialogResponse(int number)
{
// DSSock.ClickButton
SendPacket("R|.|" + ScriptId + "|.|" + number);
//SendPacket("R|.|" + ScriptId + "|.|" + number);
#if DEBUG

#endif
if (ScriptStatus < 4)
SendPacket("R|.|" + number);
else
{
SendPacket("R|.|" + Team[number - 1].DatabaseId);
}

}

public void SendAcceptEvolution(int evolvingPokemonDBid)
Expand Down Expand Up @@ -1324,6 +1334,8 @@ private void ProcessPacket(string packet)
default:
#if DEBUG
Console.WriteLine(" ^ unhandled /!\\");
Console.WriteLine($"Type: ------ {type} ------");
Console.WriteLine($"Packet: ------ {packet} ------");
#endif
break;
}
Expand Down
2 changes: 1 addition & 1 deletion SSinSS/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void InitializeVersion()
Assembly assembly = typeof(App).Assembly;
AssemblyName assemblyName = assembly.GetName();
Name = assemblyName.Name;
Version = assemblyName.Version.ToString(3) + "-beta8_d3";
Version = assemblyName.Version.ToString(3) + "-beta_Test_d";
IsBeta = true;
Author = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute), false)).Company;
Description = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute), false)).Description;
Expand Down
4 changes: 2 additions & 2 deletions SSinSS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: NeutralResourcesLanguage("en")]

28 changes: 27 additions & 1 deletion SSinSS/SSinSS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -183,7 +198,18 @@
<Name>SSinProtocol</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 2 additions & 0 deletions SSinSS/Views/BattleView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void BattleUpdated()
{
_lastOpponentName = opponent;
string sprite = _nameCleaner.Replace(opponent.ToLowerInvariant(), "");
//sprite = sprite.Replace("-", "_");
if (_bot.Game.ActiveBattle.IsShiny)
sprite = $"{_spriteDatabasePrefix}/animados-shiny/{sprite}.gif";
else
Expand Down Expand Up @@ -109,6 +110,7 @@ public void BattleUpdated()
{
_lastActiveName = active.Name;
string sprite = _nameCleaner.Replace(active.Name.ToLowerInvariant(), "");
//sprite = sprite.Replace("-", "_");
if (active.IsShiny)
sprite = $"{_spriteDatabasePrefix}/animados-espalda-shiny/{sprite}.gif"; // shiny back
else
Expand Down
4 changes: 2 additions & 2 deletions SSinSS/Views/TeamView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void MenuItemGiveItem_Click(object sender, RoutedEventArgs e)
InventoryItem item = _bot.Game.Items.Find(i => i.Name == itemName);
if (item != null)
{
_bot.Game.SendGiveItem(pokemon.Uid, item.Id);
_bot.Game.SendGiveItem(pokemon.DatabaseId, item.Id);
}
}
}
Expand All @@ -173,7 +173,7 @@ private void MenuItemTakeItem_Click(object sender, RoutedEventArgs e)
Pokemon pokemon = (Pokemon)PokemonsListView.SelectedItems[0];
lock (_bot)
{
_bot.Game.SendTakeItem(pokemon.Uid);
_bot.Game.SendTakeItem(pokemon.DatabaseId);
}
}
}
Expand Down

0 comments on commit f67c0ea

Please sign in to comment.