-
Notifications
You must be signed in to change notification settings - Fork 4
/
AutoHeal.cs
70 lines (53 loc) · 2.02 KB
/
AutoHeal.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using BrokeProtocol.Entities;
using BrokeProtocol.Utility;
using BrokeProtocol.Utility.Networking;
using BrokeProtocolClient.settings;
using BrokeProtocolClient.utils;
using ENet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrokeProtocolClient.modules.player
{
class AutoHeal : Module
{
public NumberSetting minHealth = new NumberSetting("Heal below", 50, 180, 90, 5);
public BooleanSetting whenInjured = new BooleanSetting("Only when injured", false);
float lastHealth;
public AutoHeal() : base(Categories.Player, "Auto Heal", "Automatically consumes healing items from your inventory")
{
addSetting(minHealth);
addSetting(whenInjured);
}
public override void onActivate()
{
}
public override void onDeactivate()
{
}
public override void onRender()
{
}
public override void onUpdate()
{
if (!getClient().ClManager.myPlayer) return;
if (lastHealth <= getClient().ClManager.myPlayer.health) return;
if (whenInjured.isEnabled() && !getClient().ClManager.myPlayer.injuries.Any()) return;
while (getClient().ClManager.myPlayer.health < minHealth.getValueFloat())
{
foreach (KeyValuePair<int, InventoryItem> itemSlot in getClient().ClManager.myPlayer.myItems)
{
if ((itemSlot.Value.item as ShConsumable).healthBoost <= 0) continue;
getClient().ClManager.SendToServer(PacketFlags.Reliable, SvPacket.Consume, new object[]
{
itemSlot.Key
});
break;
}
}
lastHealth = getClient().ClManager.myPlayer.health;
}
}
}