(1.5.3) Major KillFeed Tweaks/Fix
This commit is contained in:
@@ -2,8 +2,10 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Diagnostics;
|
using UnityEngine.Diagnostics;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -25,6 +27,7 @@ namespace MxValheim.KillFeed
|
|||||||
{
|
{
|
||||||
ZNet zn = new ZNet();
|
ZNet zn = new ZNet();
|
||||||
if (zn.IsDedicated()) return;
|
if (zn.IsDedicated()) return;
|
||||||
|
if (attacker == "The World") return;
|
||||||
|
|
||||||
float distance = (encodedType / 1000) / 10.0f;
|
float distance = (encodedType / 1000) / 10.0f;
|
||||||
int remainder = encodedType % 1000;
|
int remainder = encodedType % 1000;
|
||||||
@@ -42,11 +45,48 @@ namespace MxValheim.KillFeed
|
|||||||
if (c != null) localizedVictim = c.m_name;
|
if (c != null) localizedVictim = c.m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker == "The World") return;
|
// Message Format Variables
|
||||||
|
string type1Separator = " a été tué par ";
|
||||||
|
string type2Separator = " a tué ";
|
||||||
|
string finalMsg = "";
|
||||||
|
string attackerFormat = "";
|
||||||
|
string victimFormat = "";
|
||||||
|
string distanceFormat = "";
|
||||||
|
string starFormat = "";
|
||||||
|
// Format Message in Divided Section
|
||||||
|
starFormat = "<color=#fffb00>★</color>";
|
||||||
|
attackerFormat = $"<color=#00ff06>{attacker.ToUpper()}</color>";
|
||||||
|
if(type == 1)
|
||||||
|
{
|
||||||
|
victimFormat = $"<color=#00ff06>{victim.ToUpper()}</color>";
|
||||||
|
} else if(type == 2)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
victimFormat = $"<color=#00ff06>{victim.ToUpper()}</color>";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
victimFormat = $"{starFormat} <color=#00ff06>{victim.ToUpper()}</color>";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
victimFormat = $"{starFormat}{starFormat} <color=#00ff06>{victim.ToUpper()}</color>";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
victimFormat = $"{starFormat}{starFormat}{starFormat} <color=#00ff06>{victim.ToUpper()}</color>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
distanceFormat = $" à <color=#9402f5>{distance:F1}m</color> de distance.";
|
||||||
|
|
||||||
string finalMsg = (type == 1) ? $"<color=#FF3333>☠</color> <color=#00ff06>{victim.ToUpper()}</color> a été tué par <color=#ff0000>{attacker.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance." :
|
finalMsg =
|
||||||
|
(type == 1) ? $"{victimFormat}{type1Separator}{attackerFormat}{distanceFormat}":
|
||||||
|
(type == 2) ? $"{attackerFormat}{type2Separator}{victimFormat}{distanceFormat}" :
|
||||||
|
$"{attackerFormat}{type2Separator}{victimFormat}{distanceFormat}";
|
||||||
|
|
||||||
|
/*string finalMsg = (type == 1) ? $"<color=#FF3333>☠</color> <color=#00ff06>{victim.ToUpper()}</color> a été tué par <color=#ff0000>{attacker.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance." :
|
||||||
(type == 2) ? $"<color=#00ff06>{attacker.ToUpper()}</color> a tué <color=#00c0ff>{victim.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance." :
|
(type == 2) ? $"<color=#00ff06>{attacker.ToUpper()}</color> a tué <color=#00c0ff>{victim.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance." :
|
||||||
$"<color=#00ff06>{attacker.ToUpper()}</color> a tué <color=#00c0ff>{victim.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance.";
|
$"<color=#00ff06>{attacker.ToUpper()}</color> a tué <color=#00c0ff>{victim.ToUpper()}</color> à <color=#9402f5>{distance:F1}m</color> de distance.";*/
|
||||||
|
|
||||||
Sprite weaponIcon = null;
|
Sprite weaponIcon = null;
|
||||||
|
|
||||||
@@ -137,7 +177,8 @@ namespace MxValheim.KillFeed
|
|||||||
|
|
||||||
// List of common trophies that don't follow the exact pattern if needed
|
// List of common trophies that don't follow the exact pattern if needed
|
||||||
// But for most (Boar, Greyling, Neck, Deer), this works:
|
// But for most (Boar, Greyling, Neck, Deer), this works:
|
||||||
string trophyName = "Trophy" + cleanName;
|
string replace = cleanName.Replace("_","");
|
||||||
|
string trophyName = "Trophy" + replace;
|
||||||
|
|
||||||
GameObject trophyObj = ObjectDB.instance.GetItemPrefab(trophyName);
|
GameObject trophyObj = ObjectDB.instance.GetItemPrefab(trophyName);
|
||||||
if (trophyObj != null)
|
if (trophyObj != null)
|
||||||
@@ -349,6 +390,7 @@ namespace MxValheim.KillFeed
|
|||||||
_killText.supportRichText = true;
|
_killText.supportRichText = true;
|
||||||
_killText.color = Color.white;
|
_killText.color = Color.white;
|
||||||
|
|
||||||
|
|
||||||
// 4. Victim Portrait Slot
|
// 4. Victim Portrait Slot
|
||||||
GameObject victimObj = new GameObject("VictimIcon", typeof(RectTransform), typeof(Image));
|
GameObject victimObj = new GameObject("VictimIcon", typeof(RectTransform), typeof(Image));
|
||||||
victimObj.transform.SetParent(panel.transform, false);
|
victimObj.transform.SetParent(panel.transform, false);
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ using Newtonsoft.Json;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ public class MxValheimMod : BaseUnityPlugin
|
|||||||
|
|
||||||
private const string ModGUID = "ovh.mxdev.mxvalheim";
|
private const string ModGUID = "ovh.mxdev.mxvalheim";
|
||||||
private const string ModName = "MxValheim";
|
private const string ModName = "MxValheim";
|
||||||
private const string ModVersion = "1.5.2";
|
private const string ModVersion = "1.5.3";
|
||||||
|
|
||||||
public static ConfigEntry<bool> Config_Locked;
|
public static ConfigEntry<bool> Config_Locked;
|
||||||
public static ConfigEntry<int> Config_OreMultiplier;
|
public static ConfigEntry<int> Config_OreMultiplier;
|
||||||
@@ -77,6 +79,45 @@ public class MxValheimMod : BaseUnityPlugin
|
|||||||
harmony.PatchAll();
|
harmony.PatchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- TEST COMMAND: Type 'testkill' in F5 console ---
|
||||||
|
[HarmonyPatch(typeof(Terminal), nameof(Terminal.InputText))]
|
||||||
|
public static class ConsoleInputPatch
|
||||||
|
{
|
||||||
|
static void Postfix(Terminal __instance)
|
||||||
|
{
|
||||||
|
string text = __instance.m_input.text;
|
||||||
|
if (text.ToLower() == "listiconsstore")
|
||||||
|
{
|
||||||
|
var spriteAsset = Resources.FindObjectsOfTypeAll<TMP_SpriteAsset>().FirstOrDefault(x => x.name == "store_icons"); ;
|
||||||
|
|
||||||
|
if (spriteAsset != null)
|
||||||
|
{
|
||||||
|
Debug.Log($"--- Listing all sprites in {spriteAsset.name} ---");
|
||||||
|
for (int i = 0; i < spriteAsset.spriteCharacterTable.Count; i++)
|
||||||
|
{
|
||||||
|
var sprite = spriteAsset.spriteCharacterTable[i];
|
||||||
|
Debug.Log($"Index: {i} | Name: {sprite.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text.ToLower() == "listicons")
|
||||||
|
{
|
||||||
|
var spriteAsset = Resources.FindObjectsOfTypeAll<TMP_SpriteAsset>().FirstOrDefault(x => x.name == "icons"); ;
|
||||||
|
|
||||||
|
if (spriteAsset != null)
|
||||||
|
{
|
||||||
|
Debug.Log($"--- Listing all sprites in {spriteAsset.name} ---");
|
||||||
|
for (int i = 0; i < spriteAsset.spriteCharacterTable.Count; i++)
|
||||||
|
{
|
||||||
|
var sprite = spriteAsset.spriteCharacterTable[i];
|
||||||
|
Debug.Log($"Index: {i} | Name: {sprite.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Game), nameof(Game.Start))]
|
[HarmonyPatch(typeof(Game), nameof(Game.Start))]
|
||||||
public static class GameStartPatch
|
public static class GameStartPatch
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user