Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Timers;
- using System.IO;
- using System.Collections;
- using System.Drawing.Drawing2D;
- /* ################# TO DO ##################### */
- /*Можно сделать так чтобы программа спрашивала у пользователя разрешение планетсайда, затем брала разрешение экрана у винды и умножала все на коэффициент-разницу разрешений
- add magazine size into burst stats?
- Кстати, зная ширину паттерна (количество киков) можно рассчитать расстояние на котором цель гарантированно умрет за 1 бурст
- incorporate target movement if we're firing from a moving stance? subject to ADS multiplier
- add croshair movement while CoF resets in TTK simulation
- add the ability for user to control recoil with mouse
- */
- class Shot
- {
- public Double X; //Crosshair Position
- public Double Y;
- public Double Vertical_Recoil; //recoil produced by this shot (not recoil affecting this shot)
- public Double Horizontal_Recoil;
- public Double Recoil_Angle;
- public Double Accumulated_Horizontal_Recoil;
- public PointF[] bullets;
- public PointF pellet_spread_coords;
- public double CoF;
- public double Pellet_Spread;
- public Shot(Double x, Double y, Double ACR, Weapon wpn)
- {
- X = x;
- Y = y;
- Accumulated_Horizontal_Recoil = ACR;
- bullets = new PointF[wpn.Pellets];
- }
- }
- class Weapon : IEnumerable<Weapon>
- {
- public double Vertical_Recoil, Horizontal_Recoil_Minimum, Horizontal_Recoil_Maximum,
- Horizontal_Recoil_Tolerance, First_Shot_Recoil_Multiplier, Headshot_Damage_Multiplier,
- Short_Reload, Long_Reload, CoF_Standing_Still_ADS, CoF_Standing_Moving_ADS, CoF_Crouching_Still_ADS,
- CoF_Crouching_Moving_ADS, CoF_Standing_Still_Hip, CoF_Standing_Moving_Hip, CoF_Crouching_Still_Hip, CoF_Sprint,
- CoF_Crouching_Moving_HIP, CoF_Bloom_ADS, CoF_Bloom_Hip, Recoil_Angle_Minimum, Recoil_Angle_Maximum, Equip_Time, ADS_Movement_Speed_Multiplier, Pellet_Spread_ADS, Pellet_Spread_HIP;
- public int Rate_of_Fire, Maximum_Damage, Maximum_Damage_Range, Minimum_Damage, Minimum_Damage_Range,
- Projectile_Velocity, Magazine_Size, Recoil_Recovery_Rate, Pellets, Ammo_Pool, Refire_Time;
- public string Weapon_Name, Faction, Type, Fire_Mode, Attachments, Stats;
- public int ID;
- public float Starting_X, Starting_Y;
- public int ShotNumber;
- public bool dragging = false, TargetDragging = false;
- public Shot[] shot;
- public Button GetStats;
- public double CurrentCoF;
- public float Target_X, Target_Y, Target_W, Target_H;
- public Weapon() { Init(); }
- public Weapon(Weapon w)
- {
- Vertical_Recoil = w.Vertical_Recoil;
- Horizontal_Recoil_Minimum = w.Horizontal_Recoil_Minimum;
- Horizontal_Recoil_Maximum = w.Horizontal_Recoil_Maximum;
- Horizontal_Recoil_Tolerance = w.Horizontal_Recoil_Tolerance;
- First_Shot_Recoil_Multiplier = w.First_Shot_Recoil_Multiplier;
- Headshot_Damage_Multiplier = w.Headshot_Damage_Multiplier;
- Short_Reload = w.Short_Reload;
- Long_Reload = w.Long_Reload;
- CoF_Standing_Still_ADS = w.CoF_Standing_Still_ADS;
- CoF_Standing_Moving_ADS = w.CoF_Standing_Moving_ADS;
- CoF_Crouching_Still_ADS = w.CoF_Crouching_Still_ADS;
- CoF_Crouching_Moving_ADS = w.CoF_Crouching_Moving_ADS;
- CoF_Standing_Still_Hip = w.CoF_Standing_Still_Hip;
- CoF_Standing_Moving_Hip = w.CoF_Standing_Moving_Hip;
- CoF_Crouching_Still_Hip = w.CoF_Crouching_Still_Hip;
- CoF_Sprint = w.CoF_Sprint;
- CoF_Crouching_Moving_HIP = w.CoF_Crouching_Moving_HIP;
- CoF_Bloom_ADS = w.CoF_Bloom_ADS;
- CoF_Bloom_Hip = w.CoF_Bloom_Hip;
- Recoil_Angle_Minimum = w.Recoil_Angle_Minimum;
- Recoil_Angle_Maximum = w.Recoil_Angle_Maximum;
- Equip_Time = w.Equip_Time;
- ADS_Movement_Speed_Multiplier = w.ADS_Movement_Speed_Multiplier;
- Rate_of_Fire = w.Rate_of_Fire;
- Maximum_Damage = w.Maximum_Damage;
- Maximum_Damage_Range = w.Maximum_Damage_Range;
- Minimum_Damage_Range = w.Minimum_Damage_Range;
- Minimum_Damage = w.Minimum_Damage;
- Projectile_Velocity = w.Projectile_Velocity;
- Magazine_Size = w.Magazine_Size;
- Recoil_Recovery_Rate = w.Recoil_Recovery_Rate;
- Pellets = w.Pellets;
- Ammo_Pool = w.Ammo_Pool;
- Refire_Time = w.Refire_Time;
- Weapon_Name = w.Weapon_Name;
- Faction = w.Faction;
- Type = w.Type;
- ID = w.ID;
- Pellet_Spread_ADS = w.Pellet_Spread_ADS;
- Pellet_Spread_HIP = w.Pellet_Spread_HIP;
- Fire_Mode = w.Fire_Mode;
- Attachments = w.Attachments;
- Target_X = w.Target_X;
- Target_Y = w.Target_Y;
- Init();
- }
- public void InitButton()
- {
- GetStats = new Button();
- GetStats.Text = "Get stats";
- GetStats.Size = new Size(60, 30);
- GetStats.Location = new Point((int)Starting_X - 65, (int)Starting_Y + 10);
- GetStats.Click += GetStats_Click;
- }
- private void GetStats_Click(object sender, EventArgs e)
- {
- if (Attachments != "") MessageBox.Show(Stats + "\n\n" + "ATTACHMENTS:\n" + Attachments + "\n" + "You can press Ctrl + C to copy\nthe contents of this message box.", "Weapon Stats");
- else MessageBox.Show(Stats + "\n\n" + "You can press Ctrl + C to copy\nthe contents of this message box.", "Weapon Stats");
- }
- public void Init()
- {
- shot = new Shot[200];
- ShotNumber = 0;
- }
- public int CompareTo(Weapon other)
- {
- throw new NotImplementedException();
- }
- public IEnumerator<Weapon> GetEnumerator()
- {
- throw new NotImplementedException();
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- throw new NotImplementedException();
- }
- public double GetCurrentCoF(bool ADSing, bool Standing, bool Still)
- {
- double Minimum_CoF = GetCurrentMinimumCoF(ADSing, Standing, Still);
- if (CurrentCoF < Minimum_CoF || ShotNumber == 0) CurrentCoF = Minimum_CoF;
- if (ADSing && CurrentCoF > 3) CurrentCoF = 3;
- else if (CurrentCoF > 7) CurrentCoF = 7;
- return CurrentCoF;
- }
- public double GetCurrentMinimumCoF(bool ADSing, bool Standing, bool Still)
- {
- double Minimum_CoF = 0;
- switch (Convert.ToString(Convert.ToInt32(ADSing)) + Convert.ToString(Convert.ToInt32(Standing)) + Convert.ToString(Convert.ToInt32(Still)))
- {
- case "111": Minimum_CoF = CoF_Standing_Still_ADS; break;
- case "011": Minimum_CoF = CoF_Standing_Still_Hip; break;
- case "101": Minimum_CoF = CoF_Crouching_Still_ADS; break;
- case "001": Minimum_CoF = CoF_Crouching_Still_Hip; break;
- case "110": Minimum_CoF = CoF_Standing_Moving_ADS; break;
- case "010": Minimum_CoF = CoF_Standing_Moving_Hip; break;
- case "100": Minimum_CoF = CoF_Crouching_Moving_ADS; break;
- case "000": Minimum_CoF = CoF_Crouching_Moving_HIP; break;
- }
- return Minimum_CoF;
- }
- public void Fire(Random rand, double Left_or_Right, bool ADSing, bool Standing, bool Still, bool Ignore_Vertical_Recoil)
- {
- if (ShotNumber >= shot.Length) Init();
- PointF pt = new PointF(0, 0);
- double Minimum_CoF = 0;
- switch (Convert.ToString(Convert.ToInt32(ADSing)) + Convert.ToString(Convert.ToInt32(Standing)) + Convert.ToString(Convert.ToInt32(Still)))
- {
- case "111": Minimum_CoF = CoF_Standing_Still_ADS; break;
- case "011": Minimum_CoF = CoF_Standing_Still_Hip; break;
- case "101": Minimum_CoF = CoF_Crouching_Still_ADS; break;
- case "001": Minimum_CoF = CoF_Crouching_Still_Hip; break;
- case "110": Minimum_CoF = CoF_Standing_Moving_ADS; break;
- case "010": Minimum_CoF = CoF_Standing_Moving_Hip; break;
- case "100": Minimum_CoF = CoF_Crouching_Moving_ADS; break;
- case "000": Minimum_CoF = CoF_Crouching_Moving_HIP; break;
- }
- //creating a new shot instance and giving it crosshair position and accumulated horizontal recoil
- if (ShotNumber == 0)
- {
- shot[0] = new Shot(0, 0, 0, this);
- CurrentCoF = Minimum_CoF;
- }
- else
- {
- pt = CalculateAngle(shot[ShotNumber - 1].X, shot[ShotNumber - 1].Y, shot[ShotNumber - 1].Recoil_Angle, shot[ShotNumber - 1].Vertical_Recoil);
- pt = CalculateAngle(pt.X, pt.Y, 90 + shot[ShotNumber - 1].Recoil_Angle, shot[ShotNumber - 1].Horizontal_Recoil);
- shot[ShotNumber] = new Shot(pt.X, pt.Y, shot[ShotNumber - 1].Accumulated_Horizontal_Recoil, this);
- }
- //checking CoF stance
- if (CurrentCoF < Minimum_CoF) CurrentCoF = Minimum_CoF;
- shot[ShotNumber].CoF = CurrentCoF;
- //storing pellet spread for this shot
- if (ADSing) shot[ShotNumber].Pellet_Spread = Pellet_Spread_ADS;
- else shot[ShotNumber].Pellet_Spread = Pellet_Spread_HIP;
- //assign bullet positions
- shot[ShotNumber].pellet_spread_coords = Random_Bullet_Position(rand, pt.X, pt.Y, CurrentCoF);
- for (int i = 0; i < Pellets; i++)
- shot[ShotNumber].bullets[i] = Random_Bullet_Position(rand, shot[ShotNumber].pellet_spread_coords.X, shot[ShotNumber].pellet_spread_coords.Y, shot[ShotNumber].Pellet_Spread);
- //assign vertical recoil
- if (ShotNumber == 0) shot[0].Vertical_Recoil = -Vertical_Recoil * First_Shot_Recoil_Multiplier * Convert.ToInt32(!Ignore_Vertical_Recoil);
- else shot[ShotNumber].Vertical_Recoil = -Vertical_Recoil * Convert.ToInt32(!Ignore_Vertical_Recoil);
- //assign recoil angle
- shot[ShotNumber].Recoil_Angle = Recoil_Angle_Minimum + rand.NextDouble() * (Recoil_Angle_Maximum - Recoil_Angle_Minimum);
- //assign horizontal recoil
- if (Left_or_Right > 0.5) shot[ShotNumber].Horizontal_Recoil = (Horizontal_Recoil_Minimum + rand.NextDouble() * (Horizontal_Recoil_Maximum - Horizontal_Recoil_Minimum));
- else shot[ShotNumber].Horizontal_Recoil = -1 * (Horizontal_Recoil_Minimum + rand.NextDouble() * (Horizontal_Recoil_Maximum - Horizontal_Recoil_Minimum));
- //force horizontal recoil to be in tolerance
- if (ShotNumber > 0 && Math.Abs(shot[ShotNumber - 1].Accumulated_Horizontal_Recoil) > (Horizontal_Recoil_Tolerance / 2))
- {
- if (shot[ShotNumber - 1].Accumulated_Horizontal_Recoil > 0) shot[ShotNumber].Horizontal_Recoil = -1 * Math.Abs(shot[ShotNumber].Horizontal_Recoil);
- else shot[ShotNumber].Horizontal_Recoil = Math.Abs(shot[ShotNumber].Horizontal_Recoil);
- }
- shot[ShotNumber].Accumulated_Horizontal_Recoil += shot[ShotNumber].Horizontal_Recoil;
- ShotNumber++;
- //Assign CoF. Add stance checking here
- if (ADSing) CurrentCoF += CoF_Bloom_ADS;
- else CurrentCoF += CoF_Bloom_Hip;
- if (ADSing && CurrentCoF > 3) CurrentCoF = 3;
- else if (CurrentCoF > 7) CurrentCoF = 7;
- }
- PointF CalculateAngle(Double X, Double Y, Double Angle, Double Length)
- {
- Double angle1 = (90 + Angle) * Math.PI / 180;
- PointF pt = new PointF((float)(X + Math.Cos(angle1) * Length), (float)(Y + Math.Sin(angle1) * Length));
- return pt;
- }
- PointF Random_Bullet_Position(Random rand, float X, float Y, Double CoF)
- {
- var angle = rand.NextDouble() * Math.PI * 2;
- var radius = Math.Sqrt(rand.NextDouble()) * (CoF / 2);
- var x = X + radius * Math.Cos(angle);
- var y = Y + radius * Math.Sin(angle);
- return new PointF((float)x, (float)y);
- }
- }
- class MainWindow : Form
- {
- System.Timers.Timer timer;
- public float Vertical_Pixels;
- CheckBox chk_ShowCoF, chk_ShowTolerance, chk_ShowRecoilPattern, chk_ShowGrid, chk_ShowConnectors, chk_AngledGrid,
- btn_Record, chk_Ignore_Vertical_Recoil, chk_Draw_Crosshair_Positions, chk_Draw_Bullet_Hits, chk_Draw_Target;
- //attachment checkboxes
- CheckBox chk_SPA, chk_HVA, chk_Slugs, chk_SmartChoke, chk_FG, chk_AFG, chk_ExMags, chk_Compensator, chk_Suppressor, chk_LS, chk_ALS;
- RadioButton Optic_1x, Optic_2x, Optic_3_4x, Optic_4x, Optic_6x, Optic_7x, Optic_8x, Optic_10x, Optic_12x;
- RadioButton rb_Crouching, rb_Standing, rb_Moving, rb_Still, rb_ADSing, rb_HipFiring;
- RadioButton mode_Graphs, mode_Simulation;
- GroupBox group_Still_Moving, group_ADSing, group_Stand_Crouch, group_thresholds, group_target;
- Label ConfigPanel_Label3, ConfigPanel_Label7, ConfigPanel_Label10, ConfigPanel_Label11;
- Button btn_show_help, btn_headshot, btn_bodyshot, btn_legshot, btn_Fire_Burst, btn_Reset;
- //calculations GroupBox calculations;
- ListBox lb; //choose weapon
- TextBox tb, burst_stats, tb_thresholds, tb_target_health, tb_damage_multiplier, tb_bonus_headshots, tb_target, tb_pause; //weapon stats
- TextBox tb_Burst_Length;
- public int ConfigX, ConfigY;
- public int distance = 5;
- public float time_elapsed = 0;
- public int assign_damage = 0, target_health = 1000, headshots = 0, legshots = 0, bodyshots = 0;
- string Database_Date;
- int Zoom = 1;
- Random rand;
- Pen pen, pen_red, pen_blue;
- Brush brush, brush_black, brush_red;
- Image img, img2;
- bool Recording = false, show_help = false;
- int MX, MY; //MX, MY - how far you dragged with middle mouse.
- int number_of_weapons;
- Weapon[] weapons;
- Weapon[] weapons_comparison;
- int number_of_weapons_in_comparison = 1;
- Weapon weapon_orig; //weapon stats with attachments and without any
- public Double ADS_Magnification = 1.35;
- // Double FPS = 8.3333333333333333333333333333333
- public MainWindow()
- {
- Text = "PlanetSide 2 Weapon Simulator"; // WINDOW CONFIGURATION
- Rectangle resolution = Screen.PrimaryScreen.Bounds; //getting screen resolution and setting window to match
- Height = resolution.Height - 65;
- Width = resolution.Width - 20;
- AutoScroll = true;
- Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE"); //avoid issues with decimal symbol in system locale
- Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE");
- this.WindowState = FormWindowState.Maximized; //window starts maximimzed just to be sure
- this.DoubleBuffered = true;
- ConfigX = Width - 450;
- ConfigY = 10;
- KeyPreview = true;
- rb_ADSing = new RadioButton();
- rb_ADSing.Location = new Point(10, 12);
- rb_ADSing.Size = new Size(80, 30);
- rb_ADSing.Text = "Aiming Down Sights";
- rb_ADSing.CheckedChanged += Rb_ADSing_CheckedChanged;
- rb_ADSing.CheckedChanged += CheckAttachments;
- weapons = new Weapon[1000];
- weapons_comparison = new Weapon[10];
- rand = new Random();
- pen = new Pen(Color.Black);
- pen_red = new Pen(Color.Red);
- brush = new SolidBrush(Color.Orange);
- brush_black = new SolidBrush(Color.Black);
- pen_blue = new Pen(Color.Blue);
- brush_red = new SolidBrush(Color.Red);
- this.MouseDown += new System.Windows.Forms.MouseEventHandler(MainWindow_MouseDown); //register mouse controls
- this.MouseUp += new System.Windows.Forms.MouseEventHandler(MainWindow_MouseUp);
- this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);
- timer = new System.Timers.Timer();
- timer.Elapsed += Fire;
- ParseFile();
- ConfigurationPanel();
- LoadDefaults();
- if (File.Exists("target.jpg")) img = Image.FromFile("target.jpg");
- else { chk_Draw_Target.Enabled = false; MessageBox.Show("Target.jpg not found. Draw Target mode disabled.", "Error"); }
- if (File.Exists("help.jpg")) img2 = Image.FromFile("help.jpg");
- else
- {
- btn_show_help.Enabled = false;
- MessageBox.Show("Help.jpg not found. \"Legend\" button disabled.", "Error");
- }
- chk_FG.Checked = true;
- chk_FG.Checked = false;
- Show();
- Reset();
- }
- private void Rb_ADSing_CheckedChanged(object sender, EventArgs e)
- {
- CalculatePixels();
- UpdateBurstStats();
- }
- void Fire(object sender, EventArgs e)
- {
- FireWeapons();
- }
- void FireWeapons()
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++) weapons_comparison[i].Fire(rand, rand.NextDouble(), rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked, chk_Ignore_Vertical_Recoil.Checked);
- if(weapons_comparison[0].ShotNumber > 1) time_elapsed += (float)weapons_comparison[0].Refire_Time / 1000;
- Invalidate();
- }
- /* DRAWING DRAWING DRAWING DRAWING DRAWING DRAWING DRAWING DRAWING DRAWING */
- protected override void OnPaint(PaintEventArgs e) //ф-я рисования
- {
- base.OnPaint(e);
- if (mode_Graphs.Checked) DrawGraphs(e);
- if (mode_Simulation.Checked)
- {
- e.Graphics.FillRectangle(Brushes.White, 0, 0, ConfigX - 228, Height); //white background
- if (!chk_Draw_Target.Checked) e.Graphics.FillRectangle(Brushes.White, 0, 715, ConfigX - 10, Height);
- for (int i = 0; i < number_of_weapons_in_comparison; i++) DrawForWeapon(e, weapons_comparison[i]);
- UpdateBurstStats();
- if (show_help) e.Graphics.DrawImage(img2, ConfigX - 536, ConfigY + 565);
- }
- }
- void DrawForWeapon(PaintEventArgs e, Weapon weapon)
- {
- if (chk_Draw_Target.Checked)
- {
- e.Graphics.DrawImage(img, weapon.Starting_X + weapon.Target_X - weapon.Target_W / 2, weapon.Starting_Y + weapon.Target_Y - weapon.Target_H / 4, weapon.Target_W, weapon.Target_H);
- e.Graphics.FillEllipse(Brushes.Blue, weapon.Starting_X + weapon.Target_X - 5, weapon.Starting_Y + weapon.Target_Y + weapon.Target_H / 1.4F - 10, 10, 10);
- }
- if (chk_ShowGrid.Checked) DrawGrid(e, weapon);
- if (chk_ShowCoF.Checked) DrawCoF(e, weapon);
- if (chk_ShowConnectors.Checked) DrawConnectors(e, weapon);
- if (chk_ShowRecoilPattern.Checked) DrawPattern(e, weapon);
- if (chk_ShowTolerance.Checked) DrawTolerance(e, weapon);
- if (chk_Draw_Crosshair_Positions.Checked) DrawShots(e, weapon);
- if (chk_Draw_Bullet_Hits.Checked) DrawBullets(e, weapon);
- e.Graphics.DrawString(weapon.Weapon_Name, DefaultFont, Brushes.Black, weapon.Starting_X, weapon.Starting_Y + 18);
- e.Graphics.DrawString(weapon.Attachments, DefaultFont, Brushes.Black, weapon.Starting_X, weapon.Starting_Y + 34);
- if (weapon.GetStats != null) weapon.GetStats.Location = new Point((int)weapon.Starting_X - 65, (int)weapon.Starting_Y + 10);
- }
- void DrawTolerance(PaintEventArgs e, Weapon weapon)
- {
- int i;
- PointF pt1, pt2;
- pen.Width = 2; //drawing center black line
- DrawAngledLine(e, pen, weapon.Starting_X, weapon.Starting_Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2, -(weapon.ShotNumber + 1) * weapon_orig.Vertical_Recoil * Vertical_Pixels - Vertical_Pixels);
- pen.Color = Color.Cyan;
- for (i = 0; i < weapon.ShotNumber; i++)
- {
- // one side
- pt1 = CalculateAngle(weapon.shot[i].X, weapon.shot[i].Y, 90 + weapon.shot[i].Recoil_Angle, weapon.Horizontal_Recoil_Tolerance / 2 - weapon.shot[i].Accumulated_Horizontal_Recoil + weapon.shot[i].Horizontal_Recoil);
- pt2 = CalculateAngle(pt1.X, pt1.Y, weapon.shot[i].Recoil_Angle, weapon.shot[i].Vertical_Recoil - 1);
- e.Graphics.DrawLine(pen, weapon.Starting_X + pt1.X * Vertical_Pixels, weapon.Starting_Y + pt1.Y * Vertical_Pixels, weapon.Starting_X + pt2.X * Vertical_Pixels, weapon.Starting_Y + pt2.Y * Vertical_Pixels);
- //other side
- pt1 = CalculateAngle(weapon.shot[i].X, weapon.shot[i].Y, 90 + weapon.shot[i].Recoil_Angle, -weapon.Horizontal_Recoil_Tolerance / 2 - weapon.shot[i].Accumulated_Horizontal_Recoil + weapon.shot[i].Horizontal_Recoil);
- pt2 = CalculateAngle(pt1.X, pt1.Y, weapon.shot[i].Recoil_Angle, weapon.shot[i].Vertical_Recoil - 1);
- e.Graphics.DrawLine(pen, weapon.Starting_X + pt1.X * Vertical_Pixels, weapon.Starting_Y + pt1.Y * Vertical_Pixels, weapon.Starting_X + pt2.X * Vertical_Pixels, weapon.Starting_Y + pt2.Y * Vertical_Pixels);
- }
- pen.Color = Color.Black;
- pen.Width = 1;
- }
- void DrawShots(PaintEventArgs e, Weapon weapon)
- {
- int i;
- for (i = 0; i < weapon.ShotNumber; i++) e.Graphics.FillRectangle(brush, weapon.Starting_X + (float)weapon.shot[i].X * Vertical_Pixels - 3, weapon.Starting_Y + (float)weapon.shot[i].Y * Vertical_Pixels - 3, 7, 7);
- }
- void DrawBullets(PaintEventArgs e, Weapon weapon)
- {
- int i, j;
- Brush b = new SolidBrush(Color.Red);
- for (i = 0; i < weapon.ShotNumber; i++)
- if(weapon.shot[i].Pellet_Spread != 0)
- for (j = 0; j < weapon.Pellets; j++) e.Graphics.FillEllipse(b, weapon.Starting_X + weapon.shot[i].bullets[j].X * Vertical_Pixels - 3, weapon.Starting_Y + weapon.shot[i].bullets[j].Y * Vertical_Pixels - 3, 7, 7);
- else e.Graphics.FillEllipse(b, weapon.Starting_X + weapon.shot[i].bullets[0].X * Vertical_Pixels - 3, weapon.Starting_Y + weapon.shot[i].bullets[0].Y * Vertical_Pixels - 3, 7, 7);
- }
- void DrawGrid(PaintEventArgs e, Weapon weapon)
- {
- int i, j;
- e.Graphics.FillEllipse(Brushes.Blue, weapon.Starting_X - 5, weapon.Starting_Y - 5, 10, 10);
- if (!chk_AngledGrid.Checked)
- {
- for (j = 1; j < System.Convert.ToInt32(weapon_orig.Vertical_Recoil * weapon.ShotNumber) + 2; j++)
- {
- for (i = 0; i < 4; i++) e.Graphics.DrawRectangle(pen_blue, weapon.Starting_X + Vertical_Pixels * i, weapon.Starting_Y - Vertical_Pixels * j, Vertical_Pixels, Vertical_Pixels);
- for (i = 1; i < 5; i++) e.Graphics.DrawRectangle(pen_blue, weapon.Starting_X - Vertical_Pixels * i, weapon.Starting_Y - Vertical_Pixels * j, Vertical_Pixels, Vertical_Pixels);
- }
- }
- else
- {
- PointF pt = new PointF(weapon.Starting_X, weapon.Starting_Y);
- PointF pt_center = new PointF(weapon.Starting_X, weapon.Starting_Y);
- for (i = 0; i < weapon_orig.Vertical_Recoil * weapon.ShotNumber + 2; i++)
- {
- pt = pt_center;
- for (j = 0; j < 2; j++)
- {
- pt = DrawAngledLine(e, pen_blue, pt.X, pt.Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2 + 90, Vertical_Pixels);
- DrawAngledLine(e, pen_blue, pt.X, pt.Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2 + 180, Vertical_Pixels);
- }
- pt = pt_center;
- for (j = 1; j < 3; j++)
- {
- pt = DrawAngledLine(e, pen_blue, pt.X, pt.Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2 + 90, -Vertical_Pixels);
- DrawAngledLine(e, pen_blue, pt.X, pt.Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2 + 180, Vertical_Pixels);
- }
- pt = pt_center;
- pt_center = DrawAngledLine(e, pen_blue, pt.X, pt.Y, (weapon.Recoil_Angle_Maximum + weapon.Recoil_Angle_Minimum) / 2 + 180, Vertical_Pixels);
- }
- // e.Graphics.DrawString("1 notch = 1 degree", DefaultFont, brush_black, pt_center.X, pt_center.Y - Vertical_Pixels);
- }
- }
- void DrawConnectors(PaintEventArgs e, Weapon weapon)
- {
- int i;
- pen.Color = Color.Green;
- pen.Width = 3;
- for (i = 0; i + 1 < weapon.ShotNumber; i++)
- {
- e.Graphics.DrawLine(pen, (float)(weapon.Starting_X + weapon.shot[i].X * Vertical_Pixels), (float)(weapon.Starting_Y + weapon.shot[i].Y * Vertical_Pixels), (float)(weapon.Starting_X + weapon.shot[i + 1].X * Vertical_Pixels), (float)(weapon.Starting_Y + weapon.shot[i + 1].Y * Vertical_Pixels));
- }
- pen.Color = Color.Black;
- pen.Width = 1;
- }
- void DrawPattern(PaintEventArgs e, Weapon weapon)
- {
- PointF pt1, pt2;
- int i;
- for (i = 0; i < weapon.ShotNumber; i++)
- {
- pt1 = CalculateAngle(weapon.shot[i].X, weapon.shot[i].Y, weapon.shot[i].Recoil_Angle, weapon.shot[i].Vertical_Recoil);
- pt2 = CalculateAngle(pt1.X, pt1.Y, 90 + weapon.shot[i].Recoil_Angle, weapon.shot[i].Horizontal_Recoil);
- e.Graphics.DrawLine(pen, (float)(weapon.Starting_X + weapon.shot[i].X * Vertical_Pixels), (float)(weapon.Starting_Y + weapon.shot[i].Y * Vertical_Pixels), weapon.Starting_X + pt1.X * Vertical_Pixels, weapon.Starting_Y + pt1.Y * Vertical_Pixels);
- e.Graphics.DrawLine(pen_red, weapon.Starting_X + pt1.X * Vertical_Pixels, weapon.Starting_Y + pt1.Y * Vertical_Pixels, weapon.Starting_X + pt2.X * Vertical_Pixels, weapon.Starting_Y + pt2.Y * Vertical_Pixels);
- }
- }
- void DrawCoF(PaintEventArgs e, Weapon weapon)
- {
- int i;
- float size;
- for (i = 0; i < weapon.ShotNumber; i++)
- {
- size = (float)weapon.shot[i].CoF * Vertical_Pixels;
- e.Graphics.DrawEllipse(pen, (float)(weapon.Starting_X + weapon.shot[i].X * Vertical_Pixels) - size / 2, (float)(weapon.Starting_Y + weapon.shot[i].Y * Vertical_Pixels) - size / 2, size, size);
- if (weapon.Pellet_Spread_ADS > 0 && rb_ADSing.Checked || weapon.Pellet_Spread_HIP > 0 && !rb_ADSing.Checked)
- //if (!weapon.Attachments.Contains("Slug Ammunition"))
- {
- pen.Color = Color.LightGreen;
- size = (float)weapon.shot[i].Pellet_Spread * Vertical_Pixels;
- //draw pellet spread
- e.Graphics.DrawEllipse(pen, (float)(weapon.Starting_X + weapon.shot[i].pellet_spread_coords.X * Vertical_Pixels) - size / 2, (float)(weapon.Starting_Y + weapon.shot[i].pellet_spread_coords.Y * Vertical_Pixels) - size / 2, size, size);
- //draw center of the pellet spread
- e.Graphics.FillEllipse(new SolidBrush(Color.LightGreen), (float)(weapon.Starting_X + weapon.shot[i].pellet_spread_coords.X * Vertical_Pixels) - 3, (float)(weapon.Starting_Y + weapon.shot[i].pellet_spread_coords.Y * Vertical_Pixels) - 3, 7, 7);
- pen.Color = Color.Black;
- }
- }
- }
- void DrawGraphs(PaintEventArgs e)
- {
- int x = 100, y = 50;
- int z;
- int workspace_w = ConfigX - 278 - x;
- int workspace_h = Height - 100;
- Font font = new Font(DefaultFont.FontFamily, 14);
- int longest_minimum_damage_range = 0;
- int lowest_damage = 100000;
- int highest_damage = 0;
- // int[][] arr;
- Pen[] pens = new Pen[10];
- pens[0] = new Pen(Color.FromArgb(64, 166, 255));
- pens[1] = new Pen(Color.FromArgb(153, 38, 38));
- pens[2] = new Pen(Color.FromArgb(32, 128, 32));
- pens[3] = new Pen(Color.FromArgb(102, 50, 181));
- pens[4] = new Pen(Color.FromArgb(0, 242, 226));
- pens[5] = new Pen(Color.FromArgb(242, 129, 0));
- pens[6] = new Pen(Color.FromArgb(255, 0, 136));
- pens[7] = new Pen(Color.FromArgb(179, 164, 134));
- pens[8] = new Pen(Color.FromArgb(217, 163, 199));
- pens[9] = new Pen(Color.FromArgb(242, 255, 64));
- for (int i = 0; i < 10; i++) pens[i].Width = 4;
- PointF[] pt = new PointF[4];
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (longest_minimum_damage_range < weapons_comparison[i].Minimum_Damage_Range)
- longest_minimum_damage_range = weapons_comparison[i].Minimum_Damage_Range;
- if (lowest_damage > weapons_comparison[i].Minimum_Damage) lowest_damage = weapons_comparison[i].Minimum_Damage;
- if (highest_damage < weapons_comparison[i].Maximum_Damage) highest_damage = weapons_comparison[i].Maximum_Damage;
- }
- float pixel_x = (float)workspace_w / (longest_minimum_damage_range + 10);
- float pixel_y = (float)(workspace_h - y) / highest_damage;
- e.Graphics.FillRectangle(Brushes.White, 0, 0, ConfigX - 10, Height); //white background
- e.Graphics.FillRectangle(Brushes.Beige, x, y - 30, workspace_w, workspace_h - y + 30);
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- pt[0] = new Point(0, -weapons_comparison[i].Maximum_Damage);
- pt[1] = new Point(weapons_comparison[i].Maximum_Damage_Range, -weapons_comparison[i].Maximum_Damage);
- pt[2] = new Point(weapons_comparison[i].Minimum_Damage_Range, -weapons_comparison[i].Minimum_Damage);
- pt[3] = new Point(longest_minimum_damage_range + 10, -weapons_comparison[i].Minimum_Damage);
- for (int j = 0; j < 4; j++) { pt[j].X *= pixel_x; pt[j].X += x; pt[j].Y *= pixel_y; pt[j].Y += workspace_h; }
- e.Graphics.DrawLine(pens[i], pt[0], pt[1]);
- e.Graphics.DrawString(Convert.ToString(weapons_comparison[i].Maximum_Damage), font, brush_black, pt[0].X - 45, pt[0].Y - 12);
- e.Graphics.DrawLine(pens[i], pt[1], pt[2]);
- e.Graphics.DrawLine(pens[i], pt[2], pt[3]);
- e.Graphics.DrawString(Convert.ToString(weapons_comparison[i].Minimum_Damage), font, brush_black, pt[3].X + 10, pt[3].Y - 12);
- z = 0; //drawing vertical grid lines
- while (z * 5 <= longest_minimum_damage_range + 10)
- {
- /* if(z%2 == 1 && longest_minimum_damage_range > 200) e.Graphics.DrawLine(pen_red, x + z * pixel_x * 5, workspace_h, x + z * pixel_x * 5, y);
- else*/
- if (chk_ShowGrid.Checked || z < 1) e.Graphics.DrawLine(pen_blue, x + z * pixel_x * 5, workspace_h, x + z * pixel_x * 5, y - 30);
- // e.Graphics.DrawString(z * 5+"m", DefaultFont, brush_black, x + z * pixel_x * 5, workspace_h + 10 + 15 * (z % 2)* Convert.ToInt32(longest_minimum_damage_range > 200));
- e.Graphics.DrawString(z * 5 + "m", DefaultFont, brush_black, x + z * pixel_x * 5 - 5, workspace_h + 10);
- z++;
- if (longest_minimum_damage_range > 200) z++;
- }
- z = 0; //drawing horizontal grid lines
- while (z * 10 * pixel_y < workspace_h - 30)
- {
- e.Graphics.DrawLine(pen_blue, x, workspace_h - z * 10 * pixel_y, x + workspace_w, workspace_h - z * 10 * pixel_y);
- if (!chk_ShowGrid.Checked) break;
- z++;
- if (highest_damage > 200) z++;
- if (highest_damage > 400) z++;
- if (highest_damage > 600) z++;
- }
- //draw BTK thresholds
- /*
- arr = Calculate_tb_thresholds(weapons_comparison[i], (float)Convert.ToDouble(tb_target_health.Text), (float)Convert.ToDouble(tb_damage_multiplier.Text), Convert.ToInt32(tb_bonus_headshots.Text));
- for (int j = 0; j < arr.Length; j++)
- {
- e.Graphics.DrawLine(pens[j], arr[j][1] * pixel_x + x, workspace_h - arr[j][3] * pixel_y, arr[j][2] * pixel_x + x, workspace_h - arr[j][4] * pixel_y);
- // e.Graphics.DrawRectangle(pens[i], arr[j][1] * pixel_x + x - 3, workspace_h - arr[j][3] * pixel_y - 3, 7, 7);
- // e.Graphics.DrawRectangle(pens[i], arr[j][2] * pixel_x + x - 3, workspace_h - arr[j][4] * pixel_y - 3, 7, 7);
- }*/
- //drawing weapon nanems and moving "get stats" buttons
- e.Graphics.DrawString(weapons_comparison[i].Weapon_Name, font, new SolidBrush(pens[i].Color), ConfigX - 228, ConfigY + i * 110);
- if (i > 0) weapons_comparison[i].GetStats.Location = new Point(ConfigX - 225, ConfigY + 30 + i * 110);
- e.Graphics.DrawString(weapons_comparison[i].Attachments, DefaultFont, Brushes.Black, ConfigX - 155, ConfigY + 30 + i * 110);
- if (MX >= x && MX <= workspace_w + x && MY >= y - 30 && MY <= workspace_h) //Drawing mouse lines over graph
- {
- e.Graphics.DrawLine(pen_red, MX, y - 30, MX, workspace_h);
- e.Graphics.DrawLine(pen_red, x, MY, workspace_w + x, MY);
- e.Graphics.DrawString(Convert.ToInt32((MX - x) / pixel_x) + "m", font, brush_red, MX, workspace_h + 30);
- e.Graphics.DrawString(Convert.ToString(Convert.ToInt32((workspace_h - MY) / pixel_y)), font, brush_red, x - 90, MY - 12);
- }
- }
- /* for (int i = 0; i < longest_minimum_damage_range; i += 10) for (int j = y; j > 0; j -= 10)
- {
- e.Graphics.DrawLine(pen_blue, x + i, y - j, x + i + 10, y - j);
- // e.Graphics.DrawLine(pen_blue, x + i, y - j, x + i + 10, y - j);
- }*/
- }
- PointF Random_Bullet_Position(float X, float Y, Double CoF)
- {
- var angle = rand.NextDouble() * Math.PI * 2;
- var radius = Math.Sqrt(rand.NextDouble()) * (CoF / 2);
- var x = X + radius * Math.Cos(angle);
- var y = Y + radius * Math.Sin(angle);
- return new PointF((float)x, (float)y);
- }
- PointF DrawAngledLine(PaintEventArgs e, Double X, Double Y, Double Angle, Double Length)
- {
- PointF pt = CalculateAngle(X, Y, Angle, Length);
- e.Graphics.DrawLine(pen, (float)X, (float)Y, pt.X, pt.Y);
- return pt;
- }
- PointF DrawAngledLine(PaintEventArgs e, Pen pen, Double X, Double Y, Double Angle, Double Length)
- {
- PointF pt = CalculateAngle(X, Y, Angle, Length);
- e.Graphics.DrawLine(pen, (float)X, (float)Y, pt.X, pt.Y);
- return pt;
- }
- PointF CalculateAngle(Double X, Double Y, Double Angle, Double Length)
- {
- Double angle1 = (90 + Angle) * Math.PI / 180;
- PointF pt = new PointF((float)(X + Math.Cos(angle1) * Length), (float)(Y + Math.Sin(angle1) * Length));
- return pt;
- }
- void MainWindow_MouseDown(object sender, MouseEventArgs arg)
- {
- chk_AngledGrid.Focus();
- if (arg.Button == MouseButtons.Left)
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (arg.X > weapons_comparison[i].Starting_X - 10 && arg.X < weapons_comparison[i].Starting_X + 10 && arg.Y > weapons_comparison[i].Starting_Y - 10 && arg.Y < weapons_comparison[i].Starting_Y + 10)
- { Cursor.Current = Cursors.Hand; weapons_comparison[i].dragging = true; return; }
- if (arg.X > weapons_comparison[i].Starting_X + weapons_comparison[i].Target_X - 5 && arg.X < weapons_comparison[i].Starting_X + weapons_comparison[i].Target_X + weapons_comparison[i].Target_W / 2 + 10 && arg.Y > weapons_comparison[i].Starting_Y + weapons_comparison[i].Target_Y + weapons_comparison[i].Target_H / 1.4F - 10 && arg.Y < weapons_comparison[i].Starting_Y + weapons_comparison[i].Target_Y + weapons_comparison[i].Target_H / 1.4F)
- { Cursor.Current = Cursors.Hand; weapons_comparison[i].TargetDragging = true; return; }
- }
- FireWeapons();
- timer.Start();
- }
- if (arg.Button == MouseButtons.Middle)
- {
- Cursor.Current = Cursors.Hand;
- MX = arg.X;
- MY = arg.Y;
- }
- Invalidate();
- // if (arg.Button == MouseButtons.Right) { }
- }
- protected override void OnMouseMove(MouseEventArgs arg)
- {
- base.OnMouseMove(arg);
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (arg.X > weapons_comparison[i].Starting_X - 10 && arg.X < weapons_comparison[i].Starting_X + 10 && arg.Y > weapons_comparison[i].Starting_Y - 10 && arg.Y < weapons_comparison[i].Starting_Y + 10)
- Cursor.Current = Cursors.Hand;
- if (arg.X > weapons_comparison[i].Starting_X + weapons_comparison[i].Target_X - 5 && arg.X < weapons_comparison[i].Starting_X + weapons_comparison[i].Target_X + weapons_comparison[i].Target_W / 2 + 10 && arg.Y > weapons_comparison[i].Starting_Y + weapons_comparison[i].Target_Y + weapons_comparison[i].Target_H / 1.4F - 10 && arg.Y < weapons_comparison[i].Starting_Y + weapons_comparison[i].Target_Y + weapons_comparison[i].Target_H / 1.4F)
- Cursor.Current = Cursors.Hand;
- }
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (weapons_comparison[i].dragging)
- { weapons_comparison[i].Starting_X = arg.X; weapons_comparison[i].Starting_Y = arg.Y; Invalidate(); }
- if (weapons_comparison[i].TargetDragging)
- {
- weapons_comparison[i].Target_X = arg.X - weapons_comparison[i].Starting_X;
- weapons_comparison[i].Target_Y = arg.Y - weapons_comparison[i].Starting_Y + 5 - weapons_comparison[i].Target_H / 1.4F;
- Invalidate();
- }
- }
- if (mode_Graphs.Checked)
- {
- MX = arg.X;
- MY = arg.Y;
- Invalidate();
- }
- }
- void MainWindow_MouseUp(object sender, MouseEventArgs arg)
- {
- if (arg.Button == MouseButtons.Left)
- {
- timer.Stop();
- for (int i = 0; i < number_of_weapons_in_comparison; i++) if (weapons_comparison[i].dragging || weapons_comparison[i].TargetDragging) { weapons_comparison[i].dragging = false; weapons_comparison[i].TargetDragging = false; Cursor.Current = Cursors.Default; }
- }
- if (arg.Button == MouseButtons.Middle)
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- weapons_comparison[i].Starting_X -= MX - arg.X;
- weapons_comparison[i].Starting_Y -= MY - arg.Y;
- }
- Invalidate();
- }
- if (arg.Button == MouseButtons.Right)
- {
- if (rb_ADSing.Checked) rb_HipFiring.Checked = true;
- else rb_ADSing.Checked = true;
- CalculatePixels();
- }
- }
- private void MainWindow_KeyDown(object sender, KeyEventArgs e)
- {
- if (Recording)
- {
- if (e.KeyCode == Keys.A)
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- weapons_comparison[i].Fire(rand, 1, rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked, chk_Ignore_Vertical_Recoil.Checked);
- if (weapons_comparison[0].ShotNumber > 1) time_elapsed += (float)weapons_comparison[0].Refire_Time / 1000;
- Invalidate();
- }
- if (e.KeyCode == Keys.D)
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- weapons_comparison[i].Fire(rand, -1, rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked, chk_Ignore_Vertical_Recoil.Checked);
- if (weapons_comparison[0].ShotNumber > 1) time_elapsed += (float)weapons_comparison[0].Refire_Time / 1000;
- Invalidate();
- }
- }
- if (e.KeyCode == Keys.W && distance > 1)
- {
- distance--;
- CalculatePixels();
- Invalidate();
- }
- if (e.KeyCode == Keys.S)
- {
- distance++;
- CalculatePixels();
- Invalidate();
- }
- }
- private void DrawCalculations(PaintEventArgs e)
- {
- }
- int[][] Calculate_tb_thresholds(Weapon w, float health, float damage_multiplier, int headshots)
- {
- int[][] arr = new int[w.Minimum_Damage_Range][];
- float adjusted_health;
- int range = 0;
- int BTKn = 0;
- arr[BTKn] = new int[5];
- adjusted_health = (health - (float)(headshots * CalculateDamage(w, range) * (w.Headshot_Damage_Multiplier + 1))) / damage_multiplier;
- arr[BTKn][0] = Convert.ToInt32(Math.Ceiling(adjusted_health / CalculateDamage(w, range)));
- arr[BTKn][1] = 0;
- arr[BTKn][3] = Convert.ToInt32(CalculateDamage(w, range));
- for (range = 0; range < w.Minimum_Damage_Range; range++)
- {
- adjusted_health = (health - (float)(headshots * CalculateDamage(w, range) * (w.Headshot_Damage_Multiplier + 1))) / damage_multiplier;
- if (arr[BTKn][0] < Convert.ToInt32(Math.Ceiling(adjusted_health / CalculateDamage(w, range))))
- {
- arr[BTKn][2] = range - 1;
- arr[BTKn][4] = Convert.ToInt32(CalculateDamage(w, range));
- BTKn++;
- arr[BTKn] = new int[5];
- arr[BTKn][0] = Convert.ToInt32(Math.Ceiling(adjusted_health / CalculateDamage(w, range)));
- arr[BTKn][1] = range;
- arr[BTKn][3] = Convert.ToInt32(CalculateDamage(w, range));
- }
- }
- arr[BTKn][2] = range;
- return arr.Where(c => c != null).ToArray(); // removing empty members
- }
- protected override void OnMouseWheel(MouseEventArgs e)
- {
- //base.OnMouseWheel(e);
- btn_Record.Focus();
- Zoom += e.Delta / 120;
- if (Zoom < 1) Zoom = 1;
- CalculatePixels();
- }
- void btn_Reset_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Reset();
- }
- void btn_About_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- MessageBox.Show("Version 1.7.\n\nWeapon database from: " + Database_Date + "\n\nOpen \"ReadMe.txt\" in the program folder for instructions.", "PlanetSide 2 Weapon Simulator");
- }
- void btn_Fire_Burst_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- for (int i = 0; i < System.Convert.ToInt32(tb_Burst_Length.Text); i++) FireWeapons();
- Invalidate();
- }
- void btn_Record_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Recording = !Recording;
- Invalidate();
- }
- void btn_Save_Defaults_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- if (File.Exists("settings.ini")) File.Delete("settings.ini");
- TextWriter tw = new StreamWriter("settings.ini", true);
- tw.WriteLine("ShowCoF=" + chk_ShowCoF.Checked);
- tw.WriteLine("DrawBulletHits=" + chk_Draw_Bullet_Hits.Checked);
- tw.WriteLine("ShowTolerance=" + chk_ShowTolerance.Checked);
- tw.WriteLine("ShowRecoilPattern=" + chk_ShowRecoilPattern.Checked);
- tw.WriteLine("DrawTarget=" + chk_Draw_Target.Checked);
- tw.WriteLine("ShowConnectors=" + chk_ShowConnectors.Checked);
- tw.WriteLine("ShowGrid=" + chk_ShowGrid.Checked);
- tw.WriteLine("AngledGrid=" + chk_AngledGrid.Checked);
- tw.WriteLine("IgnoreVerticalRecoil=" + chk_Ignore_Vertical_Recoil.Checked);
- tw.WriteLine("DrawCrosshairPositions=" + chk_Draw_Crosshair_Positions.Checked);
- string mode = "Simulation";
- if (mode_Simulation.Checked) mode = "Simulation";
- if (mode_Graphs.Checked) mode = "Graphs";
- tw.WriteLine("Mode=" + mode);
- tw.Close();
- Invalidate();
- }
- void btn_Load_Defaults_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- LoadDefaults();
- }
- void btn_Add_Comparison_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- if (number_of_weapons_in_comparison < 9)
- {
- weapons_comparison[number_of_weapons_in_comparison++] = new Weapon(weapons_comparison[0]);
- weapons_comparison[number_of_weapons_in_comparison - 1].Starting_X = weapons_comparison[number_of_weapons_in_comparison - 2].Starting_X - Vertical_Pixels * 4;
- weapons_comparison[number_of_weapons_in_comparison - 1].Starting_Y = weapons_comparison[number_of_weapons_in_comparison - 2].Starting_Y;
- weapons_comparison[number_of_weapons_in_comparison - 1].Stats = tb.Text;
- weapons_comparison[number_of_weapons_in_comparison - 1].InitButton();
- Controls.Add(weapons_comparison[number_of_weapons_in_comparison - 1].GetStats);
- }
- CalculatePixels();
- }
- void btn_Reset_Comparison_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- for (int i = 1; i < number_of_weapons_in_comparison; i++) Controls.Remove(weapons_comparison[i].GetStats);
- number_of_weapons_in_comparison = 1;
- weapons_comparison[0].Starting_X = Width / 2;
- weapons_comparison[0].Starting_Y = Height / 2;
- Invalidate();
- }
- void LoadDefaults()
- {
- //setting factory defaults if settings file doesn't exist
- if (!File.Exists("settings.ini"))
- {
- TextWriter tw = new StreamWriter("settings.ini", true);
- tw.WriteLine("ShowCoF=False");
- tw.WriteLine("DrawBulletHits=False");
- tw.WriteLine("ShowTolerance=True");
- tw.WriteLine("ShowRecoilPattern=False");
- tw.WriteLine("DrawTarget=False");
- tw.WriteLine("ShowConnectors=True");
- tw.WriteLine("ShowGrid=True");
- tw.WriteLine("AngledGrid=True");
- tw.WriteLine("IgnoreVerticalRecoil=False");
- tw.WriteLine("DrawCrosshairPositions=True");
- tw.WriteLine("Mode=Simulation");
- tw.Close();
- MessageBox.Show("Factory default settings loaded.", "settings.ini recreated");
- }
- StreamReader reader = File.OpenText("settings.ini");
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- if (line.StartsWith("ShowCoF=")) chk_ShowCoF.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("DrawBulletHits=")) chk_Draw_Bullet_Hits.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("ShowTolerance=")) chk_ShowTolerance.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("ShowRecoilPattern=")) chk_ShowRecoilPattern.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("DrawTarget=")) chk_Draw_Target.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("ShowConnectors=")) chk_ShowConnectors.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("ShowGrid=")) chk_ShowGrid.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("AngledGrid=")) chk_AngledGrid.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("IgnoreVerticalRecoil=")) chk_Ignore_Vertical_Recoil.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("DrawCrosshairPositions=")) chk_Draw_Crosshair_Positions.Checked = System.Convert.ToBoolean(line.Substring(line.LastIndexOf('=') + 1));
- if (line.StartsWith("Mode="))
- {
- line = line.Substring(line.LastIndexOf('=') + 1);
- if (line == "Simulation") mode_Simulation.Checked = true;
- if (line == "Graphs") mode_Graphs.Checked = true;
- }
- }
- reader.Close();
- Invalidate();
- }
- void CalculatePixels()
- {
- /*if (ADSing == true) Vertical_Pixels = Zoom * GameResolution_Height / ((float)74 / (float)(ADS_Magnification * Zoom));
- else Vertical_Pixels = GameResolution_Height / ((float)74 / (float)Zoom);*/
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (weapons_comparison[i] != null)
- {
- // weapons_comparison[i].Target_X -= weapons_comparison[i].Starting_X; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Target_X /= Vertical_Pixels;
- // weapons_comparison[i].Target_Y -= weapons_comparison[i].Starting_Y; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Target_Y /= Vertical_Pixels;
- }
- }
- for (int i = 1; i < number_of_weapons_in_comparison; i++)
- {
- weapons_comparison[i].Starting_X -= weapons_comparison[0].Starting_X; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Starting_X /= Vertical_Pixels;
- weapons_comparison[i].Starting_Y -= weapons_comparison[0].Starting_Y; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Starting_Y /= Vertical_Pixels;
- }
- if (rb_ADSing.Checked) Vertical_Pixels = (float)(33.3 * Zoom * ADS_Magnification);
- else Vertical_Pixels = (float)33.3 * Zoom;
- for (int i = 1; i < number_of_weapons_in_comparison; i++)
- {
- weapons_comparison[i].Starting_X *= Vertical_Pixels; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Starting_X += weapons_comparison[0].Starting_X;
- weapons_comparison[i].Starting_Y *= Vertical_Pixels;
- weapons_comparison[i].Starting_Y += weapons_comparison[0].Starting_Y;
- }
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (weapons_comparison[i] != null)
- {
- weapons_comparison[i].Target_H = 32.02F * Vertical_Pixels / distance;
- weapons_comparison[i].Target_W = 12.48F * Vertical_Pixels / distance;
- weapons_comparison[i].Target_X *= Vertical_Pixels;
- //weapons_comparison[i].Target_X += weapons_comparison[i].Starting_X; //вычисляем расстояние между паттернами в градусах
- weapons_comparison[i].Target_Y *= Vertical_Pixels;
- // weapons_comparison[i].Target_Y += weapons_comparison[i].Starting_Y; //вычисляем расстояние между паттернами в градусах
- }
- }
- Invalidate();
- }
- void Reset()
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++) weapons_comparison[i].Init();
- CalculatePixels();
- time_elapsed = 0;
- //RESET DAMAGE IN TTK SIMULATION
- headshots = 0; bodyshots = 0; legshots = 0;
- assign_damage = 0;
- target_health = Convert.ToInt32(tb_target_health.Text);
- Invalidate();
- }
- void chk_ShowCoF_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_ShowTolerance_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_ShowRecoilPattern_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_ShowGrid_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- if (chk_ShowGrid.Checked && !mode_Graphs.Checked) chk_AngledGrid.Enabled = true;
- else chk_AngledGrid.Enabled = false;
- Invalidate();
- }
- void chk_ShowConnectors_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_AngledGrid_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_Draw_Crosshair_Positions_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_Draw_Bullet_Hits_Click(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- Invalidate();
- }
- void chk_Draw_Target_CheckedChanged(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- for (int i = 0; i < number_of_weapons_in_comparison; i++)
- {
- if (weapons_comparison[i] != null)
- {
- weapons_comparison[i].Target_X = 0;
- weapons_comparison[i].Target_Y = 0;
- }
- }
- if(chk_Draw_Target.Checked && chk_Draw_Target.Enabled)
- {
- ConfigPanel_Label11.Show();
- group_target.Show();
- assign_damage = 0;
- }
- else
- {
- ConfigPanel_Label11.Hide();
- group_target.Hide();
- }
- Invalidate();
- }
- void ConfigurationPanel()
- {
- /*
- calculations = new GroupBox();
- calculations.Location = new Point(10, 10);
- calculations.Size = new Size(ConfigX - 20, Height - 15);
- Controls.Add(calculations);
- calculations.Hide();
- //TextBox Base_Health, Damage_Multiplier, Effective_Health, Range, BTK_tb_thresholds;
- //RadioButton SetHealth_Infantry, SetHealth_Infiltrator, SetHealth_MAX;
- // RadioButton SetResistance_Nano1, SetResistance_Nano2, SetResistance_Nano3, SetResistance_Nano4, SetResistance_Nano5;
- GroupBox target = new GroupBox();
- target.Size = new Size(300, 300);
- target.Location = new Point(10, 10);
- TextBox Base_Health = new TextBox();
- Base_Health.Location = new Point(10, 40);
- Base_Health.Text = "1000";
- Base_Health.Size = new Size(40, 10);
- target.Controls.Add(Base_Health);
- AddLabel(10, 20, 100, 20, "Base Health", DefaultFont, target);
- calculations.Controls.Add(target);*/
- // ================ END OF CALCULATIONS ============================
- btn_Reset = new Button();
- btn_Reset.Location = new Point(ConfigX + 5, ConfigY + 275);
- btn_Reset.Size = new Size(110, 30);
- btn_Reset.Text = "Reset Burst";
- btn_Reset.Click += new System.EventHandler(btn_Reset_Click);
- Controls.Add(btn_Reset);
- btn_Record = new CheckBox();
- btn_Record.Location = new Point(ConfigX + 125, ConfigY + 275);
- btn_Record.Size = new Size(110, 30);
- btn_Record.Text = "Record Pattern";
- btn_Record.Appearance = Appearance.Button;
- btn_Record.Checked = false;
- btn_Record.TextAlign = ContentAlignment.MiddleCenter;
- btn_Record.Click += new System.EventHandler(btn_Record_Click);
- Controls.Add(btn_Record);
- btn_Fire_Burst = new Button();
- btn_Fire_Burst.Location = new Point(ConfigX + 5, ConfigY + 310);
- btn_Fire_Burst.Size = new Size(110, 30);
- btn_Fire_Burst.Text = "Fire Fixed Burst";
- btn_Fire_Burst.Click += new System.EventHandler(btn_Fire_Burst_Click);
- Controls.Add(btn_Fire_Burst);
- Button btn_About = new Button();
- btn_About.Location = new Point(ConfigX + 5, ConfigY + 415);
- btn_About.Size = new Size(230, 30);
- btn_About.Text = "Help / About";
- btn_About.Click += new System.EventHandler(btn_About_Click);
- Controls.Add(btn_About);
- Button btn_Save_Defaults = new Button();
- btn_Save_Defaults.Location = new Point(ConfigX + 5, ConfigY + 380);
- btn_Save_Defaults.Size = new Size(110, 30);
- btn_Save_Defaults.Text = "Save Configuration";
- btn_Save_Defaults.Click += new System.EventHandler(btn_Save_Defaults_Click);
- Controls.Add(btn_Save_Defaults);
- Button btn_Load_Defaults = new Button();
- btn_Load_Defaults.Location = new Point(ConfigX + 125, ConfigY + 380);
- btn_Load_Defaults.Size = new Size(110, 30);
- btn_Load_Defaults.Text = "Load Configuration";
- btn_Load_Defaults.Click += new System.EventHandler(btn_Load_Defaults_Click);
- Controls.Add(btn_Load_Defaults);
- Label ConfigPanel_Label = AddLabel(ConfigX + 50, ConfigY - 10, 141, 30, "Configuration", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label2 = AddLabel(ConfigX + 70, ConfigY + 240, 95, 30, "Controls", new Font(DefaultFont.FontFamily, 16));
- ConfigPanel_Label3 = AddLabel(ConfigX - 218, ConfigY - 10, 208, 30, "Firing Session Stats", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label4 = AddLabel(ConfigX + 50, ConfigY + 455, 150, 30, "Weapon Stats", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label5 = AddLabel(ConfigX + 50, ConfigY + 770, 180, 30, "Attachments", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label6 = AddLabel(ConfigX + 90, ConfigY + 920, 150, 30, "Optic", new Font(DefaultFont.FontFamily, 12));
- ConfigPanel_Label7 = AddLabel(ConfigX - 160, ConfigY + 275, 80, 30, "Stance", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label8 = AddLabel(ConfigX + 300, ConfigY + 120, 150, 30, "Weapon", new Font(DefaultFont.FontFamily, 16));
- Label ConfigPanel_Label9 = AddLabel(ConfigX + 270, ConfigY - 10, 200, 30, "Program Mode", new Font(DefaultFont.FontFamily, 16));
- ConfigPanel_Label10 = AddLabel(ConfigX - 185, ConfigY + 435, 140, 30, "Bullets to Kill", new Font(DefaultFont.FontFamily, 16));
- ConfigPanel_Label11 = AddLabel(ConfigX - 195, ConfigY + 700, 160, 30, "TTK Simulation", new Font(DefaultFont.FontFamily, 16));
- chk_ShowCoF = new CheckBox();
- chk_ShowCoF.Location = new Point(ConfigX + 5, ConfigY + 20);
- chk_ShowCoF.Text = "Show Cone of Fire";
- chk_ShowCoF.Size = new Size(120, 30);
- chk_ShowCoF.Click += new System.EventHandler(chk_ShowCoF_Click);
- Controls.Add(chk_ShowCoF);
- chk_ShowTolerance = new CheckBox();
- chk_ShowTolerance.Location = new Point(ConfigX + 5, ConfigY + 50);
- chk_ShowTolerance.Text = "Show Horizontal Recoil Tolerance";
- chk_ShowTolerance.Size = new Size(200, 30);
- chk_ShowTolerance.Click += new System.EventHandler(chk_ShowTolerance_Click);
- Controls.Add(chk_ShowTolerance);
- chk_ShowRecoilPattern = new CheckBox();
- chk_ShowRecoilPattern.Location = new Point(ConfigX + 5, ConfigY + 80);
- chk_ShowRecoilPattern.Text = "Show Recoil Pattern";
- chk_ShowRecoilPattern.Size = new Size(125, 30);
- chk_ShowRecoilPattern.Click += new System.EventHandler(chk_ShowRecoilPattern_Click);
- Controls.Add(chk_ShowRecoilPattern);
- chk_ShowConnectors = new CheckBox();
- chk_ShowConnectors.Location = new Point(ConfigX + 5, ConfigY + 110);
- chk_ShowConnectors.Text = "Show Connectors";
- chk_ShowConnectors.Size = new Size(110, 30);
- chk_ShowConnectors.Click += new System.EventHandler(chk_ShowConnectors_Click);
- Controls.Add(chk_ShowConnectors);
- chk_ShowGrid = new CheckBox();
- chk_ShowGrid.Location = new Point(ConfigX + 5, ConfigY + 140);
- chk_ShowGrid.Text = "Show Grid";
- chk_ShowGrid.Size = new Size(100, 30);
- chk_ShowGrid.Click += new System.EventHandler(chk_ShowGrid_Click);
- Controls.Add(chk_ShowGrid);
- chk_AngledGrid = new CheckBox();
- chk_AngledGrid.Location = new Point(ConfigX + 135, ConfigY + 140);
- chk_AngledGrid.Text = "Angled Grid";
- chk_AngledGrid.Size = new Size(100, 30);
- chk_AngledGrid.Enabled = true;
- chk_AngledGrid.Click += new System.EventHandler(chk_AngledGrid_Click);
- Controls.Add(chk_AngledGrid);
- chk_Ignore_Vertical_Recoil = new CheckBox();
- chk_Ignore_Vertical_Recoil.Location = new Point(ConfigX + 5, ConfigY + 170);
- chk_Ignore_Vertical_Recoil.Text = "Ignore Vertical Recoil";
- chk_Ignore_Vertical_Recoil.Size = new Size(200, 30);
- chk_Ignore_Vertical_Recoil.CheckedChanged += CheckAttachments;
- Controls.Add(chk_Ignore_Vertical_Recoil);
- //weapon stats textbox
- tb = new TextBox();
- tb.Location = new Point(ConfigX, ConfigY + 485);
- tb.Size = new Size(240, 280);
- tb.ScrollBars = ScrollBars.Vertical;
- tb.Multiline = true;
- tb.ReadOnly = true;
- Controls.Add(tb);
- //weapon list
- lb = new ListBox();
- lb.Location = new Point(Width - 200, 160);
- lb.Size = new Size(200, 855);
- Controls.Add(lb);
- lb.BeginUpdate();
- for (int i = 0; i < number_of_weapons; i++) lb.Items.Add(weapons[i].Type + " " + weapons[i].Weapon_Name);
- lb.EndUpdate();
- lb.SelectedIndexChanged += Lb_Click;
- chk_Draw_Crosshair_Positions = new CheckBox();
- chk_Draw_Crosshair_Positions.Location = new Point(ConfigX + 5, ConfigY + 200);
- chk_Draw_Crosshair_Positions.Text = "Show Crosshair Positions";
- chk_Draw_Crosshair_Positions.Size = new Size(200, 30);
- chk_Draw_Crosshair_Positions.Click += new System.EventHandler(chk_Draw_Bullet_Hits_Click);
- Controls.Add(chk_Draw_Crosshair_Positions);
- chk_Draw_Bullet_Hits = new CheckBox();
- chk_Draw_Bullet_Hits.Location = new Point(ConfigX + 135, ConfigY + 20);
- chk_Draw_Bullet_Hits.Text = "Draw Bullet Hits";
- chk_Draw_Bullet_Hits.Size = new Size(105, 30);
- chk_Draw_Bullet_Hits.Click += new System.EventHandler(chk_Draw_Bullet_Hits_Click);
- Controls.Add(chk_Draw_Bullet_Hits);
- chk_Draw_Target = new CheckBox();
- chk_Draw_Target.Location = new Point(ConfigX + 135, ConfigY + 80);
- chk_Draw_Target.Text = "Draw Target";
- chk_Draw_Target.Size = new Size(100, 30);
- chk_Draw_Target.CheckedChanged += new System.EventHandler(chk_Draw_Target_CheckedChanged);
- chk_Draw_Target.EnabledChanged += new System.EventHandler(chk_Draw_Target_CheckedChanged);
- Controls.Add(chk_Draw_Target);
- tb_Burst_Length = new TextBox();
- tb_Burst_Length.Size = new Size(110, 30);
- tb_Burst_Length.Multiline = true;
- tb_Burst_Length.Location = new Point(ConfigX + 125, ConfigY + 310);
- tb_Burst_Length.Text = "10";
- Controls.Add(tb_Burst_Length);
- //Firing Session stats textbox
- burst_stats = new TextBox();
- burst_stats.Size = new Size(209, 250);
- burst_stats.Multiline = true;
- burst_stats.Location = new Point(ConfigX - 218, ConfigY + 20);
- burst_stats.ReadOnly = true;
- Controls.Add(burst_stats);
- Button btn_Add_Comparison = new Button();
- btn_Add_Comparison.Location = new Point(ConfigX + 5, ConfigY + 345);
- btn_Add_Comparison.Size = new Size(110, 30);
- btn_Add_Comparison.Text = "Add to comparison";
- btn_Add_Comparison.Click += new System.EventHandler(btn_Add_Comparison_Click);
- Controls.Add(btn_Add_Comparison);
- Button btn_Reset_Comparison = new Button();
- btn_Reset_Comparison.Location = new Point(ConfigX + 125, ConfigY + 345);
- btn_Reset_Comparison.Size = new Size(110, 30);
- btn_Reset_Comparison.Text = "Reset comparison";
- btn_Reset_Comparison.Click += new System.EventHandler(btn_Reset_Comparison_Click);
- Controls.Add(btn_Reset_Comparison);
- // ===== BTK tb_thresholds textbox
- group_thresholds = new GroupBox();
- group_thresholds.Location = new Point(ConfigX - 218, ConfigY + 465);
- group_thresholds.Size = new Size(209, 230);
- Controls.Add(group_thresholds);
- btn_show_help = new Button();
- btn_show_help.Size = new Size(90, 40);
- btn_show_help.Location = new Point(109, 180);
- btn_show_help.Click += btn_show_help_Click;
- btn_show_help.Text = "Legend";
- group_thresholds.Controls.Add(btn_show_help);
- tb_bonus_headshots = new TextBox();
- tb_bonus_headshots.Location = new Point(10, 200);
- tb_bonus_headshots.Size = new Size(90, 30);
- tb_bonus_headshots.Text = "0";
- tb_bonus_headshots.TextChanged += tb_damage_multiplier_TextChanged;
- group_thresholds.Controls.Add(tb_bonus_headshots);
- AddLabel(10, 180, 100, 20, "Bonus Headshots", DefaultFont, group_thresholds);
- tb_thresholds = new TextBox();
- tb_thresholds.Location = new Point(5, 60);
- tb_thresholds.Size = new Size(199, 110);
- tb_thresholds.Multiline = true; tb_thresholds.ReadOnly = true;
- tb_thresholds.ScrollBars = ScrollBars.Vertical;
- group_thresholds.Controls.Add(tb_thresholds);
- tb_target_health = new TextBox();
- tb_target_health.Location = new Point(10, 30);
- tb_target_health.Size = new Size(90, 30);
- tb_target_health.Text = "1000";
- tb_target_health.TextChanged += tb_damage_multiplier_TextChanged;
- tb_target_health.TextChanged += tb_target_health_TextChanged;
- group_thresholds.Controls.Add(tb_target_health);
- tb_damage_multiplier = new TextBox();
- tb_damage_multiplier.Location = new Point(110, 30);
- tb_damage_multiplier.Size = new Size(90, 30);
- tb_damage_multiplier.Text = "1,0";
- tb_damage_multiplier.TextChanged += tb_damage_multiplier_TextChanged;
- group_thresholds.Controls.Add(tb_damage_multiplier);
- AddLabel(110, 10, 90, 20, "Damage Mult.", DefaultFont, group_thresholds);
- AddLabel(10, 10, 90, 20, "Target Health", DefaultFont, group_thresholds);
- //TTK SIMULATION
- group_target = new GroupBox();
- group_target.Location = new Point(ConfigX - 218, ConfigY + 730);
- group_target.Size = new Size(209, 250);
- Controls.Add(group_target);
- tb_target = new TextBox();
- tb_target.Size = new Size(199, 100);
- tb_target.Location = new Point(5, 10);
- tb_target.ReadOnly = true; tb_target.Multiline = true;
- group_target.Controls.Add(tb_target);
- tb_pause = new TextBox();
- tb_pause.Location = new Point(5, 120);
- tb_pause.Size = new Size(95, 30);
- tb_pause.ReadOnly = true;
- group_target.Controls.Add(tb_pause);
- Button btn_pause = new Button();
- btn_pause.Text = "Reset CoF";
- btn_pause.Size = new Size(100, 30);
- btn_pause.Location = new Point(105, 115);
- btn_pause.Click += btn_pause_Click;
- group_target.Controls.Add(btn_pause);
- AddLabel(40, 150, 140, 30, "Assign Damage", new Font(DefaultFont.FontFamily,12), group_target);
- btn_headshot = new Button();
- btn_headshot.Location = new Point(5, 180);
- btn_headshot.Size = new Size(95, 30);
- btn_headshot.Text = "Head";
- btn_headshot.Click += btn_headshot_Click;
- group_target.Controls.Add(btn_headshot);
- btn_bodyshot = new Button();
- btn_bodyshot.Location = new Point(110, 180);
- btn_bodyshot.Size = new Size(95, 30);
- btn_bodyshot.Text = "Body";
- btn_bodyshot.Click += btn_bodyshot_Click;
- group_target.Controls.Add(btn_bodyshot);
- btn_legshot = new Button();
- btn_legshot.Location = new Point(5, 215);
- btn_legshot.Size = new Size(95, 30);
- btn_legshot.Text = "Legs";
- btn_legshot.Click += btn_legshot_Click;
- group_target.Controls.Add(btn_legshot);
- Button btn_reset_damage = new Button();
- btn_reset_damage.Location = new Point(110, 215);
- btn_reset_damage.Size = new Size(95, 30);
- btn_reset_damage.Text = "Reset";
- btn_reset_damage.Click += btn_reset_damage_Click;
- group_target.Controls.Add(btn_reset_damage);
- ConfigPanel_Label11.Hide();
- group_target.Hide();
- // ############ ATTACHMENTS #############
- {
- chk_FG = CreateCheckBox("Forward Grip", ConfigX + 80, ConfigY + 800);
- chk_AFG = CreateCheckBox("Advanced", ConfigX, ConfigY + 800);
- chk_LS = CreateCheckBox("Laser Sight", ConfigX + 80, ConfigY + 820);
- chk_ALS = CreateCheckBox("Advanced", ConfigX, ConfigY + 820);
- chk_ExMags = CreateCheckBox("Extended Magazine", ConfigX, ConfigY + 840);
- chk_ExMags.Size = new Size(150, 30);
- chk_SPA = CreateCheckBox("Soft Point Ammo", ConfigX + 130, ConfigY + 865);
- chk_SPA.Size = new Size(150, 30);
- chk_HVA = CreateCheckBox("High Velocity Ammo", ConfigX, ConfigY + 865);
- chk_HVA.Size = new Size(150, 30);
- chk_Slugs = CreateCheckBox("Slug Ammunition", ConfigX, ConfigY + 865);
- chk_Slugs.Size = new Size(120, 30);
- chk_SmartChoke = CreateCheckBox("Smart Choke", ConfigX + 130, ConfigY + 865);
- chk_SmartChoke.Size = new Size(120, 30);
- chk_Compensator = CreateCheckBox("Compensator", ConfigX, ConfigY + 890);
- chk_Suppressor = CreateCheckBox("Suppressor", ConfigX + 130, ConfigY + 890);
- Optic_1x = CreateRadioButton("1x", ConfigX, ConfigY + 950);
- Optic_2x = CreateRadioButton("2x", ConfigX + 40, ConfigY + 950);
- Optic_3_4x = CreateRadioButtonW("3.4x", ConfigX + 80, ConfigY + 950);
- Optic_4x = CreateRadioButton("4x", ConfigX + 125, ConfigY + 950);
- Optic_6x = CreateRadioButton("6x", ConfigX + 165, ConfigY + 950);
- Optic_7x = CreateRadioButtonW("7x", ConfigX, ConfigY + 975);
- Optic_8x = CreateRadioButtonW("8x", ConfigX + 45, ConfigY + 975);
- Optic_10x = CreateRadioButtonW("10x", ConfigX + 90, ConfigY + 975);
- Optic_12x = CreateRadioButtonW("12x", ConfigX + 135, ConfigY + 975);
- Optic_1x.Checked = true;
- }
- lb.SetSelected(0, true);
- //STANCE
- group_Stand_Crouch = new GroupBox();
- group_Stand_Crouch.Location = new Point(ConfigX - 218, ConfigY + 300);
- group_Stand_Crouch.Size = new Size(208, 50);
- rb_Standing = new RadioButton();
- rb_Standing.Location = new Point(10, 12);
- rb_Standing.Size = new Size(80, 30);
- rb_Standing.Text = "Standing";
- group_Stand_Crouch.Controls.Add(rb_Standing);
- rb_Crouching = new RadioButton();
- rb_Crouching.Location = new Point(100, 12);
- rb_Crouching.Size = new Size(80, 30);
- rb_Crouching.Text = "Crouching";
- group_Stand_Crouch.Controls.Add(rb_Crouching);
- rb_Standing.Checked = true;
- rb_Standing.CheckedChanged += Rb_Moving_CheckedChanged;
- Controls.Add(group_Stand_Crouch);
- group_Still_Moving = new GroupBox();
- group_Still_Moving.Location = new Point(ConfigX - 218, ConfigY + 340);
- group_Still_Moving.Size = new Size(208, 50);
- rb_Still = new RadioButton();
- rb_Still.Location = new Point(10, 12);
- rb_Still.Size = new Size(80, 30);
- rb_Still.Text = "Still";
- group_Still_Moving.Controls.Add(rb_Still);
- rb_Moving = new RadioButton();
- rb_Moving.Location = new Point(100, 12);
- rb_Moving.Size = new Size(80, 30);
- rb_Moving.Text = "Moving";
- group_Still_Moving.Controls.Add(rb_Moving);
- rb_Still.Checked = true;
- rb_Moving.CheckedChanged += Rb_Moving_CheckedChanged;
- Controls.Add(group_Still_Moving);
- group_ADSing = new GroupBox();
- group_ADSing.Location = new Point(ConfigX - 218, ConfigY + 380);
- group_ADSing.Size = new Size(208, 50);
- group_ADSing.Controls.Add(rb_ADSing);
- rb_HipFiring = new RadioButton();
- rb_HipFiring.Location = new Point(100, 12);
- rb_HipFiring.Size = new Size(80, 30);
- rb_HipFiring.Text = "Hip firing";
- group_ADSing.Controls.Add(rb_HipFiring);
- rb_HipFiring.Checked = true;
- Controls.Add(group_ADSing);
- GroupBox mode = new GroupBox();
- mode.Location = new Point(ConfigX + 250, ConfigY + 20);
- mode.Size = new Size(200, 90);
- mode_Graphs = new RadioButton();
- mode_Graphs.Text = "Graphs";
- mode_Graphs.Font = new Font(DefaultFont.FontFamily, 14);
- mode_Graphs.Size = new Size(150, 30);
- mode_Graphs.Location = new Point(30, 10);
- mode_Graphs.CheckedChanged += mode_Graphs_CheckedChanged;
- mode.Controls.Add(mode_Graphs);
- mode_Simulation = new RadioButton();
- mode_Simulation.Text = "Simulation";
- mode_Simulation.Font = new Font(DefaultFont.FontFamily, 14);
- mode_Simulation.Size = new Size(150, 30);
- mode_Simulation.Location = new Point(30, 50);
- mode_Simulation.CheckedChanged += mode_Simulation_CheckedChanged;
- mode.Controls.Add(mode_Simulation);
- Controls.Add(mode);
- }
- void btn_legshot_Click(object sender, EventArgs e)
- {
- if (weapons_comparison[0].ShotNumber * weapons_comparison[0].Pellets - assign_damage > 0)
- {
- legshots++;
- assign_damage++;
- target_health -= Convert.ToInt32(0.9 * Convert.ToDouble(tb_damage_multiplier.Text) * CalculateDamage(weapons_comparison[0], distance));
- Invalidate();
- }
- }
- void btn_bodyshot_Click(object sender, EventArgs e)
- {
- if (weapons_comparison[0].ShotNumber * weapons_comparison[0].Pellets - assign_damage > 0)
- {
- bodyshots++;
- assign_damage++;
- target_health -= Convert.ToInt32(Convert.ToDouble(tb_damage_multiplier.Text) * CalculateDamage(weapons_comparison[0], distance));
- Invalidate();
- }
- }
- void btn_pause_Click(object sender, EventArgs e)
- {
- time_elapsed += (float)Convert.ToDouble(tb_pause.Text);
- weapons_comparison[0].CurrentCoF = weapons_comparison[0].GetCurrentMinimumCoF(rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked);
- Invalidate();
- }
- void tb_target_health_TextChanged(object sender, EventArgs e)
- {
- target_health = Convert.ToInt32(tb_target_health.Text);
- Invalidate();
- }
- void btn_reset_damage_Click(object sender, EventArgs e)
- {
- headshots = 0; bodyshots = 0; legshots = 0;
- assign_damage = 0;
- target_health = Convert.ToInt32(tb_target_health.Text);
- Invalidate();
- }
- void btn_headshot_Click(object sender, EventArgs e)
- {
- if (weapons_comparison[0].ShotNumber * weapons_comparison[0].Pellets - assign_damage > 0)
- {
- headshots++;
- assign_damage++;
- target_health -= Convert.ToInt32((weapons_comparison[0].Headshot_Damage_Multiplier +1) * CalculateDamage(weapons_comparison[0], distance));
- Invalidate();
- }
- }
- private void btn_show_help_Click(object sender, EventArgs e)
- {
- show_help = !show_help;
- Invalidate();
- }
- private void tb_damage_multiplier_TextChanged(object sender, EventArgs e)
- {
- WriteWeaponStats();
- }
- private void mode_Simulation_CheckedChanged(object sender, EventArgs e)
- {
- if (mode_Simulation.Checked)
- {
- chk_Draw_Bullet_Hits.Enabled = true;
- chk_Draw_Crosshair_Positions.Enabled = true;
- chk_Draw_Target.Enabled = true;
- chk_Ignore_Vertical_Recoil.Enabled = true;
- chk_ShowConnectors.Enabled = true;
- chk_ShowRecoilPattern.Enabled = true;
- chk_ShowTolerance.Enabled = true;
- chk_ShowCoF.Enabled = true;
- if (chk_ShowGrid.Checked) chk_AngledGrid.Enabled = true;
- ConfigPanel_Label3.Show();
- burst_stats.Show();
- ConfigPanel_Label10.Show();
- group_thresholds.Show();
- tb_thresholds.Show();
- ConfigPanel_Label7.Show();
- group_Still_Moving.Show();
- group_ADSing.Show();
- group_Stand_Crouch.Show();
- btn_Fire_Burst.Enabled = true;
- btn_Reset.Enabled = true;
- btn_Record.Enabled = true;
- tb_Burst_Length.Enabled = true;
- }
- Invalidate();
- }
- private void mode_Graphs_CheckedChanged(object sender, EventArgs e)
- {
- if (mode_Graphs.Checked)
- {
- chk_Draw_Bullet_Hits.Enabled = false;
- chk_Draw_Crosshair_Positions.Enabled = false;
- chk_Draw_Target.Enabled = false;
- chk_Ignore_Vertical_Recoil.Enabled = false;
- chk_ShowConnectors.Enabled = false;
- chk_ShowRecoilPattern.Enabled = false;
- chk_ShowTolerance.Enabled = false;
- chk_ShowCoF.Enabled = false;
- chk_AngledGrid.Enabled = false;
- ConfigPanel_Label10.Hide();
- group_thresholds.Hide();
- ConfigPanel_Label3.Hide();
- burst_stats.Hide();
- tb_thresholds.Hide();
- ConfigPanel_Label7.Hide();
- group_Still_Moving.Hide();
- group_ADSing.Hide();
- group_Stand_Crouch.Hide();
- btn_Fire_Burst.Enabled = false;
- btn_Reset.Enabled = false;
- btn_Record.Enabled = false;
- tb_Burst_Length.Enabled = false;
- }
- Invalidate();
- }
- private void Rb_Moving_CheckedChanged(object sender, EventArgs e)
- {
- UpdateBurstStats();
- }
- CheckBox CreateCheckBox(string title, int X, int Y)
- {
- CheckBox chk = new CheckBox();
- chk.Text = title;
- chk.Location = new Point(X, Y);
- chk.CheckedChanged += CheckAttachments;
- chk.CheckedChanged += btn_Reset_Click;
- Controls.Add(chk);
- return chk;
- }
- Label AddLabel(int X, int Y, int W, int H, string text, Font font)
- {
- Label label = new Label();
- label.Location = new Point(X, Y);
- label.Size = new Size(W, H);
- label.Text = text;
- label.Font = font;
- Controls.Add(label);
- return label;
- }
- Label AddLabel(int X, int Y, int W, int H, string text, Font font, GroupBox groupbox)
- {
- Label label = new Label();
- label.Location = new Point(X, Y);
- label.Size = new Size(W, H);
- label.Text = text;
- label.Font = font;
- groupbox.Controls.Add(label);
- return label;
- }
- RadioButton CreateRadioButton(string title, int X, int Y)
- {
- RadioButton rb = new RadioButton();
- rb.Text = title;
- rb.Location = new Point(X, Y);
- rb.Width = 40;
- rb.CheckedChanged += Rb_CheckedChanged;
- Controls.Add(rb);
- return rb;
- }
- RadioButton CreateRadioButtonW(string title, int X, int Y)
- {
- RadioButton rb = new RadioButton();
- rb.Text = title;
- rb.Location = new Point(X, Y);
- rb.Width = 45;
- rb.CheckedChanged += Rb_CheckedChanged;
- Controls.Add(rb);
- return rb;
- }
- private void Rb_CheckedChanged(object sender, EventArgs e)
- {
- ADS_Magnification = 1.35 * Convert.ToInt32(Optic_1x.Checked) + 2 * Convert.ToInt32(Optic_2x.Checked) + 3.4 * Convert.ToInt32(Optic_3_4x.Checked) + 4 * Convert.ToInt32(Optic_4x.Checked) +
- 6 * Convert.ToInt32(Optic_6x.Checked) + 7 * Convert.ToInt32(Optic_7x.Checked) + 8 * Convert.ToInt32(Optic_8x.Checked) + 10 * Convert.ToInt32(Optic_10x.Checked) + 12 * Convert.ToInt32(Optic_12x.Checked);
- CalculatePixels();
- Invalidate();
- }
- void UpdateBurstStats()
- {
- burst_stats.Text = null;
- if (rb_ADSing.Checked) burst_stats.AppendText("Aiming Down Sights");
- else burst_stats.AppendText("Hip firing");
- if (rb_Standing.Checked) burst_stats.AppendText(" while standing ");
- else burst_stats.AppendText(" while crouching ");
- if (rb_Moving.Checked) burst_stats.AppendText("moving.\n");
- else burst_stats.AppendText("still.\n");
- if (rb_ADSing.Checked) burst_stats.AppendText("ADS Magnification: " + ADS_Magnification + "x\n");
- burst_stats.AppendText("Screen Zoom: " + Zoom + "x\n");
- burst_stats.AppendText("Current Cone of Fire: " + weapons_comparison[0].GetCurrentCoF(rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked) + " degrees\n");
- burst_stats.AppendText("\n");
- burst_stats.AppendText("### CONTROLS ###\n");
- burst_stats.AppendText("Left Mouse Button to fire.\n");
- burst_stats.AppendText("Right Mouse Button to ADS.\n");
- burst_stats.AppendText("Middle Mouse Button - hold and drag to move recoil pattern.\n");
- burst_stats.AppendText("Mouse wheel to change zoom.");
- if (chk_ShowGrid.Checked)
- {
- burst_stats.AppendText("\n");
- burst_stats.AppendText("\n");
- burst_stats.AppendText("Grid enabled.\n");
- burst_stats.AppendText("1 notch = 1 degree");
- }
- if (Recording)
- {
- burst_stats.AppendText("\n");
- burst_stats.AppendText("\n");
- burst_stats.AppendText("RECORD PATTERN MODE ENABLED\n");
- burst_stats.AppendText("Press A to fire a shot left\n");
- burst_stats.AppendText("Press D to fire a shot right");
- }
- if(chk_Draw_Target.Checked)
- {
- //calculating pause time depending on weapon refire time and time necessary to reset CoF
- tb_pause.Text = Convert.ToString((float)weapons_comparison[0].Refire_Time / 1000 + (weapons_comparison[0].CurrentCoF - weapons_comparison[0].GetCurrentMinimumCoF(rb_ADSing.Checked, rb_Standing.Checked, rb_Still.Checked)) / 20);
- tb_target.Text = "";
- tb_target.AppendText("Distance: " + distance + "m\n");
- tb_target.AppendText("Damage at distance: " + CalculateDamage(weapons_comparison[0], distance) + "\n");
- tb_target.AppendText("Time elapsed: " + time_elapsed + "s\n");
- tb_target.AppendText("Shots fired: " + weapons_comparison[0].ShotNumber * weapons_comparison[0].Pellets + "\n");
- tb_target.AppendText("Shots to assign: " + (weapons_comparison[0].ShotNumber * weapons_comparison[0].Pellets - assign_damage) +"\n");
- tb_target.AppendText("Remaining health: " + target_health + "\n");
- if (target_health <= 0) tb_target.AppendText("TARGET DEAD");
- btn_bodyshot.Text = "Body (" + bodyshots + ")";
- btn_headshot.Text = "Head (" + headshots + ")";
- btn_legshot.Text = "Leg (" + legshots + ")";
- // end here start last time tb_target.AppendText("Time elapsed: " + weapons_comparison[0].ShotNumber * );
- }
- }
- float CalculateDamage(Weapon weapon, int distance)
- {
- if (distance < weapon.Maximum_Damage_Range) return weapon.Maximum_Damage;
- if (distance > weapon.Minimum_Damage_Range) return weapon.Minimum_Damage;
- return (float)Math.Sqrt(Math.Sqrt((weapon.Maximum_Damage - weapon.Minimum_Damage) * (weapon.Maximum_Damage - weapon.Minimum_Damage) + (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range) * (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range)) * (weapon.Minimum_Damage_Range - distance) / (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range) * Math.Sqrt((weapon.Maximum_Damage - weapon.Minimum_Damage) * (weapon.Maximum_Damage - weapon.Minimum_Damage) + (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range) * (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range)) * (weapon.Minimum_Damage_Range - distance) / (weapon.Minimum_Damage_Range - weapon.Maximum_Damage_Range) - (weapon.Minimum_Damage_Range - distance) * (weapon.Minimum_Damage_Range - distance)) + weapon.Minimum_Damage;
- }
- void CheckAttachments(object sender, System.EventArgs arg) //обработчик события нажатия на кнопку "Влево"
- {
- if (!chk_FG.Checked) { chk_AFG.Checked = false; chk_AFG.Enabled = false; }
- else chk_AFG.Enabled = true;
- if (!chk_LS.Checked) { chk_ALS.Checked = false; chk_ALS.Enabled = false; }
- else chk_ALS.Enabled = true;
- // HVA and SPA
- weapons_comparison[0].Maximum_Damage_Range = weapon_orig.Maximum_Damage_Range + 5 * Convert.ToInt32(chk_SPA.Checked) - 2 * Convert.ToInt32(chk_HVA.Checked) - 5 * Convert.ToInt32(chk_Suppressor.Checked);
- weapons_comparison[0].Minimum_Damage_Range = weapon_orig.Minimum_Damage_Range + 20 * Convert.ToInt32(chk_HVA.Checked) - 20 * Convert.ToInt32(chk_Suppressor.Checked) * Convert.ToInt32(weapons_comparison[0].Type != "SMG") - 10 * Convert.ToInt32(chk_Suppressor.Checked) * Convert.ToInt32(weapons_comparison[0].Type == "SMG");
- weapons_comparison[0].Projectile_Velocity = Convert.ToInt32(weapon_orig.Projectile_Velocity * (1F - 0.05F * Convert.ToInt32(chk_SPA.Checked) + 0.05F * Convert.ToInt32(chk_HVA.Checked) - (float)SuppressorVelocityPenalty(weapons_comparison[0])));
- //compensator hip fire penalty
- weapons_comparison[0].CoF_Crouching_Moving_HIP = weapon_orig.CoF_Crouching_Moving_HIP * (1 + 0.2 * Convert.ToInt32(chk_Compensator.Checked) - 0.33 * Convert.ToInt32(chk_LS.Checked) - 0.07 * Convert.ToInt32(chk_ALS.Checked));
- weapons_comparison[0].CoF_Crouching_Still_Hip = weapon_orig.CoF_Crouching_Still_Hip * (1 + 0.2 * Convert.ToInt32(chk_Compensator.Checked) - 0.33 * Convert.ToInt32(chk_LS.Checked) - 0.07 * Convert.ToInt32(chk_ALS.Checked));
- weapons_comparison[0].CoF_Standing_Moving_Hip = weapon_orig.CoF_Standing_Moving_Hip * (1 + 0.2 * Convert.ToInt32(chk_Compensator.Checked) - 0.33 * Convert.ToInt32(chk_LS.Checked) - 0.07 * Convert.ToInt32(chk_ALS.Checked));
- weapons_comparison[0].CoF_Standing_Still_Hip = weapon_orig.CoF_Standing_Still_Hip * (1 + 0.2 * Convert.ToInt32(chk_Compensator.Checked) - 0.33 * Convert.ToInt32(chk_LS.Checked) - 0.07 * Convert.ToInt32(chk_ALS.Checked));
- //compensator vertical recoil bonus
- weapons_comparison[0].Vertical_Recoil = weapon_orig.Vertical_Recoil * (1 - 0.15 * Convert.ToInt32(chk_Compensator.Checked) - 0.15 * Convert.ToInt32(chk_FG.Checked) * Convert.ToInt32(weapons_comparison[0].Type == "Sniper Rifle")); // other weapons
- if (weapons_comparison[0].ID == 7170) weapons_comparison[0].Vertical_Recoil = weapon_orig.Vertical_Recoil * (1 - 0.2 * Convert.ToInt32(chk_Compensator.Checked)); // AC-X11
- if (weapons_comparison[0].ID == 7108 || weapons_comparison[0].ID == 7125) weapons_comparison[0].Vertical_Recoil = weapon_orig.Vertical_Recoil * (1 - 0.25 * Convert.ToInt32(chk_Compensator.Checked)); //Reaper DMR and SABR
- //if (weapons_comparison[0].ShotNumber > 0 && weapons_comparison[0].shot[weapons_comparison[0].ShotNumber - 1] != null) weapons_comparison[0].shot[weapons_comparison[0].ShotNumber - 1].Vertical_Recoil = 0; это вообще что должно делать-то?
- //Extended Mags
- if (chk_ExMags.Checked)
- {
- if (weapons_comparison[0].Type == "SMG" && weapons_comparison[0].ID != 27001 && weapons_comparison[0].ID != 28001 && weapons_comparison[0].ID != 29001) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 10;
- if (weapons_comparison[0].Type == "LMG" || weapons_comparison[0].ID == 803732 || weapons_comparison[0].ID == 803779 || weapons_comparison[0].ID == 7533 || weapons_comparison[0].ID == 7540) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size * 2; // Lasher and MCG + AE versions
- if (weapons_comparison[0].Type == "Shotgun" || weapons_comparison[0].ID == 7390)
- {
- if (FireMode(weapons_comparison[0].Fire_Mode) >= 0) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 4; //semi auto and burst shotguns
- if (FireMode(weapons_comparison[0].Fire_Mode) == -1) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 2; // pump action
- if (weapons_comparison[0].ID == 75083) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 2; // Baron
- }
- if (weapons_comparison[0].ID == 7528 || weapons_comparison[0].ID == 803756) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 3; // Jackhammer
- if (weapons_comparison[0].Weapon_Name.Contains("Emissary")) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 5;
- if (weapons_comparison[0].ID == 7390) weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size + 1; // MagScatter
- }
- else weapons_comparison[0].Magazine_Size = weapon_orig.Magazine_Size;
- //Forward Grip
- weapons_comparison[0].Horizontal_Recoil_Minimum = weapon_orig.Horizontal_Recoil_Minimum * (1 - FG_Recoil_Bonus(weapons_comparison[0]));
- weapons_comparison[0].Horizontal_Recoil_Maximum = weapon_orig.Horizontal_Recoil_Maximum * (1 - FG_Recoil_Bonus(weapons_comparison[0]));
- weapons_comparison[0].Horizontal_Recoil_Tolerance = weapon_orig.Horizontal_Recoil_Tolerance - weapon_orig.Horizontal_Recoil_Tolerance * FG_Recoil_Bonus(weapons_comparison[0]);
- weapons_comparison[0].Recoil_Angle_Maximum = weapon_orig.Recoil_Angle_Maximum * (1 - FG_Angle_Bonus());
- weapons_comparison[0].Recoil_Angle_Minimum = weapon_orig.Recoil_Angle_Minimum * (1 - FG_Angle_Bonus());
- //slug ammunition
- //Full Auto and Semi-Auto slug damage: 500 @ 10m – 360 @ 40m
- //Pump Action slug damage: 800 @ 10m – 400 @ 40m
- if (chk_Slugs.Visible)
- {
- if (chk_Slugs.Checked)
- {
- chk_SmartChoke.Enabled = false;
- chk_SmartChoke.Checked = false;
- weapons_comparison[0].Pellets = 1;
- weapons_comparison[0].Pellet_Spread_ADS = 0;
- weapons_comparison[0].Pellet_Spread_HIP = 0;
- weapons_comparison[0].CoF_Crouching_Moving_HIP = weapon_orig.CoF_Crouching_Moving_HIP * 1.75;
- weapons_comparison[0].CoF_Crouching_Still_Hip = weapon_orig.CoF_Crouching_Still_Hip * 1.75;
- weapons_comparison[0].CoF_Standing_Moving_Hip = weapon_orig.CoF_Standing_Moving_Hip * 1.75;
- weapons_comparison[0].CoF_Standing_Still_Hip = weapon_orig.CoF_Standing_Still_Hip * 1.75;
- weapons_comparison[0].Projectile_Velocity = 300;
- if (FireMode(weapons_comparison[0].Fire_Mode) >= 0)//semi auto and burst shotguns
- {
- weapons_comparison[0].Maximum_Damage = 500;
- weapons_comparison[0].Maximum_Damage_Range = 10;
- weapons_comparison[0].Minimum_Damage = 360;
- weapons_comparison[0].Minimum_Damage_Range = 40;
- }
- if (FireMode(weapons_comparison[0].Fire_Mode) == -1) // pump action
- {
- weapons_comparison[0].Maximum_Damage = 800;
- weapons_comparison[0].Maximum_Damage_Range = 10;
- weapons_comparison[0].Minimum_Damage = 400;
- weapons_comparison[0].Minimum_Damage_Range = 40;
- }
- }
- else
- {
- chk_SmartChoke.Enabled = true;
- weapons_comparison[0].Pellets = weapon_orig.Pellets;
- weapons_comparison[0].Maximum_Damage = weapon_orig.Maximum_Damage;
- weapons_comparison[0].Maximum_Damage_Range = weapon_orig.Maximum_Damage_Range;
- weapons_comparison[0].Minimum_Damage = weapon_orig.Minimum_Damage;
- weapons_comparison[0].Minimum_Damage_Range = weapon_orig.Minimum_Damage_Range;
- weapons_comparison[0].Projectile_Velocity = weapon_orig.Projectile_Velocity;
- }
- if (chk_SmartChoke.Enabled)
- {
- if (chk_SmartChoke.Checked)
- {
- weapons_comparison[0].Pellet_Spread_ADS = weapon_orig.Pellet_Spread_ADS - 0.5;
- weapons_comparison[0].Pellet_Spread_HIP = weapon_orig.Pellet_Spread_HIP + 0.5;
- }
- else
- {
- weapons_comparison[0].Pellet_Spread_ADS = weapon_orig.Pellet_Spread_ADS;
- weapons_comparison[0].Pellet_Spread_HIP = weapon_orig.Pellet_Spread_HIP;
- }
- }
- }
- //ATTACHMENT STRING SETTING
- weapons_comparison[0].Attachments = "";
- if (chk_AFG.Checked) weapons_comparison[0].Attachments += "Advanced Forward Grip\n";
- else if (chk_FG.Checked) weapons_comparison[0].Attachments += "Forward Grip\n";
- if (chk_ALS.Checked) weapons_comparison[0].Attachments += "Advanced Laser Sight\n";
- else if (chk_LS.Checked) weapons_comparison[0].Attachments += "Laser Sight\n";
- if (chk_ExMags.Checked) weapons_comparison[0].Attachments += "Extended Magazine\n";
- if (chk_SPA.Checked) weapons_comparison[0].Attachments += "SPA\n";
- if (chk_HVA.Checked) weapons_comparison[0].Attachments += "HVA\n";
- if (chk_Slugs.Checked) weapons_comparison[0].Attachments += "Slug Ammunition\n";
- if (chk_SmartChoke.Checked) weapons_comparison[0].Attachments += "Smart Choke\n";
- if (chk_Suppressor.Checked) weapons_comparison[0].Attachments += "Suppressor\n";
- if (chk_Compensator.Checked) weapons_comparison[0].Attachments += "Compensator\n";
- WriteWeaponStats();
- Invalidate();
- }
- // WEAPON SELECTION
- private void Lb_Click(object sender, EventArgs e)
- {
- chk_Ignore_Vertical_Recoil.Checked = false;
- chk_FG.Checked = false;
- chk_LS.Checked = false;
- chk_SPA.Checked = false;
- chk_HVA.Checked = false;
- chk_Suppressor.Checked = false;
- chk_Compensator.Checked = false;
- Optic_1x.Checked = true;
- chk_ExMags.Checked = false;
- weapons_comparison[0] = new Weapon(weapons[lb.SelectedIndex]);
- weapons_comparison[0].Attachments = "";
- weapons_comparison[0].Starting_X = Width / 2;
- weapons_comparison[0].Starting_Y = Height / 2;
- weapon_orig = weapons[lb.SelectedIndex];
- if (weapons_comparison[0].Type == "Shotgun" || weapons_comparison[0].ID == 7390)
- {
- chk_Slugs.Show();
- chk_SmartChoke.Show();
- chk_SPA.Hide();
- chk_HVA.Hide();
- }
- else
- {
- chk_Slugs.Hide();
- chk_SmartChoke.Hide();
- chk_SPA.Show();
- chk_HVA.Show();
- }
- timer.Interval = weapons_comparison[0].Refire_Time;
- WriteWeaponStats();
- Reset();
- Invalidate();
- }
- double SuppressorVelocityPenalty(Weapon weapon)
- {
- if (chk_Suppressor.Checked)
- {
- if (weapon.Type == "SMG") return 0.2;
- if (weapon.Weapon_Name.Contains("Emissary")) return 0.12;
- if (weapon.Type == "Carbine") return 0.35;
- if (weapon.ID == 7301) return 0.505; //railjack
- return 0.4;
- }
- return 0;
- }
- double FG_Recoil_Bonus(Weapon weapon)
- {
- if (chk_FG.Checked)
- {
- if (chk_AFG.Checked) return 0.33;
- else return 0.25;
- }
- return 0;
- }
- double FG_Angle_Bonus()
- {
- if (chk_FG.Checked)
- {
- if (chk_AFG.Checked) return 0.33;
- else return 0.25;
- }
- return 0;
- }
- void WriteWeaponStats()
- {
- tb.Text = null;
- tb.AppendText("Weapon ID: " + weapons_comparison[0].ID + "\n");
- tb.AppendText("Name: " + weapons_comparison[0].Weapon_Name + "\n");
- tb.AppendText("Faction: " + weapons_comparison[0].Faction + "\n");
- tb.AppendText("Type: " + weapons_comparison[0].Type + "\n");
- tb.AppendText("Damage: " + weapons_comparison[0].Maximum_Damage + " @ " + weapons_comparison[0].Maximum_Damage_Range + "m - " + weapons_comparison[0].Minimum_Damage + " @ " + weapons_comparison[0].Minimum_Damage_Range + "m\n");
- if (weapons_comparison[0].Pellets > 1)
- {
- if (weapons_comparison[0].Pellet_Spread_ADS == weapons_comparison[0].Pellet_Spread_HIP)
- tb.AppendText("Pellets: " + weapons_comparison[0].Pellets + " / " + "Pellet Spread: " + weapons_comparison[0].Pellet_Spread_ADS + "\n");
- else tb.AppendText("Pellets: " + weapons_comparison[0].Pellets + " / " + "Pellet Spread: " + weapons_comparison[0].Pellet_Spread_ADS + " / " + weapons_comparison[0].Pellet_Spread_HIP + "\n");
- }
- tb.AppendText("Headshot Damage Multiplier: " + (1 + weapons_comparison[0].Headshot_Damage_Multiplier) + "x\n");
- if (!weapons_comparison[0].Fire_Mode.Contains("Action")) tb.AppendText("Rate of Fire: " + weapons_comparison[0].Rate_of_Fire + "\n");
- tb.AppendText("Projectile Velocity: " + weapons_comparison[0].Projectile_Velocity + " m/s \n");
- tb.AppendText("Ammo: " + weapons_comparison[0].Magazine_Size + " / " + weapons_comparison[0].Ammo_Pool + " \n");
- if (weapons_comparison[0].Fire_Mode != "Pump-Action" && !weapons_comparison[0].Weapon_Name.Contains("Baron")) tb.AppendText("Reload Time: " + weapons_comparison[0].Short_Reload / 1000 + " s / " + weapons_comparison[0].Long_Reload / 1000 + " s \n");
- tb.AppendText("ADS Movement Speed Multiplier: " + weapons_comparison[0].ADS_Movement_Speed_Multiplier + "\n");
- tb.AppendText("Hip Fire CoFs: " + weapons_comparison[0].CoF_Crouching_Still_Hip + " / " + weapons_comparison[0].CoF_Crouching_Moving_HIP + " / " + weapons_comparison[0].CoF_Standing_Still_Hip + " / " + weapons_comparison[0].CoF_Standing_Moving_Hip + "\n");
- tb.AppendText("ADS Fire CoFs: " + weapons_comparison[0].CoF_Crouching_Still_ADS + " / " + weapons_comparison[0].CoF_Crouching_Moving_ADS + " / " + weapons_comparison[0].CoF_Standing_Still_ADS + " / " + weapons_comparison[0].CoF_Standing_Moving_ADS + "\n");
- tb.AppendText("CoF Bloom: " + weapons_comparison[0].CoF_Bloom_ADS + " / " + weapons_comparison[0].CoF_Bloom_Hip + " \n");
- tb.AppendText("Recoil Angle: " + weapons_comparison[0].Recoil_Angle_Minimum + " - " + weapons_comparison[0].Recoil_Angle_Maximum + "\n");
- tb.AppendText("Vertical Recoil: " + weapons_comparison[0].Vertical_Recoil + "\n");
- tb.AppendText("First Shot Recoil Multiplier: " + weapons_comparison[0].First_Shot_Recoil_Multiplier + "x\n");
- tb.AppendText("Horizontal Recoil: " + weapons_comparison[0].Horizontal_Recoil_Minimum + " - " + weapons_comparison[0].Horizontal_Recoil_Maximum + "\n");
- tb.AppendText("Horizontal Recoil Tolerance: " + weapons_comparison[0].Horizontal_Recoil_Tolerance + "\n");
- tb.AppendText("Recoil Recovery Rate: " + weapons_comparison[0].Recoil_Recovery_Rate + "\n");
- tb.AppendText("Fire Mode: " + weapons_comparison[0].Fire_Mode);
- //write BTK thresholds
- {
- if (tb_target_health.Focused)
- {
- tb_target_health.Text = tb_target_health.Text.Replace('.', ',');
- tb_target_health.SelectionStart = tb_target_health.Text.Length;
- tb_target_health.SelectionLength = 0;
- }
- if (tb_damage_multiplier.Focused)
- {
- tb_damage_multiplier.Text = tb_damage_multiplier.Text.Replace('.', ',');
- tb_damage_multiplier.SelectionStart = tb_damage_multiplier.Text.Length;
- tb_damage_multiplier.SelectionLength = 0;
- }
- int[][] arr;
- if (tb_target_health.Text != "" && tb_target_health.Text != "" && tb_damage_multiplier.Text != "")
- if (Convert.ToDouble(tb_target_health.Text) >= 0 && Convert.ToDouble(tb_target_health.Text) >= 0 && Convert.ToDouble(tb_damage_multiplier.Text) > 0)
- {
- arr = Calculate_tb_thresholds(weapons_comparison[0], (float)Convert.ToDouble(tb_target_health.Text), (float)Convert.ToDouble(tb_damage_multiplier.Text), Convert.ToInt32(tb_bonus_headshots.Text));
- tb_thresholds.Text = null;
- tb_thresholds.AppendText("Target Effective Health: " + (float)(Convert.ToDouble(tb_target_health.Text) / Convert.ToDouble(tb_damage_multiplier.Text)) + "\n");
- if (Convert.ToInt32(tb_bonus_headshots.Text) > 0)
- {
- if (Convert.ToInt32(tb_bonus_headshots.Text) == 1) tb_thresholds.AppendText("After 1 headshot\n");
- else tb_thresholds.AppendText("After " + Convert.ToInt32(tb_bonus_headshots.Text) + " headshots\n");
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if (i + 1 == arr.Length) tb_thresholds.AppendText("BTK of " + arr[i][0] + " at " + arr[i][1] + "m+ (" + (Math.Ceiling((double)arr[i][0] / weapons_comparison[0].Pellets) - 1) * ((float)weapons_comparison[0].Refire_Time / 1000) + "s)");
- else tb_thresholds.AppendText("BTK of " + arr[i][0] + " from " + arr[i][1] + "m to " + arr[i][2] + "m (" + (Math.Ceiling((double)arr[i][0] / weapons_comparison[0].Pellets) -1) * ((float)weapons_comparison[0].Refire_Time / 1000) + "s)\n");
- }
- }
- }
- }
- void ParseFile()
- {
- StreamReader reader = null;
- if (File.Exists("Stats.csv")) reader = File.OpenText("Stats.csv");
- else
- {
- MessageBox.Show("Failed to open database file. Make sure that \"Stats.csv\" file is in application folder. Program will be closed.", "Database error");
- if (System.Windows.Forms.Application.MessageLoop) System.Windows.Forms.Application.Exit();
- else System.Environment.Exit(1);
- }
- string line = reader.ReadLine();
- string[] items = line.Split(',');
- Database_Date = items[0];
- int wpn = 0;
- while ((line = reader.ReadLine()) != null)
- {
- items = line.Split(',');
- switch (items[3])
- {
- case "AA MAX (Left)": continue;
- case "AA MAX (Right)": continue;
- case "AI MAX (Left)": continue;
- case "AI MAX (Right)": continue;
- case "ANT Top Turret": continue;
- case "AV MAX (Left)": continue;
- case "AV MAX (Right)": continue;
- case "Flash Primary Weapon": continue;
- case "Galaxy Left Weapon": continue;
- case "Galaxy Right Weapon": continue;
- case "Galaxy Tail Weapon": continue;
- case "Galaxy Top Weapon": continue;
- case "Harasser Top Gunner": continue;
- case "Liberator Belly Weapon": continue;
- case "Liberator Nose Cannon": continue;
- case "Liberator Tail Weapon": continue;
- case "Lightning Primary Weapon ": continue;
- case "Magrider Gunner Weapon": continue;
- case "Magrider Primary Weapon": continue;
- case "Mosquito Nose Cannon": continue;
- case "Mosquito Wing Mount": continue;
- case "Prowler Gunner Weapon": continue;
- case "Prowler Primary Weapon": continue;
- case "Reaver Nose Cannon": continue;
- case "Reaver Wing Mount": continue;
- case "Scythe Nose Cannon": continue;
- case "Scythe Wing Mount": continue;
- case "Sunderer Front Gunner": continue;
- case "Sunderer Rear Gunner": continue;
- case "Valkyrie Nose Gunner": continue;
- case "Vanguard Gunner Weapon": continue;
- case "Vanguard Primary Weapon": continue;
- case "Vehicle Abilities": continue;
- case "Heavy Gun": continue;
- }
- /*
- 0 Item ID
- 1 Name
- 2 Faction
- 3 Category
- 4 Min Damage
- 5 Min Range
- 6 Max Damage
- 7 Max Range
- 8 H/S Multiplier
- 9 RPM
- 10 Pellets
- 11 TTK
- 12 Velocity
- 13 Equip Time
- 14 Clip Size
- 15 Capacity
- 16 Long Reload
- 17 Short Reload
- 18 Move Mod ADS
- 19 COF Recoil Hip
- 20 COF Recoil ADS
- 21 Standing Hip
- 22 Crouching Hip
- 23 Walking Hip
- 24 Running Hip
- 25 CrouchWalking Hip
- 26 Standing ADS
- 27 Crouching ADS
- 28 Walking ADS
- 29 CrouchWalking ADS
- 30 Recoil Angle Min
- 31 Recoil Angle Max
- 32 Vertical Recoil
- 33 Horizontal Recoil Min
- 34 Horizontal Recoil Max
- 35 Horizontal Recoil Tolerance
- 36 Recoil First Shot Mod
- 37 Recoil Recovery
- */
- weapons[wpn] = new Weapon();
- weapons[wpn].ID = Convert.ToInt32(items[0]);
- weapons[wpn].Weapon_Name = items[1];
- weapons[wpn].Faction = items[2];
- weapons[wpn].Type = items[3];
- weapons[wpn].Maximum_Damage = Convert.ToInt32(items[4]);
- weapons[wpn].Maximum_Damage_Range = Convert.ToInt32(items[5]);
- weapons[wpn].Minimum_Damage = Convert.ToInt32(items[6]);
- weapons[wpn].Minimum_Damage_Range = Convert.ToInt32(items[7]);
- weapons[wpn].Headshot_Damage_Multiplier = Convert.ToDouble(items[8].Replace('.', ','));
- if (items[9] != "") weapons[wpn].Refire_Time = Convert.ToInt32(items[9]);
- else weapons[wpn].Refire_Time = 1000;
- weapons[wpn].Rate_of_Fire = 60000 / weapons[wpn].Refire_Time;
- weapons[wpn].Pellets = Convert.ToInt32(items[10]);
- if (items[12] != "") weapons[wpn].Projectile_Velocity = Convert.ToInt32(items[12]);
- else
- {
- if (items[1] == "Spiker") weapons[wpn].Projectile_Velocity = 325;
- else weapons[wpn].Projectile_Velocity = 1;
- }
- if (items[13] != "-") weapons[wpn].Equip_Time = Convert.ToDouble(items[13].Replace('.', ','));
- else weapons[wpn].Equip_Time = 1;
- if (items[14] != "") weapons[wpn].Magazine_Size = Convert.ToInt32(items[14]);
- else weapons[wpn].Magazine_Size = 1;
- if (items[15] != "") weapons[wpn].Ammo_Pool = Convert.ToInt32(items[15]);
- else weapons[wpn].Ammo_Pool = 1;
- if (items[16] != "NaN") weapons[wpn].Long_Reload = Convert.ToInt32(items[16]);
- else weapons[wpn].Short_Reload = 1;
- if (items[17] != "") weapons[wpn].Short_Reload = Convert.ToInt32(items[17]);
- else weapons[wpn].Long_Reload = 1;
- weapons[wpn].ADS_Movement_Speed_Multiplier = Convert.ToDouble(items[18].Replace('.', ','));
- weapons[wpn].CoF_Bloom_Hip = Convert.ToDouble(items[19].Replace('.', ','));
- weapons[wpn].CoF_Bloom_ADS = Convert.ToDouble(items[20].Replace('.', ','));
- weapons[wpn].CoF_Standing_Still_Hip = Convert.ToDouble(items[21].Replace('.', ','));
- weapons[wpn].CoF_Crouching_Still_Hip = Convert.ToDouble(items[22].Replace('.', ','));
- weapons[wpn].CoF_Standing_Moving_Hip = Convert.ToDouble(items[23].Replace('.', ','));
- weapons[wpn].CoF_Sprint = Convert.ToDouble(items[24].Replace('.', ','));
- weapons[wpn].CoF_Crouching_Moving_HIP = Convert.ToDouble(items[25].Replace('.', ','));
- weapons[wpn].CoF_Standing_Still_ADS = Convert.ToDouble(items[26].Replace('.', ','));
- weapons[wpn].CoF_Crouching_Still_ADS = Convert.ToDouble(items[27].Replace('.', ','));
- weapons[wpn].CoF_Standing_Moving_ADS = Convert.ToDouble(items[28].Replace('.', ','));
- weapons[wpn].CoF_Crouching_Moving_ADS = Convert.ToDouble(items[29].Replace('.', ','));
- weapons[wpn].Recoil_Angle_Maximum = Convert.ToDouble(items[30].Replace('.', ','));
- weapons[wpn].Recoil_Angle_Minimum = Convert.ToDouble(items[31].Replace('.', ','));
- weapons[wpn].Vertical_Recoil = Convert.ToDouble(items[32].Replace('.', ','));
- weapons[wpn].Horizontal_Recoil_Maximum = Convert.ToDouble(items[33].Replace('.', ','));
- weapons[wpn].Horizontal_Recoil_Minimum = Convert.ToDouble(items[34].Replace('.', ','));
- weapons[wpn].Horizontal_Recoil_Tolerance = Convert.ToDouble(items[35].Replace('.', ','));
- weapons[wpn].First_Shot_Recoil_Multiplier = Convert.ToDouble(items[36].Replace('.', ','));
- weapons[wpn].Recoil_Recovery_Rate = Convert.ToInt32(items[37]);
- weapons[wpn].Fire_Mode = items[38];
- if (items[39].Length > 0) weapons[wpn].Pellet_Spread_ADS = weapons[wpn].Pellet_Spread_HIP = Convert.ToDouble(items[39].Replace('.', ','));
- else weapons[wpn].Pellet_Spread_ADS = weapons[wpn].Pellet_Spread_HIP = 0;
- wpn++;
- }
- number_of_weapons = wpn;
- //removing empty items from array
- weapons = weapons.Where(c => c != null).ToArray();
- //sorting array by weapon type
- Array.Sort(weapons, (x, y) => x.Type.CompareTo(y.Type));
- }
- int FireMode(string FM)
- {
- if (FM == "Semi-Auto" || FM == "Charge" || FM == "Single Shot") return 1;
- if (FM == "Auto / Semi-Auto" || FM == "Auto" || FM == "Auto / 3x Burst / Semi-Auto" || FM == "Auto / 2x Burst / Semi-Auto" || FM == "2x Burst / Auto / Semi-Auto" || FM == "Auto / Semi-Auto / 3x Burst") return 0;
- if (FM == "2x Burst / Semi-Auto" || FM == "Semi-Auto / 2x Burst" || FM == "Charge / 2x Burst") return 2;
- if (FM == "Semi-Auto / 3x Burst" || FM == "3x Burst / Semi-Auto" || FM == "Semi-Auto / 3x Burst / 2x Burst") return 3;
- if (FM == "Pump-Action") return -1;
- if (FM == "Bolt Action") return -2;
- return 0;
- }
- }
- static class Program
- {
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainWindow());
- }
- }
Add Comment
Please, Sign In to add comment