-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDamager.cs
37 lines (35 loc) · 1.22 KB
/
Damager.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
using Synapse.Api;
using System.Threading.Tasks;
namespace SCP008
{
public class Damager
{
public bool DamagePlayer { get; set; } = true;
public Damager(Player player)
{
player.GiveTextHint(PluginClass.Translation.ActiveTranslation.Infected);
var _ = DamagePlayerAsync(player);
}
private async Task DamagePlayerAsync(Player player)
{
while (DamagePlayer && player != null)
{
await Task.Delay(PluginClass.Config.DamageDelay);
if (!DamagePlayer || player == null) return;
int newHealth = (int) (player.Health - player.MaxHealth / 100 * PluginClass.Config.DamagePercent);
if (newHealth <= 0)
{
player.Inventory.DropAll();
player.ChangeRoleAtPosition(RoleType.Scp0492);
player.Health = player.MaxHealth;
player.GiveTextHint(PluginClass.Translation.ActiveTranslation.Zombification, 10);
DamagePlayer = false;
}
else
{
player.Health = newHealth;
}
}
}
}
}