Skip to content

Commit

Permalink
Changelog
Browse files Browse the repository at this point in the history
- Added a option to remove structure damage to buildings built by players
- Added a option to disable portals
- Added no weather damage to objects placed in water
- Added a option to the Gathering to increase drop chances of resources from resource nodes
- Fixed iron scrap not being affected by gathering rates
- Fixed issues from crop notifications
  • Loading branch information
nxPublic committed Mar 6, 2021
1 parent 07e8b2b commit 83c94a6
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ All of these features can be adjusted by a configuration file. This also allows
* Iron
* Hardwood
* Disable structural integrity entirely, allowing you to place objects in free air.
* Disable all damage to player built structures/objects.

## Player Hud
* Show the experience you gained for a skill in the top left corner
Expand All @@ -83,12 +84,14 @@ All of these features can be adjusted by a configuration file. This also allows
## Gathering
* Modify the amount of resources dropped on destruction of objects.
*This includes all types of wood (inc. elderbark), stone, iron/bronze/tin/silver/copper and chitin.*
* Modify the drop chance of resources from destroyed objects.

## Game Difficulty
* Modify the game difficulty multipliers applied to health and damage of enemies based on the amount of connected players.
* Change the range of where the game considers other players to be nearby.
* Add a additional amount of Players to the player count for the difficulty calculation.
* Set the difficulty calculation to a specific player count.
* Option to disable the use of portals

## Skill Experience
* Modify each skill's experience gain seperately by percent.
Expand Down Expand Up @@ -134,6 +137,7 @@ Prevents players on the server from making themselves invisible on the map.
# Building
* Remove Building "Invalid Placement" restriction
* Remove Building Object deterioration by weather.
* Remove Building Object deterioration by water.
* Advanced Building Mode
* Advanced Editing Mode
* Structural Integrity modification system
Expand Down
1 change: 1 addition & 0 deletions ValheimPlus/Configurations/Sections/GameConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class GameConfiguration : ServerSyncConfig<GameConfiguration>
public int extraPlayerCountNearby { get; internal set; } = 0;
public int setFixedPlayerCountTo { get; internal set; } = 0;
public int difficultyScaleRange { get; internal set; } = 200;
public bool disablePortals { get; set; } = false;
}
}
1 change: 1 addition & 0 deletions ValheimPlus/Configurations/Sections/GatherConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class GatherConfiguration : ServerSyncConfig<GatherConfiguration>
public float copperOre { get; internal set; } = 0;
public float silverOre { get; internal set; } = 0;
public float chitin { get; internal set; } = 0;
public float dropChance { get; internal set; } = 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class StructuralIntegrityConfiguration : ServerSyncConfig<StructuralInteg
public float iron { get; internal set; } = 0;
public float hardWood { get; internal set; } = 0;
public bool disableStructuralIntegrity { get; set; } = false;
public bool disableDamageToPlayerStructures { get; set; } = false;
}
}
24 changes: 22 additions & 2 deletions ValheimPlus/GameClasses/DropTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,28 @@ namespace ValheimPlus.GameClasses
[HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })]
public static class DropTable_GetDropList_Patch
{
private static void Postfix(ref DropTable __instance, ref List<GameObject> __result, int amount)

static float originalDropChance = 0;
private static void Prefix(ref DropTable __instance, ref List<GameObject> __result, int amount)
{
originalDropChance = __instance.m_dropChance; // we have to save the original to change it back after the function
if (Configuration.Current.Gathering.IsEnabled && Configuration.Current.Gathering.dropChance != 0)
{
float newDropChance = Helper.applyModifierValue(__instance.m_dropChance, Configuration.Current.Gathering.dropChance);
if (newDropChance >= 1)
newDropChance = 1;
if (newDropChance <= 0)
newDropChance = 0;

if (__instance.m_dropChance != 1)
__instance.m_dropChance = newDropChance;
}
}

private static void Postfix(ref DropTable __instance, ref List<GameObject> __result, int amount)
{
__instance.m_dropChance = originalDropChance; // Apply the original drop chance in case modified

if (!Configuration.Current.Gathering.IsEnabled)
return;

Expand Down Expand Up @@ -65,7 +85,7 @@ private static void Postfix(ref DropTable __instance, ref List<GameObject> __res
stone += 1;
stoneObject = toDrop;
break;
case "ScrapIron": // Iron
case "IronScrap": // Iron
scrapIron += 1;
scrapIronObject = toDrop;
break;
Expand Down
3 changes: 0 additions & 3 deletions ValheimPlus/GameClasses/ItemDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ private static bool Prefix(ref ItemDrop.ItemData __instance, ref int quality, re
if (!Configuration.Current.Durability.IsEnabled)
return true;



// Tools: Axe, How, Cultivator, Hammer, Pickaxe
string itemName = __instance.m_shared.m_name.Replace("$item_", "");
string itemType = itemName.Split(new char[] { '_' })[0];

Expand Down
7 changes: 6 additions & 1 deletion ValheimPlus/GameClasses/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,14 @@ private static void Postfix(ref Player __instance)

}
}



if (Configuration.Current.Player.IsEnabled && Configuration.Current.Player.cropNotifier)
{

if (__instance.m_placementGhost == null)
return;

// Check to see if the current placement ghost is has a plant component
Plant plantComponent = __instance.m_placementGhost.GetComponent<Plant>();
if (plantComponent != null && __instance.m_placementStatus == Player.PlacementStatus.Valid)
Expand Down
25 changes: 25 additions & 0 deletions ValheimPlus/GameClasses/TeleportWorld.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using HarmonyLib;
using ValheimPlus.Configurations;
using UnityEngine;

namespace ValheimPlus
{

/// <summary>
/// Disable portals
/// </summary>
[HarmonyPatch(typeof(TeleportWorld), "Teleport", new System.Type[] { typeof(Player) })]
public static class TeleportWorld_Teleport_Patch
{
private static bool Prefix(ref TeleportWorld __instance, ref Player player)
{
if (Configuration.Current.Game.IsEnabled && Configuration.Current.Game.disablePortals)
{
MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "Portals have been disabled on this Server.");
return false;
}

return true;
}
}
}
34 changes: 32 additions & 2 deletions ValheimPlus/GameClasses/WearNTear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,41 @@ private static void Postfix(ref bool __result)
}
}
}


/// <summary>
/// Disable weather damage under water
/// </summary>
[HarmonyPatch(typeof(WearNTear), "IsUnderWater")]
public static class RemoveWearNTearFromUnderWater
{
private static void Postfix(ref bool __result)
{
if (Configuration.Current.Building.IsEnabled && Configuration.Current.Building.noWeatherDamage)
{
__result = false;
}
}
}

/// <summary>
/// Disable damage to player structures
/// </summary>
[HarmonyPatch(typeof(WearNTear), "ApplyDamage")]
public static class WearNTear_ApplyDamage_Patch
{
private static bool Prefix(ref WearNTear __instance,ref float damage)
{
if (Configuration.Current.StructuralIntegrity.IsEnabled && Configuration.Current.StructuralIntegrity.disableDamageToPlayerStructures && __instance.m_piece && __instance.m_piece.IsPlacedByPlayer())
return false;

return true;
}
}

/// <summary>
/// Disable structural integrity
/// </summary>
[HarmonyPatch(typeof(WearNTear), "GetMaterialProperties")]
[HarmonyPatch(typeof(WearNTear), "GetMaterialProperties")]
public static class RemoveStructualIntegrity
{
private static bool Prefix(ref WearNTear __instance, out float maxSupport, out float minSupport, out float horizontalLoss, out float verticalLoss)
Expand Down
2 changes: 1 addition & 1 deletion ValheimPlus/ValheimPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ValheimPlus
[BepInPlugin("org.bepinex.plugins.valheim_plus", "Valheim Plus", version)]
public class ValheimPlusPlugin : BaseUnityPlugin
{
public const string version = "0.9.3";
public const string version = "0.9.4";
public static string newestVersion = "";
public static bool isUpToDate = false;

Expand Down
1 change: 1 addition & 0 deletions ValheimPlus/ValheimPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
<Compile Include="GameClasses\Fireplace.cs" />
<Compile Include="GameClasses\GameCamera.cs" />
<Compile Include="GameClasses\Hud.cs" />
<Compile Include="GameClasses\TeleportWorld.cs" />
<Compile Include="GameClasses\Humanoid.cs" />
<Compile Include="ValheimPlus.cs" />
<Compile Include="GameClasses\Fermenter.cs" />
Expand Down
13 changes: 12 additions & 1 deletion valheim_plus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ setFixedPlayerCountTo=0
; The range in meters at which other players count towards nearby players for the difficulty scale
difficultyScaleRange=200

; If you set this to true, all portals will be disabled
disablePortals=false

[Hotkeys]
; https://docs.unity3d.com/ScriptReference/KeyCode.html <- a list of keycodes

Expand Down Expand Up @@ -232,6 +235,11 @@ removeDamageFlash=false
; Change false to true to enable this section
enabled=false

; Modify the chance to drop resources from resource nodes affected by this category
; This only works on resource nodes that do not have garuanteed drops
; As example by default scrap piles in dungeons have a 20% chance to drop a item, if you set this option to 200, you will then have a 60% chance to drop iron.
dropChance=0

; Each of these values increase or reduce the dropped items from destroyed objects with tools (Stones, Trees, Resource nodes, etc.) by %
; The value 50 will increase the dropped wood from trees from 10 to 15. The value -50 will reduce the amount of dropped wood from 10 to 5.
wood=0
Expand Down Expand Up @@ -352,7 +360,7 @@ dataRate=60


[Stamina]
; Each of these values allow for - values, 50% will increase the stamina cost by 50, -50 will reduce the stamina cost by 50%
; Each of these values allow for - values, 50 will increase the stamina cost by 50%, -50 will reduce the stamina cost by 50%
; Change false to true to enable this section
enabled=false

Expand Down Expand Up @@ -409,6 +417,9 @@ enabled=false
; Disables the entire structural integrity system and allows for placement in free air, does not prevent building damage.
disableStructuralIntegrity=false

; Disables any damage from anything to all player built structures
disableDamageToPlayerStructures=false

; Each of these values reduce the loss of structural integrity by % less. The value 100 would result in disabled structural integrity and allow placement in free air.
wood=0
stone=0
Expand Down

0 comments on commit 83c94a6

Please sign in to comment.