Tool Storm Modding API

Discussion in 'Mods' started by Handsome Matt, Mar 7, 2016.

  1. Dukko

    Dukko Void-Bound Voyager

    Hi guys I'm getting a CTD without any error log of any kind whenever I go to sleep.
    It apparently try to save and die on the spot. It's not the infamous "run as admin" bug and it only happens while using STORM.

    Here's a log.

    Code:
    Application: StormLoader.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.IO.IOException
       at System.IO.__Error.WinIOError(Int32, System.String)
       at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
       at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
       at System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean)
       at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
       at System.IO.StreamWriter..ctor(System.String, Boolean)
       at Storm.Logging.LogToFile(System.String)
       at Storm.ExternalEvent.LocalModLoader.LoadMod(System.Collections.Generic.List`1<Storm.ExternalEvent.LoadedMod>, System.String)
       at Storm.ExternalEvent.LocalModLoader.Load()
       at Storm.StardewValley.ManagedStardewValleyLauncher.Launch()
       at Storm.Program.Main(System.String[])
    
     
    • MaximumZero

      MaximumZero Void-Bound Voyager

      Good call. Seems to have worked. Many thanks.
       
      • mdbell

        mdbell Seal Broken

        Can you tell us what mods you have install @Dukko
         
        • Dukko

          Dukko Void-Bound Voyager

          Yeah I actually managed to find out that one of my mods must be causing it, after some trial and error. Thanks, now I have to find out which one is it :'(
           
          • iarspider

            iarspider Big Damn Hero

            What does "1.05" mean? I've grabbed the latest Storm from this link, and the game version is the latest on GOG.

            UPD. I *am* on 1.05, executable file is version "1.0.5912.42429"
             
              Last edited: Mar 19, 2016
            • keyten

              keyten Cosmic Narwhal

              Well can anyone familiar with code help me again?)
              I have this error:

              Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
              been thrown by the target of an invocation. ---> System.Reflection.TargetInvocat
              ionException: Exception has been thrown by the target of an invocation. ---> Sys
              tem.AccessViolationException: Attempted to read or write protected memory. This
              is often an indication that other memory is corrupt.

              Each time I try to write information contained in stack CurrentDialogue.
              Example:
              Code:
                          Stack stack;
                          stack = curloc.Characters[0].CurrentDialogue;
                          Console.WriteLine("123   " + stack.Pop());
              Well, looks like that stack is protected indeed and Storm needs Dialogue injector to do some advanced stuff like changing what characters say.
               
                Last edited: Mar 19, 2016
              • WarFollowsMe

                WarFollowsMe Aquatic Astronaut

                You can just add Storm-Hooked-Game.exe in reference of your mod project. And then
                Code:
                var dialogues = curloc.Characters[0].CurrentDialogue.OfType<StardewValley.Dialogue>();
                 
                  keyten likes this.
                • aracco

                  aracco Void-Bound Voyager

                  Where the heck is storm_log.txt? Am I dumb? My versions are up to date, not in beta, I've reinstalled XNA, and my game is crashing on loading a save or starting a new game, after the intro cinematic. I've tried both with no mods and with the freeze indoors mod. I'm sorry, I would post a log if I knew where they were. Help would be very much appreciated.
                   
                  • keyten

                    keyten Cosmic Narwhal

                    It is here: AppData\Roaming\StardewValley\Storm\.
                    Also it doesn't generate logs If you use version with console enabled (one that you have to compile yourself).
                     
                    • aracco

                      aracco Void-Bound Voyager

                      Ah, that explains it. I wiped my Stardew directory and started over with a ready build and it works like magic. Thank you!
                       
                      • keyten

                        keyten Cosmic Narwhal

                        This is actually amazing. We can call functions from the game. And also means I have no idea how the Storm Api works and what the point of accessors and wrappers.
                         
                        • iarspider

                          iarspider Big Damn Hero

                          I am on 1.05:

                          [​IMG]

                          If this helps:
                          Code:
                          MD5 checksum: adb892bf62068789bea50cc85f5b35eb *Stardew Valley.exe
                          File version (from manifest file): 1.0.5912.42429
                          


                          Clean installation, only Storm installed (no mods) - crash:
                          Code:
                          [CecilInjectorFactory] Loaded 1545 injectors.
                          System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
                            at new[](UInt32 )
                            at Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.AllocateArrayAndReadFile(String filename, Void** ppData, UInt32* pdwBufferSize)
                            at Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.WaveBank.CreateHandle(UInt32 hEngine, String string, Int32 length, IntPtr& pCleanup)
                            at Microsoft.Xna.Framework.Audio.WaveBank..ctor(AudioEngine audioEngine, String nonStreamingWaveBankFilename)
                            at StardewValley.Game1.Initialize()
                            at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
                            at StardewValley.Program.Main(String[] args)
                            --- End of inner exception stack trace ---
                            at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
                            at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
                            at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
                            at Storm.StardewValley.ManagedStardewValleyLauncher.Launch()
                            at Storm.Program.Main(String[] args)
                          
                           
                          • aracco

                            aracco Void-Bound Voyager

                            Okay, so I asked this a while back, and I didn't understand what the answer meant at the time:
                            After actually looking through the API, I'm assuming this is Character.Name, right? What I'm looking to do is change a character's name right when their assets are loaded, but going through both character and dialogue AssetLoadEvents to their Roots didn't turn up any NPC objects. So, when/where/how does the game populate its NPC/Character objects and what event can I use to get to them?
                             
                            • keyten

                              keyten Cosmic Narwhal

                              I am almost sure Npcs are not loaded during assets load. They are loaded during new game start/load. I don't know how to catch that exact moment too.
                               
                              • WarFollowsMe

                                WarFollowsMe Aquatic Astronaut

                                All charm in Storm API it's injection. You can create event and link it with function in game, and when function calling, you can handle it in you event callback. It's very useful.
                                 
                                  keyten likes this.
                                • WarFollowsMe

                                  WarFollowsMe Aquatic Astronaut

                                  Change Character.Name not a good idea. You need handle some dialogue draw event and change name string. so in the game Character name stay correct, but user can see some new name.
                                   
                                    keyten likes this.
                                  • keyten

                                    keyten Cosmic Narwhal

                                    Yeah, too bad that didn't help much in my problem. I dug in code for hours and still have no idea how the game catches dialogues answers. Looks like that part is Ultra hard coded or IlSpy doesn't allow to see that parts of code.
                                    I guess I will try to find another way.
                                     
                                    • WarFollowsMe

                                      WarFollowsMe Aquatic Astronaut

                                      What exactly you need to get? Maybe, I can help you.
                                       
                                      • keyten

                                        keyten Cosmic Narwhal

                                        There is a question system in the game. You can call StardewValley.Game1.drawObjectQuestionDialogue("Hey. Your tool is ready but you don't have any room in your inventory.",list); for example to make a dialogue box with answers. I try to make so that choosing questions would call other functions.
                                        Also any example of event callback when function is calling would be extremely nice.
                                         
                                          Last edited: Mar 19, 2016
                                        • WarFollowsMe

                                          WarFollowsMe Aquatic Astronaut

                                          If you call StardewValley.Game1.drawObjectQuestionDialogue("Hey. Your tool is ready but you don't have any room in your inventory.",list); from your mode that just do nothing, cause this function doesn't call in game.
                                          You need create wrapper for this function.
                                          In Strom class StaticContext is wrapper for Game1(Storm.StardewValley.Wrapper.StaticContext). This class using StaticContextAccessor for wrapp game function.
                                          So for new function you need add in StaticContext class
                                          Code:
                                          public void DrawObjectQuestionDialogue(string dialogue, List<string> choices)
                                          {
                                                Cast<StaticContextAccessor>()._DrawObjectQuestionDialogue(dialogue,choices);
                                          }
                                          
                                          and in StaticContextAccessor
                                          Code:
                                          void _DrawObjectQuestionDialogue(string dialogue, IList choices)
                                          
                                          And last important thing that you need add description of injection in json file game1_injectors.json in "InvokerParams"
                                          Code:
                                          {
                                                "OwnerAccessorType": "@StaticContext",
                                                "OwnerMethodName": "drawObjectQuestionDialogue",
                                                "OwnerMethodDesc": "(System.String, System.Collections.Generic.List`1)System.Void",
                                                "InvokerName": "_DrawObjectQuestionDialogue",
                                                "InvokerReturnParams": [
                                                  "System.String",
                                                  "System.Collections.IList"
                                                ],
                                                "InvokerReturnType": "System.Void",
                                                "IsStatic": "true"
                                          }
                                          
                                          So now you can call this function from your mode:
                                          Code:
                                          @event.Root.DrawObjectQuestionDialogue("Hey. Your tool is ready but you don't have any room in your inventory.",list);
                                           
                                            Last edited: Mar 19, 2016
                                            keyten likes this.

                                          Share This Page