using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Valheim-mod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Valheim-mod")]
[assembly: AssemblyTitle("Valheim-mod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ValheimMod;
[BepInPlugin("kuuhaku.ValheimMod", "Ballista infinite ammo", "1.0.0")]
[BepInProcess("valheim.exe")]
public class ValheimMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(Turret), "ShootProjectile")]
public static class Patch_Turret_ShootProjectile
{
private static void Prefix(ref ZNetView ___m_nview, Turret __instance, ref float ___m_attackCooldown)
{
___m_attackCooldown = 0.5f;
int @int = ___m_nview.GetZDO().GetInt(ZDOVars.s_ammo, 0);
___m_nview.GetZDO().Set(ZDOVars.s_ammo, @int + 1, false);
MethodInfo methodInfo = AccessTools.Method(typeof(Turret), "GetAmmoItem", (Type[])null, (Type[])null);
object? obj = methodInfo.Invoke(__instance, null);
ItemData val = (ItemData)((obj is ItemData) ? obj : null);
if (val != null)
{
val.m_shared.m_attack.m_projectileAccuracy = 0f;
Debug.Log((object)"Modified Projectile Accuracy");
}
}
}
private readonly Harmony harmony = new Harmony("kuuhaku.ValheimMod");
public static ManualLogSource logger = Logger.CreateLogSource("Ballista infinite ammo");
private void Awake()
{
logger.LogInfo((object)"Ballista infinite ammo Mod has been loaded");
harmony.PatchAll();
}
}