Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Threading;
- using Plus.HabboHotel.GameClients;
- using Plus.HabboRoleplay.Misc;
- using Plus.HabboHotel.Rooms;
- using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
- using Plus.HabboHotel.Quests;
- using System.Collections.Generic;
- using System.Drawing;
- using Plus.HabboHotel.Pathfinding;
- using Plus.Utilities;
- using Plus.HabboHotel.Users.Effects;
- namespace Plus.HabboRoleplay.Events.Methods
- {
- /// <summary>
- /// Triggered when the user's health changes
- /// </summary>
- public class OnHealthChange : IEvent
- {
- /// <summary>
- /// Responds to the event
- /// </summary>
- public void Execute(object Source, object[] Params)
- {
- GameClient Client = (GameClient)Source;
- if (Client == null || Client.GetRoleplay() == null || Client.GetHabbo() == null)
- return;
- if (Client.GetRoleplay().CurHealth <= 0 && !Client.GetRoleplay().IsJailed && !Client.GetRoleplay().IsDead)
- {
- Client.GetRoleplay().BeingHealed = false;
- Client.GetRoleplay().CloseInteractingUserDialogues();
- Client.GetRoleplay().ClearWebSocketDialogue(true);
- if (Client.GetRoleplay().Game != null)
- EventDeath(Client);
- else
- NormalDeath(Client);
- return;
- }
- else
- Client.GetRoleplay().UpdateInteractingUserDialogues();
- Client.GetRoleplay().RefreshStatDialogue();
- if (Client.GetRoleplay().BeingHealed || Client.GetRoleplay().CurHealth <= 0 || Client.GetRoleplay().CurHealth >= Client.GetRoleplay().MaxHealth)
- return;
- if (Client.GetRoleplay().Hunger >= 100 && Client.GetRoleplay().TimerManager.ActiveTimers.ContainsKey("hunger"))
- {
- int TimeCount = Client.GetRoleplay().TimerManager.ActiveTimers["hunger"].TimeCount;
- if (TimeCount == 0)
- Client.SendWhisper("Su vida ahora es de [" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]! Será mejor que comas algo antes de morir de hambre!", 1);
- else
- RoleplayManager.Shout(Client, "*[" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]*", 3);
- }
- else
- RoleplayManager.Shout(Client, "*[" + Client.GetRoleplay().CurHealth + "/" + Client.GetRoleplay().MaxHealth + "]*", 3);
- }
- /// <summary>
- /// Kills the user normally, sends them to the hospital
- /// </summary>
- /// <param name="Client"></param>
- private void NormalDeath(GameClient Client)
- {
- RoleplayManager.Shout(Client, "*Se cae al suelo y se muere*", 32);
- if (Client.GetRoomUser() != null)
- Client.GetRoomUser().ApplyEffect(0);
- #region Lays User Down
- if (Client.GetRoomUser() != null)
- {
- var User = Client.GetRoomUser();
- if (User.isLying)
- {
- User.RemoveStatus("lay");
- User.isLying = false;
- }
- if (User.isSitting)
- {
- User.RemoveStatus("sit");
- User.isSitting = false;
- }
- if ((User.RotBody % 2) == 0)
- {
- if (User == null)
- return;
- try
- {
- User.Statusses.Add("lay", "1.0 null");
- User.Z -= 0.35;
- User.isLying = true;
- User.UpdateNeeded = true;
- }
- catch { }
- }
- else
- {
- User.RotBody--;
- User.Statusses.Add("lay", "1.0 null");
- User.Z -= 0.35;
- User.isLying = true;
- User.UpdateNeeded = true;
- }
- }
- #endregion
- if (Client.GetRoleplay().IsWorking)
- {
- WorkManager.RemoveWorkerFromList(Client);
- Client.GetRoleplay().IsWorking = false;
- }
- Client.GetRoleplay().IsDead = true;
- Client.GetRoleplay().DeadTimeLeft = RoleplayManager.DeathTime;
- if (Client.GetRoleplay() != null && Client.GetRoleplay().TimerManager != null && Client.GetRoleplay().TimerManager.ActiveTimers != null)
- {
- if (Client.GetRoleplay().TimerManager.ActiveTimers.ContainsKey("death"))
- Client.GetRoleplay().TimerManager.ActiveTimers["death"].EndTimer();
- Client.GetRoleplay().TimerManager.CreateTimer("death", 1000, true);
- }
- PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, QuestType.DEATH);
- int HospitalRID = Convert.ToInt32(RoleplayData.GetData("hospital", "roomid2"));
- RoomData roomData = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(HospitalRID);
- if (Client != null && Client.GetHabbo() != null)
- {
- if (Client.GetHabbo().CurrentRoomId == HospitalRID)
- {
- RoleplayManager.GetLookAndMotto(Client);
- RoleplayManager.SpawnBeds(Client, "hosptl_bed");
- Client.SendMessage(new RoomNotificationComposer("room_death_axe", "message", "¡Usted murió! Usted está siendo transportado al hospital."));
- }
- else
- {
- Client.SendMessage(new RoomNotificationComposer("room_death_axe", "message", "¡Usted murió! Usted está siendo transportado al hospital."));
- RoleplayManager.SendUser(Client, HospitalRID);
- }
- }
- }
- /// <summary>
- /// Kills the user normally, depends on the event mode
- /// </summary>
- /// <param name="Client"></param>
- private void EventDeath(GameClient Client)
- {
- if (Client.GetRoleplay().Game == null)
- NormalDeath(Client);
- #region Brawl
- else if (Client.GetRoleplay().Game == Games.RoleplayGameManager.GetGame(Games.GameMode.Brawl))
- {
- Client.GetRoleplay().ReplenishStats();
- RoleplayManager.Shout(Client, "*Se sale de la pelea*", 32);
- RoleplayManager.SpawnChairs(Client, "es_bench");
- Client.SendMessage(new RoomNotificationComposer("room_kick_cannonball", "message", "You have been knocked out of the Brawl!"));
- Client.GetRoleplay().Game.RemovePlayerFromGame(Client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement