Decompiled source of BowPlugin v1.8.5
BowPlugin.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BowPlugin.Functions; using BowPlugin.Patches; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.8.5")] [assembly: AssemblyInformationalVersion("1.8.5")] [assembly: AssemblyProduct("BowPlugin")] [assembly: AssemblyTitle("BowPlugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.8.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BowPlugin { [BepInPlugin("blacks7ar.BowPlugin", "BowPlugin", "1.8.5")] public class Plugin : BaseUnityPlugin { private const string modGUID = "blacks7ar.BowPlugin"; public const string modName = "BowPlugin"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.8.5"; public const string tsLink = "https://valheim.thunderstore.io/package/blacks7ar/BowPlugin/"; private static readonly Harmony _harmony = new Harmony("blacks7ar.BowPlugin"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.BowPlugin") { DisplayName = "BowPlugin", CurrentVersion = "1.8.5", MinimumRequiredVersion = "1.8.5" }; private static ConfigEntry<BowPlugin.Functions.Toggle> _serverConfigLocked; private static ConfigEntry<KeyCode> _nextArrowKey; public static ConfigEntry<BowPlugin.Functions.Toggle> _autoEquipbow; public static ConfigEntry<BowPlugin.Functions.Toggle> _arrowSelection; public static ConfigEntry<float> _accuracyMultiplier; public static ConfigEntry<float> _velocityMultiplier; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableExpMultiplier; public static ConfigEntry<BowPlugin.Functions.Toggle> _scaleByBowLevel; public static ConfigEntry<float> _bowDrawSpeed; public static ConfigEntry<float> _bowDrawSpeedFactor; public static ConfigEntry<float> _bowZoomSpeedFactor; public static ConfigEntry<float> _bowExpMultiplier; public static ConfigEntry<BowPlugin.Functions.Toggle> _scaleByXbowLevel; public static ConfigEntry<float> _xbowReloadSpeed; public static ConfigEntry<float> _xbowReloadSpeedFactor; public static ConfigEntry<float> _xbowRecoil; public static ConfigEntry<float> _xbowExpMultiplier; public static ConfigEntry<BowPlugin.Functions.Toggle> _displayExpGained; public static ConfigEntry<float> _sneakAttackMultiplier; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableRotation; public static ConfigEntry<float> _critChance; public static ConfigEntry<float> _critBonus; public static ConfigEntry<CrosshairSelection> _crosshairSelection; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableBowZoom; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableAutoZoom; public static ConfigEntry<Color> _crosshairColor; public static ConfigEntry<KeyCode> _zoomKey; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableXbowZoom; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableXbowSpeedRdction; public static ConfigEntry<float> _bowLaunchAngle; public static ConfigEntry<float> _xbowLaunchAngle; public static ConfigEntry<float> _spawnChance; public static ConfigEntry<BowPlugin.Functions.Toggle> _bowSpeedReduction; public static ConfigEntry<BowPlugin.Functions.Toggle> _bowDrawSpeedTweak; public static ConfigEntry<BowPlugin.Functions.Toggle> _xbowReloadSpeedTweak; public static ConfigEntry<BowPlugin.Functions.Toggle> _enableArrowReticle; public static ConfigEntry<Color> _ammoTextColor; public static ConfigEntry<Color> _ammoReticleColor; public static ConfigEntry<float> _reticleDuration; public static float _zoomIntimer; public static float _zoomOutTimer; public static float _zoomOutDelayTimer; public static float _defaultZoom; public static float _previousZoom; public static float _currentZoom = 0f; public static float _bowZoomFactor = 2f; public static float _stayInZoomTime = 2f; public static float _spineTimer = 0.5f; public static Transform _spine; public static bool _onBowDrawing; public static ZoomLevel _zoomLevel; public static GameObject _PrefabContainer; public static Plugin _Instance; private const string GeneralSection = "2- General"; private const string ReticleSection = "3- Reticle"; private const string BowSection = "4- Bows"; private const string CrossbowSection = "5 Crossbows"; private const string SkillExpSection = "6- Skill Exp"; private const string OtherFeatures = "7- Other Features"; public static bool _IsBBHInstalled; private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); _configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig; return val2; } public void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Expected O, but got Unknown //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Expected O, but got Unknown //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Expected O, but got Unknown //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Expected O, but got Unknown //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Expected O, but got Unknown //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Expected O, but got Unknown //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Expected O, but got Unknown //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Expected O, but got Unknown //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Expected O, but got Unknown //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Expected O, but got Unknown //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Expected O, but got Unknown //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Expected O, but got Unknown //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Expected O, but got Unknown //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Expected O, but got Unknown //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Expected O, but got Unknown //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Expected O, but got Unknown //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Expected O, but got Unknown //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_0729: Expected O, but got Unknown //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Expected O, but got Unknown //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Expected O, but got Unknown //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Expected O, but got Unknown _Instance = this; Localizer.Load(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _serverConfigLocked = config("1- ServerSync", "Lock Configuration", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<BowPlugin.Functions.Toggle>(_serverConfigLocked); _accuracyMultiplier = config("2- General", "Accuracy Multiplier", 0f, new ConfigDescription("Projectiles accuracy multiplier.\nRecommended: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { new BowPlugin.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _velocityMultiplier = config("2- General", "Velocity Multiplier", 4f, new ConfigDescription("Projectiles velocity multiplier.\nRecommended: 3", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>())); _spawnChance = config("2- General", "Retrieve Chance", 0.25f, new ConfigDescription("Arrow and bolt retrieve chance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _enableArrowReticle = config("3- Reticle", "Custom Bow Reticle", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disable new bow reticle.", (AcceptableValueBase)null, Array.Empty<object>())); _ammoReticleColor = config<Color>("3- Reticle", "Ammo Reticle Color", new Color(255f, 255f, 255f, 1f), new ConfigDescription("Use to modify the new custom reticle color.", (AcceptableValueBase)null, Array.Empty<object>())); _ammoTextColor = config<Color>("3- Reticle", "Ammo Name Text Color", new Color(255f, 255f, 255f, 1f), new ConfigDescription("Use to modify the ammos name color.", (AcceptableValueBase)null, Array.Empty<object>())); _reticleDuration = config("3- Reticle", "Reticle Duration", 2f, new ConfigDescription("How long does the reticle hud stays visible in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 25f), Array.Empty<object>())); _bowLaunchAngle = config("4- Bows", "Launch Angle", -1f, new ConfigDescription("The vertical angle at which the projectile leaves the bow after being fired.\nVanilla: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 0f), Array.Empty<object>())); _bowDrawSpeed = config("4- Bows", "Draw Speed", 1f, new ConfigDescription("Bows draw speed value if ScaleBySkillLevel is set to Off.\nVanilla: 2.5", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); _bowDrawSpeedFactor = config("4- Bows", "Bow Draw Speed Factor", 0.6f, new ConfigDescription("Bow draw speed factor at bow skill level 100\nIf Scale By Skill Level is On\nRecommended: 0.6", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); _bowZoomSpeedFactor = config("4- Bows", "Bow Zoom Speed Factor", 1.4f, new ConfigDescription("Bow zoom speed factor at bow skill level 100.\nRecommended: 1.4", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.2f, 2f), Array.Empty<object>())); _scaleByBowLevel = config("4- Bows", "Scale By Skill Level", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, bow draw speed is scaled by bows skill level.", (AcceptableValueBase)null, Array.Empty<object>())); _bowSpeedReduction = config("4- Bows", "BowDraw MovementSpeed Reduction", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, speed will be reduced while aiming/drawing a bow", (AcceptableValueBase)null, Array.Empty<object>())); _bowDrawSpeedTweak = config("4- Bows", "Tweak Draw Speed", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, bow draw speed is overwritten by this mod.", (AcceptableValueBase)null, Array.Empty<object>())); _xbowRecoil = config("5 Crossbows", "Recoil", 0f, new ConfigDescription("Crossbows pushback amount.\nVanilla: 40", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); _xbowReloadSpeed = config("5 Crossbows", "Reload Speed", 0.6f, new ConfigDescription("Crossbows reload time value if ScaleBySkillLevel is set to Off.\nVanilla: 3.5", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); _xbowReloadSpeedFactor = config("5 Crossbows", "Reload Speed Factor", 2f, new ConfigDescription("Crossbow reload speed factor at crossbow skill level 100\nIf Scale By Skill Level is On", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3.5f), Array.Empty<object>())); _scaleByXbowLevel = config("5 Crossbows", "Scale By Skill Level", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, crossbows reload time is scaled by crossbows skill level.", (AcceptableValueBase)null, Array.Empty<object>())); _xbowLaunchAngle = config("5 Crossbows", "Launch Angle", -1f, new ConfigDescription("The vertical angle at which the projectile leaves the crossbow after being fired.\nVanilla: -1", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 0f), Array.Empty<object>())); _xbowReloadSpeedTweak = config("5 Crossbows", "Tweak Reload Speed", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, crossbows reload speed is overwritten by this mod.", (AcceptableValueBase)null, Array.Empty<object>())); _enableExpMultiplier = config("6- Skill Exp", "Enable Exp Multiplier", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables exp multiplier for both bows and crossbows.", (AcceptableValueBase)null, Array.Empty<object>())); _bowExpMultiplier = config("6- Skill Exp", "Bows Exp Multiplier", 1f, new ConfigDescription("Exp multiplier for bow skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); _xbowExpMultiplier = config("6- Skill Exp", "Crossbows Exp Multiplier", 1f, new ConfigDescription("Exp multiplier for crossbow skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); _displayExpGained = config("6- Skill Exp", "Display Exp Gained", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables exp gained notification for both bows and crossbows.", (AcceptableValueBase)null, Array.Empty<object>())); _nextArrowKey = config<KeyCode>("7- Other Features", "Next Arrow Hotkey", (KeyCode)103, new ConfigDescription("Key to press to change arrows.", (AcceptableValueBase)null, Array.Empty<object>())); _autoEquipbow = config("7- Other Features", "Auto Equip Bow", BowPlugin.Functions.Toggle.On, new ConfigDescription("When NextArrowHotkey is pressed, bow is auto equip.\n(Only works if there's only one type of bow in the inventory.", (AcceptableValueBase)null, Array.Empty<object>())); _arrowSelection = config("7- Other Features", "Display Equipped Arrow Message", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables notification when NextArrowHotkey is pressed.", (AcceptableValueBase)null, Array.Empty<object>())); _sneakAttackMultiplier = config("7- Other Features", "Sneak Attack Multiplier", 1f, new ConfigDescription("Bonus damage multiplier to creatures with a successful sneak attack.\nRecommended: 1", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); _enableRotation = config("7- Other Features", "Enable Character Rotation", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, character always faces the direction of your crosshair.", (AcceptableValueBase)null, Array.Empty<object>())); _critChance = config("2- General", "Critical Chance", 25f, new ConfigDescription("Percentage chance to make a custom critical hit using bows or crossbows.\nSet to 0 to disable\nNeeds logout to take effect", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); _critBonus = config("2- General", "Critical Damage Multiplier", 3f, new ConfigDescription("Damage multiplier for a successful custom critical hit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _crosshairSelection = config("2- General", "Crosshair Options", CrosshairSelection.Default, new ConfigDescription("Custom crosshair selection for bows crosshair.", (AcceptableValueBase)null, Array.Empty<object>())); _enableBowZoom = config("4- Bows", "Enable Zooming", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables bow draw zooming.", (AcceptableValueBase)null, Array.Empty<object>())); _enableAutoZoom = config("4- Bows", "Auto Zoom In", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables auto zooming in when drawing a bow.", (AcceptableValueBase)null, Array.Empty<object>())); _crosshairColor = config<Color>("2- General", "Crosshair Color", new Color(255f, 0f, 0f), new ConfigDescription("Crosshair color selection.", (AcceptableValueBase)null, Array.Empty<object>())); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; _zoomKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2- General", "Zoom Key", (KeyCode)120, new ConfigDescription("Key to press to zoom-in while drawing a bow when auto zoom is disabled.", (AcceptableValueBase)null, Array.Empty<object>())); _enableXbowZoom = config("5 Crossbows", "Enable Zooming", BowPlugin.Functions.Toggle.On, new ConfigDescription("Enable/Disables crossbow zooming.", (AcceptableValueBase)null, Array.Empty<object>())); _enableXbowSpeedRdction = config("5 Crossbows", "Speed Reduction", BowPlugin.Functions.Toggle.On, new ConfigDescription("If On, reduce walking speed when reloading a crossbow.", (AcceptableValueBase)null, Array.Empty<object>())); _IsBBHInstalled = Helper.CheckBBHMod(); SetupPrefabs.Init(); CustomCrosshairs.Init(); PrefabContainerInit(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main") && ZInput.instance != null && !ZNet.instance.InPasswordDialog() && _nextArrowKey != null) { Player localPlayer = Player.m_localPlayer; if (Input.GetKeyDown(_nextArrowKey.Value) && ((Character)localPlayer).TakeInput()) { BowFeature.SwitchArrow(); } if (_zoomLevel == ZoomLevel.ZoomedIn && Input.GetKeyDown((KeyCode)114) && ((Character)localPlayer).TakeInput()) { GameCamera.instance.m_fov = _defaultZoom; _zoomLevel = ZoomLevel.FixedZoom; _zoomOutDelayTimer = 0f; _zoomIntimer = 0f; _zoomOutTimer = 0f; ((Character)localPlayer).SetWalk(false); } } } public static void PrefabContainerInit() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (!_IsBBHInstalled) { _PrefabContainer = new GameObject("ArrowContainer"); _PrefabContainer.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_PrefabContainer); } } } } namespace BowPlugin.Patches { [HarmonyPatch] public static class AttackPatch { [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "FireProjectileBurst")] public static bool FireProjectileBurst_Prefix(Attack __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!__instance.m_bowDraw || !__instance.m_requiresReload) { return true; } for (int i = 0; i < __instance.m_projectiles; i++) { if (__instance.m_destroyPreviousProjectile && Object.op_Implicit((Object)(object)__instance.m_weapon.m_lastProjectile)) { ZNetScene.instance.Destroy(__instance.m_weapon.m_lastProjectile); __instance.m_weapon.m_lastProjectile = null; } new HitData().m_backstabBonus = Helper.BackstabBonusMultiplier(__instance.m_weapon.m_shared.m_backstabBonus, ((Character)__instance.m_character).GetSkillFactor((SkillType)101)); } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "Start")] public static void AttackStart_Prefix(Attack __instance, Humanoid character) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if ((__instance == null && !((Character)character).IsPlayer()) || (((Character)character).m_name != "Human" && (Object)(object)character != (Object)(object)Player.m_localPlayer) || (!__instance.m_bowDraw && !__instance.m_requiresReload) || !((Character)character).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BowMastery"))) { return; } SE_Critical sE_Critical = ((Character)character).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("BowMastery")) as SE_Critical; if (!((float)new Random().Next(1, 100) <= sE_Critical.GetCritChance())) { return; } Attack obj = __instance; obj.m_damageMultiplier *= sE_Critical.GetCritBonus(); foreach (Vector3 item in Enumerable.Select(Enumerable.Select(Enumerable.Select(new List<HitPoint>(), (HitPoint item) => new { item, item.go }), <>h__TransparentIdentifier0 => new { <>h__TransparentIdentifier0 = <>h__TransparentIdentifier0, vector = <>h__TransparentIdentifier0.item.avgPoint / (float)<>h__TransparentIdentifier0.item.count }), <>h__TransparentIdentifier1 => (Vector3)((int)__instance.m_hitPointtype switch { 1 => <>h__TransparentIdentifier1.vector, 2 => <>h__TransparentIdentifier1.<>h__TransparentIdentifier0.item.firstPoint, 0 => <>h__TransparentIdentifier1.<>h__TransparentIdentifier0.item.closestPoint, _ => <>h__TransparentIdentifier1.vector, }))) { __instance.m_weapon.m_shared.m_hitEffect.Create(item, Quaternion.identity, (Transform)null, 1f, -1); __instance.m_hitEffect.Create(item, Quaternion.identity, (Transform)null, 1f, -1); Object.Instantiate<GameObject>(SetupPrefabs._fxBowCrit, item, Quaternion.identity); } ((Character)character).Message((MessageType)1, "<color=orange>Critical Hit!</color>", 0, (Sprite)null); Debug.Log((object)"Critical Hit!"); } [HarmonyPostfix] [HarmonyPatch(typeof(Attack), "Start")] public static void AttackStart_Postfix(Attack __instance) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Invalid comparison between Unknown and I4 if (__instance == null) { return; } Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val == null || (((Character)val).m_name != "Human" && (Object)(object)val != (Object)(object)Player.m_localPlayer) || (((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType == "$ammo_bullets")) { return; } ItemData ammoItem = ((Humanoid)val).GetAmmoItem(); if (ammoItem != null && ammoItem.m_shared.m_name.ToLower().Contains("bait")) { return; } bool flag = ((Humanoid)val).GetCurrentWeapon() == null; if (!flag) { SkillType skillType = ((Humanoid)val).GetCurrentWeapon().m_shared.m_skillType; bool flag2 = (((int)skillType == 8 || (int)skillType == 14) ? true : false); flag = !flag2; } if (flag) { return; } Plugin._velocityMultiplier.SettingChanged += delegate { Attack obj7 = __instance; obj7.m_projectileVel *= Plugin._velocityMultiplier.Value; Attack obj8 = __instance; obj8.m_projectileVelMin *= Plugin._velocityMultiplier.Value; }; Attack obj = __instance; obj.m_projectileVel *= Plugin._velocityMultiplier.Value; Attack obj2 = __instance; obj2.m_projectileVelMin *= Plugin._velocityMultiplier.Value; Plugin._accuracyMultiplier.SettingChanged += delegate { Attack obj5 = __instance; obj5.m_projectileAccuracy *= Plugin._accuracyMultiplier.Value; Attack obj6 = __instance; obj6.m_projectileAccuracyMin *= Plugin._accuracyMultiplier.Value; }; Attack obj3 = __instance; obj3.m_projectileAccuracy *= Plugin._accuracyMultiplier.Value; Attack obj4 = __instance; obj4.m_projectileAccuracyMin *= Plugin._accuracyMultiplier.Value; if ((int)((Humanoid)val).GetCurrentWeapon().m_shared.m_skillType == 8) { Plugin._bowLaunchAngle.SettingChanged += delegate { __instance.m_launchAngle = Plugin._bowLaunchAngle.Value; }; __instance.m_launchAngle = Plugin._bowLaunchAngle.Value; } else if ((int)((Humanoid)val).GetCurrentWeapon().m_shared.m_skillType == 14) { Plugin._xbowLaunchAngle.SettingChanged += delegate { __instance.m_launchAngle = Plugin._xbowLaunchAngle.Value; }; __instance.m_launchAngle = Plugin._xbowLaunchAngle.Value; } } } [HarmonyPatch] public static class CharacterPatch { [HarmonyTranspiler] [HarmonyPatch(typeof(Character), "UpdateStagger")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)3f)) { instruction.operand = 4f; } } return instructions; } } [HarmonyPatch] public static class GameCameraPatch { [HarmonyPriority(100)] [HarmonyPostfix] [HarmonyPatch(typeof(GameCamera), "GetCameraPosition")] private static void GetCameraPosition_Postfix(GameCamera __instance, float dt, Vector3 pos, Quaternion rot) { if ((Object)(object)__instance != (Object)null && Plugin._enableBowZoom.Value == BowPlugin.Functions.Toggle.On && Plugin._defaultZoom == 0f) { Plugin._defaultZoom = __instance.m_fov; } } [HarmonyPriority(0)] [HarmonyPrefix] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public static void UpdateCamera_Prefix(GameCamera __instance) { bool flag = Plugin._enableBowZoom.Value == BowPlugin.Functions.Toggle.On; if (flag) { ZoomLevel zoomLevel = Plugin._zoomLevel; bool flag2 = (uint)(zoomLevel - 1) <= 1u; flag = flag2; } if (flag) { __instance.m_fov = Plugin._currentZoom; } } } [HarmonyPatch] public static class HudPatch { [CompilerGenerated] private sealed class <PulseText>d__22 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TMP_Text text; public float scaleUp; public float duration; private RectTransform <rect>5__2; private Vector3 <targetScale>5__3; private float <time>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PulseText>d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <rect>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <rect>5__2 = text.rectTransform; ((Transform)<rect>5__2).localScale = _baseScale; <targetScale>5__3 = _baseScale * scaleUp; <time>5__4 = 0f; goto IL_00b7; case 1: <>1__state = -1; goto IL_00b7; case 2: { <>1__state = -1; break; } IL_00b7: if (<time>5__4 < duration) { <time>5__4 += Time.deltaTime; ((Transform)<rect>5__2).localScale = Vector3.Lerp(_baseScale, <targetScale>5__3, <time>5__4 / duration); <>2__current = null; <>1__state = 1; return true; } <time>5__4 = 0f; break; } if (<time>5__4 < duration) { <time>5__4 += Time.deltaTime; ((Transform)<rect>5__2).localScale = Vector3.Lerp(<targetScale>5__3, _baseScale, <time>5__4 / duration); <>2__current = null; <>1__state = 2; return true; } ((Transform)<rect>5__2).localScale = _baseScale; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ShowAndFadeHud>d__23 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TMP_Text text; public float fadeTime; private CanvasGroup <group>5__2; private float <start>5__3; private float <time>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShowAndFadeHud>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <group>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; float value = Plugin._reticleDuration.Value; <group>5__2 = ((Component)text).GetComponent<CanvasGroup>(); if ((Object)(object)<group>5__2 == (Object)null) { return false; } <group>5__2.alpha = 1f; ((Component)<group>5__2).gameObject.SetActive(true); <>2__current = (object)new WaitForSeconds(value); <>1__state = 1; return true; } case 1: <>1__state = -1; <start>5__3 = <group>5__2.alpha; <time>5__4 = 0f; break; case 2: <>1__state = -1; break; } if (<time>5__4 < fadeTime) { <time>5__4 += Time.deltaTime; <group>5__2.alpha = Mathf.Lerp(<start>5__3, 0f, <time>5__4 / fadeTime); <>2__current = null; <>1__state = 2; return true; } <group>5__2.alpha = 0f; ((Component)<group>5__2).gameObject.SetActive(false); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <UpdateAmmoHud>d__20 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <UpdateAmmoHud>d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { BowFeature.ShowAmmoEquipped(); ((Graphic)_ammoHudText).color = Plugin._ammoTextColor.Value; ((Graphic)_ammoReticle).color = Plugin._ammoReticleColor.Value; (int currentStack, string currentName, int nextStack, string nextName, int prevStack, string prevName) ammoHudNames = BowFeature.GetAmmoHudNames(localPlayer); int item = ammoHudNames.currentStack; string item2 = ammoHudNames.currentName; int item3 = ammoHudNames.nextStack; string item4 = ammoHudNames.nextName; int item5 = ammoHudNames.prevStack; string item6 = ammoHudNames.prevName; string text = Localization.instance.Localize(item2); if (!string.IsNullOrEmpty(text) && _lastEquippedArrow != text) { _lastEquippedArrow = text; _ammoHudText.text = $" x{item} {text}"; if (_pulseCoroutine != null) { ((MonoBehaviour)Hud.instance).StopCoroutine(_pulseCoroutine); } _pulseCoroutine = ((MonoBehaviour)Hud.instance).StartCoroutine(PulseText(_ammoHudText)); if (_currentAmmoRoutine != null) { ((MonoBehaviour)Hud.instance).StopCoroutine(_currentAmmoRoutine); } _currentAmmoRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_ammoHudText)); } if (!string.IsNullOrEmpty(item4) && item4 != item2) { if (item4 != _lastNextAmmo) { _lastNextAmmo = item4; _nextAmmoHudText.text = $"<color=#AAAAAA> x{item3} {Localization.instance.Localize(item4)}</color>"; if (_nextAmmoRoutine != null) { ((MonoBehaviour)Hud.instance).StopCoroutine(_nextAmmoRoutine); } _nextAmmoRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_nextAmmoHudText)); } } else { _lastNextAmmo = ""; } if (!string.IsNullOrEmpty(item6) && item6 != item2) { if (item6 != _lastPrevAmmo) { _lastPrevAmmo = item6; _previousAmmoHudText.text = $"<color=#AAAAAA> x{item5} {Localization.instance.Localize(item6)}</color>"; if (_prevAmmoRoutine != null) { ((MonoBehaviour)Hud.instance).StopCoroutine(_prevAmmoRoutine); } _prevAmmoRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_previousAmmoHudText)); } } else { _lastPrevAmmo = ""; } } } else { <>1__state = -1; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static GameObject _ammoHud; public static TMP_Text _ammoHudText; public static TMP_Text _nextAmmoHudText; public static TMP_Text _previousAmmoHudText; public static GameObject _ammoPanel; private static Image _ammoReticle; private static RectTransform _ammoHudRectTransform; private static RectTransform _ammoPanelRectTransform; private static bool _justWalk; private static string _lastEquippedArrow = ""; private static Coroutine _pulseCoroutine; private static readonly Vector3 _baseScale = Vector3.one; private static Coroutine _currentAmmoRoutine; private static Coroutine _nextAmmoRoutine; private static Coroutine _prevAmmoRoutine; private static string _lastNextAmmo = ""; private static string _lastPrevAmmo = ""; [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "Awake")] private static void HudAwake_Postfix(Hud __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) _ammoHud = new GameObject("AmmoNameHud"); _ammoHud.transform.SetParent(__instance.m_rootObject.transform); _ammoHudRectTransform = _ammoHud.AddComponent<RectTransform>(); ((Component)_ammoHudRectTransform).transform.SetParent(_ammoHud.transform); _ammoHudRectTransform.sizeDelta = new Vector2(320f, 64f); float num = ((Component)__instance.m_crosshair).transform.localPosition.x + 216f; float y = ((Component)__instance.m_crosshair).transform.localPosition.y; _ammoHudRectTransform.anchoredPosition = new Vector2(num, y); GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _ammoHud.transform); ((Object)obj).name = "CurrentAmmoText"; obj.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; _ammoHudText = (TMP_Text)(object)obj.GetComponent<TextMeshProUGUI>(); _ammoHudText.text = ""; _ammoHudText.fontSize = 18f; _ammoHudText.enableAutoSizing = false; _ammoHudText.alignment = (TextAlignmentOptions)4097; _ammoHudText.fontStyle = (FontStyles)1; CanvasGroup obj2 = obj.AddComponent<CanvasGroup>(); obj2.alpha = 0f; obj2.interactable = false; obj2.blocksRaycasts = false; ((Component)obj2).gameObject.SetActive(false); GameObject obj3 = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _ammoHud.transform); ((Object)obj3).name = "NextAmmoText"; obj3.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 24f); _nextAmmoHudText = (TMP_Text)(object)obj3.GetComponent<TextMeshProUGUI>(); _nextAmmoHudText.text = ""; _nextAmmoHudText.fontSize = 14f; _nextAmmoHudText.enableAutoSizing = false; _nextAmmoHudText.alignment = (TextAlignmentOptions)4097; _nextAmmoHudText.fontStyle = (FontStyles)2; CanvasGroup obj4 = obj3.AddComponent<CanvasGroup>(); obj4.alpha = 0f; obj4.interactable = false; obj4.blocksRaycasts = false; ((Component)obj4).gameObject.SetActive(false); GameObject obj5 = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _ammoHud.transform); ((Object)obj5).name = "PreviousAmmoText"; obj5.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -24f); _previousAmmoHudText = (TMP_Text)(object)obj5.GetComponent<TextMeshProUGUI>(); _previousAmmoHudText.text = ""; _previousAmmoHudText.fontSize = 14f; _previousAmmoHudText.enableAutoSizing = false; _previousAmmoHudText.alignment = (TextAlignmentOptions)4097; _previousAmmoHudText.fontStyle = (FontStyles)2; CanvasGroup obj6 = obj5.AddComponent<CanvasGroup>(); obj6.alpha = 0f; obj6.interactable = false; obj6.blocksRaycasts = false; ((Component)obj6).gameObject.SetActive(false); _ammoPanel = new GameObject("AmmoPanel", new Type[2] { typeof(RectTransform), typeof(Image) }); _ammoPanel.transform.SetParent(__instance.m_rootObject.transform); _ammoPanelRectTransform = _ammoPanel.GetComponent<RectTransform>(); _ammoPanelRectTransform.sizeDelta = new Vector2(96f, 96f); float x = ((Component)__instance.m_crosshair).transform.localPosition.x; float y2 = ((Component)__instance.m_crosshair).transform.localPosition.y; _ammoPanelRectTransform.anchoredPosition = new Vector2(x, y2); _ammoReticle = _ammoPanel.GetComponent<Image>(); _ammoReticle.sprite = SetupPrefabs._bowBundle.LoadAsset<Sprite>("bbp_magic_crosshair"); _ammoReticle.fillCenter = true; _ammoReticle.fillMethod = (FillMethod)0; ((MonoBehaviour)__instance).StartCoroutine(UpdateAmmoHud()); } [HarmonyPriority(0)] [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] public static void UpdateCrosshair_Postfix(Hud __instance, Player player, float bowDrawPercentage) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Invalid comparison between Unknown and I4 //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) if (((Humanoid)player).GetCurrentWeapon() == null) { return; } Plugin._onBowDrawing = bowDrawPercentage > 0.1f; if (bowDrawPercentage > 0.1f) { if (Plugin._bowSpeedReduction.Value == BowPlugin.Functions.Toggle.On) { ((Character)player).SetWalk(true); _justWalk = true; } ((Graphic)__instance.m_crosshair).color = Color.Lerp(new Color(1f, 1f, 1f), Plugin._crosshairColor.Value, 0.5f); float num = Mathf.Lerp(1f, 0.15f, bowDrawPercentage); ((Component)__instance.m_crosshairBow).gameObject.SetActive(true); ((Component)__instance.m_crosshairBow).transform.localScale = new Vector3(num, num, num); ((Graphic)__instance.m_crosshairBow).color = Color.Lerp(new Color(1f, 1f, 1f), Plugin._crosshairColor.Value, bowDrawPercentage); } else if (((Character)player).GetWalk() && _justWalk) { _justWalk = false; ((Character)player).SetWalk(false); ((Graphic)__instance.m_crosshair).color = new Color(1f, 1f, 1f, 0.5f); ((Component)__instance.m_crosshairBow).gameObject.SetActive(false); } if (Plugin._enableBowZoom.Value == BowPlugin.Functions.Toggle.Off || Plugin._defaultZoom == 0f) { return; } if (((Humanoid)player).GetCurrentWeapon() == null || (int)((Humanoid)player).GetCurrentWeapon().m_shared.m_itemType != 4) { ZoomedOut(); return; } double num2 = 2.5 * ((double)Plugin._bowZoomSpeedFactor.Value - Helper.DiminishingReturn(((Character)player).GetSkillLevel((SkillType)8), 0f, 100f)); float num3 = Mathf.InverseLerp(0.1f, (float)num2, Plugin._zoomIntimer); if (Plugin._enableAutoZoom.Value == BowPlugin.Functions.Toggle.On) { if (bowDrawPercentage > 0.01f) { Plugin._zoomIntimer += Time.deltaTime; Plugin._zoomLevel = ZoomLevel.ZoomedIn; GameCamera.instance.m_fov = (Plugin._previousZoom = Mathf.Lerp(Plugin._defaultZoom, Plugin._defaultZoom / Plugin._bowZoomFactor, num3)); Plugin._currentZoom = (Plugin._previousZoom = Mathf.Lerp(Plugin._defaultZoom, Plugin._defaultZoom / Plugin._bowZoomFactor, num3)); return; } ZoomedOut(); } if (Input.GetKey(Plugin._zoomKey.Value)) { if (!(bowDrawPercentage > 0.01f)) { Plugin._zoomOutDelayTimer += Time.deltaTime; if (Plugin._zoomOutDelayTimer > Plugin._stayInZoomTime) { ZoomedOut(); } } else { Plugin._zoomIntimer += Time.deltaTime; Plugin._zoomOutDelayTimer = 0f; Plugin._zoomLevel = ZoomLevel.ZoomedIn; GameCamera.instance.m_fov = (Plugin._previousZoom = Mathf.Lerp(Plugin._defaultZoom, Plugin._defaultZoom / Plugin._bowZoomFactor, num3)); Plugin._currentZoom = (Plugin._previousZoom = Mathf.Lerp(Plugin._defaultZoom, Plugin._defaultZoom / Plugin._bowZoomFactor, num3)); } } else { Plugin._zoomOutDelayTimer = 1f; ZoomedOut(); } if (((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_requiresReload && Plugin._enableXbowZoom.Value == BowPlugin.Functions.Toggle.On) { if (Input.GetKey(Plugin._zoomKey.Value) && ((Humanoid)player).IsWeaponLoaded()) { Plugin._zoomLevel = ZoomLevel.ZoomedIn; GameCamera.instance.m_fov = 30f; Plugin._currentZoom = 30f; } else { ZoomedOut(); } } } [HarmonyPrefix] [HarmonyPatch(typeof(Hud), "Awake")] public static bool HudAwake_Prefix(Hud __instance) { if ((Object)(object)__instance.m_crosshair == (Object)null) { return false; } Sprite _default = Enumerable.FirstOrDefault((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>(), (Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "crosshair_bow")); Plugin._crosshairSelection.SettingChanged += delegate { Image crosshairBow2 = __instance.m_crosshairBow; crosshairBow2.sprite = (Sprite)(Plugin._crosshairSelection.Value switch { CrosshairSelection.PistolTarget => CustomCrosshairs._pistolTarget, CrosshairSelection.SimpleCrosshair => CustomCrosshairs._simpleCrosshair, CrosshairSelection.TargetDesign => CustomCrosshairs._targetDesign, CrosshairSelection.TriangularCrosshair => CustomCrosshairs._triangularCrosshair, CrosshairSelection.CircularGunTarget => CustomCrosshairs._circularGunTarget, CrosshairSelection.DartBoardTarget => CustomCrosshairs._dartBoardTarget, CrosshairSelection.DeviceFocusPoint => CustomCrosshairs._deviceFocusPoint, CrosshairSelection.EyeWideOpen => CustomCrosshairs._eyeWideOpen, CrosshairSelection.FightingWeaponTarget => CustomCrosshairs._fightingWeaponTarget, CrosshairSelection.RoundTargetSymbol => CustomCrosshairs._roundTargetSymbol, CrosshairSelection.SharpDecoratedTarget => CustomCrosshairs._sharpDecoratedTarget, CrosshairSelection.ShootTargetPoint => CustomCrosshairs._shootTargetPoint, CrosshairSelection.Default => _default, _ => __instance.m_crosshairBow.sprite, }); }; Image crosshairBow = __instance.m_crosshairBow; crosshairBow.sprite = (Sprite)(Plugin._crosshairSelection.Value switch { CrosshairSelection.PistolTarget => CustomCrosshairs._pistolTarget, CrosshairSelection.SimpleCrosshair => CustomCrosshairs._simpleCrosshair, CrosshairSelection.TargetDesign => CustomCrosshairs._targetDesign, CrosshairSelection.TriangularCrosshair => CustomCrosshairs._triangularCrosshair, CrosshairSelection.CircularGunTarget => CustomCrosshairs._circularGunTarget, CrosshairSelection.DartBoardTarget => CustomCrosshairs._dartBoardTarget, CrosshairSelection.DeviceFocusPoint => CustomCrosshairs._deviceFocusPoint, CrosshairSelection.EyeWideOpen => CustomCrosshairs._eyeWideOpen, CrosshairSelection.FightingWeaponTarget => CustomCrosshairs._fightingWeaponTarget, CrosshairSelection.RoundTargetSymbol => CustomCrosshairs._roundTargetSymbol, CrosshairSelection.SharpDecoratedTarget => CustomCrosshairs._sharpDecoratedTarget, CrosshairSelection.ShootTargetPoint => CustomCrosshairs._shootTargetPoint, CrosshairSelection.Default => _default, _ => __instance.m_crosshairBow.sprite, }); return true; } [IteratorStateMachine(typeof(<UpdateAmmoHud>d__20))] private static IEnumerator UpdateAmmoHud() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <UpdateAmmoHud>d__20(0); } private static void ZoomedOut() { if (Plugin._zoomLevel != 0) { if (Plugin._zoomLevel == ZoomLevel.ZoomedIn) { Plugin._zoomLevel = ZoomLevel.ZoomedOut; Plugin._zoomOutTimer = 0f; Plugin._zoomIntimer = 0f; } else { Plugin._zoomOutTimer += Time.deltaTime; if (Plugin._zoomOutTimer > 1f) { GameCamera.instance.m_fov = Plugin._defaultZoom; Plugin._zoomLevel = ZoomLevel.FixedZoom; Plugin._zoomOutDelayTimer = 0f; return; } } float num = Mathf.InverseLerp(0f, 0.3f, Plugin._zoomOutTimer); GameCamera.instance.m_fov = Mathf.Lerp(Plugin._previousZoom, Plugin._defaultZoom, num); Plugin._currentZoom = Mathf.Lerp(Plugin._previousZoom, Plugin._defaultZoom, num); } else if (GameCamera.instance.m_fov != Plugin._defaultZoom) { GameCamera.instance.m_fov = Plugin._defaultZoom; } } [IteratorStateMachine(typeof(<PulseText>d__22))] private static IEnumerator PulseText(TMP_Text text, float scaleUp = 1.2f, float duration = 0.2f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PulseText>d__22(0) { text = text, scaleUp = scaleUp, duration = duration }; } [IteratorStateMachine(typeof(<ShowAndFadeHud>d__23))] private static IEnumerator ShowAndFadeHud(TMP_Text text, float fadeTime = 0.5f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShowAndFadeHud>d__23(0) { text = text, fadeTime = fadeTime }; } } [HarmonyPatch] public class HumanoidPatch { [HarmonyPostfix] [HarmonyPatch(typeof(Humanoid), "UseItem")] private static void UseItem_Postfix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui) { if (inventory == null) { inventory = __instance.m_inventory; } if (inventory.ContainsItem(item) && fromInventoryGui && (!(item.m_shared.m_ammoType != "$ammo_arrows") || !(item.m_shared.m_ammoType != "$ammo_bolts"))) { BowFeature.ShowAmmoEquipped(); } } [HarmonyPostfix] [HarmonyPatch(typeof(Humanoid), "UpdateEquipment")] private static void UpdateEquipment_Postfix(ref Humanoid __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && (!(__instance.GetCurrentWeapon().m_shared.m_ammoType != "$ammo_arrows") || !(__instance.GetCurrentWeapon().m_shared.m_ammoType != "$ammo_bolts")) && HaveAmmo(__instance, __instance.GetCurrentWeapon()) && BowFeature.CountArrowStacks() > 0) { EquipAmmoItem(__instance, __instance.GetCurrentWeapon()); } } private static bool HaveAmmo(Humanoid humanoid, ItemData weapon) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType)) { return true; } ItemData val = humanoid.GetAmmoItem(); if (val != null && (!humanoid.GetInventory().ContainsItem(val) || val.m_shared.m_ammoType != weapon.m_shared.m_ammoType)) { val = null; } if (val == null) { val = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null); } if (val == null) { return false; } if ((int)val.m_shared.m_itemType == 2) { return humanoid.CanConsumeItem(val, false); } return true; } private static bool EquipAmmoItem(Humanoid humanoid, ItemData weapon) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 FindAmmo(humanoid, weapon); if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType)) { return true; } ItemData ammoItem = humanoid.GetAmmoItem(); if (ammoItem != null && humanoid.GetInventory().ContainsItem(ammoItem) && ammoItem.m_shared.m_ammoType == weapon.m_shared.m_ammoType) { return true; } ItemData ammoItem2 = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null); ItemType itemType = ammoItem2.m_shared.m_itemType; if (((int)itemType == 9 || (int)itemType == 23) ? true : false) { return humanoid.EquipItem(ammoItem2, true); } return true; } private static ItemData FindAmmo(Humanoid humanoid, ItemData weapon) { if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType)) { return null; } ItemData val = humanoid.GetAmmoItem(); if (val != null && (!humanoid.GetInventory().ContainsItem(val) || val.m_shared.m_ammoType != weapon.m_shared.m_ammoType)) { val = null; } return val ?? (val = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null)); } } [HarmonyPatch] public static class ItemDataPatch { [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] public static void GetTooltip_Postfix(ref string __result, ItemData item, int qualityLevel, bool crafting) { try { if (Helper.IsBow(item)) { int index = -1; Helper.UpdateBackstabMultiplier(ref index, ref __result, item); if (!(Plugin._critChance.Value <= 0f)) { Helper.UpdateCriticalMultiplier(ref index, ref __result, item); } } } catch { } } } [HarmonyPatch] public static class ObjectDBPatch { [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")] public static void UpdateItemHashes_Postfix(ObjectDB __instance) { foreach (ItemDrop item in Enumerable.Where(Enumerable.Select(__instance.m_items, (GameObject item) => item.GetComponent<ItemDrop>()), (ItemDrop component) => Object.op_Implicit((Object)(object)component) && Helper.IsBow(component.m_itemData) && component.m_itemData.m_shared.m_attack.m_bowDraw)) { Helper.ApplyWeaponStaggerChanges(item); } } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void ObjectDBAwake_Postfix(ObjectDB __instance) { if ((Object)(object)__instance == (Object)null) { return; } foreach (ItemDrop item in Enumerable.Select(__instance.m_items, (GameObject item) => item.GetComponent<ItemDrop>())) { if (Helper.IsBow(item.m_itemData)) { SE_Critical se_critical = ScriptableObject.CreateInstance<SE_Critical>(); Plugin._critChance.SettingChanged += delegate { se_critical.SetCritChance(Plugin._critChance.Value); }; se_critical.SetCritChance(Plugin._critChance.Value); Plugin._critBonus.SettingChanged += delegate { se_critical.SetCritBonus(Plugin._critBonus.Value); }; se_critical.SetCritBonus(Plugin._critBonus.Value); if (Plugin._critChance.Value <= 0f) { break; } item.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)se_critical; } if (Plugin._IsBBHInstalled) { break; } SwitchProjectile.Init(item); if (!Helper.IsArrow(item.m_itemData)) { continue; } Projectile projectile = item.m_itemData.m_shared.m_attack.m_attackProjectile.GetComponent<Projectile>(); if (Object.op_Implicit((Object)(object)projectile)) { projectile.m_spawnOnHit = ((Component)item).gameObject; Plugin._spawnChance.SettingChanged += delegate { projectile.m_spawnOnHitChance = Plugin._spawnChance.Value; }; projectile.m_spawnOnHitChance = Plugin._spawnChance.Value; } } } [HarmonyPrefix] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void Awake_Prefix(ref ObjectDB __instance) { if ((Object)(object)__instance == (Object)null) { return; } foreach (Recipe item in Enumerable.Where(__instance.m_recipes, (Recipe recipe) => ((Object)recipe).name == "Recipe_ArrowWood")) { item.m_craftingStation = null; } } } [HarmonyPatch] public static class PlayerPatch { private static bool _justWalk; [HarmonyPrefix] [HarmonyPatch(typeof(Player), "AlwaysRotateCamera")] public static bool AlwaysRotateCamera_Prefix(Player __instance, ref bool __result) { if (Plugin._enableRotation.Value == BowPlugin.Functions.Toggle.On && ((Humanoid)__instance).GetCurrentWeapon() != null && ((Humanoid)__instance).GetCurrentWeapon() != ((Humanoid)__instance).m_unarmedWeapon.m_itemData && !((Character)__instance).IsRunning() && !((Character)__instance).InEmote()) { __result = true; return false; } __result = false; return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "PlayerAttackInput")] public static bool PlayerAttackInput_Prefix(Player __instance, float dt) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (((Humanoid)__instance).GetCurrentWeapon() != null && ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_ammoType == "$ammo_bullets") { return true; } if (((Humanoid)__instance).GetCurrentWeapon() != null && ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_bowDraw) { float drawDurationMin = ObjectDB.instance.GetItemPrefab(((Object)((Humanoid)__instance).GetCurrentWeapon().m_dropPrefab).name).GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_drawDurationMin; Plugin._bowDrawSpeedTweak.SettingChanged += delegate { if (Plugin._bowDrawSpeedTweak.Value == BowPlugin.Functions.Toggle.On) { Plugin._scaleByBowLevel.SettingChanged += delegate { ToggleScaleByBowLevel(__instance); }; ToggleScaleByBowLevel(__instance); } else { ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = drawDurationMin; } }; if (Plugin._bowDrawSpeedTweak.Value == BowPlugin.Functions.Toggle.On) { Plugin._scaleByBowLevel.SettingChanged += delegate { ToggleScaleByBowLevel(__instance); }; ToggleScaleByBowLevel(__instance); } else { ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = drawDurationMin; } } if (((Humanoid)__instance).GetCurrentWeapon() != null && ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_requiresReload) { Plugin._xbowRecoil.SettingChanged += delegate { ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_recoilPushback = Plugin._xbowRecoil.Value; }; ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_recoilPushback = Plugin._xbowRecoil.Value; float reloadTime = ObjectDB.instance.GetItemPrefab(((Object)((Humanoid)__instance).GetCurrentWeapon().m_dropPrefab).name).GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_reloadTime; Plugin._xbowReloadSpeedTweak.SettingChanged += delegate { if (Plugin._xbowReloadSpeedTweak.Value == BowPlugin.Functions.Toggle.On) { Plugin._scaleByXbowLevel.SettingChanged += delegate { ToggleScaleByXbowLevel(__instance); }; ToggleScaleByXbowLevel(__instance); } else { ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = reloadTime; } }; if (Plugin._xbowReloadSpeedTweak.Value == BowPlugin.Functions.Toggle.On) { Plugin._scaleByXbowLevel.SettingChanged += delegate { ToggleScaleByXbowLevel(__instance); }; ToggleScaleByXbowLevel(__instance); } else { ((Humanoid)__instance).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = reloadTime; } } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "UseHotbarItem")] public static bool UseHotbarItem_Prefix(Player __instance) { if (Plugin._zoomLevel != ZoomLevel.ZoomedIn) { return true; } GameCamera.instance.m_fov = Plugin._defaultZoom; Plugin._zoomLevel = ZoomLevel.FixedZoom; Plugin._zoomOutDelayTimer = 0f; Plugin._zoomIntimer = 0f; Plugin._zoomOutTimer = 0f; return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "QueueReloadAction")] public static void QueueReloadAction_Prefix(Player __instance) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown if (__instance.IsReloadActionQueued()) { return; } ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon(); if (currentWeapon != null && currentWeapon.m_shared.m_attack.m_requiresReload) { if (Plugin._enableXbowSpeedRdction.Value == BowPlugin.Functions.Toggle.On) { ((Character)__instance).SetWalk(true); _justWalk = true; } MinorActionData item = new MinorActionData { m_item = currentWeapon, m_type = (ActionType)2, m_duration = currentWeapon.GetWeaponLoadingTime(), m_progressText = "$hud_reloading " + currentWeapon.m_shared.m_name, m_animation = currentWeapon.m_shared.m_attack.m_reloadAnimation, m_doneAnimation = currentWeapon.m_shared.m_attack.m_reloadAnimation + "_done", m_staminaDrain = currentWeapon.m_shared.m_attack.m_reloadStaminaDrain }; __instance.m_actionQueue.Add(item); } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "IsWeaponLoaded")] public static void IsWeaponLoaded_Postfix(Player __instance, ref bool __result) { if (__result && ((Character)__instance).GetWalk() && _justWalk && Plugin._enableXbowSpeedRdction.Value == BowPlugin.Functions.Toggle.On) { ((Character)__instance).SetWalk(false); _justWalk = false; } } private static void ToggleScaleByBowLevel(Player player) { float drawDurationMin = ObjectDB.instance.GetItemPrefab(((Object)((Humanoid)player).GetCurrentWeapon().m_dropPrefab).name).GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_drawDurationMin; if (Plugin._scaleByBowLevel.Value == BowPlugin.Functions.Toggle.On) { ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = drawDurationMin; double num = (double)Plugin._bowDrawSpeedFactor.Value * Helper.DiminishingReturn(((Character)player).GetSkillLevel((SkillType)8), 0f, 100f); ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = drawDurationMin - (float)num; return; } ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = drawDurationMin; Plugin._bowDrawSpeed.SettingChanged += delegate { ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = Plugin._bowDrawSpeed.Value; }; ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_drawDurationMin = Plugin._bowDrawSpeed.Value; } private static void ToggleScaleByXbowLevel(Player player) { float reloadTime = ObjectDB.instance.GetItemPrefab(((Object)((Humanoid)player).GetCurrentWeapon().m_dropPrefab).name).GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_reloadTime; if (Plugin._scaleByXbowLevel.Value == BowPlugin.Functions.Toggle.On) { ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = reloadTime; double num = (double)Plugin._xbowReloadSpeedFactor.Value * Helper.DiminishingReturn(((Character)player).GetSkillLevel((SkillType)8), 0f, 100f); ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = reloadTime - (float)num; return; } ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = reloadTime; Plugin._xbowReloadSpeed.SettingChanged += delegate { ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = Plugin._xbowReloadSpeed.Value; }; ((Humanoid)player).GetCurrentWeapon().m_shared.m_attack.m_reloadTime = Plugin._xbowReloadSpeed.Value; } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "LateUpdate")] private static void LateUpdate_Postfix(Player __instance, Transform ___m_head, ref Rigidbody ___m_body, ref VisEquipment ___m_visEquipment, ItemData ___m_rightItem, ItemData ___m_leftItem) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if ((Object)(object)Plugin._spine == (Object)null) { Plugin._spine = Enumerable.SingleOrDefault((IEnumerable<Transform>)((Humanoid)__instance).m_visEquipment.m_bodyModel.bones, (Func<Transform, bool>)((Transform x) => ((Object)x).name == "Spine")); } Quaternion rotation; if (___m_leftItem != null && (int)___m_leftItem.m_shared.m_itemType == 4 && Object.op_Implicit((Object)(object)___m_body) && Plugin._onBowDrawing) { Plugin._spineTimer = 0.5f; rotation = ((Component)((Character)__instance).m_eye).transform.rotation; float num = ((Quaternion)(ref rotation)).eulerAngles.y + 90f; Transform spine = Plugin._spine; rotation = Plugin._spine.rotation; float x2 = ((Quaternion)(ref rotation)).eulerAngles.x; rotation = ((Component)((Character)__instance).m_eye).transform.rotation; spine.rotation = Quaternion.Euler(x2, num, ((Quaternion)(ref rotation)).eulerAngles.x); } else if (Plugin._spineTimer > 0f) { Plugin._spineTimer -= Time.deltaTime; rotation = ((Component)((Character)__instance).m_eye).transform.rotation; float num2 = ((Quaternion)(ref rotation)).eulerAngles.y + 90f; Transform spine2 = Plugin._spine; rotation = Plugin._spine.rotation; float x3 = ((Quaternion)(ref rotation)).eulerAngles.x; rotation = ((Component)((Character)__instance).m_eye).transform.rotation; spine2.rotation = Quaternion.Euler(x3, num2, ((Quaternion)(ref rotation)).eulerAngles.x); } } } [HarmonyPatch] public static class ProjectilePatch { [HarmonyPrefix] [HarmonyPatch(typeof(Projectile), "OnHit")] public static void ProjectileOnHit_Prefix(Projectile __instance, Collider collider, Vector3 hitPoint, bool water) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon(); if (currentWeapon == null || (Object)(object)Player.m_localPlayer == (Object)null || !currentWeapon.m_shared.m_attack.m_bowDraw || !currentWeapon.m_shared.m_attack.m_requiresReload) { return; } GameObject val = (Object.op_Implicit((Object)(object)collider) ? Projectile.FindHitObject(collider) : null); IDestructible val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<IDestructible>() : null); bool flag = false; bool flag2 = false; if (__instance.m_aoe > 0f) { __instance.DoAOE(hitPoint, ref flag2, ref flag); } else if (val2 != null) { if (!__instance.IsValidTarget(val2)) { return; } flag = true; } Character val3 = (Character)(object)((val2 is Character) ? val2 : null); if (Object.op_Implicit((Object)(object)val3) && (Object)(object)__instance.m_owner != (Object)null && flag && __instance.m_owner.IsPlayer() && __instance.m_backstabBonus > 1f && (Object)(object)val3.m_baseAI != (Object)null && !val3.m_baseAI.IsAlerted() && Time.time - val3.m_backstabTime > 300f) { __instance.m_owner.RaiseSkill((SkillType)101, 3f); } } } [HarmonyPatch] public static class SkillsPatch { [HarmonyPatch(typeof(Skills), "RaiseSkill")] public static class RaiseSkillPatch { public static void Prefix(ref SkillType skillType, ref float factor) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (Plugin._enableExpMultiplier.Value != BowPlugin.Functions.Toggle.On) { return; } SkillType val = skillType; if ((int)val != 8) { if ((int)val == 14) { factor *= Plugin._xbowExpMultiplier.Value; } } else { factor *= Plugin._bowExpMultiplier.Value; } } public static void Postfix(Skills __instance, SkillType skillType) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (Plugin._enableExpMultiplier.Value != BowPlugin.Functions.Toggle.On || Plugin._displayExpGained.Value != BowPlugin.Functions.Toggle.On || ((int)skillType != 8 && (int)skillType != 14)) { return; } try { if (__instance.GetSkillLevel((SkillType)8) < 100f && __instance.GetSkillLevel((SkillType)14) < 100f) { Skill skill = __instance.GetSkill(skillType); float value = skill.m_accumulator / (skill.GetNextLevelRequirement() / 100f); ((Character)__instance.m_player).Message((MessageType)1, $"Level {skill.m_level.tFloat(0)} {((object)(SkillType)(ref skill.m_info.m_skill)).ToString()} [{skill.m_accumulator.tFloat(2)}/{skill.GetNextLevelRequirement().tFloat(2)} ({value.tFloat(0)}%)", 0, skill.m_info.m_icon); } } catch { } } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public class ZNetScenePatch { public static void Postfix(ZNetScene __instance) { if (!((Object)(object)__instance == (Object)null)) { List<GameObject> prefabs = __instance.m_prefabs; if (prefabs != null && prefabs.Count > 0 && !Plugin._IsBBHInstalled) { Plugin.PrefabContainerInit(); ArrowProjectile.Init(__instance); } } } } } namespace BowPlugin.Functions { public static class ArrowProjectile { public static void Init(ZNetScene zNetScene) { FlintArrow(zNetScene); BronzeArrow(zNetScene); IronArrow(zNetScene); ObsidianArrow(zNetScene); SilverArrow(zNetScene); BlackMetalBolt(zNetScene); IronBolt(zNetScene); CharredArrow(zNetScene); } private static void FlintArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_flint"); zNetScene.AddClonedObject(gameObject); } private static void BronzeArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_bronze"); zNetScene.AddClonedObject(gameObject); } private static void IronArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_iron"); zNetScene.AddClonedObject(gameObject); } private static void ObsidianArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_obsidian"); zNetScene.AddClonedObject(gameObject); } private static void SilverArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_silver"); zNetScene.AddClonedObject(gameObject); } private static void BlackMetalBolt(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("arbalest_projectile_carapace").Clone("arbalest_projectile_blackmetal"); zNetScene.AddClonedObject(gameObject); } private static void IronBolt(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("arbalest_projectile_carapace").Clone("arbalest_projectile_iron"); zNetScene.AddClonedObject(gameObject); } private static void CharredArrow(ZNetScene zNetScene) { GameObject gameObject = zNetScene.GetPrefab("bow_projectile").Clone("bow_projectile_charred"); zNetScene.AddClonedObject(gameObject); } } public static class BowFeature { private static readonly List<string> AmmoList = new List<string>(); public static void SwitchArrow() { Player localPlayer = Player.m_localPlayer; if (!CheckIfBowExist()) { return; } if (Plugin._enableArrowReticle.Value == Toggle.On) { switch (CountArrowStacks()) { case 0: ((Character)localPlayer).Message((MessageType)2, "There's no arrow in your inventory.", 0, (Sprite)null); return; case 1: ((Character)localPlayer).Message((MessageType)2, "There's only one type of arrow in your inventory.", 0, (Sprite)null); return; } } ((Humanoid)localPlayer).EquipItem(EquipNextArrow(), true); if (Plugin._enableArrowReticle.Value == Toggle.On) { ShowAmmoEquipped(); } else { ShowArrowEquipped(); } } private static bool CheckIfBowExist() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "main") { return false; } Player localPlayer = Player.m_localPlayer; if ((int)((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_skillType != 8 && (int)((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_skillType != 14) { return false; } if (string.IsNullOrEmpty(((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType)) { List<ItemData> list = new List<ItemData>(); ((Humanoid)localPlayer).GetInventory().GetAllItems((ItemType)4, list); switch (list.Count) { case 0: if (Plugin._arrowSelection.Value == Toggle.On && Plugin._enableArrowReticle.Value == Toggle.Off) { ((Character)localPlayer).Message((MessageType)2, "<size=28>There's no bow in your inventory.</size>", 0, (Sprite)null); } break; case 1: if (Plugin._autoEquipbow.Value == Toggle.On) { ((Humanoid)localPlayer).EquipItem(list[0], true); if (Plugin._enableArrowReticle.Value == Toggle.On) { ShowAmmoEquipped(); } else { ShowArrowEquipped(); } } break; } return false; } switch (CountArrowStacks()) { case 0: if (Plugin._arrowSelection.Value == Toggle.On && Plugin._enableArrowReticle.Value == Toggle.Off) { ((Character)localPlayer).Message((MessageType)2, "<size=28>There's no arrow in your inventory.</size>", 0, (Sprite)null); } return false; case 1: if (Plugin._arrowSelection.Value == Toggle.On && Plugin._enableArrowReticle.Value == Toggle.Off) { ((Character)localPlayer).Message((MessageType)2, "<size=28>You only have one type of arrow.</size>", 0, (Sprite)null); } return true; default: return true; } } public static void ShowArrowEquipped() { if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { Player localPlayer = Player.m_localPlayer; if (Plugin._arrowSelection.Value == Toggle.On && Plugin._enableArrowReticle.Value == Toggle.Off) { ((Character)localPlayer).Message((MessageType)2, "<size=28><color=red>" + ((Humanoid)localPlayer).GetAmmoItem()?.m_shared.m_name + "</color> equipped.</size>", 0, (Sprite)null); } } } public static void ShowAmmoEquipped() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { Player localPlayer = Player.m_localPlayer; if (!((Character)localPlayer).IsDead() && !Minimap.IsOpen() && Plugin._enableArrowReticle.Value == Toggle.On && CheckIfBowExist() && !((Character)localPlayer).IsDrawingBow()) { HudPatch._ammoPanel.SetActive(true); HudPatch._ammoHud.SetActive(true); } else { HudPatch._ammoHud.SetActive(false); HudPatch._ammoPanel.SetActive(false); } if (Plugin._enableArrowReticle.Value == Toggle.Off) { HudPatch._ammoHud.SetActive(false); HudPatch._ammoPanel.SetActive(false); } if ((int)((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_skillType != 8 && (int)((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_skillType != 14 && ((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_arrows" && ((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_bolts") { HudPatch._ammoHud.SetActive(false); HudPatch._ammoPanel.SetActive(false); } } } public static int CountArrowStacks() { int num = 0; Player localPlayer = Player.m_localPlayer; AmmoList.Clear(); foreach (ItemData item in Enumerable.Where(((Humanoid)localPlayer).GetInventory().GetAllItems(), (ItemData item) => (int)item.m_shared.m_itemType == 9 && !AmmoList.Contains(item.m_shared.m_name))) { AmmoList.Add(item.m_shared.m_name); num++; } return num; } private static ItemData EquipNextArrow() { Player player = Player.m_localPlayer; if (((Humanoid)player).GetAmmoItem() == null) { return ((Humanoid)player).GetInventory().GetAmmoItem(((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType, (string)null); } int num = CalculateArrows(((Humanoid)player).GetAmmoItem()); int num2 = -1; ItemData result = null; AmmoList.Clear(); foreach (ItemData item in Enumerable.Where(((Humanoid)player).GetInventory().GetAllItems(), delegate(ItemData item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 ItemType itemType = item.m_shared.m_itemType; bool flag = (((int)itemType == 2 || (int)itemType == 9) ? true : false); return flag && item.m_shared.m_ammoType == ((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType && !AmmoList.Contains(item.m_shared.m_name); })) { AmmoList.Add(item.m_shared.m_name); int num3 = CalculateArrows(item); if (num3 > num && num2 == -1) { num2 = num3; result = item; } else if (num3 < num2 && num3 > num) { num2 = num3; result = item; } } if (num2 != -1) { return result; } return ((Humanoid)player).GetInventory().GetAmmoItem(((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType, (string)null); } private static int CalculateArrows(ItemData item) { return item.m_gridPos.y * ((Humanoid)Player.m_localPlayer).GetInventory().GetWidth() + item.m_gridPos.x; } public static (int currentStack, string currentName, int nextStack, string nextName, int prevStack, string prevName) GetAmmoHudNames(Player player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 List<ItemData> list = new List<ItemData>(); HashSet<string> hashSet = new HashSet<string>(); foreach (ItemData item in ((Humanoid)player).m_inventory.m_inventory) { if ((int)item.m_shared.m_itemType == 9 && hashSet.Add(item.m_shared.m_name)) { list.Add(item); } } if (list.Count == 0) { return (0, "", 0, "", 0, ""); } ItemData currentAmo = ((Humanoid)player).GetAmmoItem(); int num = list.FindIndex((ItemData item) => item == currentAmo); if (num == -1) { num = 0; } int stack = list[num].m_stack; string name = list[num].m_shared.m_name; int index = (num + 1) % list.Count; int stack2 = list[index].m_stack; string name2 = list[index].m_shared.m_name; int index2 = (num - 1 + list.Count) % list.Count; int stack3 = list[index2].m_stack; string name3 = list[index2].m_shared.m_name; return (stack, name, stack2, name2, stack3, name3); } } public class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ShowRangeAsPercent; } public enum CrosshairSelection { Default, CircularGunTarget, SimpleCrosshair, DartBoardTarget, DeviceFocusPoint, EyeWideOpen, FightingWeaponTarget, PistolTarget, RoundTargetSymbol, SharpDecoratedTarget, ShootTargetPoint, TargetDesign, TriangularCrosshair } public static class CustomCrosshairs { public static Sprite _circularGunTarget; public static Sprite _simpleCrosshair; public static Sprite _dartBoardTarget; public static Sprite _deviceFocusPoint; public static Sprite _eyeWideOpen; public static Sprite _fightingWeaponTarget; public static Sprite _pistolTarget; public static Sprite _roundTargetSymbol; public static Sprite _sharpDecoratedTarget; public static Sprite _shootTargetPoint; public static Sprite _targetDesign; public static Sprite _triangularCrosshair; public static void Init() { _circularGunTarget = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/circular-gun-target.png"); _simpleCrosshair = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/crosshair.png"); _dartBoardTarget = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/dart-board-target.png"); _deviceFocusPoint = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/device-focus-point.png"); _eyeWideOpen = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/eye-wide-open.png"); _fightingWeaponTarget = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/fighting-weapon-target.png"); _pistolTarget = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/pistol-target.png"); _roundTargetSymbol = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/round-target-symbol.png"); _sharpDecoratedTarget = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/sharp-decorated-target.png"); _shootTargetPoint = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/shoot-target-point.png"); _targetDesign = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/target-design.png"); _triangularCrosshair = SetupPrefabs._bowBundle.LoadAsset<Sprite>("Assets/CustomAsset/Sprite/triangular-cross-hair.png"); } } public static class Helper { public static double DiminishingReturn(float value, float min, float max) { float num = max - min; float num2 = (value - min) / num; return Math.Sin(Math.PI / 2.0 * (double)num2); } public static bool IsBow(ItemData item) { return item.m_shared.m_name.ToLower().Contains("bow"); } public static bool IsArrow(ItemData item) { if (!item.m_shared.m_name.Contains("_arrow")) { return item.m_shared.m_name.Contains("_bolt"); } return true; } public static bool CheckBBHMod() { return Chainloader.PluginInfos.ContainsKey("Azumatt.BowsBeforeHoes"); } public static GameObject Clone(this GameObject gameObject, string name) { GameObject obj = Object.Instantiate<GameObject>(gameObject, Plugin._PrefabContainer.transform, false); ((Object)obj).name = name; obj.transform.SetParent(Plugin._PrefabContainer.transform, false); return obj; } public static void AddClonedObject(this ZNetScene zNetScene, GameObject gameObject, bool overWrite = true) { GameObject prefab; if ((Object)(object)(prefab = zNetScene.GetPrefab(((Object)gameObject).name)) != (Object)null) { if (!overWrite) { return; } zNetScene.m_prefabs.Remove(prefab); zNetScene.m_namedPrefabs.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name)); } zNetScene.m_prefabs.Add(gameObject); zNetScene.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject); } public static float tFloat(this float value, int digits) { double num = Math.Pow(10.0, digits); return (float)Math.Truncate(num * (double)value / num); } public static float BackstabBonusMultiplier(float backstabBonus, float skillFactor) { float num = backstabBonus; num = (1f + skillFactor) * backstabBonus / 2f; Plugin._sneakAttackMultiplier.SettingChanged += delegate { num *= Plugin._sneakAttackMultiplier.Value; }; num *= Plugin._sneakAttackMultiplier.Value; return Mathf.Max(num, 1f); } public static void UpdateBackstabMultiplier(ref int index, ref string tooltip, ItemData item) { string text = $"$item_backstab: <color=orange>{item.m_shared.m_backstabBonus}x</color>"; index = tooltip.IndexOf(text); if (index > -1) { Player localPlayer = Player.m_localPlayer; float num = BackstabBonusMultiplier(item.m_shared.m_backstabBonus, ((Character)localPlayer).GetSkillFactor((SkillType)101)); string text2 = $"$item_backstab: <color=orange>{item.m_shared.m_backstabBonus}x</color> <color=yellow>({num:#.##}x)</color>"; tooltip = tooltip.Replace(text, text2); index += text2.Length; } } public static void UpdateCriticalMultiplier(ref int index, ref string tooltip, ItemData item) { float num = 0f; float num2 = 0f; Plugin._critChance.SettingChanged += delegate { num = Plugin._critChance.Value; }; num = Plugin._critChance.Value; Plugin._critBonus.SettingChanged += delegate { num2 = Plugin._critBonus.Value; }; num2 = Plugin._critBonus.Value; string text = $"\n$bbp_critical_chance: <color=orange>{num}%</color>" + $"\n$bbp_critical_damage: <color=orange>{num2}x</color>"; tooltip = tooltip.Insert(index, text); index += text.Length; } public static void ApplyWeaponStaggerChanges(ItemDrop item) { if (IsBow(item.m_itemData)) { item.m_itemData.m_shared.m_attack.m_staggerMultiplier = 0.9f; } } } public static class SetupPrefabs { public static AssetBundle _bowBundle; public static GameObject _fxBowCrit; public static void Init() { _bowBundle = PrefabManager.RegisterAssetBundle("bowpluginbundle"); Arrows(); Bows(); Effects(); } private static void Arrows() { Item item = new Item(_bowBundle, "BBP_Bolt_Bronze"); item.Crafting.Add(CraftingTable.Forge, 1); item.CraftAmount = 20; item.RequiredItems.Add("Bronze", 5); item.RequiredItems.Add("Resin", 8); item.RequiredItems.Add("RoundLog", 10); item.RequiredItems.Add("Feathers", 5); item.Configurable = Configurability.Full; Item item2 = new Item(_bowBundle, "BBP_Bolt_Flint"); item2.Crafting.Add(CraftingTable.Workbench, 1); item2.CraftAmount = 20; item2.RequiredItems.Add("Flint", 3); item2.RequiredItems.Add("Stone", 5); item2.RequiredItems.Add("Wood", 8); item2.Configurable = Configurability.Full; Item item3 = new Item(_bowBundle, "BBP_Bolt_Wood"); item3.Crafting.Add(CraftingTable.Inventory, 1); item3.CraftAmount = 20; item3.RequiredItems.Add("Wood", 10); item3.Configurable = Configurability.Full; Item item4 = new Item(_bowBundle, "BBP_ExplodingArrow_Fire"); item4.Crafting.Add(CraftingTable.Forge, 1); item4.CraftAmount = 20; item4.RequiredItems.Add("BlackMetal", 20); item4.RequiredItems.Add("YggdrasilWood", 20); item4.RequiredItems.Add("Feathers", 20); item4.RequiredItems.Add("Resin", 20); item4.Configurable = Configurability.Full; Item item5 = new Item(_bowBundle, "BBP_ExplodingArrow_Frost"); item5.Crafting.Add(CraftingTable.Forge, 1); item5.CraftAmount = 20; item5.RequiredItems.Add("BlackMetal", 20); item5.RequiredItems.Add("YggdrasilWood", 20); item5.RequiredItems.Add("Feathers", 20); item5.RequiredItems.Add("FreezeGland", 20); item5.Configurable = Configurability.Full; Item item6 = new Item(_bowBundle, "BBP_ExplodingArrow_Poison"); item6.Crafting.Add(CraftingTable.Forge, 1); item6.CraftAmount = 20; item6.RequiredItems.Add("BlackMetal", 20); item6.RequiredItems.Add("YggdrasilWood", 20); item6.RequiredItems.Add("Feathers", 20); item6.RequiredItems.Add("Guck", 20); item6.Configurable = Configurability.Full; Item item7 = new Item(_bowBundle, "BBP_ExplodingBolt_Fire"); item7.Crafting.Add(CraftingTable.Forge, 1); item7.CraftAmount = 20; item7.RequiredItems.Add("BlackMetal", 20); item7.RequiredItems.Add("YggdrasilWood", 20); item7.RequiredItems.Add("Feathers", 20); item7.RequiredItems.Add("Resin", 20); item7.Configurable = Configurability.Full; Item item8 = new Item(_bowBundle, "BBP_ExplodingBolt_Frost"); item8.Crafting.Add(CraftingTable.Forge, 1); item8.CraftAmount = 20; item8.RequiredItems.Add("BlackMetal", 20); item8.RequiredItems.Add("YggdrasilWood", 20); item8.RequiredItems.Add("Feathers", 20); item8.RequiredItems.Add("FreezeGland", 20); item8.Configurable = Configurability.Full; Item item9 = new Item(_bowBundle, "BBP_ExplodingBolt_Poison"); item9.Crafting.Add(CraftingTable.Forge, 1); item9.CraftAmount = 20; item9.RequiredItems.Add("BlackMetal", 20); item9.RequiredItems.Add("YggdrasilWood", 20); item9.RequiredItems.Add("Feathers", 20); item9.RequiredItems.Add("Guck", 20); item9.Configurable = Configurability.Full; } private static void Bows() { Item item = new Item(_bowBundle, "BBP_Crossbow_BlackMetal"); item.Crafting.Add(CraftingTable.Forge, 1); item.RequiredItems.Add("BBP_Crossbow_Silver", 1); item.RequiredItems.Add("BlackMetal", 64); item.RequiredItems.Add("FineWood", 44); item.RequiredItems.Add("Chain", 6); item.RequiredUpgradeItems.Add("BlackMetal", 32); item.RequiredUpgradeItems.Add("FineWood", 22); item.RequiredUpgradeItems.Add("Chain", 3); item.Configurable = Configurability.Full; Item item2 = new Item(_bowBundle, "BBP_Crossbow_Bronze"); item2.Crafting.Add(CraftingTable.Forge, 1); item2.RequiredItems.Add("BBP_Crossbow_Flint", 1); item2.RequiredItems.Add("Bronze", 12); item2.RequiredItems.Add("RoundLog", 4); item2.RequiredItems.Add("Tin", 8); item2.RequiredUpgradeItems.Add("Bronze", 6); item2.RequiredUpgradeItems.Add("RoundLog", 2); item2.RequiredUpgradeItems.Add("Tin", 4); item2.Configurable = Configurability.Full; Item item3 = new Item(_bowBundle, "BBP_Crossbow_Flint"); item3.Crafting.Add(CraftingTable.Workbench, 1); item3.RequiredItems.Add("Flint", 8); item3.RequiredItems.Add("RoundLog", 2); item3.RequiredItems.Add("Wood", 10); item3.RequiredItems.Add("BoneFragments", 4); item3.RequiredUpgradeItems.Add("RoundLog", 1); item3.RequiredUpgradeItems.Add("Wood", 5); item3.RequiredUpgradeItems.Add("BoneFragments", 2); item3.Configurable = Configurability.Full; Item item4 = new Item(_bowBundle, "BBP_Crossbow_Iron"); item4.Crafting.Add(CraftingTable.Forge, 1); item4.RequiredItems.Add("BBP_Crossbow_Bronze", 1); item4.RequiredItems.Add("Iron", 28); item4.RequiredItems.Add("ElderBark", 12); item4.RequiredItems.Add("FineWood", 8); item4.RequiredUpgradeItems.Add("Iron", 14); item4.RequiredUpgradeItems.Add("ElderBark", 6); item4.RequiredUpgradeItems.Add("FineWood", 4); item4.Configurable = Configurability.Full; Item item5 = new Item(_bowBundle, "BBP_Crossbow_Silver"); item5.Crafting.Add(CraftingTable.Forge, 1); item5.RequiredItems.Add("BBP_Crossbow_Iron", 1); item5.RequiredItems.Add("Silver", 40); item5.RequiredItems.Add("FineWood", 32); item5.RequiredItems.Add("WolfFang", 10); item5.RequiredUpgradeItems.Add("Silver", 20); item5.RequiredUpgradeItems.Add("FineWood", 16); item5.RequiredUpgradeItems.Add("WolfFang", 5); item5.Configurable = Configurability.Full; Item item6 = new Item(_bowBundle, "BBP_BoneBow"); item6.Crafting.Add(CraftingTable.Workbench, 1); item6.RequiredItems.Add("BoneFragments", 8); item6.RequiredItems.A