Jump to content

[REQUEST] Decrease map reveal radius during exploration


Recommended Posts

I asked about "Map Reveal Hidden Until Dug Out" before, but realized this morning that the far more likely possible way to do this is by just decreasing the radius of map revealed by exploration. Ideally the distance revealed would be configurable.

Is this currently doable with the modding tools?

Link to comment
Share on other sites

Yea, that's incredible easy. This should work:

using Harmony;
using UnityEngine;

[HarmonyPatch(typeof(MinionConfig), "CreatePrefab")]
internal class MinionConfig_CreatePrefab
{
    internal static void Postfix(GameObject __result)
    {
        GridVisibility gridVisibility = __result.GetComponent<GridVisibility>();
        if (gridVisibility != null)
        {
            gridVisibility.radius = 30f;
            gridVisibility.innerRadius = 20f;
        }
    }
}

Since the transition is smooth, I would expect that innerRadius is where it is fully revealed and radius where it's clickable but dimmed. Anyone feel free to make a mod out of this.

Note that the map reveal at the start of the game is managed by WorldGenSpawner instead.

Link to comment
Share on other sites

I had quite some fun learning C# again. Sure, sometimes it was frustrating, but that's life, isn't it.

Try it out and tell us when you get stuck :)

Best if you start looking at other peoples projects. I used to study from javisar's github. Although I wouldn't recommend his ONI-Common library. People just didn't find the folder path and the log file wasn't useful to me. I will shortly publish the source of what I use to save the configuration.

Link to comment
Share on other sites

On 9/25/2019 at 4:23 AM, Candide said:

I had quite some fun learning C# again. Sure, sometimes it was frustrating, but that's life, isn't it.

Try it out and tell us when you get stuck :)

Best if you start looking at other peoples projects. I used to study from javisar's github. Although I wouldn't recommend his ONI-Common library. People just didn't find the folder path and the log file wasn't useful to me. I will shortly publish the source of what I use to save the configuration.

Thanks for the encouragement! I do have some amateur programming under my belt, java and web design but not yet C#. I'm sure having a model to copy will be helpful (if I find/make the time to hunker down and do this!)

Link to comment
Share on other sites

OK, so I spent some hours this morning working on this from scratch. Have to throw in the towel for a moment though because there's too much that I'm not understanding and I need a some pointers if I'm going to continue.

So, from scratch:

1) I read and referred to 

2) So I installed Microsoft Visual Studio, and got a C# .Net Framework class project going as advised. I couldn't figure out how to "Double check that your under '.NET Framework 3.5'!" but reading around I think it refers to a global installation on my laptop, not something about the MSFT Visual Studio settings.

3) I was able to copy the reference dlls over successfully into a lib folder and refer to them. I hope they are in the right place. But later I think I broke something there by trying to add more from javisar's examples. I don't really understand how having them in the solution explorer list differs from having them in the .csproj code. 

 

4) I copied the code Candide provided pretty much exactly. I understand coding a bit from web design work, so I don't think I screwed that up. Hopefully I got the using references right.

5) I compiled without any errors. Found this old post that says to put local mods in a local folder. Then loaded ONI, and saw my mod in the mod list! Loaded it, restarted, black hole crash.

6) I looked in the logs and saw a reference to ModLoader, and reading around discovered that it was maybe required to use a 3rd part mod loader? I tried to install Javisar's Modloader, but couldn't really get it to work.. it seems to say that if I'm using it right and putting my mod in the right folder that my Steam mods will disappear from the list in game and only my mod will be there. And it will only see the steam mods. Now I doubt if it's actually necessary to use the modloader, because I can see my mod using the steps before, even though it crashes.

7) While I was working on that, I followed everyone's advice and tried to copy some of javisar's code examples. Probably risked breaking my code and adding things that I don't need, but though maybe I was missing something. After a couple of compile errors sorted out (that .net framework thing still makes me nervous), I got a compiled version, but it in a /local folder, and it still black hole crashes.

I copied the pertinent(?) bit of the log from that crash below. I feel like this is more steps than chromiumboy's guide, and that I'm missing something to make it as easy as his guide seemed to indicate.

Help?

[18:21:14.475] [1] [INFO] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Could not sort dependencies topologically due to a cyclic dependency.
  at ModLoader.DependencyGraph.TopologicalSort () [0x00000] in <filename unknown>:0 
  at ModLoader.ModLoader.Start () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at KMod.DLLLoader.LoadUserModLoaderDLL () [0x00000] in <filename unknown>:0 
[18:21:14.475] [1] [INFO] ModLoader.dll failed to load. Either it is not present or it encountered an error
[18:21:14.476] [1] [INFO] Loading mod content DLL [ONI_FogOfWar:ONI_FogOfWar] (provides DLL)
[18:21:14.478] [1] [INFO] Loading MOD dll: ONI_FogOfWar.dll
[18:21:14.483] [1] [INFO] Failed to load mod ONI_FogOfWar...disabling
[18:21:14.632] [1] [INFO] Localization.Initialize!
[18:21:14.638] [1] [INFO] Subscribe to mod ONI_FogOfWar

Link to comment
Share on other sites

11 hours ago, pharmswede said:

2) So I installed Microsoft Visual Studio, and got a C# .Net Framework class project going as advised. I couldn't figure out how to "Double check that your under '.NET Framework 3.5'!" but reading around I think it refers to a global installation on my laptop, not something about the MSFT Visual Studio settings.

This is certainly something you set in Visual Studio. While you can and probably have multiple frameworks installed, the project settings will define which framework is actually needed to run your code. Honestly I forgot about this setting. Good chance I screwed that up, would explain some rare issues some people have with my mods... Anyway, this should work: https://stackoverflow.com/questions/21078058/how-to-set-the-target-framework-in-visual-studio-2013

11 hours ago, pharmswede said:

4) I copied the code Candide provided pretty much exactly. I understand coding a bit from web design work, so I don't think I screwed that up. Hopefully I got the using references right.

I typed without testing it. While it still seems correct to me, don't take it for absolute. No-one is perfect.

11 hours ago, pharmswede said:

6) I looked in the logs and saw a reference to ModLoader, and reading around discovered that it was maybe required to use a 3rd part mod loader?

That was before Klei had official mod support. Nowadays the modloader is already installed.

Regarding your crash log. It seems to happen before it even tries to load the mod, "Loading MOD dll: ONI_FogOfWar.dll" comes after the error. "ModLoader.dll failed to load." also points to a bigger issue. Maybe you deleted or corrupted stuff trying to fix it.

Try following:

1) Check game file via Steam: https://support.steampowered.com/kb_article.php?ref=2037-QEUH-3335

2) Go through your references. Click each and check that "local copy" is saying NO (except if that dll is not already in the game folders, like other modders libraries). If there is a file in the output folder other than your dll, then you probably need to copy that too.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...