#Sivakrux drop rate %
1 messages · Page 1 of 1 (latest)
||```using BepInEx;
using BepInEx.Logging;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[BepInPlugin("com.reckss.sivakdropany", "Sivakrux Drop Anywhere", "1.0.2")]
public class SivakDropAnywhere : BaseUnityPlugin
{
internal static ManualLogSource Log;
private static ConfigEntry<float> DropChance;
private void Awake()
{
Log = Logger;
// 0.0–1.0 drop chance
DropChance = Config.Bind(
"General",
"SivakruxDropChance",
1.0f,
new ConfigDescription(
"Chance (0.0–1.0) that Sivakrux (ID=23431650) drops from any loot table",
new AcceptableValueRange<float>(0f, 1f)
)
);
var harmony = new Harmony("com.reckss.sivakdropany");
harmony.PatchAll();
Log.LogInfo($"[SivakDropAnywhere] Plugin loaded. DropChance = {DropChance.Value:P0}");
}
// Patch the private InitLootTable method by name
[HarmonyPatch(typeof(LootTable), "InitLootTable")]
static class LootTable_InitLootTable_Patch
{
static void Postfix(LootTable __instance)
{
// 1) Trace to confirm this is ever called
Log.LogInfo($"[SivakDropAnywhere] ▶ InitLootTable on “{__instance.gameObject.name}” (drops so far: {__instance.ActualDrops.Count})");
// 2) Remove any stray vanilla Sivak
__instance.ActualDrops.RemoveAll(i => i == GameData.GM.Sivak);
// 3) Roll exactly once at your configured chance
float roll = Random.value;
Log.LogDebug($"[SivakDropAnywhere] Roll = {roll:F2}, threshold = {DropChance.Value:F2}");
if (roll <= DropChance.Value)
{
__instance.ActualDrops.Add(GameData.GM.Sivak);
__instance.ActualDropsQual.Add(100);
__instance.special = true;
Log.LogInfo($"[SivakDropAnywhere] → Injected Sivakrux into “{__instance.gameObject.name}”"); // Just testing if actually loading drop code
}
}
}
}```||