Ejemplo n.º 1
0
        public static void Use(Client client, Client target)
        {
            Account            account    = client.GetData(EntityData.Account);
            LevelRanks         ranks      = account.GetLevelRanks();
            LevelRankCooldowns cooldowns  = AccountUtil.GetCooldowns(client);
            string             itemToBurn = "Medkit";

            if (client.Position.DistanceTo2D(target.Position) > 5)
            {
                return;
            }

            if (account.IsDead)
            {
                return;
            }

            // They don't have Medicine.
            if (ranks.Medicine <= 0)
            {
                return;
            }

            if (!cooldowns.IsMedicineReady)
            {
                return;
            }

            if (!account.Inventory.ToLower().Contains(itemToBurn.ToLower()))
            {
                client.SendChatMessage("~r~You don't have a Medkit to heal the other player.");
                return;
            }

            bool didItBurn = InventoryHandler.BurnItemFromInventory(client, itemToBurn);

            if (!didItBurn)
            {
                return;
            }

            cooldowns.IsMedicineReady = false;
            cooldowns.NotifyClientsideOfChange(client);

            int healAmount = 25 + ranks.Medicine * 2;

            if (healAmount + target.Health > 100)
            {
                target.Health = 100;
            }
            else
            {
                target.Health += healAmount;
            }

            Account targetAccount = target.GetData(EntityData.Account);

            targetAccount.SetPlayerRevived(target);
            target.StopAnimation();
            Account.PlayerUpdateEvent.Trigger(target, targetAccount);

            client.SendNotification($"You ~g~healed~w~ {target.Name} for {healAmount} Health.");
            target.SendNotification($"{client.Name} ~g~healed~w~ you for {healAmount} Health.");
        }