rabi_display
wcko87 8 years ago
parent 66aecce5ef
commit 62a3b6a64d
  1. 249
      rabi_splitter_WPF/MainContext.cs
  2. 54
      rabi_splitter_WPF/MainWindow.xaml
  3. 379
      rabi_splitter_WPF/MainWindow.xaml.cs
  4. 4
      rabi_splitter_WPF/MemoryHelper.cs
  5. 150
      rabi_splitter_WPF/RabiRibiDisplay.cs
  6. 1
      rabi_splitter_WPF/rabi_display.csproj

@ -120,6 +120,11 @@ namespace rabi_splitter_WPF
}
}
public void Log(string message)
{
this.DebugLog += message + "\n";
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
@ -130,145 +135,196 @@ namespace rabi_splitter_WPF
}
class MainContext : INotifyPropertyChanged
{
private bool _musicStart;
private bool _musicEnd;
private bool _computer;
private bool _miruDe;
private bool _sideCh;
private bool _aliusI;
private bool _tm2;
private bool _irisu1;
private bool _dontSplitOnReload;
private bool _debugArea;
public string oldtitle;
public int veridx;
private int _serverPort;
private string _gameVer;
private string _gameMusic;
private bool _igt;
public bool _autoReset;
public bool _autoStart;
public bool Noah1Reload
private string _text1;
private string _text2;
private string _text3;
private string _text4;
private string _text5;
private string _text6;
private string _text7;
private string _text8;
private string _text9;
private string _text10;
private string _text11;
private string _text12;
private string _text13;
private string _text14;
private string _text15;
public string Text1
{
get { return _text1; }
set
{
if (value == _text1) return;
_gameVer = value;
OnPropertyChanged(nameof(Text1));
}
}
public string Text2
{
get { return _text2; }
set
{
if (value == _text2) return;
_gameVer = value;
OnPropertyChanged(nameof(Text2));
}
}
public string Text3
{
get { return _noah1Reload; }
get { return _text3; }
set
{
if (value == _noah1Reload) return;
_noah1Reload = value;
OnPropertyChanged(nameof(Noah1Reload));
if (value == _text3) return;
_gameVer = value;
OnPropertyChanged(nameof(Text3));
}
}
public bool MusicStart
public string Text4
{
get { return _musicStart; }
get { return _text4; }
set
{
if (value == _musicStart) return;
_musicStart = value;
OnPropertyChanged(nameof(MusicStart));
if (value == _text4) return;
_gameVer = value;
OnPropertyChanged(nameof(Text4));
}
}
public bool MusicEnd
public string Text5
{
get { return _musicEnd; }
get { return _text5; }
set
{
if (value == _musicEnd) return;
_musicEnd = value;
OnPropertyChanged(nameof(MusicEnd));
if (value == _text5) return;
_gameVer = value;
OnPropertyChanged(nameof(Text5));
}
}
public bool Computer
public string Text6
{
get { return _computer; }
get { return _text6; }
set
{
if (value == _computer) return;
_computer = value;
OnPropertyChanged(nameof(Computer));
if (value == _text6) return;
_gameVer = value;
OnPropertyChanged(nameof(Text6));
}
}
public bool MiruDe
public string Text7
{
get { return _miruDe; }
get { return _text7; }
set
{
if (value == _miruDe) return;
_miruDe = value;
OnPropertyChanged(nameof(MiruDe));
if (value == _text7) return;
_gameVer = value;
OnPropertyChanged(nameof(Text7));
}
}
public string Text8
{
get { return _text8; }
set
{
if (value == _text8) return;
_gameVer = value;
OnPropertyChanged(nameof(Text8));
}
}
public bool SideCh
public string Text9
{
get { return _sideCh; }
get { return _text9; }
set
{
if (value == _sideCh) return;
_sideCh = value;
OnPropertyChanged(nameof(SideCh));
if (value == _text9) return;
_gameVer = value;
OnPropertyChanged(nameof(Text9));
}
}
public bool AliusI
public string Text10
{
get { return _aliusI; }
get { return _text10; }
set
{
if (value == _aliusI) return;
_aliusI = value;
OnPropertyChanged(nameof(AliusI));
if (value == _text10) return;
_gameVer = value;
OnPropertyChanged(nameof(Text10));
}
}
public bool Tm2
public string Text11
{
get { return _tm2; }
get { return _text11; }
set
{
if (value == _tm2) return;
_tm2 = value;
OnPropertyChanged(nameof(Tm2));
if (value == _text11) return;
_gameVer = value;
OnPropertyChanged(nameof(Text11));
}
}
public bool Irisu1
public string Text12
{
get { return _irisu1; }
get { return _text12; }
set
{
if (value == _irisu1) return;
_irisu1 = value;
OnPropertyChanged(nameof(Irisu1));
if (value == _text12) return;
_gameVer = value;
OnPropertyChanged(nameof(Text12));
}
}
public bool DontSplitOnReload
public string Text13
{
get { return _dontSplitOnReload; }
get { return _text13; }
set
{
if (value == _dontSplitOnReload) return;
_dontSplitOnReload = value;
OnPropertyChanged(nameof(DontSplitOnReload));
if (value == _text13) return;
_gameVer = value;
OnPropertyChanged(nameof(Text13));
}
}
public bool DebugArea
public string Text14
{
get { return _debugArea; }
get { return _text14; }
set
{
if (value == _debugArea) return;
_debugArea = value;
OnPropertyChanged(nameof(DebugArea));
if (value == _text14) return;
_gameVer = value;
OnPropertyChanged(nameof(Text14));
}
}
public string Text15
{
get { return _text15; }
set
{
if (value == _text15) return;
_gameVer = value;
OnPropertyChanged(nameof(Text15));
}
}
public int ServerPort
{
get { return _serverPort; }
@ -312,63 +368,11 @@ namespace rabi_splitter_WPF
OnPropertyChanged(nameof(Igt));
}
}
public bool AutoStart
{
get { return _autoStart; }
set
{
if (value == _autoStart) return;
_autoStart = value;
OnPropertyChanged(nameof(AutoStart));
}
}
public bool AutoReset
{
get { return _autoReset; }
set
{
if (value == _autoReset) return;
_autoReset = value;
OnPropertyChanged(nameof(AutoReset));
}
}
public int previousBlackness = -1;
public string oldtitle;
public int veridx;
public int lastmoney;
public int lastmapid;
public int lastmusicid;
public int lastplaytime = 0;
public bool bossbattle;
public List<int> lastbosslist;
public int lastnoah3hp;
public int lastTM;
public DateTime LastTMAddTime;
private bool _noah1Reload;
public MainContext()
{
this.MusicEnd = true;
this.MusicStart = false;
this.Computer = true;
this.MiruDe = true;
this.SideCh = true;
this.AliusI = true;
this.Tm2 = true;
this.Irisu1 = true;
this.DontSplitOnReload = false;
this.DebugArea = false;
this.ServerPort = 16834;
this.Igt = true;
this.Noah1Reload = false;
this.AutoStart = false;
this.AutoReset = true;
}
public event PropertyChangedEventHandler PropertyChanged;
@ -378,9 +382,6 @@ namespace rabi_splitter_WPF
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -16,7 +16,7 @@
<TextBlock Text="GitHub" MouseUp="TextBlock_MouseUp" Cursor="Hand" Foreground="Blue" TextDecorations="Underline" VerticalAlignment="Top" />
</StackPanel>
<DockPanel Margin="5" DockPanel.Dock="Top">
<StackPanel Margin="0,0,100,0">
<StackPanel Margin="0,0,100,0" Width="356">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,3">
<TextBlock TextWrapping="Wrap" Text="LiveSplit Server Port" VerticalAlignment="Center" FontSize="16" Margin="0,0,10,0"/>
<TextBox TextWrapping="Wrap" Text="{Binding ServerPort}" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalContentAlignment="Center" FontSize="16" Padding="6,0"/>
@ -26,23 +26,43 @@
<TextBlock TextWrapping="Wrap" Text="Rabi-Ribi Status:" FontSize="16"/>
<TextBlock TextWrapping="Wrap" Text="{Binding GameVer}" FontSize="16"/>
</StackPanel>
<TextBlock TextWrapping="Wrap" Text="{Binding GameMusic}" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4"/>
<CheckBox Content="Split when BOSS music STARTS" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding MusicStart, Mode=TwoWay}"/>
<CheckBox Content="Split when BOSS music ENDS" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding MusicEnd, Mode=TwoWay}"/>
<CheckBox Content="Split when the computer is found" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding Computer, Mode=TwoWay}"/>
<CheckBox Content="Split when Miru despawns" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding MiruDe, Mode=TwoWay}"/>
<CheckBox Content="Ignore the Side Chapter" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding SideCh, Mode=TwoWay}"/>
<CheckBox Content="Ignore the next &quot;SUDDEN DEATH&quot; (Ignore Alius I)" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding AliusI, Mode=TwoWay}" IsEnabled="{Binding AutoReset, Converter={StaticResource InverseBooleanConverter},Mode=TwoWay}" />
<CheckBox Content="Ignore the &quot;M.R.&quot; (Reload on Noah 1)" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding Noah1Reload, Mode=TwoWay}" IsEnabled="{Binding AutoReset, Converter={StaticResource InverseBooleanConverter},Mode=TwoWay}"/>
<CheckBox Content="Split when Town Member +2 or Nixie despawns" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding Tm2, Mode=TwoWay}"/>
<CheckBox Content="Ignore Irisu Phase 1" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding Irisu1, Mode=TwoWay}"/>
<CheckBox Content="Don't split on reload during boss (1.75, experimental)" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding DontSplitOnReload, Mode=TwoWay}"/>
<CheckBox Content="Track In-Game Time" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding Igt, Mode=TwoWay}"/>
<CheckBox Content="Start timer on game start (1.75 only)" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding AutoStart, Mode=TwoWay}"/>
<CheckBox Content="Reset timer when returning to title screen" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding AutoReset, Mode=TwoWay}"/>
<CheckBox Content="Show debug area" HorizontalAlignment="Left" FontSize="15" Margin="0,0,0,4" IsChecked="{Binding DebugArea, Mode=TwoWay}"/>
<Grid Height="280">
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" TextWrapping="Wrap" Text="{Binding Text1}" FontSize="16"/>
<TextBlock Grid.Row="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Text2}" FontSize="16"/>
<TextBlock Grid.Row="0" Grid.Column="2" TextWrapping="Wrap" Text="{Binding Text3}" FontSize="16"/>
<TextBlock Grid.Row="1" Grid.Column="0" TextWrapping="Wrap" Text="{Binding Text4}" FontSize="16"/>
<TextBlock Grid.Row="1" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Text5}" FontSize="16"/>
<TextBlock Grid.Row="1" Grid.Column="2" TextWrapping="Wrap" Text="{Binding Text6}" FontSize="16"/>
<TextBlock Grid.Row="2" Grid.Column="0" TextWrapping="Wrap" Text="{Binding Text7}" FontSize="16"/>
<TextBlock Grid.Row="2" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Text8}" FontSize="16"/>
<TextBlock Grid.Row="2" Grid.Column="2" TextWrapping="Wrap" Text="{Binding Text9}" FontSize="16"/>
<TextBlock Grid.Row="3" Grid.Column="0" TextWrapping="Wrap" Text="{Binding Text10}" FontSize="16"/>
<TextBlock Grid.Row="3" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Text11}" FontSize="16"/>
<TextBlock Grid.Row="3" Grid.Column="2" TextWrapping="Wrap" Text="{Binding Text12}" FontSize="16"/>
<TextBlock Grid.Row="4" Grid.Column="0" TextWrapping="Wrap" Text="{Binding Text13}" FontSize="16"/>
<TextBlock Grid.Row="4" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Text14}" FontSize="16"/>
<TextBlock Grid.Row="4" Grid.Column="2" TextWrapping="Wrap" Text="{Binding Text15}" FontSize="16"/>
</Grid>
</StackPanel>
<DockPanel Visibility="{Binding DebugArea, Converter={StaticResource BooleanToVisibilityConverter}, Mode=TwoWay}" >
<DockPanel>
<TextBlock TextWrapping="Wrap" Text="debug area" Height="15.24" Width="352.251" DockPanel.Dock="Top"/>
<CheckBox x:Name="BossEventDebug" IsEnabled="False" Content="(DEBUG)BOSS event tracked" FontSize="15" VerticalAlignment="Top" HorizontalAlignment="Left" IsChecked="{Binding BossEvent, Mode=TwoWay}" DockPanel.Dock="Top"/>
<Grid x:Name="DebugPanel" d:DataContext="{d:DesignData local:DebugContext}" DockPanel.Dock="Top">

@ -25,18 +25,18 @@ namespace rabi_splitter_WPF
public partial class MainWindow : Window
{
private MainContext mainContext;
private RabiRibiDisplay rabiRibiDisplay;
private DebugContext debugContext;
private static TcpClient tcpclient;
private static NetworkStream networkStream;
private readonly Regex titleReg = new Regex(@"ver.*?(\d+\.?\d+.*)$");
private readonly Thread memoryThread;
private void ReadMemory()
{
var processlist = Process.GetProcessesByName("rabiribi");
if (processlist.Length > 0)
{
Process process = processlist[0];
if (process.MainWindowTitle != mainContext.oldtitle)
{
@ -44,393 +44,37 @@ namespace rabi_splitter_WPF
string rabiver;
if (result.Success)
{
rabiver = result.Groups[1].Value;
rabiver = result.Groups[1].Value;
mainContext.veridx = Array.IndexOf(StaticData.VerNames, rabiver);
if (mainContext.veridx < 0)
{
mainContext.GameVer = rabiver + " Running (not support)";
mainContext.GameVer = rabiver + " Running (not supported)";
return;
}
}
else
{
mainContext.veridx = -1;
mainContext.GameVer = "Running (Unknown version)";
return;
}
mainContext.GameVer = rabiver + " Running";
mainContext.oldtitle = process.MainWindowTitle;
}
if (mainContext.veridx < 0) return;
#region read igt
int igt = MemoryHelper.GetMemoryValue<int>(process, StaticData.IGTAddr[mainContext.veridx]);
if (igt > 0 && mainContext.Igt)
{
sendigt((float)igt / 60);
}
#endregion
#region Detect Reload
bool reloaded = false;
{
int playtime = MemoryHelper.GetMemoryValue<int>(process, StaticData.PlaytimeAddr[mainContext.veridx]);
reloaded = playtime != 0 && playtime < mainContext.lastplaytime;
if (reloaded) DebugLog("Reload Game!");
mainContext.lastplaytime = playtime;
}
#endregion
#region Detect Start Game
{
int blackness = MemoryHelper.GetMemoryValue<int>(process, StaticData.BlacknessAddr[mainContext.veridx]);
if (mainContext.previousBlackness == 0 && blackness >= 100000)
{
// Sudden increase by 100000
// Have to be careful, though. I don't know whether anything else causes blackness to increase by 100000
if (mainContext.AutoStart) sendstarttimer();
DebugLog("Start Game!");
}
mainContext.previousBlackness = blackness;
}
#endregion
#region CheckMoney
if (mainContext.Computer)
{
var newmoney = MemoryHelper.GetMemoryValue<int>(process, StaticData.MoneyAddress[mainContext.veridx]);
if (newmoney - mainContext.lastmoney == 17500)
{
sendsplit();
DebugLog("get 17500 en, split");
}
mainContext.lastmoney = newmoney;
}
#endregion
int mapid = MemoryHelper.GetMemoryValue<int>(process, StaticData.MapAddress[mainContext.veridx]);
if (mainContext.lastmapid != mapid)
{
DebugLog("newmap: " + mapid + ":" + StaticData.MapNames[mapid]);
mainContext.lastmapid = mapid;
}
#region checkTM
#endregion
#region Music
int musicaddr = StaticData.MusicAddr[mainContext.veridx];
int musicid = MemoryHelper.GetMemoryValue<int>(process, musicaddr);
if (musicid > 0 && musicid < StaticData.MusicNames.Length)
{
if (mainContext.lastmusicid != musicid)
{
DebugLog("new music:" + musicid + ":" + StaticData.MusicNames[musicid]);
mainContext.GameMusic = StaticData.MusicNames[musicid];
if ((musicid == 45 || musicid == 46 || musicid == 53) && mainContext.AutoReset)
{
DebugLog("Title music, reset");
//reset
sendreset();
mainContext.AliusI = true;
mainContext.Noah1Reload = false;
mainContext.bossbattle = false;
}
else
{
var bossmusicflag = StaticData.BossMusics.Contains(musicid);
if (bossmusicflag)
{
if (mainContext.bossbattle)
{
if (mainContext.Noah1Reload && (mainContext.lastmusicid == 52 || musicid == 52))
{
DebugLog("noah 1 reload? ignore");
}
else
{
if (mainContext.MusicStart || mainContext.MusicEnd)
{
sendsplit();
DebugLog("new boss music, split");
}
if (musicid == 37)
{
mainContext.Noah1Reload = true;
DebugLog("noah1 music start, ignore MR forever");
}
}
mainContext.lastmusicid = musicid;
return;
}
}
if (!mainContext.bossbattle)
{
if (musicid == 54 && mainContext.AliusI)
{
mainContext.bossbattle = false;
mainContext.AliusI = false;
DebugLog("Alius music, ignore once");
}
else if (musicid == 42 && mapid == 1 && mainContext.Irisu1)
{
mainContext.bossbattle = false;
DebugLog("Irisu P1, ignore");
}
else
{
if (bossmusicflag)
{
if (mapid == 5 && musicid == 44 && mainContext.SideCh)
{
mainContext.bossbattle = false;
DebugLog("sidechapter, ignore");
}
else
{
mainContext.bossbattle = true;
mainContext.lastbosslist = new List<int>();
mainContext.lastnoah3hp = -1;
if (musicid == 37)
{
mainContext.Noah1Reload = true;
DebugLog("noah1 music start, ignore MR forever");
}
if (mainContext.MusicStart)
{
sendsplit();
DebugLog("music start, split");
}
}
}
}
}
else
{
if (!bossmusicflag) //boss music end!
{
mainContext.bossbattle = false;
if (mainContext.MusicEnd)
{
if (!mainContext.DontSplitOnReload || !reloaded) sendsplit();
DebugLog(reloaded ? "music end, don't split (reload)" : "music end, split");
}
}
}
}
mainContext.lastmusicid = musicid;
}
}
else
{
mainContext.GameMusic = "N/A";
}
#endregion Music
#region SpecialBOSS
if (mainContext.bossbattle)
{
if (mainContext.MiruDe || false)//todo noah3 option
{
int Noah3HP = -1;
if (mapid >= 0 && mapid < StaticData.MapNames.Length)
{
int ptr = MemoryHelper.GetMemoryValue<int>(process, StaticData.EnenyPtrAddr[mainContext.veridx]);
List<int> bosses = new List<int>();
for (var i = 0; i < 50; i++)
{
ptr = ptr + StaticData.EnenyEntitySize[mainContext.veridx];
var emyid = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyIDOffset[mainContext.veridx], false);
if (StaticData.BossNames.ContainsKey(emyid))
{
bosses.Add(emyid);
if (emyid == 1053)
{
Noah3HP = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyHPOffset[mainContext.veridx], false);
}
}
}
if (mainContext.MiruDe && mapid==8)
{
foreach (var boss in mainContext.lastbosslist)
{
if (boss == 1043)
{
if (!bosses.Contains(boss)) //despawn
{
sendsplit();
DebugLog("miru despawn, split");
mainContext.bossbattle = false;
}
}
}
}
// if (cbBoss3.Checked)
// {
// if (bosses.Contains(1053) && Noah3HP < lastnoah3hp && Noah3HP == 1)
// {
// sendsplit();
// DebugLog("noah3 hp 1, split");
// bossbattle = false;
// }
// }
if (mainContext.Tm2 && musicid == 8)
{
bool f = true;
foreach (var boss in mainContext.lastbosslist)
{
if (boss == 1024)
{
if (!bosses.Contains(boss)) //despawn
{
sendsplit();
DebugLog("nixie despawn, split");
mainContext.bossbattle = false;
f = false;
break;
}
}
}
int newTM = MemoryHelper.GetMemoryValue<int>(process, StaticData.TownMemberAddr[mainContext.veridx]);
if (newTM - mainContext.lastTM == 1 && f) //for after 1.71 , 1.71 isn't TM+2 at once when skip Nixie, it's TM+1 twice
{
if (DateTime.Now - mainContext.LastTMAddTime < TimeSpan.FromSeconds(1))
{
var d = DateTime.Now - mainContext.LastTMAddTime;
mainContext.bossbattle = false;
sendsplit();
DebugLog("TM+2 in " + d.TotalMilliseconds + " ms, split");
}
mainContext.LastTMAddTime = DateTime.Now;
}
else if (newTM - mainContext.lastTM == 2 && f)//for 1.65-1.70
{
mainContext.bossbattle = false;
sendsplit();
DebugLog("TM+2, split");
}
mainContext.lastTM = newTM;
}
mainContext.lastbosslist = bosses;
mainContext.lastnoah3hp = Noah3HP;
}
}
}
#endregion SpecialBOSS
if (mainContext.DebugArea)
{
int ptr = MemoryHelper.GetMemoryValue<int>(process, StaticData.EnenyPtrAddr[mainContext.veridx]);
// List<int> bosses = new List<int>();
// List<int> HPS = new List<int>();
// this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => debugContext.BossList.Clear()));
// ptr += StaticData.EnenyEntitySize[mainContext.veridx] * 3;
for (var i = 0; i < 50; i++)
{
ptr += StaticData.EnenyEntitySize[mainContext.veridx];
debugContext.BossList[i].BossID = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyIDOffset[mainContext.veridx], false);
debugContext.BossList[i].BossHP = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyHPOffset[mainContext.veridx], false);
}
}
debugContext.BossEvent = mainContext.bossbattle;
rabiRibiDisplay.ReadMemory(process);
}
else
{
mainContext.oldtitle = "";
mainContext.GameVer = "Not Found";
mainContext.GameMusic = "N/A";
}
}
private void DebugLog(string log)
{
this.debugContext.DebugLog += log + "\n";
}
private void sendsplit()
{
SendMessage("split\r\n");
}
private void sendreset()
{
SendMessage("reset\r\n");
}
private void sendstarttimer()
{
SendMessage("starttimer\r\n");
}
private void sendigt(float time)
{
SendMessage($"setgametime {time}\r\n");
}
private void SendMessage(string message)
public void SendMessage(string message)
{
if (tcpclient != null && tcpclient.Connected)
{
@ -446,6 +90,7 @@ namespace rabi_splitter_WPF
}
}
}
void disconnect()
{
tcpclient = null;
@ -453,8 +98,11 @@ namespace rabi_splitter_WPF
{
BtnConnect.IsEnabled = true;
}));
}
private void DebugLog(string log)
{
this.debugContext.Log(log);
}
public MainWindow()
@ -466,6 +114,7 @@ namespace rabi_splitter_WPF
DebugPanel.DataContext = debugContext;
this.Grid.ItemsSource = debugContext.BossList;
BossEventDebug.DataContext = debugContext;
rabiRibiDisplay = new RabiRibiDisplay(mainContext, debugContext, this);
memoryThread = new Thread(() =>
{
while (true)

@ -9,6 +9,9 @@ namespace rabi_splitter_WPF
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess,
int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
@ -57,6 +60,7 @@ namespace rabi_splitter_WPF
datasize, ref bytesRead);
}
CloseHandle(processHandle);
switch (Type.GetTypeCode(typeof(T)))
{

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace rabi_splitter_WPF
{
class RabiRibiDisplay
{
private MainContext mainContext;
private DebugContext debugContext;
private MainWindow mainWindow;
public int previousBlackness = -1;
public int lastmoney;
public int lastmapid;
public int lastmusicid;
public int lastplaytime = 0;
public bool bossbattle;
public List<int> lastbosslist;
public int lastnoah3hp;
public int lastTM;
public DateTime LastTMAddTime;
private bool _noah1Reload;
public RabiRibiDisplay(MainContext mainContext, DebugContext debugContext, MainWindow mainWindow)
{
this.mainContext = mainContext;
this.debugContext = debugContext;
this.mainWindow = mainWindow;
}
public void ReadMemory(Process process)
{
#region read igt
int igt = MemoryHelper.GetMemoryValue<int>(process, StaticData.IGTAddr[mainContext.veridx]);
if (igt > 0 && mainContext.Igt)
{
sendigt((float)igt / 60);
}
#endregion
#region Detect Reload
bool reloaded = false;
{
int playtime = MemoryHelper.GetMemoryValue<int>(process, StaticData.PlaytimeAddr[mainContext.veridx]);
reloaded = playtime != 0 && playtime < lastplaytime;
if (reloaded) DebugLog("Reload Game!");
lastplaytime = playtime;
}
#endregion
#region Detect Start Game
{
int blackness = MemoryHelper.GetMemoryValue<int>(process, StaticData.BlacknessAddr[mainContext.veridx]);
if (previousBlackness == 0 && blackness >= 100000)
{
// Sudden increase by 100000
// Have to be careful, though. I don't know whether anything else causes blackness to increase by 100000
DebugLog("Start Game!");
}
previousBlackness = blackness;
}
#endregion
#region CheckMoney
{
var newmoney = MemoryHelper.GetMemoryValue<int>(process, StaticData.MoneyAddress[mainContext.veridx]);
if (newmoney - lastmoney == 17500)
{
sendsplit();
DebugLog("get 17500 en, split");
}
lastmoney = newmoney;
}
#endregion
int mapid = MemoryHelper.GetMemoryValue<int>(process, StaticData.MapAddress[mainContext.veridx]);
if (lastmapid != mapid)
{
DebugLog("newmap: " + mapid + ":" + StaticData.MapNames[mapid]);
lastmapid = mapid;
}
#region checkTM
#endregion
UpdateDebugArea(process);
}
private void UpdateDebugArea(Process process)
{
int ptr = MemoryHelper.GetMemoryValue<int>(process, StaticData.EnenyPtrAddr[mainContext.veridx]);
// List<int> bosses = new List<int>();
// List<int> HPS = new List<int>();
// this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => debugContext.BossList.Clear()));
// ptr += StaticData.EnenyEntitySize[mainContext.veridx] * 3;
for (var i = 0; i < 50; i++)
{
ptr += StaticData.EnenyEntitySize[mainContext.veridx];
debugContext.BossList[i].BossID = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyIDOffset[mainContext.veridx], false);
debugContext.BossList[i].BossHP = MemoryHelper.GetMemoryValue<int>(process,
ptr + StaticData.EnenyEnitiyHPOffset[mainContext.veridx], false);
}
debugContext.BossEvent = bossbattle;
}
private void DebugLog(string log)
{
this.debugContext.Log(log);
}
private void sendsplit()
{
mainWindow.SendMessage("split\r\n");
}
private void sendreset()
{
mainWindow.SendMessage("reset\r\n");
}
private void sendstarttimer()
{
mainWindow.SendMessage("starttimer\r\n");
}
private void sendigt(float time)
{
mainWindow.SendMessage($"setgametime {time}\r\n");
}
}
}

@ -55,6 +55,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="RabiRibiDisplay.cs" />
<Compile Include="StaticData.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>

Loading…
Cancel
Save