(1.6.9) Major EventSystem Update (see release)
This commit is contained in:
@@ -102,17 +102,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,8 +169,8 @@ namespace MxValheim.EventSystem
|
||||
isEventCreature = Traverse.Create(mai).Field<bool>("m_eventCreature").Value;
|
||||
}
|
||||
|
||||
if (!isEventCreature) return;
|
||||
|
||||
if (isEventCreature)
|
||||
{
|
||||
RandomEvent activeEvent = RandEventSystem.instance.GetActiveEvent();
|
||||
if (activeEvent != null)
|
||||
{
|
||||
@@ -180,20 +181,32 @@ namespace MxValheim.EventSystem
|
||||
if (entry == null)
|
||||
{
|
||||
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerRegisterEvent", pkg);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerSetEventKill", pkg);
|
||||
}
|
||||
ZRoutedRpc.instance.InvokeRoutedRPC(0, "RPC_ServerGetEventKill", pkg);
|
||||
}
|
||||
|
||||
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);
|
||||
} else
|
||||
{
|
||||
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);
|
||||
@@ -202,3 +215,4 @@ namespace MxValheim.EventSystem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace MxValheim.KillFeed
|
||||
itemIcon = item?.m_itemData?.m_shared?.m_icons[0];
|
||||
}
|
||||
biomeSprite = itemIcon;
|
||||
weaponIcon = null;
|
||||
}
|
||||
|
||||
lastVictimName = victim;
|
||||
|
||||
@@ -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.9";
|
||||
|
||||
public static ConfigEntry<bool> Config_DebugRandomEventInterval;
|
||||
public static ConfigEntry<float> Config_bowDrawSpeedBonusPerLevel;
|
||||
|
||||
Reference in New Issue
Block a user