diff --git a/ChebsNecromancy/BasePlugin.cs b/ChebsNecromancy/BasePlugin.cs index 3d9c570..e2c09dc 100644 --- a/ChebsNecromancy/BasePlugin.cs +++ b/ChebsNecromancy/BasePlugin.cs @@ -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); diff --git a/ChebsNecromancy/Package/manifest.json b/ChebsNecromancy/Package/manifest.json index 75f077e..62f11f6 100644 --- a/ChebsNecromancy/Package/manifest.json +++ b/ChebsNecromancy/Package/manifest.json @@ -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" diff --git a/ChebsNecromancy/Patches/TameablePatches.cs b/ChebsNecromancy/Patches/TameablePatches.cs index 918f7b6..c7abfce 100644 --- a/ChebsNecromancy/Patches/TameablePatches.cs +++ b/ChebsNecromancy/Patches/TameablePatches.cs @@ -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 @@ -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") + }; } } } diff --git a/Translations/English/chebsnecromancy.english.json b/Translations/English/chebsnecromancy.english.json index bcbcf8c..483b6d3 100644 --- a/Translations/English/chebsnecromancy.english.json +++ b/Translations/English/chebsnecromancy.english.json @@ -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",