Modding Discussion A place to discuss map editing and other related stuff

Discussion in 'Mods' started by QuantumConcious, Apr 1, 2016.

Thread Status:
Not open for further replies.
  1. OrSpeeder

    OrSpeeder Phantasmal Quasar

    I am waiting for the release of certain API features (SMAPI and Storm both can't do it yet) to add a Robin buildable storage shack (to put all those chests and kegs)

    I am not an artist... and you people handle the mapping software for xTile way better than me, so when the time comes I might want to recruit you :) Or make a public API for buildable buildings and see what you people do with it.
     
      taintedwheat and Zelnite like this.
    • Advize

      Advize Cosmic Narwhal

      I've rewritten my tile editing code that I use to edit existing locations without touching the .xnb files. It no longer needs to search a location for a tile to copy when the tile in a layer you are attempting to edit is null, it can finally instantiate new tile objects (F**k you xTile).

      First, it requires a custom tile class (not optimally written, wrote it in a hurry and never went back to polish it up):

      Code:
          public class Tile
          {
              public int l;
              public int x;
              public int y;
              public int tileIndex;
              public string layer;
      
              public Tile(int l, int x, int y, int tileIndex)
              {
                  this.l = l; this.x = x; this.y = y; this.tileIndex = tileIndex;
                  switch (l)
                  {
                      case 0:
                          this.layer = "Back";
                          break;
                      case 1:
                          this.layer = "Buildings";
                          break;
                      case 2:
                          this.layer = "Paths";
                          break;
                      case 3:
                          this.layer = "Front";
                          break;
                      case 4:
                          this.layer = "AlwaysFront";
                          break;
                  }
              }
          }
      

      Then you'll need to create a list of these custom tile objects:

      Code:
              //Meticulously planned tile edits for Farm.xnb
              /*Create array of custom tile objects with layer, x & y location, and new texture information
                  (-1 as a texture means set the tile to null) */
              private static List<Tile> FarmEdits = new List<Tile>()
              {
                  new Tile(0, 0, 38, 175), new Tile(0, 1, 38, 175), new Tile(0, 0, 43, 537),
                  new Tile(0, 1, 43, 537), new Tile(0, 2, 43, 586), new Tile(0, 0, 44, 566),
                  new Tile(0, 1, 44, 537), new Tile(0, 2, 44, 618), new Tile(0, 0, 45, 587),
                  new Tile(0, 1, 45, 473), new Tile(0, 0, 46, 587), new Tile(0, 1, 46, 587),
                  new Tile(0, 0, 48, 175), new Tile(0, 1, 48, 175),
      
                  new Tile(1, 0, 39, 175), new Tile(1, 1, 39, 175), new Tile(1, 2, 39, 444),
                  new Tile(1, 0, 40, 446), new Tile(1, 1, 40, 468), new Tile(1, 2, 40, 469),
                  new Tile(1, 0, 41, 492), new Tile(1, 1, 41, 493), new Tile(1, 2, 41, 494),
                  new Tile(1, 0, 42, 517), new Tile(1, 1, 42, 518), new Tile(1, 2, 42, 519),
                  new Tile(1, 0, 43, 542), new Tile(1, 1, 43, 543), new Tile(1, 2, 43, 544),
                  new Tile(1, 0, 44, -1), new Tile(1, 1, 44, -1), new Tile(1, 2, 44, -1),
                  new Tile(1, 0, 45, -1), new Tile(1, 1, 45, -1), new Tile(1, 2, 45, -1),
                  new Tile(1, 0, 46, -1), new Tile(1, 1, 46, -1), new Tile(1, 2, 46, -1),
                  new Tile(1, 0, 47, 175), new Tile(1, 1, 47, 175), new Tile(1, 0, 48, -1),
      
                  new Tile(3, 0, 36, -1), new Tile(3, 1, 36, -1), new Tile(3, 0, 37, -1),
                  new Tile(3, 1, 37, -1), new Tile(3, 0, 38, -1), new Tile(3, 1, 38, -1),
                  new Tile(3, 0, 39, -1), new Tile(3, 1, 39, -1), new Tile(3, 0, 40, -1),
                  new Tile(3, 0, 41, -1), new Tile(3, 0, 46, 414), new Tile(3, 1, 46, 413),
                  new Tile(3, 2, 46, 438), new Tile(3, 0, 47, 175), new Tile(3, 1, 47, 175),
                  new Tile(3, 2, 47, 394)
              };
      

      Third, you'll need this method I wrote which performs tile edits to a game location:

      Code:
              private static void PatchMap(GameLocation gl, List<Tile> tileArray)
              {
                  foreach (Tile tile in tileArray)
                  {
                      if (tile.tileIndex < 0)
                      {
                          gl.removeTile(tile.x, tile.y, tile.layer);
                          continue;
                      }
      
                      if (gl.map.Layers[tile.l].Tiles[tile.x, tile.y] == null)
                      {
                          gl.map.Layers[tile.l].Tiles[tile.x, tile.y] = new StaticTile(gl.map.GetLayer(tile.layer), gl.map.TileSheets[1], xTile.Tiles.BlendMode.Alpha, tile.tileIndex);
                      }
                      else
                      {
                          gl.setMapTileIndex(tile.x, tile.y, tile.tileIndex, tile.layer);
                      }
                  }
              }
      

      Finally, you call the method during mod initialization (or whenever you want to perform the tile edits) and send it an instance of the location you want to edit:

      Code:
      PatchMap(Game1.locations[1], FarmEdits);
      //or if you've created your own GameLocation object when you loaded your mod, just send that instead of referencing the Game1.locations array
      


      Adding warps and tile properties is as simple as:
      Code:
      //These are random made up examples
      Game1.locations[1].warps.Add(new Warp(64, 19, "Farm", 62, 23, false));
      Game1.locations[1].setTileProperty(63, 13, "Buildings", "Action", "Warp 64 18 Farm");
      

      Do note, however, that the PatchMap method specifically uses the second tilesheet in a location for any tile edit above the first layer. This was specifically for my purposes, you may need to change this depending on what you're doing. I'll probably end up editing the custom Tile class to allow you to specify which tilesheet to use.

      Edit: Creating the list of tiles to edit is the hardest part. I open a map twice in tIDE, snap the windows to either side of 1 monitor, and make all the changes I need to one of them. Then, tile by tile, I begin to replicate the process on the other tIDE window writing a line of code to match each one. One thing I'm working on now required 191 tile edits, and there are no redundant tile edits in here: http://pastebin.com/yBaJa0HU.
       
        Last edited: Apr 1, 2016
        Lorekiss likes this.
      • BoffoBoy

        BoffoBoy Existential Complex

        too tired to understand anything said do far but I finished mod except the warps... need sleep before I try and attempt 11 x warps


        thank you again for all the help and the much needed place to discuss our collective wailing and wisdom.


        Wot could this possibly be anyway?

        [​IMG]
         
        • Advize

          Advize Cosmic Narwhal

          Ice, fire/lava, water, earth/sand. I like where this is going...
           
            BoffoBoy and taintedwheat like this.
          • Zelnite

            Zelnite Big Damn Hero

            Warp to different area of the whole valley xD
             
            • taintedwheat

              taintedwheat Master Astronaut

              I helped with the colors!!!!

              I'm an artist, sorta. Not going to school for it though. Let me talk your ear off about art stuff, but then theories on mass communication/social media/journalism and history.
               
              • Jinxiewinxie

                Jinxiewinxie Farmer Fashionista

                Thanks to Advize's help, I've figured out how to add tilesheets to maps that change their tilesheets dynanically (like Town and Farm).




                This specifically covers how to add a tilesheet to Farm.xnb

                Copy Farm.xnb, Paths.xnb and spring_outdoorsTileSheet.xnb from Stardew Valley/Content/Maps and then whatever other tilesheet that has the .png you want to use in it. My example uses townInterior.xnb's .png. So copy these 4 items.

                Paste them into a new folder and then use XNB_Node to unpack them into a new-new folder

                In your new-new folder you should have .png files, .yaml files and one .xbin file for Farm

                Make 3 copies of townInterior.png and townInterior.yaml so you have a total of 4 each

                Rename each of your townInterior.pngs and .yamls to the following format: spring_townInterior.png/.yaml, summer_townInterior.png/.yaml, fall_townInterior.png/.yaml and winter_townInterior.png/.yaml

                Open up Farm.xbin in tIDE

                In the Map Explorer go to the Tile Sheets section, right click and choose New..

                On the General tab, give your new Tile Sheet a name and click the browse button to find spring_townInterior.png. On the Alignment tab, change Tile Size to 16 x 16 and press Apply

                Make changes to your Farm.xbin as needed and save it to your new-new folder. (Maybe specifically use a tile from spring_townInterior.png so you'll know where to look for it when you test it in game)

                Open up Farm.yaml from new-new and add "spring_townInterior.png" to the list of tilesheets. Make sure its in the same place as it was in your tIDE tilesheet list. (i.e. if it was at the bottom of the tilesheet list, make sure its at the bottom of the list in the .yaml) Make sure to save it to your new-new folder.

                Use XNB_Node to pack all your edited files back into .xnb files.

                Copy those repacked .xnb files to Stardew Valley/Content/Maps and copy spring_townInterior.xnb to Stardew Valley / Content

                Start up the game and see your changes ^_^ If you want to package your .xnb files to share with others, make sure they know to put all their .xnb files into Stardew Valley/Content/Maps and that they have to add the spring_WhateverYouNamedIt.xnb to just the Stardew Valley/Content folder.

                 
                • BoffoBoy

                  BoffoBoy Existential Complex

                  I was going to go that route but it looked bad and required far too many new tilesets*, ended up with something a bit more domestic from town interior/walls_andfloors.


                  *Not to mention Sand proper is hoe-able.

                  oh yeah, Taintedwheat is the clutter master, I plant nothing down without checking first.


                  I guess for sanity before I pack all this, Can the Click based warps be on the front or back layer?
                   
                  • Jinxiewinxie

                    Jinxiewinxie Farmer Fashionista


                    As far as I can tell, they need to be on the Buildings layer for some reason. Also almost all the tIDE files I've looked at for base game have their Action Properties on the Buildings layer too.
                     
                      QuantumConcious likes this.
                    • BoffoBoy

                      BoffoBoy Existential Complex

                      Well, gonna try! sure does not.
                       
                      • BoffoBoy

                        BoffoBoy Existential Complex

                        So I moved all my warps to buildings level, updated the bus stop map to remove front level actions , pack it all and get this on loading test character...

                        https://gyazo.com/8ae7a6b8ca72cfcd919eda782fb7a36f



                        In other news, though missing a screen because something I did locked me out of game for the moment, the use of an Always Back layer behind Back seems not to work at all, instead of matching bracketed flooring, I get dark pits...


                        Why does always front work but not always back, am I missing a setting?
                         
                          Last edited: Apr 1, 2016
                        • QuantumConcious

                          QuantumConcious Phantasmal Quasar

                          If anyone has anything they wish to have added to the first post or as an addition to what is already added just pm me with the details
                           
                          • Jinxiewinxie

                            Jinxiewinxie Farmer Fashionista


                            What is happening on the lines of code the error message is angry about?
                             
                            • BoffoBoy

                              BoffoBoy Existential Complex

                              Typo someplace I'd imagine, , took shower and back to see what I did wrong.


                              Oh yeah it's not warp then name of map then coordinates for click warps.... a bit too used to just laying it all down on the map properties hehe.

                              Well I fixed the obvious ones, gonna take a break from this, bummed about the always back layer not working.... bye neato framing.



                              I cannot for the life of me figure out where this typo is that's screwing up one of the entries. I have gone over all the warps, the map property ones as well as the click based ones but eff me if I cannot find out where that extra space is. Gone over each custom property like 6 times now paranoid about near invisible spaces.

                              I love the all in one warp line because I can go to one place to debug it, I might just go back to that.

                              oh my, glad I went back to notetab++ to verify everything....

                              https://gyazo.com/122ceb3cae3b8a2f7d312532e0e177ff can you see the trailing space? neither could I....

                              Is there a more robust debugger around that tells me where the exception is, not merely there there is one at line 7921 etc?
                               
                                Last edited: Apr 2, 2016
                              • QuantumConcious

                                QuantumConcious Phantasmal Quasar

                                BoffoBoy Iwould have to make a educated guess that the space was after JoshHouse or after Action
                                 
                                • BoffoBoy

                                  BoffoBoy Existential Complex

                                  After joshhouse.... first time but prolly last time I ever use click based warps en mass again; the trouble shooting aspect is a total and complete pita.

                                  bad news though.... Always back seems not to work.

                                  opps wrong link!
                                  https://gyazo.com/6197828d026ac3c71263324368b7301b

                                  Is there something I'm missing that would allow me to use a back layer behind back itself?

                                  I fear I might have to eschew the fancy re-purposed framing around the teleport locations.
                                   
                                    Last edited: Apr 2, 2016
                                  • Jinxiewinxie

                                    Jinxiewinxie Farmer Fashionista

                                    I got mine working, sort of ^_^

                                    Warps:

                                    [​IMG]

                                    WizardShrine:


                                    [​IMG]

                                    I just can't seem to find a way to edit the dialogue on the WizardShrine pop up =(
                                     
                                      taintedwheat likes this.
                                    • BoffoBoy

                                      BoffoBoy Existential Complex

                                      ok here's a puzzle we can all try and figure out.... some of my rooms up top are nice and bright while others are are complete and total dark like see nothing, they are futher out so I would assume there's a daylight mod going on that covers some of the map and not all.....

                                      the property is called Day Tiles
                                      Code:
                                      Front 2 1 256 Front 2 2 288 Front 22 1 256 Front 22 2 288 Front 20 13 256 Front 20 14 288 Front 3 14 469 Front 3 15 501
                                       
                                        Last edited: Apr 2, 2016
                                        QuantumConcious likes this.
                                      • Jinxiewinxie

                                        Jinxiewinxie Farmer Fashionista

                                        I threw in some lightbulb tiles into a map I was playing with yesterday. Could those help?
                                         
                                        • BoffoBoy

                                          BoffoBoy Existential Complex

                                          These rooms are.... too large, there has to be a way for me to take it all and tun it all day light just need to figure out what all that

                                          Front 2 1 256

                                          stuff is.
                                           
                                          Thread Status:
                                          Not open for further replies.

                                          Share This Page