mirror of
https://gitee.com/cssfw/EasyTools.git
synced 2026-03-28 03:51:36 +08:00
feat: SCP站立回血机制
This commit is contained in:
@@ -85,5 +85,20 @@ namespace EasyTools.Configs
|
|||||||
|
|
||||||
[Description("Is 1853 harmless? / 是否开启1853(洗手液)无害?")]
|
[Description("Is 1853 harmless? / 是否开启1853(洗手液)无害?")]
|
||||||
public bool harmless_1853 { get; set; } = true;
|
public bool harmless_1853 { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
|
/// /////////////////////////////////////////////////
|
||||||
|
[Description("SCP静止回血?")]
|
||||||
|
public bool heal_scp { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
|
[Description("等待多少秒后持续回血")]
|
||||||
|
public float heal_scp_secend { get; set; } = 6;
|
||||||
|
|
||||||
|
[Description("受伤检测")]
|
||||||
|
public float heal_atk_secend { get; set; } = 2;
|
||||||
|
|
||||||
|
[Description("回血量")]
|
||||||
|
public int heal_scp_x { get; set; } = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@
|
|||||||
<Compile Include="Utils\Ini.cs" />
|
<Compile Include="Utils\Ini.cs" />
|
||||||
<Compile Include="Utils\Pool\IPool.cs" />
|
<Compile Include="Utils\Pool\IPool.cs" />
|
||||||
<Compile Include="Utils\Pool\StringBuilderPool.cs" />
|
<Compile Include="Utils\Pool\StringBuilderPool.cs" />
|
||||||
|
<Compile Include="Utils\ScpReal.cs" />
|
||||||
<Compile Include="Utils\Util.cs" />
|
<Compile Include="Utils\Util.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ namespace EasyTools.Events
|
|||||||
{
|
{
|
||||||
Timing.RunCoroutine(Util.AutoServerBroadcast());
|
Timing.RunCoroutine(Util.AutoServerBroadcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.heal_scp)
|
||||||
|
{
|
||||||
|
Timing.RunCoroutine(ScpReal.AutoReal());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
78
Utils/ScpReal.cs
Normal file
78
Utils/ScpReal.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using CustomPlayerEffects;
|
||||||
|
using EasyTools.Events;
|
||||||
|
using LabApi.Features.Wrappers;
|
||||||
|
using MEC;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace EasyTools.Utils
|
||||||
|
{
|
||||||
|
public class ScpReal
|
||||||
|
{
|
||||||
|
|
||||||
|
private static readonly Dictionary<Player, (Vector3 pos, DateTime time)> _lastMove = [];
|
||||||
|
|
||||||
|
private static readonly Dictionary<Player, float> _lastHealth = [];
|
||||||
|
private static readonly Dictionary<Player, DateTime> _lastDamageTime = [];
|
||||||
|
|
||||||
|
public static IEnumerator<float> AutoReal()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (Round.IsRoundEnded || !Round.IsRoundStarted)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Player p in Player.ReadyList)
|
||||||
|
{
|
||||||
|
if (p.IsSCP)
|
||||||
|
{
|
||||||
|
|
||||||
|
// 先检测玩家是否正在受到伤害
|
||||||
|
if (_lastHealth.TryGetValue(p, out var lastHealth))
|
||||||
|
{
|
||||||
|
if (p.Health < lastHealth)
|
||||||
|
{
|
||||||
|
_lastDamageTime[p] = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastHealth[p] = lastHealth;
|
||||||
|
|
||||||
|
Vector3 pos = p.Position;
|
||||||
|
if(_lastMove.TryGetValue(p,out var last))
|
||||||
|
{
|
||||||
|
if (Vector3.Distance(pos,last.pos) < 0.1f)
|
||||||
|
{
|
||||||
|
|
||||||
|
bool canceled = false;
|
||||||
|
// 检测是否正在受伤
|
||||||
|
if (_lastDamageTime.TryGetValue(p,out var lastDamageTime))
|
||||||
|
{
|
||||||
|
if (DateTime.UtcNow - lastDamageTime < TimeSpan.FromSeconds(CustomEventHandler.Config.heal_atk_secend)) { canceled = true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!canceled && DateTime.UtcNow - last.time > TimeSpan.FromSeconds(CustomEventHandler.Config.heal_scp_secend))
|
||||||
|
{
|
||||||
|
float old_health = p.Health;
|
||||||
|
float new_health = old_health + CustomEventHandler.Config.heal_scp_x;
|
||||||
|
if (new_health <= p.MaxHealth)
|
||||||
|
{
|
||||||
|
p.Health = new_health;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { _lastMove[p] = (pos, DateTime.UtcNow); }
|
||||||
|
}else { _lastMove[p] = (pos, DateTime.UtcNow); }
|
||||||
|
}else if (_lastMove.ContainsKey(p)) { _lastMove.Remove(p); }
|
||||||
|
}
|
||||||
|
yield return Timing.WaitForSeconds(1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user