Skip to content

Commit

Permalink
3.0.3: toggle wait/follow/roam with E; generic bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpw1991 committed Apr 11, 2023
1 parent 74191de commit 15ed855
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ChebsNecromancy/BasePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class BasePlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.chebgonaz.ChebsNecromancy";
public const string PluginName = "ChebsNecromancy";
public const string PluginVersion = "3.0.2";
public const string PluginVersion = "3.0.3";
private const string ConfigFileName = PluginGuid + ".cfg";
private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, ConfigFileName);

Expand Down
2 changes: 1 addition & 1 deletion ChebsNecromancy/Package/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ChebsNecromancy",
"description": "Cheb's Necromancy adds Necromancy to Valheim via craftable wands and structures. Minions will follow you, guard your base, and perform menial tasks.",
"version_number": "3.0.2",
"version_number": "3.0.3",
"website_url": "https://github.com/jpw1991/chebs-necromancy",
"dependencies": [
"ValheimModding-Jotunn-2.11.2"
Expand Down
36 changes: 25 additions & 11 deletions ChebsNecromancy/Patches/TameablePatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,31 @@ static bool InteractPrefix(Humanoid user, bool hold, bool alt, Tameable __instan
return false; // deny base method completion
}

var currentStatus = undeadMinion.Status;
var nextStatus = currentStatus switch
{
ChebGonazMinion.State.Following => ChebGonazMinion.State.Waiting,
ChebGonazMinion.State.Waiting => ChebGonazMinion.State.Roaming,
_ => ChebGonazMinion.State.Following
};

// use the minion methods to ensure the ZDO is updated
if (undeadMinion.Status == ChebGonazMinion.State.Following)
if (nextStatus.Equals(ChebGonazMinion.State.Following))
{
user.Message(MessageHud.MessageType.Center, "$friendlyskeletonwand_skeletonwaiting");
undeadMinion.Wait(player.transform.position);
user.Message(MessageHud.MessageType.Center, "$chebgonaz_following");
undeadMinion.Follow(player.gameObject);
return false; // deny base method completion
}
else
if (nextStatus.Equals(ChebGonazMinion.State.Waiting))
{
user.Message(MessageHud.MessageType.Center, "$friendlyskeletonwand_skeletonfollowing");
undeadMinion.Follow(player.gameObject);
user.Message(MessageHud.MessageType.Center, "$chebgonaz_waiting");
undeadMinion.Wait(player.transform.position);
return false; // deny base method completion
}

user.Message(MessageHud.MessageType.Center, "$chebgonaz_roaming");
undeadMinion.Roam();
return false; // deny base method completion
}

return true; // permit base method to complete
Expand All @@ -68,13 +80,15 @@ static void Postfix(Tameable __instance, ref string __result)
{
if (__instance.m_nview.IsValid()
&& __instance.m_commandable
&& __instance.TryGetComponent(out UndeadMinion _)
&& __instance.TryGetComponent(out MonsterAI monsterAI)
&& __instance.TryGetComponent(out UndeadMinion undeadMinion)
&& Player.m_localPlayer != null)
{
__result = monsterAI.GetFollowTarget() == Player.m_localPlayer.gameObject
? Localization.instance.Localize("$chebgonaz_wait")
: Localization.instance.Localize("$chebgonaz_follow");
__result = undeadMinion.Status switch
{
ChebGonazMinion.State.Following => Localization.instance.Localize("$chebgonaz_wait"),
ChebGonazMinion.State.Waiting => Localization.instance.Localize("$chebgonaz_roam"),
_ => Localization.instance.Localize("$chebgonaz_follow")
};
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Translations/English/chebsnecromancy.english.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"chebgonaz_spiritpylon_name": "Spirit Pylon",
"chebgonaz_spiritpylonghost": "Spirit Pylon Ghost",
"chebgonaz_wait": "Wait",
"chebgonaz_roam": "Roam",
"chebgonaz_follow": "Follow",
"chebgonaz_roaming": "Roaming, master...",
"chebgonaz_waiting": "Waiting, master...",
"chebgonaz_following": "Following, master...",
"friendlyskeletonwand_attack": "Attack",
"friendlyskeletonwand_attacktarget": "Target",
"friendlyskeletonwand_create": "Create Minion",
Expand Down

0 comments on commit 15ed855

Please sign in to comment.