PsyOps

WeaponTracker

Nov 14th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.45 KB | None | 0 0
  1.         // This checks if weapon will impact and how much damage it will inflict
  2.         public void RegisterShot(MakeSentinel Sent, PlayerPositionEvent p)
  3.         {
  4.             // used to check for impact
  5.             WeaponCalc newshot = new WeaponCalc();
  6.             string result = newshot.Configure(Sent.Info.HitRegion, p);
  7.  
  8.             // If thor change to lvl 4 bomb
  9.             // This makes it easier to calculate damage since thor prox is same as lvl4 bomb
  10.             if (p.Weapon.Type == WeaponTypes.Thor)
  11.             {
  12.                 p.Weapon.Type = WeaponTypes.ProxBomb;
  13.                 p.Weapon.Level = 3;
  14.             }
  15.  
  16.             // First check for direct hits
  17.             if (!result.Equals("~miss"))
  18.             {
  19.                 // storing time until impact
  20.                 double time2hit = newshot.timeHit(result);
  21.  
  22.                 // Bombs
  23.                 if (p.Weapon.Type.ToString().ToLower().Contains("bomb"))
  24.                     TargetHit(p.PlayerName, time2hit, Sent.Settings.BombDamage);
  25.                 // Bullets
  26.                 else
  27.                     TargetHit(p.PlayerName, time2hit, Sent.Settings.BulletDamage[p.Weapon.Level]);
  28.             }
  29.             // checks for the next 2 lvls out for prox - a cheap way to calculate prox
  30.             else if (p.Weapon.Type == WeaponTypes.ProxBomb)
  31.             {
  32.                 // a list of how far out bomb proximity is at each lvl
  33.                 ushort[] _BombProx = new ushort[4] { 53, 71, 89, 107 };
  34.                 // outer area between direct hit and outer proximity
  35.                 ushort range = (ushort)(_BombProx[p.Weapon.Level] / 2);
  36.                 // making the hit region a tad bigger for collision check
  37.                 ushort[] _NewHitRegion = new ushort[4] { (ushort)(Sent.Info.HitRegion[0] - range), (ushort)(Sent.Info.HitRegion[1] - range),
  38.                     (ushort)(Sent.Info.HitRegion[2] + range), (ushort)(Sent.Info.HitRegion[3] + range) };
  39.  
  40.                 // checking for impact
  41.                 result = newshot.Configure(_NewHitRegion, p);
  42.                 if (!result.Equals("~miss"))
  43.                 {
  44.                     // storing time until impact
  45.                     double time2hit = newshot.timeHit(result);
  46.                     // less damage at this proximity
  47.                     TargetHit(p.PlayerName, time2hit, (ushort)(Sent.Settings.BombDamage / 1.5));
  48.                     return;
  49.                 }
  50.                 // Final check in prox- most outer section
  51.                 else
  52.                 {
  53.                     range = _BombProx[p.Weapon.Level];
  54.                     // adjusting area for collision check
  55.                     _NewHitRegion = new ushort[4] { (ushort)(Sent.Info.HitRegion[0] - range), (ushort)(Sent.Info.HitRegion[1] - range),
  56.                     (ushort)(Sent.Info.HitRegion[2] + range), (ushort)(Sent.Info.HitRegion[3] + range) };
  57.                     // checking for impact
  58.                     result = newshot.Configure(_NewHitRegion, p);
  59.  
  60.                     if (!result.Equals("~miss"))
  61.                     {
  62.                         // storing time until impact
  63.                         double time2hit = newshot.timeHit(result);
  64.                         // we will deal 1/3rd the max damage of a bomb
  65.                         TargetHit(p.PlayerName, time2hit, (ushort)(Sent.Settings.BombDamage / 3));
  66.                         return;
  67.                     }
  68.                     return;
  69.                 }
  70.             }
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment