2 Commits

Author SHA1 Message Date
mikx
b6dec0efa6 (1.6.10) KillFeed missing info fix 2026-03-03 04:47:30 -05:00
mikx
19a6a2f62d (1.6.9) Major EventSystem Update (see release) 2026-03-01 00:36:07 -05:00
5 changed files with 133 additions and 50 deletions

View File

@@ -20,12 +20,14 @@ namespace MxValheim.EventSystem
Dictionary<int, float> biomeBase = new Dictionary<int, float>()
{
{ 1, 1.0f },
{ 2, 1.5f },
{ 8, 2.0f },
{ 8, 1.5f },
{ 2, 2.0f },
{ 4, 2.5f },
{ 16, 3.0f },
{ 256, 3.5f },
{ 32, 4.0f },
{ 512, 4.0f },
{ 64, 2.5f },
{ 32, 5.0f },
{ 256, 1.0f },
};
float rewardExpMulti = biomeBase[((int)biome)];

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
@@ -102,17 +103,18 @@ namespace MxValheim.EventSystem
Reward.GiveItemStatic("Coins", Reward.CalculateRewardCoin(Profiles.serverLevel, currentBiome, kill));
System.Random rand = new System.Random();
Reward.GiveItemStatic("Feathers", rand.Next(5, 20));
if (rand.Next(100) < 50)
float dayPercent = ((float)EnvMan.instance.GetDay() / 10);
if (rand.Next(100) < (50+dayPercent))
{
Reward.GiveItemRandom(Reward.GetRewardPrefab(Profiles.serverLevel, "food"), 1);
}
if (rand.Next(100) < 25)
if (rand.Next(100) < (25+dayPercent))
{
Reward.GiveItemRandom(Reward.GetRewardPrefab(Profiles.serverLevel, "heal"), 1);
}
if (rand.Next(100) < 10)
if (rand.Next(100) < (10+dayPercent))
{
Reward.GiveItemRandom(Reward.GetRewardPrefab(Profiles.serverLevel, "metal"), rand.Next(5, 20));
Reward.GiveItemRandom(Reward.GetRewardPrefab(Profiles.serverLevel, "metal"), rand.Next(5, (20+Profiles.serverLevel)));
}
if (Chainloader.PluginInfos.ContainsKey("randyknapp.mods.epicloot"))
{
@@ -168,35 +170,54 @@ namespace MxValheim.EventSystem
isEventCreature = Traverse.Create(mai).Field<bool>("m_eventCreature").Value;
}
if (!isEventCreature) return;
RandomEvent activeEvent = RandEventSystem.instance.GetActiveEvent();
if (activeEvent != null)
if (isEventCreature)
{
ZPackage pkg = new ZPackage();
pkg.Write(activeEvent.m_name);
pkg.Write($"{activeEvent.m_pos}");
ActiveEventData entry = MxValheimMod.ActiveEvents.Find(e => e.Position == activeEvent.m_pos.ToString());
if (entry == null)
RandomEvent activeEvent = RandEventSystem.instance.GetActiveEvent();
if (activeEvent != null)
{
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerRegisterEvent", pkg);
} else
{
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerSetEventKill", pkg);
ZPackage pkg = new ZPackage();
pkg.Write(activeEvent.m_name);
pkg.Write($"{activeEvent.m_pos}");
ActiveEventData entry = MxValheimMod.ActiveEvents.Find(e => e.Position == activeEvent.m_pos.ToString());
if (entry == null)
{
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerRegisterEvent", pkg);
}
else
{
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerSetEventKill", pkg);
}
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerGetEventKill", pkg);
}
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerGetEventKill", pkg);
}
int level = __instance.GetLevel();
int exp =
(level == 1) ? 2 :
(level == 2) ? 4 :
(level == 3) ? 6 :
6;
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_RequestProfile", "Event");
Heightmap.Biome currentBiome = EnvMan.instance.GetCurrentBiome();
int expFinal = ((int)(exp * Experience.CalculateExpMultiplier(currentBiome))) + Profiles.serverLevel;
Experience.AddExperience(expFinal);
int level = __instance.GetLevel();
int exp =
(level == 1) ? 4 :
(level == 2) ? 6 :
(level == 3) ? 8 :
8;
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_RequestProfile", "Event");
Heightmap.Biome currentBiome = EnvMan.instance.GetCurrentBiome();
int expFinal = ((int)(exp * Experience.CalculateExpMultiplier(currentBiome))) + Profiles.serverLevel;
Experience.AddExperience(expFinal);
Color magicPurple = new Color(0.921f, 0.475f, 0.990f);
Vector3 spawnPos = __instance.transform.position + Vector3.up * 1.0f;
DamageText.instance.ShowText(HitData.DamageModifier.Normal, spawnPos, expFinal, true);
} else
{
int level = __instance.GetLevel();
int exp =
(level == 1) ? 2 :
(level == 2) ? 4 :
(level == 3) ? 6 :
6;
Heightmap.Biome currentBiome = EnvMan.instance.GetCurrentBiome();
int expFinal = ((int)(exp * Experience.CalculateExpMultiplier(currentBiome))) + Profiles.serverLevel;
Experience.AddExperience(expFinal);
Color magicPurple = new Color(0.921f, 0.475f, 0.990f);
Vector3 spawnPos = __instance.transform.position + Vector3.up * 1.0f;
DamageText.instance.ShowText(HitData.DamageModifier.Normal, spawnPos, expFinal, true);
}
}
}
}

View File

@@ -1,10 +1,12 @@
using EpicLoot;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Navigation;
using UnityEngine;
namespace MxValheim.EventSystem
@@ -52,7 +54,7 @@ namespace MxValheim.EventSystem
int qty = rand.Next(1, Profiles.serverLevel);
string[] rarity = { "Rare", "Epic", "Legendary", "Mythic" };
string[] rarity = GetRarityList(Watcher.eventKill);
string itemName = $"Dust{rarity[rand.Next(0, rarity.Length - 1)]}";
@@ -62,7 +64,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
}
else
{
@@ -76,7 +78,7 @@ namespace MxValheim.EventSystem
int qty = rand.Next(1, Profiles.serverLevel);
string[] rarity = { "Rare", "Epic", "Legendary", "Mythic" };
string[] rarity = GetRarityList(Watcher.eventKill);
string itemName = $"Shard{rarity[rand.Next(0, rarity.Length - 1)]}";
@@ -86,7 +88,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
}
else
{
@@ -100,7 +102,7 @@ namespace MxValheim.EventSystem
int qty = rand.Next(1, Profiles.serverLevel);
string[] rarity = { "Rare", "Epic", "Legendary", "Mythic" };
string[] rarity = GetRarityList(Watcher.eventKill);
string itemName = $"Essence{rarity[rand.Next(0, rarity.Length - 1)]}";
@@ -110,7 +112,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
}
else
{
@@ -124,7 +126,7 @@ namespace MxValheim.EventSystem
int qty = rand.Next(1, 2);
string[] rarity = { "Rare", "Epic", "Legendary", "Mythic" };
string[] rarity = GetRarityList(Watcher.eventKill);
string itemName = $"Runestone{rarity[rand.Next(0, rarity.Length - 1)]}";
@@ -134,7 +136,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
SendRewardMessage(player, prefab, itemName, qty);
}
else
@@ -153,7 +155,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
}
else
{
@@ -169,7 +171,7 @@ namespace MxValheim.EventSystem
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
if (prefab != null)
{
player.GetInventory().AddItem(itemName, qty, 1, 0, 0, "");
GiveItemInWorld(itemName, player, qty);
if (itemName == "Coins")
{
SendRewardMessage(player, prefab, itemName, qty);
@@ -181,6 +183,37 @@ namespace MxValheim.EventSystem
}
}
public static void GiveItemInWorld(string itemName, Player player, int qty)
{
GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName);
Vector3 spawnPos = player.transform.position + player.transform.forward + Vector3.up;
GameObject go = UnityEngine.Object.Instantiate(prefab, spawnPos, Quaternion.identity);
ItemDrop itemDrop = go.GetComponent<ItemDrop>();
if (itemDrop != null)
{
itemDrop.m_itemData.m_stack = qty;
ZNetView nview = go.GetComponent<ZNetView>();
if (nview != null && nview.IsValid())
{
nview.GetZDO().Set("stack", qty);
}
GameObject vfxPrefab = ZNetScene.instance.GetPrefab("vfx_item_spawn");
if (vfxPrefab != null)
{
UnityEngine.Object.Instantiate(vfxPrefab, spawnPos, Quaternion.identity);
}
GameObject sfxPrefab = ZNetScene.instance.GetPrefab("sfx_item_spawn");
if (sfxPrefab != null)
{
UnityEngine.Object.Instantiate(sfxPrefab, spawnPos, Quaternion.identity);
}
}
}
public static void SendRewardMessage(Player player, GameObject prefab, string itemName, int qty)
{
if (ZRoutedRpc.instance != null)
@@ -190,5 +223,29 @@ namespace MxValheim.EventSystem
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_MxKillMsg", Player.m_localPlayer.GetHoverName(), qty.ToString(), Localization.instance.Localize(nameToken), itemName, -2);
}
}
public static string[] GetRarityList(int victim)
{
string[] rarity = { };
switch (victim)
{
case <= 1:
rarity = ["Magic"];
break;
case > 1 and < 5:
rarity = ["Rare"];
break;
case >= 5 and <= 10:
rarity = ["Rare", "Epic"];
break;
case >= 11 and <= 20:
rarity = ["Rare", "Epic", "Legendary"];
break;
case >= 21:
rarity = ["Rare", "Epic", "Legendary", "Mythic"];
break;
}
return rarity;
}
}
}

View File

@@ -200,7 +200,7 @@ namespace MxValheim.KillFeed
{
int qty = Convert.ToInt32(victim);
borderColor = new Color(0.0196f, 0.250f, 0.00750f);
finalMsg = $"<color=#32a852>{attacker.ToUpper()}{Localization.instance.Localize("$EventSystem_format_reward_Msg_GiveItem")}</color><color=#ffd000>{qty} {victimInternalName}</color><color=#32a852>{Localization.instance.Localize("$EventSystem_format_reward_Msg_GiveItemEnd")}</color>";
finalMsg = $"<color=#32a852>{attacker.ToUpper()}{Localization.instance.Localize("$EventSystem_format_reward_Msg_GiveItem")}</color><color=#ffd000>{qty}</color> <color=#32a852>x</color> <color=#ffd000>{victimInternalName}</color><color=#32a852>{Localization.instance.Localize("$EventSystem_format_reward_Msg_GiveItemEnd")}</color>";
GameObject itemObj = ObjectDB.instance.GetItemPrefab(weaponPrefab);
Sprite itemIcon = null;
if (itemObj != null)
@@ -208,7 +208,8 @@ namespace MxValheim.KillFeed
ItemDrop item = itemObj.GetComponent<ItemDrop>();
itemIcon = item?.m_itemData?.m_shared?.m_icons[0];
}
biomeSprite = itemIcon;
biomeSprite = LoadCustomSprite("eventsystem_reward.png");
weaponIcon = itemIcon;
}
lastVictimName = victim;
@@ -367,6 +368,8 @@ namespace MxValheim.KillFeed
}
string victimName = __instance.GetHoverName();
if (victimName == null) return;
int type = 0;
if (__instance.IsPlayer())
{
@@ -490,8 +493,8 @@ namespace MxValheim.KillFeed
_weaponIconSlot = iconObj.GetComponent<Image>();
_weaponIconSlot.preserveAspect = true;
LayoutElement weaponLayout = iconObj.AddComponent<LayoutElement>();
weaponLayout.preferredWidth = 24;
weaponLayout.preferredHeight = 24;
weaponLayout.preferredWidth = 32;
weaponLayout.preferredHeight = 32;
RectTransform iRect = iconObj.GetComponent<RectTransform>();
iRect.anchorMin = iRect.anchorMax = iRect.pivot = new Vector2(0, 0.5f);
@@ -532,8 +535,8 @@ namespace MxValheim.KillFeed
_victimIconSlot = victimObj.GetComponent<Image>();
_victimIconSlot.preserveAspect = true;
LayoutElement victimLayout = victimObj.AddComponent<LayoutElement>();
victimLayout.preferredWidth = 24;
victimLayout.preferredHeight = 24;
victimLayout.preferredWidth = 32;
victimLayout.preferredHeight = 32;
RectTransform vRect = victimObj.GetComponent<RectTransform>();
vRect.anchorMin = vRect.anchorMax = vRect.pivot = new Vector2(1, 0.5f);

View File

@@ -33,7 +33,7 @@ public class MxValheimMod : BaseUnityPlugin
private const string ModGUID = "ovh.mxdev.mxvalheim";
private const string ModName = "MxValheim";
private const string ModVersion = "1.6.8";
private const string ModVersion = "1.6.10";
public static ConfigEntry<bool> Config_DebugRandomEventInterval;
public static ConfigEntry<float> Config_bowDrawSpeedBonusPerLevel;