Modding Help More Rings (official) + Level Extender (unofficial): The Ring of Wide Nets

Discussion in 'Mods' started by KHope314, Feb 3, 2020.

  1. KHope314

    KHope314 Space Hobo

    Hello, brand-new account, and first-time poster here. I apologize in advance if this post appears in the wrong spot on the forum.

    I'm using the unofficial Level Extender mod with the official More Rings mod, and it seems as though the Ring of Wide Nets stops functioning properly once the player's fishing level rises above 10.

    Quick background:
    • From More Rings, the Ring of Wide Nets increases the size of the fishing bar by 50%.
    • From Level Extender, the size of the fishing bar caps at Fishing level 10. Instead, the rate at which the fishing meter falls while a fish is "off the hook" decreases as Fishing level rises beyond 10.

    I've looked at the source code for both mods to see what might be causing the problem, and maybe this is it? (I would hardly call myself even an amateur programmer, so please go easy on me if I'm totally wrong) :rofl:

    From More Rings, file Mod.cs, lines 60-67:

    private void onMenuChanged(object sender, MenuChangedEventArgs e)
    {

    if ( e.NewMenu is BobberBar bobber && hasRingEquipped( Ring_Fishing_LargeBar ) > 0 )
    {

    var field = Helper.Reflection.GetField<int>(bobber, "bobberBarHeight");
    field.SetValue((int)(field.GetValue() * 1.50));
    }
    }

    And from Level Extender, file ModEntry.cs, lines 683-716:

    private void GameEvents_QuarterSecondTick(object sender, UpdateTickedEventArgs e)
    {

    if (Context.IsWorldReady && e.IsMultipleOf(8) && Game1.player.FishingLevel > 10)
    {

    if (Game1.activeClickableMenu is BobberBar && !firstFade)
    {

    firstFade = true;
    this.Monitor.Log($"{this.Helper.Reflection.GetField<int>(Game1.activeClickableMenu, "bobberBarHeight").GetValue()} -SIZE.");

    this.Helper.Reflection.GetField<int>(Game1.activeClickableMenu, "bobberBarHeight").SetValue(176);
    this.Helper.Reflection.GetField<float>(Game1.activeClickableMenu, "bobberBarPos").SetValue((float)(568 - 176));
    }
    else if (!(Game1.activeClickableMenu is BobberBar) && firstFade)
    {

    firstFade = false;
    //this.Monitor.Log($"Fade set false. -SIZE.");
    }
    else if (Game1.activeClickableMenu is BobberBar && firstFade)
    {

    bool bobberInBar = this.Helper.Reflection.GetField<bool>(Game1.activeClickableMenu, "bobberInBar").GetValue();
    if (!bobberInBar)
    {

    float dist = this.Helper.Reflection.GetField<float>(Game1.activeClickableMenu, "distanceFromCatching").GetValue();
    this.Helper.Reflection.GetField<float>(Game1.activeClickableMenu, "distanceFromCatching").SetValue(dist + ((float)(Game1.player.FishingLevel - 10) / 22000.0f));
    }
    }
    }
    }

    I've highlighted in green what I think are the relevant lines, but I've also included the entire methods (or functions?) from both mods for context. If I'm reading this right, More Rings adjusts the size of the fishing bar once, only when the interface menu changes to that of the fishing mini-game. Level Extender, however, adjusts the size of the fishing bar after 8 QuarterSecond game ticks (2 seconds?). So, both mods are still executing their code, but Level Extender sets the size of the fishing bar back to a flat 176 (pixels?) after More Rings has already increased the size by 150%.

    Would adding a check for whether the player is wearing the Ring of Wide Nets (Ring_Fishing_LargeBar) in the Level Extender mod fix this issue? I'm unsure, because Ring_Fishing_LargeBar is a defined public int from the More Rings mod. If simply adding this check wouldn't work, does the entire method from Level Extender need to be rewritten to activate only at the beginning of the fishing mini-game, rather than every several game ticks?

    I'm bringing this question here because it looks like the author for Level Extender hasn't updated their work in about a year. Also, I'm so new to SMAPI that I don't yet know how to simply add two lines of code to an existing mod and rebuild it for personal use. From what I've read so far, it involves installing Visual Studio, creating some new accounts, and a bunch of other confusing things. Something about cloning a repository -- I don't even know what file extension to look for... *.rep, maybe?

    I'm a sophomore at this stuff. I've been trying to solve this problem for a while now, and I'm in dire need of some helpful direction. Also, I'm uncertain as to what rules of etiquette there are when it comes to changing another author's mods (I was kind of afraid to even write this post), so I thought posting here would elicit some helpful advice on that topic.

    Thanks for reading!
     
    • KHope314

      KHope314 Space Hobo

      Well, I've learned a lot, and certainly there's a bunch more to learn~

      I've learned that using Visual Studio 2019 is okay (https://stardewvalleywiki.com/Modding:IDE_reference instructions are for Visual Studio 2017). Some of the instructions at the wiki don't apply exactly, but I think I navigated through the little differences without blowing up my computer :)

      I've learned that C++, which was already in my Visual Studio, is different from C#. I'm not sure exactly how different, but it was enough that I needed to download a bunch of tools for it in Visual Studio.

      I ended up copy/pasting the code from the various .cs files for Level Extender from gitHub to Visual Studio, after spending around 20 minutes trying to figure out (unsuccessfully) how to find a repository.

      I sort of figured out what a namespace was, and that adding the check for whether or not the player is wearing a specific ring involved a lot more than adding an IF statement into Level Extender. The... thingie (method/procedure/function?) that checks a player's equipped rings is a... thingie written inside of the More Rings mod, so Level Extender had no idea what I was talking about when I told it to parse hasRingEquipped(). It also spat at me for telling it to look for a Ring_Fishing_LargeBar. I spent a while trying to figure out how to add that functionality to Level Extender, but I ended up breaking the entire thing. So, I started from scratch again.

      In the end, I just changed the number 176 to 264 (150% of 176) and rebuilt Level Extender. I feel icky after doing it, because it feels so darned sloppy, but I just couldn't figure out how to make things work properly. I'll just leave the Ring of Wide Nets on my finger, knowing it doesn't actually do anything but look nice in my imagination~

      I'm lying to myself. Even money says I'll be trying to fix this nagging problem tomorrow evening. But already I'm scratching my head at how I'm going to tell Level Extender how to recognize a ring from a different mod...

      For now, at least, I've got my bigger fishing bar. I'm going fishing now!
       

      Share This Page