-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6a81321
Showing
9 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
InstantMonsterDrop/bin/** | ||
InstantMonsterDrop/obj/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# v0.6.0 | ||
- Removed terminal reload | ||
- Added compatibility for v0.217.46 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstantMonsterDrop", "InstantMonsterDrop\InstantMonsterDrop.csproj", "{B1AB407E-A3BD-4A00-853B-1368EEC5CC30}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B1AB407E-A3BD-4A00-853B-1368EEC5CC30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B1AB407E-A3BD-4A00-853B-1368EEC5CC30}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B1AB407E-A3BD-4A00-853B-1368EEC5CC30}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B1AB407E-A3BD-4A00-853B-1368EEC5CC30}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4EBA0353-83CD-4B8F-BC5B-A2D6136F2877} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using BepInEx; | ||
using BepInEx.Configuration; | ||
using HarmonyLib; | ||
using System.Collections; | ||
using System.Reflection; | ||
using UnityEngine; | ||
|
||
namespace InstantMonsterDrop | ||
{ | ||
[BepInPlugin("mchangrh.InstantMonsterDrop", "Instant Monster Drop", "0.6.0")] | ||
public class BepInExPlugin : BaseUnityPlugin | ||
{ | ||
private static BepInExPlugin context; | ||
private static ConfigEntry<bool> modEnabled; | ||
private static ConfigEntry<float> dropDelay; | ||
private static ConfigEntry<float> destroyDelay; | ||
|
||
private void Awake() | ||
{ | ||
context = this; | ||
modEnabled = Config.Bind<bool>("General", "Enabled", true, "Enable this mod"); | ||
dropDelay = Config.Bind<float>("General", "DropDelay", 0.01f, "Delay before dropping loot"); | ||
destroyDelay = Config.Bind<float>("General", "DestroyDelay", 0.05f, "Delay before destroying ragdoll"); | ||
Config.Save(); | ||
if (!modEnabled.Value) | ||
return; | ||
|
||
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), null); | ||
} | ||
|
||
[HarmonyPatch(typeof(Ragdoll), "Awake")] | ||
static class Ragdoll_Awake_Patch | ||
{ | ||
static void Postfix(Ragdoll __instance, ZNetView ___m_nview, EffectList ___m_removeEffect) | ||
{ | ||
if (!ZNetScene.instance) | ||
return; | ||
context.StartCoroutine(DropNow(__instance, ___m_nview, ___m_removeEffect)); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(Ragdoll), "DestroyNow")] | ||
static class Ragdoll_DestroyNow_Patch | ||
{ | ||
static bool Prefix(Ragdoll __instance) | ||
{ | ||
return !modEnabled.Value; | ||
} | ||
} | ||
|
||
private static IEnumerator DropNow(Ragdoll ragdoll, ZNetView nview, EffectList removeEffect) | ||
{ | ||
if(dropDelay.Value < 0) | ||
{ | ||
context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect)); | ||
yield break; | ||
} | ||
|
||
yield return new WaitForSeconds(dropDelay.Value); | ||
|
||
if (!modEnabled.Value) | ||
yield break; | ||
|
||
if (!nview.IsValid() || !nview.IsOwner()) | ||
{ | ||
yield break; | ||
} | ||
Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition(); | ||
Traverse.Create(ragdoll).Method("SpawnLoot", new object[] { averageBodyPosition }).GetValue(); | ||
context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect)); | ||
} | ||
|
||
private static IEnumerator DestroyNow(Ragdoll ragdoll, ZNetView nview, EffectList m_removeEffect) | ||
{ | ||
yield return new WaitForSeconds(Mathf.Max(destroyDelay.Value - dropDelay.Value, 0)); | ||
|
||
if (!modEnabled.Value) | ||
yield break; | ||
|
||
if (!nview.IsValid() || !nview.IsOwner()) | ||
{ | ||
yield break; | ||
} | ||
Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition(); | ||
m_removeEffect.Create(averageBodyPosition, Quaternion.identity, null, 1f, -1); | ||
ZNetScene.instance.Destroy(ragdoll.gameObject); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net40</TargetFramework> | ||
<AssemblyName>InstantMonsterDrop</AssemblyName> | ||
<Description>Updated Fork of InstantMonsterDrop</Description> | ||
<Version>1.0.0</Version> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<LangVersion>latest</LangVersion> | ||
<RestoreAdditionalProjectSources> | ||
https://api.nuget.org/v3/index.json; | ||
https://nuget.bepinex.dev/v3/index.json | ||
</RestoreAdditionalProjectSources> | ||
<RootNamespace>InstantDrop</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(SolutionDir)\valheim.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This entire repository's contents, as far as legally possible and unless a project specifies otherwise, are released into the public domain. | ||
|
||
The creator of this file disavows any copyright over any content in this repository, and content licensed from other sources is clearly labeled as such. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# InstantMonsterDropFork | ||
|
||
An updated fork of [aedenthorn/InstantMonsterDrop](https://github.com/aedenthorn/ValheimMods/tree/master/InstantMonsterDrop) patched for v0.217.46+ | ||
|
||
[ThunderStore]() | [NexusMods]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "InstantMonsterDropFork", | ||
"version_number": "0.6.0", | ||
"website_url": "https://github.com/mchangrh/InstantMonsterDrop_Fork", | ||
"description": "Fork of aedenthorn/InstantMonsterDrop for v0.217.46+", | ||
"dependencies": [ | ||
"denikson-BepInExPack_Valheim-5.4.2202" | ||
] | ||
} |
Oops, something went wrong.