Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

add Future show monter HP and Max HP by Press C #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 56 additions & 10 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public partial class MainWindow : Window, IComponentConnector
private int[] player_damages = new int[4] { 0, 0, 0, 0 };
private int[] prev_player_damages = new int[4] { 0, 0, 0, 0 };
private float[] player_damages_avg = new float[4] { 0, 0, 0, 0 };
private float monster_hp = 0;
private float monster_max_hp = 0;
private float monter_percen = 0;
private int my_seat_id = -5;
private TextBlock[] monster_hp_txt = new TextBlock[1];
private Rectangle[] damage_bar_rects = new Rectangle[4];
private TextBlock[] player_name_tbs = new TextBlock[4];
private TextBlock[] player_dmg_tbs = new TextBlock[4];
Expand Down Expand Up @@ -104,6 +108,19 @@ private void update_tick(object sender, EventArgs e)
Application.Current.Shutdown();
if (!this.init_finished)
return;


this.monster_hp = mhw.get_monster_hp(this.game);
this.monster_max_hp = mhw.get_monster_max_hp(this.game);

//Console.WriteLine("monster_hp = " + monster_hp);
if (this.monster_max_hp == 0)
this.monster_hp_txt[0].Text = "";
else
{
this.monter_percen = (this.monster_hp / this.monster_max_hp) * 100;
this.monster_hp_txt[0].Text = this.monster_hp + "/" + this.monster_max_hp + "( " + this.monter_percen + "% )";
}
int[] teamDmg = mhw.get_team_dmg(this.game);
string[] teamPlayerNames = mhw.get_team_player_names(this.game);
int playerSeatId = mhw.get_player_seat_id(this.game);
Expand All @@ -116,7 +133,7 @@ private void update_tick(object sender, EventArgs e)
Array.Clear(this.prev_player_damages, 0, this.prev_player_damages.Length);
Array.Clear(this.player_damages, 0, this.player_damages.Length);
}

this.prev_player_damages = this.player_damages;
this.player_damages = teamDmg;
this.player_names = teamPlayerNames;
Expand All @@ -137,6 +154,7 @@ private void update_tick(object sender, EventArgs e)
}
}


private void update_info(bool quest_end)
{
if (!this.init_finished)
Expand All @@ -149,7 +167,7 @@ private void update_info(bool quest_end)
float dps = this.player_damages[index] / (float)(this.quest_end - this.first_damage).TotalSeconds;
this.player_name_tbs[index].Text = this.player_names[index];
this.player_dmg_tbs[index].Text = this.player_names[index] == "" ? "" : this.player_damages[index].ToString() + " (" + ((float)((double)this.player_damages[index] / (double)num * 100.0)).ToString("0.0") + "%) " + dps.ToString("0.0") + " DPS ";

this.player_dmg_tbs[index].TextAlignment = TextAlignment.Right;
}
}
Expand All @@ -161,10 +179,12 @@ private void update_info(bool quest_end)
this.player_damages_avg[index] -= this.player_damages_avg[index] / 8;
this.player_damages_avg[index] += new_sample / 8;
this.player_name_tbs[index].Text = this.player_names[index];
this.player_dmg_tbs[index].Text = this.player_names[index] == "" ? "" : " " + ((float)((double)this.player_damages[index] / (double)num * 100.0)).ToString("0.0") + "% " + this.player_damages_avg[index].ToString("0.0") + " DPS ";
//this.player_dmg_tbs[index].Text = this.player_names[index] == "" ? "" : " " + ((float)((double)this.player_damages[index] / (double)num * 100.0)).ToString("0.0") + "% " + this.player_damages_avg[index].ToString("0.0") + " DPS ";
this.player_dmg_tbs[index].Text = this.player_names[index] == "" ? "" : this.player_damages[index].ToString() + " (" + ((float)((double)this.player_damages[index] / (double)num * 100.0)).ToString("0.0") + "%) " + this.player_damages_avg[index].ToString("0.0") + " DPS ";

this.player_dmg_tbs[index].TextAlignment = TextAlignment.Right;
}
//Console.WriteLine(this.monster_hp);
if (num == 0)
{
for (int index = 0; index < 4; ++index)
Expand Down Expand Up @@ -218,11 +238,37 @@ private void update_layout()
}
}

private void add_monter_hp()
{
//monster hp
this.monster_hp_txt[0] = new TextBlock();
this.monster_hp_txt[0].FontSize = 16.0;
this.monster_hp_txt[0].Width = 220.0;
this.monster_hp_txt[0].Height = 40.0;
this.monster_hp_txt[0].FontWeight = FontWeights.Bold;
this.monster_hp_txt[0].Foreground = (Brush)new SolidColorBrush(Colors.White);
this.monster_hp_txt[0].Effect = (Effect)new DropShadowEffect()
{
ShadowDepth = 0.0,
Color = Colors.Black,
BlurRadius = 4.0,
Opacity = 1.0
};
Canvas.SetTop((UIElement)this.monster_hp_txt[0], 0);
Canvas.SetLeft((UIElement)this.monster_hp_txt[0], 0);
this.monster_hp_ui.Children.Add((UIElement)this.monster_hp_txt[0]);
this.monster_hp_txt[0].Text = "Monster HP Here";

//
}

private void init_canvas()
{
this.init_finished = true;
double num1 = this.front_canvas.ActualHeight * 0.200000002980232 - 1.75;
double num2 = (this.front_canvas.ActualHeight - num1) / 3.0;

this.add_monter_hp();
for (int index = 0; index < 4; ++index)
{
this.damage_bar_rects[index] = new Rectangle();
Expand Down Expand Up @@ -453,13 +499,13 @@ static MainWindow()
nullableArray4[35] = new byte?((byte)95);
nullableArray4[36] = new byte?((byte)195);
MainWindow.pattern_4 = nullableArray4;
// MainWindow.player_colors = new Color[4]
// {
//Color.FromRgb((byte) 225, (byte) 65, (byte) 55),
//Color.FromRgb((byte) 53, (byte) 136, (byte) 227),
//Color.FromRgb((byte) 196, (byte) 172, (byte) 44),
//Color.FromRgb((byte) 42, (byte) 208, (byte) 55)
// };
// MainWindow.player_colors = new Color[4]
// {
//Color.FromRgb((byte) 225, (byte) 65, (byte) 55),
//Color.FromRgb((byte) 53, (byte) 136, (byte) 227),
//Color.FromRgb((byte) 196, (byte) 172, (byte) 44),
//Color.FromRgb((byte) 42, (byte) 208, (byte) 55)
// };
}

}
Expand Down
9 changes: 5 additions & 4 deletions mainwindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:mhw_dps_wpf"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" MouseDown="Window_MouseDown" MouseWheel="Window_MouseWheel"
Title="mhw_dps_display" Height="187" Width="400" MinWidth="300" MinHeight="140"
Title="mhw_dps_display" Height="318.357" Width="400" MinWidth="300" MinHeight="140"
Background="Transparent">
<Grid>
<Canvas Name="front_canvas" Grid.Row="1" Grid.Column="0"/>
</Grid>
<Grid>
<Canvas Name="front_canvas" Grid.Column="0" Margin="0,58,0,0"/>
<Canvas Name="monster_hp_ui" Grid.Column="0" Margin="0,0,0,230.8"/>
</Grid>
</Window>
56 changes: 56 additions & 0 deletions mhw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,62 @@ public static int get_player_seat_id(Process proc)
return num3;
}

public static float get_monster_hp(Process proc)
{

byte[] lpBuffer = new byte[8];

mhw.ReadProcessMemory(proc.Handle, (IntPtr)0x143B20D98, lpBuffer);
ulong num1 = BitConverter.ToUInt64(lpBuffer, 0) + 0x168;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num1, lpBuffer);
ulong num2 = BitConverter.ToUInt64(lpBuffer, 0) + 0x8A8;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num2, lpBuffer);
ulong num3 = BitConverter.ToUInt64(lpBuffer, 0) + 0x3B0;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num3, lpBuffer);
ulong num4 = BitConverter.ToUInt64(lpBuffer, 0) + 0x18;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num4, lpBuffer);
ulong num5 = BitConverter.ToUInt64(lpBuffer, 0) + 0x58;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num5, lpBuffer);
ulong num6 = BitConverter.ToUInt64(lpBuffer, 0) + 0x64;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num6, lpBuffer);

return BitConverter.ToSingle(lpBuffer, 0);
}

public static float get_monster_max_hp(Process proc)
{

byte[] lpBuffer = new byte[8];

mhw.ReadProcessMemory(proc.Handle, (IntPtr)0x143B20D98, lpBuffer);
ulong num1 = BitConverter.ToUInt64(lpBuffer, 0) + 0x168;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num1, lpBuffer);
ulong num2 = BitConverter.ToUInt64(lpBuffer, 0) + 0x8A8;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num2, lpBuffer);
ulong num3 = BitConverter.ToUInt64(lpBuffer, 0) + 0x3B0;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num3, lpBuffer);
ulong num4 = BitConverter.ToUInt64(lpBuffer, 0) + 0x18;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num4, lpBuffer);
ulong num5 = BitConverter.ToUInt64(lpBuffer, 0) + 0x58;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num5, lpBuffer);
ulong num6 = BitConverter.ToUInt64(lpBuffer, 0) + 0x60;

mhw.ReadProcessMemory(proc.Handle, (IntPtr)num6, lpBuffer);

return BitConverter.ToSingle(lpBuffer, 0);
}

public static string[] get_team_player_names(Process proc)
{
string[] strArray = new string[4];
Expand Down