Add execute mechanic to Vampiric Aura and bump version to 1.3.5

This commit is contained in:
Ferdinando 2026-07-31 08:49:55 +02:00
commit c580871a2d
6 changed files with 140 additions and 1 deletions

View file

@ -48,6 +48,65 @@ namespace RacesOfValheim
}
}
[HarmonyPatch(typeof(MessageHud), "ShowMessage")]
public static class MessageHud_ShowMessage_Patch
{
private static System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<float>> messageTimestamps = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<float>>();
private static System.Collections.Generic.Dictionary<string, float> messageBans = new System.Collections.Generic.Dictionary<string, float>();
public static bool Prefix(MessageHud __instance, MessageHud.MessageType type, string text)
{
if (Player.m_localPlayer != null && SkeletonRace.IsSkeleton())
{
if (string.IsNullOrEmpty(text)) return true;
// Exception for resting messages to never be filtered
string lowerText = text.ToLower();
if (text == "$se_resting_name" || text == "$se_resting" || lowerText.Contains("resting") || lowerText.Contains("riposo"))
{
return true;
}
float currentTime = Time.time;
// Check if message is currently banned (4 hours = 14400 seconds)
if (messageBans.TryGetValue(text, out float banTime))
{
if (currentTime - banTime < 14400f)
{
return false; // Still banned
}
else
{
messageBans.Remove(text); // Ban expired
if (messageTimestamps.ContainsKey(text))
{
messageTimestamps[text].Clear(); // Reset spam count
}
}
}
if (!messageTimestamps.ContainsKey(text))
{
messageTimestamps[text] = new System.Collections.Generic.List<float>();
}
// Remove timestamps older than 5 seconds
messageTimestamps[text].RemoveAll(t => currentTime - t > 5f);
if (messageTimestamps[text].Count >= 2)
{
// Trigger a 4-hour ban
messageBans[text] = currentTime;
return false;
}
messageTimestamps[text].Add(currentTime);
}
return true;
}
}
[HarmonyPatch(typeof(Player), "Message")]
public static class Player_Message_Patch
{