From f4d42085c62f1032544583aa11be68fd81238672 Mon Sep 17 00:00:00 2001 From: AzumattDev Date: Mon, 10 Jul 2023 23:04:07 -0400 Subject: [PATCH] v1.2.8 : Refactor patches, update README.md, CHANGELOG.md,etc. --- README.md | 105 +++++++++++-- VeinMine/Patches.cs | 221 ++++++++++++---------------- VeinMine/Properties/AssemblyInfo.cs | 2 +- VeinMine/Thunderstore/CHANGELOG.md | 92 ++++++++++-- VeinMine/Thunderstore/README.md | 105 +++++++++++-- VeinMine/VeinMinePlugin.cs | 40 ++--- VeinMine/VersionHandshake.cs | 2 +- 7 files changed, 387 insertions(+), 180 deletions(-) diff --git a/README.md b/README.md index 18aa0b7..59773c6 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,103 @@ ![Valheim VeinMine](https://i.imgur.com/OAfRGXK.jpg) + Tired of mining for ages? With Veinmine you're able to mine the whole ore/rock vein at once! You can do this by holding down the assigned key (Left Alt by default) while mining! +`Version checks with itself. If installed on the server, it will kick clients who do not have it installed.` + +`This mod uses ServerSync, if installed on the server and all clients, it will sync all configs to client` + +`This mod uses a file watcher. If the configuration file is not changed with BepInEx Configuration manager, but changed in the file directly on the server, upon file save, it will sync the changes to all clients.` + ## **Version 1.0.0 - Progressive mode added!** ### **Please delete your previous config when updating as it might break something.** -You can now enable progressive mode in the config, making it so veinmining is scaled by your Pickaxes level. This is intended to be a less OP way of veinmining, where the tradeoff is taking higher durability damage (and less xp) than if you mined manually. - -The radius of the veinmined area is also scaled by your Pickaxes level. - -It works by checking for rocks in a radius set by the Progressive Level Multiplier value in the config. This value is multiplied by your Pickaxes level to obtain a radius. - -By default, it's set to 0.1 so assuming your Pickaxes level is 20, the radius will be 0.1 * 20 = 2. - -What does 2 mean, you ask? - -It's simple! A standard 2x2 floor piece has a length of 2, exactly like its name suggests. \ No newline at end of file +You can now enable progressive mode in the config, making it so veinmining is scaled by your Pickaxes level. This is +intended to be a less OP way of veinmining, where the tradeoff is taking higher durability damage (and less xp) than if +you mined manually. + +The radius of the veinmined area is also scaled by your Pickaxes level. + +It works by checking for rocks in a radius set by the Progressive Level Multiplier value in the config. This value is +multiplied by your Pickaxes level to obtain a radius. + +By default, it's set to 0.1 so assuming your Pickaxes level is 20, the radius will be 0.1 * 20 = 2. + +What does 2 mean, you ask? + +It's simple! A standard 2x2 floor piece has a length of 2, exactly like its name suggests. + +--- + +
+Installation Instructions + +***You must have BepInEx installed correctly! I can not stress this enough.*** + +### Manual Installation + +`Note: (Manual installation is likely how you have to do this on a server, make sure BepInEx is installed on the server correctly)` + +1. **Download the latest release of BepInEx.** +2. **Extract the contents of the zip file to your game's root folder.** +3. **Download the latest release of VeinMine from Thunderstore.io. (or Nexus Mods)** +4. **Extract the contents of the zip file to the `BepInEx/plugins` folder.** +5. **Launch the game.** + +### Installation through Vortex + +https://www.youtube.com/watch?v=Kt_6lwGd2Ns + +### Installation through r2modman or Thunderstore Mod Manager + +1. **Install [r2modman](https://valheim.thunderstore.io/package/ebkr/r2modman/) + or [Thunderstore Mod Manager](https://www.overwolf.com/app/Thunderstore-Thunderstore_Mod_Manager).** + + > For r2modman, you can also install it through the Thunderstore site. + ![](https://i.imgur.com/s4X4rEs.png "r2modman Download") + + > For Thunderstore Mod Manager, you can also install it through the Overwolf app store + ![](https://i.imgur.com/HQLZFp4.png "Thunderstore Mod Manager Download") +2. **Open the Mod Manager and search for "" under the Online + tab. `Note: You can also search for "Azumatt" to find all my mods.`** + + `The image below shows VikingShip as an example, but it was easier to reuse the image.` + + ![](https://i.imgur.com/5CR5XKu.png) + +3. **Click the Download button to install the mod.** +4. **Launch the game.** + +
+ +
+
+ +`Feel free to reach out to me on discord if you need manual download assistance.` + +# Current Author (Maintainer) Information + +### Azumatt + +`DISCORD:` Azumatt#2625 + +`STEAM:` https://steamcommunity.com/id/azumatt/ + +`GITHUB:` https://github.com/AzumattDev + +For Questions or Comments, find me in the Odin Plus Team Discord or in mine: + +[![https://i.imgur.com/XXP6HCU.png](https://i.imgur.com/XXP6HCU.png)](https://discord.gg/Pb6bVMnFb2) + + +
+ +# Original Author Information + +### WiseHorror + +`DISCORD:` WiseHorror (wisehorror) + +`GitHub:` https://github.com/WiseHorror \ No newline at end of file diff --git a/VeinMine/Patches.cs b/VeinMine/Patches.cs index 69e941d..21dfeaa 100644 --- a/VeinMine/Patches.cs +++ b/VeinMine/Patches.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using HarmonyLib; using UnityEngine; @@ -9,69 +10,30 @@ static class MineRockDamagePatch { static bool Prefix(MineRock __instance, HitData hit) { + Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 5f); + if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld()) { - if (VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On) + Vector3 firstHitPoint = hit.m_point; + foreach (var area in __instance.m_hitAreas) { - float radius = VeinMinePlugin.progressiveMult.Value * (float)Functions.GetSkillLevel(Player.GetClosestPlayer(hit.m_point, 5f).GetSkills(), Skills.SkillType.Pickaxes); - Vector3 firstHitPoint = hit.m_point; + if (area == null) continue; - foreach (var area in __instance.m_hitAreas) + if (VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On) { - if (Functions.GetDistanceFromPlayer(Player.GetClosestPlayer(hit.m_point, 5f).GetTransform().position, area.bounds.center) <= radius && area != null) - { - hit.m_point = area.transform.position; - hit.m_hitCollider = area; - if (hit.m_hitCollider == null) - { - ZLog.Log("Minerock hit has no collider"); - return false; - } - - int areaIndex = __instance.GetAreaIndex(hit.m_hitCollider); - if (areaIndex == -1) - { - //ZLog.Log("Invalid hit area on " + base.gameObject.name); - return false; - } + float radius = VeinMinePlugin.progressiveMult.Value * (float)Functions.GetSkillLevel(closestPlayer.GetSkills(), Skills.SkillType.Pickaxes); - ZLog.Log("Hit mine rock area " + areaIndex); - __instance.m_nview.InvokeRPC("Hit", new object[] - { - hit, - areaIndex - }); - hit.m_point = firstHitPoint; + if (Functions.GetDistanceFromPlayer(closestPlayer.GetTransform().position, area.bounds.center) <= radius) + { + ProcessHitArea(__instance, hit, area, firstHitPoint); } } - } - else - { - foreach (var area in __instance.m_hitAreas) + else { - string hpAreaName = "Health" + __instance.GetAreaIndex(area).ToString(); + string hpAreaName = $"Health{__instance.GetAreaIndex(area)}"; hit.m_damage.m_pickaxe = __instance.m_nview.GetZDO().GetFloat(hpAreaName, __instance.m_health); - hit.m_point = __instance.GetHitArea(__instance.GetAreaIndex(area)).bounds.center; - hit.m_hitCollider = area; - if (hit.m_hitCollider == null) - { - ZLog.Log("Minerock hit has no collider"); - return false; - } - - int areaIndex = __instance.GetAreaIndex(hit.m_hitCollider); - if (areaIndex == -1) - { - //ZLog.Log("Invalid hit area on " + base.gameObject.name); - return false; - } - - ZLog.Log("Hit mine rock area " + areaIndex); - __instance.m_nview.InvokeRPC("Hit", new object[] - { - hit, - areaIndex - }); + hit.m_point = area.bounds.center; + ProcessHitArea(__instance, hit, area, firstHitPoint); } } @@ -80,8 +42,26 @@ static bool Prefix(MineRock __instance, HitData hit) return true; } + + private static void ProcessHitArea(MineRock __instance, HitData hit, Collider area, Vector3 firstHitPoint) + { + hit.m_hitCollider = area; + if (hit.m_hitCollider == null) + { + VeinMinePlugin.logger.LogInfo("Minerock hit has no collider"); + return; + } + + int areaIndex = __instance.GetAreaIndex(hit.m_hitCollider); + if (areaIndex == -1) return; + + VeinMinePlugin.logger.LogInfo($"Hit mine rock area {areaIndex}"); + __instance.m_nview.InvokeRPC("Hit", hit, areaIndex); + hit.m_point = firstHitPoint; + } } + [HarmonyPatch(typeof(MineRock5), nameof(MineRock5.Damage))] static class MineRock5DamagePatch { @@ -90,66 +70,50 @@ static void Prefix(MineRock5 __instance, HitData hit, out Dictionary(); - if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld() && VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On) - { - var radiusColliders = Physics.OverlapSphere(hit.m_point, VeinMinePlugin.progressiveMult.Value * (float)Functions.GetSkillLevel(Player.GetClosestPlayer(hit.m_point, 5f).GetSkills(), Skills.SkillType.Pickaxes)); - - if (radiusColliders != null) - { - foreach (var area in radiusColliders) - { - if (__instance.GetAreaIndex(area) >= 0) - { - __state.Add(__instance.GetAreaIndex(area), __instance.GetHitArea(__instance.GetAreaIndex(area)).m_bound.m_pos + - __instance.GetHitArea(__instance.GetAreaIndex(area)).m_collider.transform.position); - } - } - } - } + Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 5f); + float radius = VeinMinePlugin.progressiveMult.Value * (float)Functions.GetSkillLevel(closestPlayer.GetSkills(), Skills.SkillType.Pickaxes); - if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld() && VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.Off) + if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld()) { - List radiusColliders = new List(); - foreach (var area in __instance.m_hitAreas) - { - radiusColliders.Add(area.m_collider); - } + IEnumerable radiusColliders; + + if (VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On) + radiusColliders = Physics.OverlapSphere(hit.m_point, radius); + else + radiusColliders = __instance.m_hitAreas.Select(area => area.m_collider); - if (radiusColliders != null) + foreach (var area in radiusColliders) { - foreach (var area in radiusColliders) + int areaIndex = __instance.GetAreaIndex(area); + if (areaIndex >= 0) { - if (__instance.GetAreaIndex(area) >= 0) - { - __state.Add(__instance.GetAreaIndex(area), __instance.GetHitArea(__instance.GetAreaIndex(area)).m_bound.m_pos + - __instance.GetHitArea(__instance.GetAreaIndex(area)).m_collider.transform.position); - } + __state.Add(areaIndex, + __instance.GetHitArea(areaIndex).m_bound.m_pos + + __instance.GetHitArea(areaIndex).m_collider.transform.position); } } } } - public static void Postfix(MineRock5 __instance, ZNetView ___m_nview, List ___m_hitAreas, HitData hit, Dictionary __state) + public static void Postfix(MineRock5 __instance, ZNetView ___m_nview, HitData hit, Dictionary __state) { - if (Player.GetClosestPlayer(hit.m_point, 5f) != null && hit.m_attacker == Player.GetClosestPlayer(hit.m_point, 5f).GetZDOID()) + Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 5f); + if (closestPlayer != null && hit.m_attacker == closestPlayer.GetZDOID() && VeinMinePlugin.veinMineKey.Value.IsKeyHeld()) { - if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld() && Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().GetDamage().m_pickaxe > 0) + var currentWeapon = closestPlayer.GetCurrentWeapon(); + if (currentWeapon.GetDamage().m_pickaxe > 0) { foreach (var index in __state) { - if (Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_durability > 0 || !Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_shared.m_useDurability) + if (currentWeapon.m_durability > 0 || !currentWeapon.m_shared.m_useDurability) { try { - ___m_nview.InvokeRPC("Damage", new object[] - { - hit, - index.Key - }); + ___m_nview.InvokeRPC("Damage", hit, index.Key); } catch { - VeinMinePlugin.logger.LogInfo("Skipping section: " + index.Key + "."); + VeinMinePlugin.logger.LogInfo($"Skipping section: {index.Key}."); } } } @@ -158,35 +122,44 @@ public static void Postfix(MineRock5 __instance, ZNetView ___m_nview, List 0f) hit.m_damage.m_pickaxe = __instance.m_health; - bool isVeinmined = false; + if (VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.Off && currentWeapon.GetDamage().m_pickaxe > 0f) hit.m_damage.m_pickaxe = __instance.m_health; + MineRock5.HitArea hitArea = __instance.GetHitArea(hitAreaIndex); + if (hitArea == null) + { + VeinMinePlugin.logger.LogInfo($"Missing hit area {hitAreaIndex}"); + __state = 0f; + __result = false; + return false; + } + __state = hitArea.m_health; Vector3 hitPoint = hitArea.m_collider.bounds.center; if (VeinMinePlugin.enableSpreadDamage.Value == VeinMinePlugin.Toggle.On) hit = Functions.SpreadDamage(hit); - if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld()) isVeinmined = true; - ZLog.Log("hit mine rock " + hitAreaIndex); + bool isVeinmined = VeinMinePlugin.veinMineKey.Value.IsKeyHeld(); + VeinMinePlugin.logger.LogInfo($"Hit mine rock {hitAreaIndex}"); + if (hitArea == null) { - ZLog.Log("Missing hit area " + hitAreaIndex); + VeinMinePlugin.logger.LogInfo($"Missing hit area {hitAreaIndex}"); __result = false; return false; } @@ -194,7 +167,7 @@ static bool Prefix(MineRock5 __instance, HitData hit, int hitAreaIndex, ref Effe __instance.LoadHealth(); if (hitArea.m_health <= 0f) { - ZLog.Log("Already destroyed"); + VeinMinePlugin.logger.LogInfo("Already destroyed"); __result = false; return false; } @@ -264,32 +237,32 @@ static bool Prefix(MineRock5 __instance, HitData hit, int hitAreaIndex, ref Effe static void Postfix(MineRock5 __instance, HitData hit, float __state, bool __result) { - if ( - hit != null - && Player.GetClosestPlayer(hit.m_point, 5f) != null - && Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon() != null - ) + Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 5f); + ItemDrop.ItemData? currentWeapon = closestPlayer?.GetCurrentWeapon(); + + if (hit != null && closestPlayer != null && currentWeapon != null && VeinMinePlugin.veinMineKey.Value.IsKeyHeld() && currentWeapon.GetDamage().m_pickaxe > 0) { - if (VeinMinePlugin.veinMineKey.Value.IsKeyHeld() && Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().GetDamage().m_pickaxe > 0) + if (__state > 0f && hit.m_attacker == closestPlayer.GetZDOID()) { - if (__state > 0f && hit.m_attacker == Player.GetClosestPlayer(hit.m_point, 5f).GetZDOID() && VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.Off) - { - Player.GetClosestPlayer(hit.m_point, 5f).RaiseSkill(Skills.SkillType.Pickaxes, Functions.GetSkillIncreaseStep(Player.GetClosestPlayer(hit.m_point, 5f).GetSkills(), Skills.SkillType.Pickaxes)); + var skills = closestPlayer.GetSkills(); + float skillIncreaseStep = Functions.GetSkillIncreaseStep(skills, Skills.SkillType.Pickaxes); - if (VeinMinePlugin.veinMineDurability.Value == VeinMinePlugin.Toggle.On && Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_shared.m_useDurability) - { - Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_durability -= Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_shared.m_useDurabilityDrain; - } + if (VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.Off) + { + closestPlayer.RaiseSkill(Skills.SkillType.Pickaxes, skillIncreaseStep); + } + else // VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On + { + closestPlayer.RaiseSkill(Skills.SkillType.Pickaxes, skillIncreaseStep * VeinMinePlugin.xpMult.Value); } - else if (__state > 0f && hit.m_attacker == Player.GetClosestPlayer(hit.m_point, 5f).GetZDOID() && VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On) + + if (VeinMinePlugin.veinMineDurability.Value == VeinMinePlugin.Toggle.On && currentWeapon.m_shared.m_useDurability) { - Player.GetClosestPlayer(hit.m_point, 5f).RaiseSkill(Skills.SkillType.Pickaxes, Functions.GetSkillIncreaseStep(Player.GetClosestPlayer(hit.m_point, 5f).GetSkills(), Skills.SkillType.Pickaxes) * VeinMinePlugin.xpMult.Value); + float durabilityLoss = VeinMinePlugin.progressiveMode.Value == VeinMinePlugin.Toggle.On + ? currentWeapon.m_shared.m_useDurabilityDrain * ((120 - Functions.GetSkillLevel(skills, Skills.SkillType.Pickaxes)) / (20 * VeinMinePlugin.durabilityMult.Value)) + : currentWeapon.m_shared.m_useDurabilityDrain; - if (VeinMinePlugin.veinMineDurability.Value == VeinMinePlugin.Toggle.On && Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_shared.m_useDurability) - { - float durabilityLoss = Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_shared.m_useDurabilityDrain * ((120 - Functions.GetSkillLevel(Player.GetClosestPlayer(hit.m_point, 5f).GetSkills(), Skills.SkillType.Pickaxes)) / (20 * VeinMinePlugin.durabilityMult.Value)); - Player.GetClosestPlayer(hit.m_point, 5f).GetCurrentWeapon().m_durability -= durabilityLoss; - } + currentWeapon.m_durability -= durabilityLoss; } } } diff --git a/VeinMine/Properties/AssemblyInfo.cs b/VeinMine/Properties/AssemblyInfo.cs index df3271c..0ca69a2 100644 --- a/VeinMine/Properties/AssemblyInfo.cs +++ b/VeinMine/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyTitle(VeinMinePlugin.ModName)] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany(VeinMinePlugin.Author + " & Azumatt")] +[assembly: AssemblyCompany($"{VeinMinePlugin.Author} & Azumatt")] [assembly: AssemblyProduct(VeinMinePlugin.ModName)] [assembly: AssemblyCopyright("Copyright © WiseHorror/Azumatt 2023")] [assembly: AssemblyTrademark("")] diff --git a/VeinMine/Thunderstore/CHANGELOG.md b/VeinMine/Thunderstore/CHANGELOG.md index eb58382..64ab3ae 100644 --- a/VeinMine/Thunderstore/CHANGELOG.md +++ b/VeinMine/Thunderstore/CHANGELOG.md @@ -1,65 +1,133 @@ +## 1.2.8 + +- Azumatt begins maintaining the mod. (Thanks WiseHorror for the opportunity!) +- `Changes to the configuration file have been made. Please delete your previous config when updating to this version. Sorry for the inconvenience.` +- Refactor a lot of code to make it more readable. +- Addition of ServerSync internally to allow for syncing of config between players and the server. + - This addition adds a new config option to enable/disable syncing of config between players and the server. +- Change the project to have more automation in the build process so that it is easier to maintain and push updates out + faster. +- Addition of MIT license to the code repository per WiseHorror's request. +- Update the README.md to have more information and add installation instructions. + ## 1.2.7 + - Fixed mod being broken. - Infinite durability can now be enabled for progressive mode. + ### 1.2.6 + - Compatibility with Mistlands and fix for Silver ore exception. + ### 1.2.5 + - Tentative fix for multiplayer veinmining by replacing the use of Player.m_localPlayer with Player.GetClosestPlayer. + ### 1.2.4 + - Fixed an exception that was thrown when mining Leviathans. - Added veinmining support for Leviathans and Glowing Metal (Flametal Ore). + ### 1.2.3 + - Fixed a bug that allowed players to veinmine (and gain exp) without a pickaxe. + ### 1.2.2 + - Possible fix for ore drop quantities (Not sure why they weren't correct, as I don't change drop rates) + ### 1.2.1 + - Compatibility for Hearth and Home; - Tentative fix for ores spawning at 0,0 (unable to test without other players) + ### 1.2.0 -- Replaced 'Even' spread damage option with 'Level' as even was useless when the mined vein had a large number of sections. + +- Replaced 'Even' spread damage option with 'Level' as even was useless when the mined vein had a large number of + sections. - Refactored code. + ### 1.1.9 + - Fixed incompatibility with Rocky Ore mod. + ### 1.1.8 + - Fixed a bug that was causing no ores to be dropped (hopefully) + ### 1.1.7 + - Fixed a bug that caused ores to drop every single pickaxe swing when mining manually. + ### 1.1.6 + - Fixed a bug that was causing no drops to be received when veinmining. + ### 1.1.5 + #### Please delete your previous config when updating to this version. + - Damage text when veinmining should now display on top of each rock section - Veinmining when Progressive mode is disabled is now instant - Spread damage now has two options: Even and Distance - Even is the same as previous versions - - Distance makes it so the damage dealt to a rock section is based on distance. The farther away a section is, the less damage is dealt. + - Distance makes it so the damage dealt to a rock section is based on distance. The farther away a section is, the + less damage is dealt. ### 1.1.4 + - Fixed a bug where if you had spread damage enabled, mining damage would also be reduced when mining manually. + ### 1.1.3 -- Added config option for spreading damage in progressive mode (divides your mining damage equally between all rock sections affected, as opposed to doing full damage to all sections) + +- Added config option for spreading damage in progressive mode (divides your mining damage equally between all rock + sections affected, as opposed to doing full damage to all sections) - This is disabled by default. + ### 1.1.2 -- Fixed incompatibility with mods that alter the pickaxe's durability drain values. The value modified by such mods (m_useDurabilityDrain) is now multiplied by the result of the previous formula (which is shown in the config). Take this into account when editing this mod's durability modifier. + +- Fixed incompatibility with mods that alter the pickaxe's durability drain values. The value modified by such mods ( + m_useDurabilityDrain) is now multiplied by the result of the previous formula (which is shown in the config). Take + this into account when editing this mod's durability modifier. + ### 1.1.1 + - Added config options for durability and xp multipliers for Progressive mode. + ### 1.1.0 -- Durability taken is now scaled to the player's Pickaxes level when Progressive mode is enabled. This is meant to (somewhat) balance veinmining so it fits in with vanilla. -- The formula is (120 - Level) / 20, so if you have level 50: (120 - 50) / 20 = 3.5 durability taken **per rock section veinmined** + +- Durability taken is now scaled to the player's Pickaxes level when Progressive mode is enabled. This is meant to ( + somewhat) balance veinmining so it fits in with vanilla. +- The formula is (120 - Level) / 20, so if you have level 50: (120 - 50) / 20 = 3.5 durability taken **per rock section + veinmined** + ### 1.0.1 + - Removed log messages to avoid spam. + ### 1.0.0 + - Added Progressive mode. + #### 0.0.1.4 -- Fixed a bug that allowed monsters to veinmine and/or give XP to the player. + +- Fixed a bug that allowed monsters to veinmine and/or give XP to the player. + #### 0.0.1.3 -- Indestructible items no longer lose durability. (such as items from Epic Loot) -- Added config option to disable mining visual effects, which *might* help reduce fps lag. (disabled by default) + +- Indestructible items no longer lose durability. (such as items from Epic Loot) +- Added config option to disable mining visual effects, which *might* help reduce fps lag. (disabled by default) + #### 0.0.1.2 -- Added config option for veinmining to take pickaxe durability for each section mined (default = true). -- XP is now only awarded if the section mined wasn't already destroyed. -- Fixed a NullReferenceException thrown when there were more than 128 rock sections. + +- Added config option for veinmining to take pickaxe durability for each section mined (default = true). +- XP is now only awarded if the section mined wasn't already destroyed. +- Fixed a NullReferenceException thrown when there were more than 128 rock sections. + #### 0.0.1.1 + - Mining xp is now awarded for every rock section mined. + #### 0.0.1.0 + - Initial release \ No newline at end of file diff --git a/VeinMine/Thunderstore/README.md b/VeinMine/Thunderstore/README.md index 18aa0b7..59773c6 100644 --- a/VeinMine/Thunderstore/README.md +++ b/VeinMine/Thunderstore/README.md @@ -1,20 +1,103 @@ ![Valheim VeinMine](https://i.imgur.com/OAfRGXK.jpg) + Tired of mining for ages? With Veinmine you're able to mine the whole ore/rock vein at once! You can do this by holding down the assigned key (Left Alt by default) while mining! +`Version checks with itself. If installed on the server, it will kick clients who do not have it installed.` + +`This mod uses ServerSync, if installed on the server and all clients, it will sync all configs to client` + +`This mod uses a file watcher. If the configuration file is not changed with BepInEx Configuration manager, but changed in the file directly on the server, upon file save, it will sync the changes to all clients.` + ## **Version 1.0.0 - Progressive mode added!** ### **Please delete your previous config when updating as it might break something.** -You can now enable progressive mode in the config, making it so veinmining is scaled by your Pickaxes level. This is intended to be a less OP way of veinmining, where the tradeoff is taking higher durability damage (and less xp) than if you mined manually. - -The radius of the veinmined area is also scaled by your Pickaxes level. - -It works by checking for rocks in a radius set by the Progressive Level Multiplier value in the config. This value is multiplied by your Pickaxes level to obtain a radius. - -By default, it's set to 0.1 so assuming your Pickaxes level is 20, the radius will be 0.1 * 20 = 2. - -What does 2 mean, you ask? - -It's simple! A standard 2x2 floor piece has a length of 2, exactly like its name suggests. \ No newline at end of file +You can now enable progressive mode in the config, making it so veinmining is scaled by your Pickaxes level. This is +intended to be a less OP way of veinmining, where the tradeoff is taking higher durability damage (and less xp) than if +you mined manually. + +The radius of the veinmined area is also scaled by your Pickaxes level. + +It works by checking for rocks in a radius set by the Progressive Level Multiplier value in the config. This value is +multiplied by your Pickaxes level to obtain a radius. + +By default, it's set to 0.1 so assuming your Pickaxes level is 20, the radius will be 0.1 * 20 = 2. + +What does 2 mean, you ask? + +It's simple! A standard 2x2 floor piece has a length of 2, exactly like its name suggests. + +--- + +
+Installation Instructions + +***You must have BepInEx installed correctly! I can not stress this enough.*** + +### Manual Installation + +`Note: (Manual installation is likely how you have to do this on a server, make sure BepInEx is installed on the server correctly)` + +1. **Download the latest release of BepInEx.** +2. **Extract the contents of the zip file to your game's root folder.** +3. **Download the latest release of VeinMine from Thunderstore.io. (or Nexus Mods)** +4. **Extract the contents of the zip file to the `BepInEx/plugins` folder.** +5. **Launch the game.** + +### Installation through Vortex + +https://www.youtube.com/watch?v=Kt_6lwGd2Ns + +### Installation through r2modman or Thunderstore Mod Manager + +1. **Install [r2modman](https://valheim.thunderstore.io/package/ebkr/r2modman/) + or [Thunderstore Mod Manager](https://www.overwolf.com/app/Thunderstore-Thunderstore_Mod_Manager).** + + > For r2modman, you can also install it through the Thunderstore site. + ![](https://i.imgur.com/s4X4rEs.png "r2modman Download") + + > For Thunderstore Mod Manager, you can also install it through the Overwolf app store + ![](https://i.imgur.com/HQLZFp4.png "Thunderstore Mod Manager Download") +2. **Open the Mod Manager and search for "" under the Online + tab. `Note: You can also search for "Azumatt" to find all my mods.`** + + `The image below shows VikingShip as an example, but it was easier to reuse the image.` + + ![](https://i.imgur.com/5CR5XKu.png) + +3. **Click the Download button to install the mod.** +4. **Launch the game.** + +
+ +
+
+ +`Feel free to reach out to me on discord if you need manual download assistance.` + +# Current Author (Maintainer) Information + +### Azumatt + +`DISCORD:` Azumatt#2625 + +`STEAM:` https://steamcommunity.com/id/azumatt/ + +`GITHUB:` https://github.com/AzumattDev + +For Questions or Comments, find me in the Odin Plus Team Discord or in mine: + +[![https://i.imgur.com/XXP6HCU.png](https://i.imgur.com/XXP6HCU.png)](https://discord.gg/Pb6bVMnFb2) + + +
+ +# Original Author Information + +### WiseHorror + +`DISCORD:` WiseHorror (wisehorror) + +`GitHub:` https://github.com/WiseHorror \ No newline at end of file diff --git a/VeinMine/VeinMinePlugin.cs b/VeinMine/VeinMinePlugin.cs index b5ddf36..c410226 100644 --- a/VeinMine/VeinMinePlugin.cs +++ b/VeinMine/VeinMinePlugin.cs @@ -13,15 +13,13 @@ namespace Veinmine { [BepInPlugin(ModGUID, ModName, ModVersion)] - [BepInProcess("valheim.exe")] - [BepInProcess("valheim_server.exe")] public class VeinMinePlugin : BaseUnityPlugin { internal const string ModName = "Veinmine"; - internal const string ModVersion = "1.2.7"; + internal const string ModVersion = "1.2.8"; internal const string Author = "wisehorror"; - private const string ModGUID = "com." + Author + "." + ModName; - private static string ConfigFileName = ModGUID + ".cfg"; + private const string ModGUID = $"com.{Author}.{ModName}"; + private static string ConfigFileName = $"{ModGUID}.cfg"; private static string ConfigFileFullPath = Paths.ConfigPath + Path.DirectorySeparatorChar + ConfigFileName; internal static string ConnectionError = ""; private readonly Harmony _harmony = new(ModGUID); @@ -43,7 +41,9 @@ public enum Toggle void Awake() { - _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, + _serverConfigLocked = config("1 - General", + "Lock Configuration", + Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); _ = ConfigSync.AddLockingConfigEntry(_serverConfigLocked); @@ -136,15 +136,15 @@ private void ReadConfigValues(object sender, FileSystemEventArgs e) #region ConfigOptions private static ConfigEntry _serverConfigLocked = null!; - public static ConfigEntry veinMineKey; - public static ConfigEntry veinMineDurability; - public static ConfigEntry removeEffects; - public static ConfigEntry progressiveMode; - public static ConfigEntry enableSpreadDamage; - public static ConfigEntry spreadDamageType; - public static ConfigEntry progressiveMult; - public static ConfigEntry durabilityMult; - public static ConfigEntry xpMult; + public static ConfigEntry veinMineKey = null!; + public static ConfigEntry veinMineDurability = null!; + public static ConfigEntry removeEffects = null!; + public static ConfigEntry progressiveMode = null!; + public static ConfigEntry enableSpreadDamage = null!; + public static ConfigEntry spreadDamageType = null!; + public static ConfigEntry progressiveMult = null!; + public static ConfigEntry durabilityMult = null!; + public static ConfigEntry xpMult = null!; private ConfigEntry config(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) @@ -171,10 +171,10 @@ private ConfigEntry config(string group, string name, T value, string desc private class ConfigurationManagerAttributes { - [UsedImplicitly] public int? Order; - [UsedImplicitly] public bool? Browsable; - [UsedImplicitly] public string? Category; - [UsedImplicitly] public Action? CustomDrawer; + [UsedImplicitly] public int? Order = null!; + [UsedImplicitly] public bool? Browsable = null!; + [UsedImplicitly] public string Category = null!; + [UsedImplicitly] public Action CustomDrawer = null!; } class AcceptableShortcuts : AcceptableValueBase @@ -187,7 +187,7 @@ public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) public override bool IsValid(object value) => true; public override string ToDescriptionString() => - "# Acceptable values: " + string.Join(", ", KeyboardShortcut.AllKeyCodes); + $"# Acceptable values: {string.Join(", ", UnityInput.Current.SupportedKeyCodes)}"; } #endregion diff --git a/VeinMine/VersionHandshake.cs b/VeinMine/VersionHandshake.cs index 9f217b1..21794f2 100644 --- a/VeinMine/VersionHandshake.cs +++ b/VeinMine/VersionHandshake.cs @@ -53,7 +53,7 @@ private static void Postfix(FejdStartup __instance) { __instance.m_connectionFailedError.resizeTextMaxSize = 25; __instance.m_connectionFailedError.resizeTextMinSize = 15; - __instance.m_connectionFailedError.text += "\n" + VeinMinePlugin.ConnectionError; + __instance.m_connectionFailedError.text += $"\n{VeinMinePlugin.ConnectionError}"; } } }