Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading;
  4. using Plus.HabboHotel.GameClients;
  5. using Plus.HabboRoleplay.Misc;
  6. using Plus.HabboHotel.Rooms;
  7. using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
  8. using Plus.HabboHotel.Quests;
  9. using System.Collections.Generic;
  10. using System.Drawing;
  11. using Plus.HabboHotel.Pathfinding;
  12. using Plus.Utilities;
  13. using Plus.HabboHotel.Users.Effects;
  14.  
  15. namespace Plus.HabboRoleplay.Events.Methods
  16. {
  17. /// <summary>
  18. /// Triggered when the user's health changes
  19. /// </summary>
  20. public class OnHealthChange : IEvent
  21. {
  22. /// <summary>
  23. /// Responds to the event
  24. /// </summary>
  25. public void Execute(object Source, object[] Params)
  26. {
  27. GameClient Client = (GameClient)Source;
  28. if (Client == null || Client.GetRoleplay() == null || Client.GetHabbo() == null)
  29. return;
  30.  
  31. if (Client.GetRoleplay().CurHealth <= 0 && !Client.GetRoleplay().IsJailed && !Client.GetRoleplay().IsDead)
  32. {
  33. Client.GetRoleplay().BeingHealed = false;
  34. Client.GetRoleplay().CloseInteractingUserDialogues();
  35. Client.GetRoleplay().ClearWebSocketDialogue(true);
  36.  
  37. if (Client.GetRoleplay().Game != null)
  38. EventDeath(Client);
  39. else
  40. NormalDeath(Client);
  41. return;
  42. }
  43. else
  44. Client.GetRoleplay().UpdateInteractingUserDialogues();
  45.  
  46. Client.GetRoleplay().RefreshStatDialogue();
  47.  
  48. if (Client.GetRoleplay().BeingHealed || Client.GetRoleplay().CurHealth <= 0 || Client.GetRoleplay().CurHealth >= Client.GetRoleplay().MaxHealth)
  49. return;
  50.  
  51. if (Client.GetRoleplay().Hunger >= 100 && Client.GetRoleplay().TimerManager.ActiveTimers.ContainsKey("hunger"))
  52. {
  53. int TimeCount = Client.GetRoleplay().TimerManager.ActiveTimers["hunger"].TimeCount;
  54.  
  55. if (TimeCount == 0)
  56. Client.SendWhisper("Su vida ahora es de [" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]! Será mejor que comas algo antes de morir de hambre!", 1);
  57. else
  58. RoleplayManager.Shout(Client, "*[" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]*", 3);
  59. }
  60. else
  61. RoleplayManager.Shout(Client, "*[" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]*", 3);
  62. }
  63.  
  64. /// <summary>
  65. /// Kills the user normally, sends them to the hospital
  66. /// </summary>
  67. /// <param name="Client"></param>
  68. private void NormalDeath(GameClient Client)
  69. {
  70. RoleplayManager.Shout(Client, "*Se cae al suelo y se muere*", 32);
  71.  
  72. if (Client.GetRoomUser() != null)
  73. Client.GetRoomUser().ApplyEffect(0);
  74.  
  75. #region Lays User Down
  76. if (Client.GetRoomUser() != null)
  77. {
  78. var User = Client.GetRoomUser();
  79.  
  80. if (User.isLying)
  81. {
  82. User.RemoveStatus("lay");
  83. User.isLying = false;
  84. }
  85.  
  86. if (User.isSitting)
  87. {
  88. User.RemoveStatus("sit");
  89. User.isSitting = false;
  90. }
  91.  
  92. if ((User.RotBody % 2) == 0)
  93. {
  94. if (User == null)
  95. return;
  96.  
  97. try
  98. {
  99. User.Statusses.Add("lay", "1.0 null");
  100. User.Z -= 0.35;
  101. User.isLying = true;
  102. User.UpdateNeeded = true;
  103. }
  104. catch { }
  105. }
  106. else
  107. {
  108. User.RotBody--;
  109. User.Statusses.Add("lay", "1.0 null");
  110. User.Z -= 0.35;
  111. User.isLying = true;
  112. User.UpdateNeeded = true;
  113. }
  114. }
  115. #endregion
  116.  
  117. if (Client.GetRoleplay().IsWorking)
  118. {
  119. WorkManager.RemoveWorkerFromList(Client);
  120. Client.GetRoleplay().IsWorking = false;
  121. }
  122.  
  123. Client.GetRoleplay().IsDead = true;
  124. Client.GetRoleplay().DeadTimeLeft = RoleplayManager.DeathTime;
  125.  
  126. if (Client.GetRoleplay() != null && Client.GetRoleplay().TimerManager != null && Client.GetRoleplay().TimerManager.ActiveTimers != null)
  127. {
  128. if (Client.GetRoleplay().TimerManager.ActiveTimers.ContainsKey("death"))
  129. Client.GetRoleplay().TimerManager.ActiveTimers["death"].EndTimer();
  130. Client.GetRoleplay().TimerManager.CreateTimer("death", 1000, true);
  131. }
  132.  
  133. PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, QuestType.DEATH);
  134.  
  135. int HospitalRID = Convert.ToInt32(RoleplayData.GetData("hospital", "roomid2"));
  136. RoomData roomData = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(HospitalRID);
  137.  
  138. if (Client != null && Client.GetHabbo() != null)
  139. {
  140. if (Client.GetHabbo().CurrentRoomId == HospitalRID)
  141. {
  142. RoleplayManager.GetLookAndMotto(Client);
  143. RoleplayManager.SpawnBeds(Client, "hosptl_bed");
  144. Client.SendMessage(new RoomNotificationComposer("room_death_axe", "message", "¡Usted murió! Usted está siendo transportado al hospital."));
  145. }
  146. else
  147. {
  148. Client.SendMessage(new RoomNotificationComposer("room_death_axe", "message", "¡Usted murió! Usted está siendo transportado al hospital."));
  149. RoleplayManager.SendUser(Client, HospitalRID);
  150. }
  151. }
  152. }
  153.  
  154. /// <summary>
  155. /// Kills the user normally, depends on the event mode
  156. /// </summary>
  157. /// <param name="Client"></param>
  158. private void EventDeath(GameClient Client)
  159. {
  160. if (Client.GetRoleplay().Game == null)
  161. NormalDeath(Client);
  162.  
  163. #region Brawl
  164. else if (Client.GetRoleplay().Game == Games.RoleplayGameManager.GetGame(Games.GameMode.Brawl))
  165. {
  166. Client.GetRoleplay().ReplenishStats();
  167.  
  168. RoleplayManager.Shout(Client, "*Se sale de la pelea*", 32);
  169. RoleplayManager.SpawnChairs(Client, "es_bench");
  170.  
  171. Client.SendMessage(new RoomNotificationComposer("room_kick_cannonball", "message", "You have been knocked out of the Brawl!"));
  172. Client.GetRoleplay().Game.RemovePlayerFromGame(Client);
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement