RELEASED FLO - New Custom NPC [XNB & SMAPI]

Discussion in 'Mods' started by randomAnon123, Oct 11, 2016.

  1. velarixx

    velarixx Orbital Explorer

    I think there might have been one where cigarettes was spelled sigarettes?

    Will do, thanks!
     
    • randomAnon123

      randomAnon123 Orbital Explorer

      I'll have to check his dialogue thoroughly, but I probably won't release any fixes for it, since I'll have to release a new dialogue file when I make him dateable anyway.

      Ah, yep, that sounds like me. I dunno why, I always end up spelling it "sigarettes". Might be my native language messing with my brain.
       
      • DJ_Zapple

        DJ_Zapple Pangalactic Porcupine

        ...Yup, that's the one. I remembered the moment I saw it. ^.^'
         
        • randomAnon123

          randomAnon123 Orbital Explorer

          Hey guys, guess what?
          After binge watching cute cat videos and thinking about my chemistry assignment while laying in bed (it's like 1:40 AM here right now), I somehow reached enlightenment.

          I managed to add custom events through code! HELL YEAH [​IMG]
          You can find the updated SMAPI mod in the OP! The content has literally been reduced to only new files, so it should be compatible with everything :nod:
          Here's to hoping I didn't mess up the files again. Or that I somehow managed to completely destroy the game.

          If anyone's wondering how I did it, here's the code:

          Code:
          if (!(Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").ContainsKey("75982147/t 600 900/w sunny")))
                              Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").Add("75982147/t 600 900/w sunny", "continue/64 15/farmer 64 16 2 Florence 64 18 0/pause 500/skippable/emote farmer 8/pause 500/speak Florence \"So, you're the guy that owns all of this land, uh?\"/faceDirection Florence 3/pause 500/speak Florence \"It's pretty big, don't you think?\"/faceDirection Florence 0/speak Florence \"Hell, I'd say it's too big for just one guy.^Hell, I'd say it's too big for just one gal.\"/emote farmer 40/emote farmer 8/speak Florence \"... a bit thick, aintcha?$u\"/emote farmer 16/speak Florence \"Look, what I'm saying is...#$b#Joja Corp's pretty interested in this town. And they need all the land they can get.#$b#Now, you could just quietly buy a joja membership and keep your farm...#$b#... or you could try going against the big guys.$s#$b#And trust me, if you do, it ain't gonna be pretty.$s\"/emote farmer 16/speak Florence \"So, what do ya say?\"/question fork1 \"#I'm going to get a joja membership.#I don't care about the 'big guys'.\"/fork gotGuts/speak Florence \"Yeah, you better.\"/move Florence 0 2 2/pause 250/animate Florence false true 100 16 16 16 17 17 17 18 18 18 19 19 19 18 18 18 17 17 17/pause 1000/speak Florence \"See ya around, farmer guy.$s^See ya around, farmer girl.$s\"/end");
                              Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").Add("gotGuts", "emote Florence 16/speak Florence \"Oh! You got guts!$h\"/emote Florence 56/emote farmer 8/speak Florence \"If you show the same kinda guts against Joja Corp, you might just make it.$h\"/emote farmer 40/speak Florence \"Guess I'll see ya around, farmer.$h\"/end");

          The code of the event itself is the same as the one in the normal xnb file.

          By the way, should I also make a thread for each one of my mods in the correct mod sections (which would always be Characters I guess)?
           
            Last edited: Oct 26, 2016
          • k9warriorchi

            k9warriorchi Scruffy Nerf-Herder

            Hey, so I downloaded the updated file and I have no idea if it's related but after loading up my save...my 'Get Dressed' mod doesn't work anymore o_O? It worked when I had Flo before but it's not too big of a deal. I will forego my cute outfits if it means I get to hang out with Knuckle-er, I mean Flo ^.^ I love that guy.
             
            • Entoarox

              Entoarox Oxygen Tank

              Ok, all logic in there says this code shouldnt work simply because of how the content loader works :S The fact that it apparently does is making me wonder how many souls microsoft sold to the devil in order to get xna written...
               
                randomAnon123 likes this.
              • randomAnon123

                randomAnon123 Orbital Explorer

                I actually didn't get an error when I first tested it (the Get Dressed mod is one of my must-haves, so I already had it), but apparently now it does :lod:
                Here's the error log, in case someone that actually understands code somehow stumbles by.



                By the way, you might want to download the mod again because as usual I made an error while writing the event before (I basically forgot that the fork had to be added along the event itself, instead of separately).

                EDIT

                I saw something similar being used in the game's code, so I tried to apply it to the code of the mod... and somehow it worked. It was the only way I could add lines to the Data/Events files like Travoos' original code did for the NPC Gift Tastes file.
                I've only got a vague idea of what I'm doing, really.
                 
                  Last edited: Oct 26, 2016
                • k9warriorchi

                  k9warriorchi Scruffy Nerf-Herder

                  Okay. I downloaded it again. The Get Dressed mod still isn't working but everything else seems seems okay. Were there any other changes I should check for or was it just his introduction event?
                   
                  • randomAnon123

                    randomAnon123 Orbital Explorer

                    Nothing new yet. I was looking for a way to add events through SMAPI before actually writing the others out.
                    But I've got most of the ideas down, so it shouldn't take too long to actually update the mod with new content.
                     
                    • Entoarox

                      Entoarox Oxygen Tank

                      Actually, the newer versions of EntoFramework let you intercept a attempt to load a file, and (for example) load it yourself, then modify the result before actually giving it to stardew.

                      So it is not the *only* way, it would just require EntoFramework if this (peculiar) way didnt work.
                       
                      • randomAnon123

                        randomAnon123 Orbital Explorer

                        Oh, I see. I have yet to check out the EntoFramework (mostly because I hadn't even considered the possibility of creating SMAPI mods), so I didn't know about that.
                        Thanks for the information!
                         
                        • Entoarox

                          Entoarox Oxygen Tank

                          No problem, It is a incredibly new feature to be able to intercept and modify files.

                          But you might want to look into EntoFramework if you want to be able to remove the need to edit Content, since EntoFramework also lets you setup redirects so that if stardew asks for "Content/Data/Something.xnb" you can give it "Mods/YourMod/Something.xnb" instead.
                          And the best part is, that even once we move to FarmHand these features will work just the same, because the framework detects if SMAPI or FarmHand is used, and reacts accordingly :D

                          (Sorry if it seems I am bragging, but I am very proud of the work that has gone into the framework, equally for bits I wrote and for bits written by other people! :D)
                           
                            Draksy and randomAnon123 like this.
                          • DJ_Zapple

                            DJ_Zapple Pangalactic Porcupine

                            Well cripes. ALL of my SMAPI mods died when I updated. Suppose I should wait for it to get fixed...
                             
                            • randomAnon123

                              randomAnon123 Orbital Explorer

                              Ah, damnit. Do you have an error log? And what mods are you using?
                               
                              • DJ_Zapple

                                DJ_Zapple Pangalactic Porcupine

                                I don't really know how to get error logs... As for my mods, GetDressed, ExtendedFridge, NPCMapLocations, and StardewValleyMP. And, obviously, FlorenceMod.
                                 
                                • k9warriorchi

                                  k9warriorchi Scruffy Nerf-Herder

                                  Oh dang, I forgot to check the NPCMapLocations - mine crashes too when I try to use it. My other SMAPI mods seem to work. I have CJB's Cheats Menu and Item Spawner, and the GiftTasteHelper mods. Those seem to be working ok. Like DJ_Zapple, I don't know how to get the error logs...
                                   
                                  • randomAnon123

                                    randomAnon123 Orbital Explorer

                                    Ok, I seem to have found and (hopefully) fixed the problem after fiddling around a bit, by making it so that the mod only loads the changes to the files after the game has loaded everything, and not everytime the game updates.

                                    Basically added this:
                                    Code:
                                                GameEvents.LoadContent += GameEvents_LoadContent;
                                    to the public override void Entry(params object[] objects).
                                    And then I added this:
                                    Code:
                                    private void GameEvents_LoadContent(object sender, EventArgs e)
                                            {
                                                if (!(Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").ContainsKey("75982147/t 600 900/w sunny")))
                                                    Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").Add("75982147/t 600 900/w sunny", "continue/64 15/farmer 64 16 2 Florence 64 18 0/pause 500/skippable/emote farmer 8/pause 500/speak Florence \"So, you're the guy that owns all of this land, uh?\"/faceDirection Florence 3/pause 500/speak Florence \"It's pretty big, don't you think?\"/faceDirection Florence 0/speak Florence \"Hell, I'd say it's too big for just one guy.^Hell, I'd say it's too big for just one gal.\"/emote farmer 40/emote farmer 8/speak Florence \"... a bit thick, aintcha?$u\"/emote farmer 16/speak Florence \"Look, what I'm saying is...#$b#Joja Corp's pretty interested in this town. And they need all the land they can get.#$b#Now, you could just quietly buy a joja membership and keep your farm...#$b#... or you could try going against the big guys.$s#$b#And trust me, if you do, it ain't gonna be pretty.$s\"/emote farmer 16/speak Florence \"So, what do ya say?\"/question fork1 \"#I'm going to get a joja membership.#I don't care about the 'big guys'.\"/fork gotGuts/speak Florence \"Yeah, you better.\"/move Florence 0 2 2/pause 250/animate Florence false true 100 16 16 16 17 17 17 18 18 18 19 19 19 18 18 18 17 17 17/pause 1000/speak Florence \"See ya around, farmer guy.$s^See ya around, farmer girl.$s\"/end");
                                                Game1.content.Load<Dictionary<string, string>>("Data\\Events\\Farm").Add("gotGuts", "emote Florence 16/speak Florence \"Oh! You got guts!$h\"/emote Florence 56/emote farmer 8/speak Florence \"If you show the same kinda guts against Joja Corp, you might just make it.$h\"/emote farmer 40/speak Florence \"Guess I'll see ya around, farmer.$h\"/end");
                                                if (!(Game1.content.Load<Dictionary<string, string>>("Data\\animationDescriptions").ContainsKey("flo_smoke")))
                                                    (Game1.content.Load<Dictionary<string, string>>("Data\\animationDescriptions")).Add("flo_smoke", "16/16 16 16 17 17 17 18 18 18 19 19 19 18 18 18 17 17 17 16 16 16/16/%Flo is too busy smoking to notice you.");
                                            }


                                    Long story short, now it works! :)
                                    I've tested it with the Get Dressed mod, the CJB Cheats Menu and Item Spawner and the NPC Map Locations mod, but it should also work with everything else.

                                    By the way, if you're having problems with the NPC Map Locations mod, you might want to update it here! Bouhm was kind enough as to add the possibility of using custom NPCs along with his mod.

                                    Oh, and you can find your errorlogs in the %appdata%\Roaming\StardewValley\ErrorLogs folder.

                                    Jeez.
                                    Here's to hoping that nothing else pops up. But if you do find other problems/errors, feel free to post.
                                     
                                      Last edited: Oct 26, 2016
                                    • k9warriorchi

                                      k9warriorchi Scruffy Nerf-Herder

                                      So...I tried the updated files in the OP as well as NexusMods...and it didn't seem to fix the problems. This is what I got from the error log when I loaded the game:


                                      [08:22:24.659 AM] An exception occured in XNA LoadContent: System.ArgumentException: An item with the same key has already been added.
                                      at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
                                      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
                                      at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
                                      at FlorenceMod.FlorenceMod.GameEvents_LoadContent(Object sender, EventArgs e)
                                      at System.EventHandler.Invoke(Object sender, EventArgs e)
                                      at StardewModdingAPI.Events.GameEvents.InvokeLoadContent() in Z:\Projects\SMAPI\src\StardewModdingAPI\Events\Game.cs:line 68
                                      [08:22:25.291 AM] An exception occured in XNA UpdateTick: System.MissingMethodException: Method not found: 'StardewValley.NPC StardewValley.Game1.getCharacterFromName(System.String)'.
                                      at FlorenceMod.FlorenceMod.GameEvents_UpdateTick(Object sender, EventArgs e)
                                      at System.EventHandler.Invoke(Object sender, EventArgs e)
                                      at StardewModdingAPI.Events.GameEvents.InvokeUpdateTick() in Z:\Projects\SMAPI\src\StardewModdingAPI\Events\Game.cs:line 80


                                      Oh and I think this is my map error:

                                      [08:22:48.506 AM] [ERROR] An error occured in the overridden draw loop: System.NullReferenceException: Object reference not set to an instance of an object.
                                      at NPCMapLocations.MapModMain.drawMarkers(GameMenu menu)
                                      at NPCMapLocations.MapModMain.GraphicsEvents_OnPostRenderEvent(Object sender, EventArgs e)
                                      at System.EventHandler.Invoke(Object sender, EventArgs e)
                                      at StardewModdingAPI.Events.GraphicsEvents.InvokeOnPostRenderGuiEvent(Object sender, EventArgs e) in Z:\Projects\SMAPI\src\StardewModdingAPI\Events\Graphics.cs:line 90
                                      at StardewModdingAPI.Inheritance.SGame.Draw(GameTime gameTime) in Z:\Projects\SMAPI\src\StardewModdingAPI\Inheritance\SGame.cs:line 1303
                                       
                                      • randomAnon123

                                        randomAnon123 Orbital Explorer

                                        I can't seem to trigger the same error, even with different save files.
                                        Maybe I uploaded the wrong files for nth time? Could you please try to re-download the mod? (I'm so sorry :facepalm: I'm such a scatterbrain)
                                         
                                          Last edited: Oct 26, 2016
                                        • k9warriorchi

                                          k9warriorchi Scruffy Nerf-Herder

                                          I seem to be getting the same issues. -.- I might be messing things up on my end somehow. I tried it on different saves, and even started a new game but my dresser is gone (and the 'C' hotkey for it doesn't work) and my maps crash.

                                          Don't be sorry, though. I really love Flo and will download your files each and every update.
                                           

                                          Share This Page