Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.35 KB | None | 0 0
  1. #region shoot
  2.         public void Shoot()
  3.         {
  4.             bool CanShoot = false;
  5.  
  6.             if (Session.GetHabbo().CurrentWeapon.WeaponType.ToLower() == "gun" || Session.GetHabbo().CurrentWeapon.WeaponType.ToLower() == "projectile")
  7.                 CanShoot = true;
  8.  
  9.             if (Session.GetHabbo().CurrentWeapon != null && CanShoot)
  10.             {
  11.                 string Username = Params[1];
  12.                 string DeathMessage = String.Empty;
  13.                 List<GameClient> ToSplashDamage = new List<GameClient>();
  14.  
  15.                 if (!String.IsNullOrEmpty(Username) || Username != null)
  16.                 {
  17.                     Room Room = Session.GetHabbo().CurrentRoom;
  18.                     RoomUser Me = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username);
  19.                     RoomUser Rival = Room.GetRoomUserManager().GetRoomUserByHabbo(Username);
  20.  
  21.                     if (Me.IsTazed)
  22.                         return;
  23.  
  24.                     if (Username.ToLower() == Session.GetHabbo().Username.ToLower())
  25.                     {
  26.                         return;
  27.                     }
  28.  
  29.                     if (Room.Description.Contains("HIT_DISABLED") && Session.GetHabbo().Rank < 10)
  30.                     {
  31.                         if (!Rival.GetClient().GetHabbo().IsZombie)
  32.                         {
  33.                             Session.SendNotif("Fighting has been disabled in this room.");
  34.                             return;
  35.                         }
  36.                         else if (!ButterflyEnvironment.ZombieInfectionMode && Rival.GetClient().GetHabbo().IsZombie)
  37.                         {
  38.                             Rival.GetClient().GetHabbo().IsZombie = false;
  39.                         }
  40.                         else if (Rival.GetClient().GetHabbo().IsWorking)
  41.                         {
  42.                             Session.SendNotif("Fighting has been disabled in this room.");
  43.                             return;
  44.                         }
  45.                     }
  46.  
  47.                     if (Session.GetHabbo().CurrentWeapon.AmmoLoaded < 1)
  48.                     {
  49.                         Me.ForceWhisper(Session, "You are out of ammo for this weapon! You must :reload before you can use it again!");
  50.                         return;
  51.                     }
  52.  
  53.                     if (Rival != null && Me != null)
  54.                     {
  55.                         int WeaponRange = Session.GetHabbo().CurrentWeapon.WeaponRange;
  56.                         int MaxDamage = Session.GetHabbo().CurrentWeapon.MaxDamage;
  57.  
  58.                         if (Session.GetHabbo().CurrentWeapon.HasFmj)
  59.                         {
  60.                             MaxDamage += 60;
  61.                         }
  62.  
  63.                         if (Session.GetHabbo().CurrentWeapon.HasRedDot)
  64.                         {
  65.                             WeaponRange += 6;
  66.                         }
  67.  
  68.                         if (Rival.GetClient().GetHabbo().IsAfk)
  69.                         {
  70.                             Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username).ForceWhisper(Session, "You cannot shoot users who are afk!");
  71.                             return;
  72.                         }
  73.  
  74.                         if (Rival.GetClient().GetHabbo().HitPoints > Rival.GetClient().GetHabbo().MaxHitPoints)
  75.                         {
  76.                             Rival.GetClient().GetHabbo().HitPoints = Rival.GetClient().GetHabbo().MaxHitPoints;
  77.                         }
  78.  
  79.                         if(Rival.GetClient().GetHabbo().CurrentRoomId == Session.GetHabbo().CurrentRoomId && Session.GetHabbo().CanReachUser(Rival, WeaponRange))
  80.                         {
  81.                             Random rand = new Random();
  82.                             int WillHit = rand.Next(1, MaxDamage);
  83.  
  84.                             TimeSpan Span = DateTime.Now - Session.GetHabbo().LastShotAt;
  85.  
  86.                             int CoolDown = Session.GetHabbo().CocaineEffects ? 2 : 4;
  87.  
  88.                             if (Span.Seconds <= CoolDown && Session.GetHabbo().ShootCounter >= 1)
  89.                             {
  90.                                 Me.ForceWhisper(Session, "*Cooling down (" + Span.Seconds + "/" + CoolDown + ")*");
  91.                                 return;
  92.                             }
  93.                             else
  94.                             {
  95.                                 Session.GetHabbo().ShootCounter = 0;
  96.                             }
  97.  
  98.                             int NewHealth = Rival.GetClient().GetHabbo().HitPoints - WillHit;
  99.  
  100.                             if (WillHit > 0)
  101.                             {
  102.                                 int Chance = rand.Next(1, 20);
  103.                                 bool Bypass = true;
  104.                                 double AgilChance = Convert.ToDouble(Rival.GetClient().GetHabbo().AgilityHitChance);
  105.                                 int FinalChance = Rival.GetClient().GetHabbo().AgilityHitChance;
  106.  
  107.                                 if (Session.GetHabbo().HasMDMAEffects && Rival.GetClient().GetHabbo().AgilityLevel > 1)
  108.                                 {
  109.                                     AgilChance = AgilChance / 2;
  110.                                     FinalChance += Convert.ToInt32(Math.Round(AgilChance, 0, MidpointRounding.AwayFromZero));
  111.                                 }
  112.  
  113.                                 if (Session.GetHabbo().CurrentWeapon.WeaponType.ToLower() == "projectile")
  114.                                 {
  115.                                     ToSplashDamage = Rival.GetClient().GetHabbo().GetUsersInRadius(Session.GetHabbo().CurrentWeapon.WeaponRadius);
  116.                                 }
  117.  
  118.                                 if (Chance > FinalChance)
  119.                                     Bypass = false;
  120.  
  121.                                 if (Session.GetHabbo().CurrentWeapon.WeaponName.ToLower() == "the force")
  122.                                     Bypass = true;
  123.  
  124.                                 if (!Bypass)
  125.                                 {
  126.                                     Session.GetHabbo().CurrentWeapon.AmmoLoaded -= 1;
  127.                                     Me.Chat(Session, "*Shoots their " + Session.GetHabbo().CurrentWeapon.WeaponName + " at " + Rival.GetClient().GetHabbo().Username + ", but " + Rival.GetClient().GetHabbo().Username + " dodged it*", true, true);
  128.                                     Session.GetHabbo().LastShotAt = DateTime.Now;
  129.                                     Session.GetHabbo().ShootCounter = Session.GetHabbo().ShootCounter + 1;
  130.                                     return;
  131.                                 }
  132.  
  133.                                 if (NewHealth > 0)
  134.                                 {
  135.                                     Me.Chat(Session, "*Shoots their " + Session.GetHabbo().CurrentWeapon.WeaponName + " at " + Rival.GetClient().GetHabbo().Username + ", hitting them for " + WillHit.ToString() + " damage. (" + NewHealth.ToString() + "/" + Rival.GetClient().GetHabbo().MaxHitPoints.ToString() + ")*", true, true);
  136.                                     Rival.GetClient().GetHabbo().HitPoints = NewHealth;
  137.  
  138.                                     Logging.WriteLine("[Combat] " + Session.GetHabbo().Username + " has hit " + Rival.GetClient().GetHabbo().Username + " for " + WillHit.ToString() + " damage");
  139.                                 }
  140.                                 else
  141.                                 {
  142.                                     Me.Chat(Session, "*Shoots their " + Session.GetHabbo().CurrentWeapon.WeaponName + " at " + Rival.GetClient().GetHabbo().Username + ", killing them*", true, true);
  143.  
  144.                                     Session.GetHabbo().KillCount = Session.GetHabbo().KillCount + 1;
  145.  
  146.                                     if (Rival.GetClient().GetHabbo().IsWorkingOut)
  147.                                     {
  148.                                         Rival.GetClient().GetHabbo().StopWorkoutTimer(false);
  149.                                     }
  150.  
  151.                                     if (Rival.GetClient().GetHabbo().Credits > 1 && !Rival.GetClient().GetHabbo().IsZombie)
  152.                                     {
  153.                                         int MaxTake = Rival.GetClient().GetHabbo().Credits;
  154.                                         int MyTake = rand.Next(1, Rival.GetClient().GetHabbo().Credits - 1);
  155.  
  156.                                         Session.GetHabbo().Credits = Session.GetHabbo().Credits + MyTake;
  157.                                         Session.GetHabbo().UpdateCreditsBalance();
  158.  
  159.                                         Rival.GetClient().GetHabbo().Credits = Rival.GetClient().GetHabbo().Credits - MyTake;
  160.                                         Rival.GetClient().GetHabbo().UpdateCreditsBalance();
  161.  
  162.                                         Me.Chat(Session, "*Has picked up $" + MyTake.ToString() + " from " + Rival.GetClient().GetHabbo().Username + "'s dead body*", true);
  163.                                         DeathMessage = "You have been killed by " + Session.GetHabbo().Username + " and transported to hospital. You must wait 2 minutes to heal fully.\rYou lost $" + MyTake.ToString() + " on death. Remember to utilise your bank account!";
  164.                                     }
  165.                                     else
  166.                                     {
  167.                                         DeathMessage = "You have been killed by " + Session.GetHabbo().Username + " and transported to hospital. You must wait 2 minutes to heal fully.";
  168.                                     }
  169.  
  170.                                     Rival.GetClient().GetHabbo().IsSmokingWeed = false;
  171.  
  172.                                     int BountyAmount = 0;
  173.                                     if (ButterflyEnvironment.Bounties.TryGetValue(Rival.GetClient(), out BountyAmount) && !ButterflyEnvironment.ZombieInfectionMode)
  174.                                     {
  175.                                         Session.GetHabbo().Credits += BountyAmount;
  176.                                         Session.GetHabbo().UpdateCreditsBalance();
  177.                          
  178.                                         ServerMessage HotelAlert = new ServerMessage(808);
  179.                                         HotelAlert.AppendStringWithBreak("Message from the Agency");
  180.                                         HotelAlert.AppendStringWithBreak("The bounty placed on " + Rival.GetClient().GetHabbo().Username + " for $" + BountyAmount + " has been collected by " + Session.GetHabbo().Username);
  181.                                         ButterflyEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(HotelAlert);
  182.  
  183.                                         ButterflyEnvironment.Bounties.Remove(Rival.GetClient());
  184.  
  185.                                         Logging.WriteLine("[Bounty] The bounty on " + Rival.GetClient().GetHabbo().Username + " has been collected by " + Session.GetHabbo().Username);
  186.                                     }
  187.  
  188.                                     Rival.GetClient().GetHabbo().HitPoints = 0;
  189.                                     Rival.GetClient().GetHabbo().GotKilledAt = DateTime.Now;
  190.                                     Rival.GetClient().GetHabbo().JustGotKilled = true;
  191.                                     Rival.GetClient().GetHabbo().UserDead = true;
  192.                                     Rival.GetClient().SendNotif(DeathMessage);
  193.                                     Rival.GetClient().GetHabbo().CanTravel = true;
  194.                                     Rival.GetClient().GetMessageHandler().PrepareRoomForUser(ButterflyEnvironment.HospitalRoomId, String.Empty);
  195.  
  196.                                     Logging.WriteLine("[Combat] " + Session.GetHabbo().Username + " has killed " + Rival.GetClient().GetHabbo().Username);
  197.                                 }
  198.  
  199.                                 Session.GetHabbo().CurrentWeapon.AmmoLoaded -= 1;
  200.  
  201.                                 Session.GetHabbo().LastShotAt = DateTime.Now;
  202.                                 Session.GetHabbo().ShootCounter = Session.GetHabbo().ShootCounter + 1;
  203.  
  204.                                 if (Session.GetHabbo().CurrentWeapon.WeaponType.ToLower() == "projectile" && ToSplashDamage.Count > 0)
  205.                                 {
  206.                                     foreach (GameClient Cli in ToSplashDamage)
  207.                                     {
  208.                                         if (Cli == null || Cli == Session || Cli.GetHabbo().IsAfk)
  209.                                             continue;
  210.  
  211.                                         int SplashDamageHit = rand.Next(1, WillHit);
  212.  
  213.                                         if (Cli.GetHabbo().HitPoints - SplashDamageHit < 1)
  214.                                         {
  215.                                             Cli.GetHabbo().IsSmokingWeed = false;
  216.                                             Cli.GetHabbo().GotKilledAt = DateTime.Now;
  217.                                             Cli.GetHabbo().JustGotKilled = true;
  218.                                             Cli.GetHabbo().UserDead = true;
  219.                                             Cli.GetHabbo().CanTravel = true;
  220.                                             Cli.SendNotif("You were killed by an explosive fired by " + Session.GetHabbo().Username + ".\rYou have not lost any money.");
  221.                                             Cli.GetMessageHandler().PrepareRoomForUser(ButterflyEnvironment.HospitalRoomId, String.Empty);
  222.  
  223.                                             Logging.WriteLine("[Combat] " + Cli.GetHabbo().Username + " has been killed due to splash damage");
  224.                                         }
  225.                                         else
  226.                                         {
  227.                                             Cli.GetHabbo().HitPoints -= SplashDamageHit;
  228.                                             Cli.GetHabbo().Shout("*Has been hit by an explosion, causing " + SplashDamageHit.ToString() + " damage (" + Cli.GetHabbo().HitPoints.ToString() + "/" + Cli.GetHabbo().MaxHitPoints + ")*", true);
  229.  
  230.                                             Logging.WriteLine("[Combat] " + Cli.GetHabbo().Username + " has been hit for " + SplashDamageHit.ToString() + " health by splash damage");
  231.                                         }
  232.                                     }
  233.                                 }
  234.                             }
  235.                         }
  236.                     }
  237.                 }
  238.             }
  239.         }
  240.         #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement