Skip to content

Commit 2aa7bd9

Browse files
committed
Initial working prototype.
0 parents  commit 2aa7bd9

File tree

9 files changed

+267
-0
lines changed

9 files changed

+267
-0
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#Ignore thumbnails created by Windows
3+
Thumbs.db
4+
#Ignore files built by Visual Studio
5+
*.obj
6+
*.exe
7+
*.pdb
8+
*.user
9+
*.aps
10+
*.pch
11+
*.vspscc
12+
*_i.c
13+
*_p.c
14+
*.ncb
15+
*.suo
16+
*.tlb
17+
*.tlh
18+
*.bak
19+
*.cache
20+
*.ilk
21+
*.log
22+
[Bb]in
23+
[Dd]ebug*/
24+
*.lib
25+
*.sbr
26+
obj/
27+
[Rr]elease*/
28+
_ReSharper*/
29+
[Tt]est[Rr]esult*
30+
.vs/
31+
#Nuget packages folder
32+
packages/
33+
#Valheim References
34+
libs/

NamedPetPatch.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using HarmonyLib;
2+
using UnityEngine;
3+
4+
namespace NamedPetTags
5+
{
6+
[HarmonyPatch]
7+
internal class NamedPetPatch
8+
{
9+
[HarmonyPatch(typeof(Tameable), "GetHoverText")]
10+
[HarmonyPostfix]
11+
public static void Tameable_GetHoverText(Tameable __instance, ref string __result)
12+
{
13+
string petName = __instance.GetText();
14+
15+
if (petName.Contains("<pet>"))
16+
{
17+
__result = __result.Insert(__result.IndexOf(" )"), ", Pet");
18+
}
19+
}
20+
21+
[HarmonyPatch(typeof(Character), "ApplyDamage")]
22+
[HarmonyPostfix]
23+
public static void Character_ApplyDamage(Character __instance, HitData hit, ref bool showDamageText, ref bool triggerEffects, ref HitData.DamageModifier mod, Tameable ___m_tameable)
24+
{
25+
if (!__instance.IsTamed() || ___m_tameable == false) return;
26+
string petName = ___m_tameable.GetText();
27+
28+
if (petName.Contains("<pet>"))
29+
{
30+
__instance.SetHealth(__instance.GetMaxHealth());
31+
}
32+
}
33+
34+
[HarmonyPatch(typeof(Procreation), "MakePregnant")]
35+
[HarmonyPostfix]
36+
public static void Procreation_MakePregnant(Tameable ___m_tameable, ZNetView ___m_nview)
37+
{
38+
string petName = ___m_tameable.GetText();
39+
40+
if (petName.Contains("<pet>"))
41+
{
42+
___m_nview.GetZDO().Set(ZDOVars.s_pregnant, 0L);
43+
}
44+
}
45+
46+
[HarmonyPatch(typeof(Procreation), "IsDue")]
47+
[HarmonyPostfix]
48+
public static void Procreation_IsDue(Tameable ___m_tameable, ZNetView ___m_nview, ref bool __result)
49+
{
50+
string petName = ___m_tameable.GetText();
51+
52+
if (petName.Contains("<pet>"))
53+
{
54+
___m_nview.GetZDO().Set(ZDOVars.s_pregnant, 0L);
55+
__result = false;
56+
}
57+
}
58+
}
59+
}

NamedPetTags.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using BepInEx;
2+
using HarmonyLib;
3+
4+
namespace NamedPetTags
5+
{
6+
[BepInPlugin(modGUID, modName, modVersion)]
7+
public class NamedPetTags : BaseUnityPlugin
8+
{
9+
private const string modGUID = "Fusionette.NamedPetTags";
10+
private const string modName = "Named Pet Tags";
11+
private const string modVersion = "0.9.0";
12+
private readonly Harmony harmony = new Harmony(modGUID);
13+
14+
void Awake()
15+
{
16+
harmony.PatchAll();
17+
}
18+
19+
void OnDestroy()
20+
{
21+
harmony.UnpatchSelf();
22+
}
23+
}
24+
}

NamedPetTags.csproj

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{92B68BD7-AF4D-408E-9A79-849CF19F112C}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>NamedPetTags</RootNamespace>
11+
<AssemblyName>NamedPetTags</AssemblyName>
12+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="0Harmony">
35+
<HintPath>libs\0Harmony.dll</HintPath>
36+
</Reference>
37+
<Reference Include="assembly_valheim">
38+
<HintPath>libs\assembly_valheim.dll</HintPath>
39+
</Reference>
40+
<Reference Include="BepInEx">
41+
<HintPath>libs\BepInEx.dll</HintPath>
42+
</Reference>
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Data.DataSetExtensions" />
47+
<Reference Include="Microsoft.CSharp" />
48+
<Reference Include="System.Data" />
49+
<Reference Include="System.Net.Http" />
50+
<Reference Include="System.Xml" />
51+
<Reference Include="UnityEngine">
52+
<HintPath>libs\UnityEngine.dll</HintPath>
53+
</Reference>
54+
<Reference Include="UnityEngine.CoreModule">
55+
<HintPath>libs\UnityEngine.CoreModule.dll</HintPath>
56+
</Reference>
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="NamedPetPatch.cs" />
60+
<Compile Include="NamedPetTags.cs" />
61+
<Compile Include="Properties\AssemblyInfo.cs" />
62+
</ItemGroup>
63+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
64+
</Project>

NamedPetTags.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34009.444
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NamedPetTags", "NamedPetTags.csproj", "{92B68BD7-AF4D-408E-9A79-849CF19F112C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{92B68BD7-AF4D-408E-9A79-849CF19F112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{92B68BD7-AF4D-408E-9A79-849CF19F112C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{92B68BD7-AF4D-408E-9A79-849CF19F112C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{92B68BD7-AF4D-408E-9A79-849CF19F112C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B35F7434-6F9F-40F2-A910-E016E2260E01}
24+
EndGlobalSection
25+
EndGlobal

Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("NamedPetTags")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("NamedPetTags")]
13+
[assembly: AssemblyCopyright("Copyright © Fusionette 2023")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("92b68bd7-af4d-408e-9a79-849cf19f112c")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("0.9.0.0")]
36+
[assembly: AssemblyFileVersion("0.9.0.0")]

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Named Pet Tags
2+
3+
A Valheim mod to change the behavior of tamed creatures by putting tags on their names.
4+
5+
## Installation
6+
7+
- Extract `NamedPetTags.dll` file to your `plugins` folder.
8+
9+
## Features
10+
11+
- Add `<pet>` to the name of any tamed creature to prevent it from taking damage or breeding.
12+
- Works on Valheim 0.217.14 (Hildir's Request)
13+
14+
## Changelog
15+
16+
v0.9.0
17+
- Initial working prototype.

icon.png

31.5 KB
Loading

manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Named Pet Tags",
3+
"description": "A Valheim mod to change the behavior of tamed creatures by putting tags on their names.",
4+
"author": "Fusionette",
5+
"version_number": "0.9.0",
6+
"website_url": "https://github.com/Fusionette/NamedPetTags/releases",
7+
"dependencies": ["denikson-BepInExPack_Valheim-5.4.2105"]
8+
}

0 commit comments

Comments
 (0)