Modding Help I am trying to offset a shortsword so when it is held it doesn't float above a character's hand

Discussion in 'Starbound Modding' started by boochy1997, Mar 25, 2021.

  1. boochy1997

    boochy1997 Orbital Explorer

    I have no idea if I'm just not smart enough to figure out how to properly use weapon offset, or if there just isn't enough information about this online, but whenever I try to change the active item file for a sword I'm trying to make so lowers the sprite to actually being held by my character instead of just floating mid air nothing changes.

    Is there a specific spot you put the stances thing in? Do you use something other than "weaponOffset"? Is setting the y axis to "-11.5" not enough to get an actual change? I mean I'm spawning in a new version of the weapon each time because I saw you're supposed to do that but nothing fixes the problem and there's never a change from what I am seeing.

    Anyone have any knowledge on this? I'm stuck.
     
  2. Zaakari

    Zaakari Pangalactic Porcupine

    Nah, you're smart enough, it's just that coding is super frustrating when there are no guides at hand to tell you where to find stuff. Add to that the fact that Starbound has changed a lot over time--and consequently the code to modify it--thereby nullifying some of the guides that exist, and it can be pretty hard to find the right information.

    I could be wrong, but I'm guessing that "weaponOffset" might be an out-of-date way of moving the weapon. At least, I'm not sure where it gets used.

    It would help if could post the ".activeitem" and ".animation" files for you weapon. However, I believe the variable you want to modify is the "offset" contained within the ".animation" file. Probably located under "animatedParts/parts/blade/properties". It should be an array containing the modifications for the x/y of the image for that section (likely the blade). You can either edit the animation file directly, or you can edit it "dynamically" by using the "animationCustom" object in the '.activeitem" file.

    For example, here's a snippet from one the melee weapons' ".activeitem" files in the Starbound Mass Effect Edition mod:
    Code:
    {
      "itemName" : "smeeomniblade1",
      "price" : 600,
      "maxStack" : 1,
      "rarity" : "Uncommon",
      "description" : "A basic version of an Omni-blade. Sharp and reliable.",
      "shortdescription" : "Omni-Blade B-1",
      "tooltipKind" : "sword",
      "category" : "shortsword",
      "twoHanded" : false,
      "itemTags" : ["weapon","melee","shortsword"],
    
      "inventoryIcon" : "smeeomniblade1.png",
    
      "animation" : "smeeomniblade.animation",
      "animationParts" :  {  "sword": "smeeomniblade1.png"  },
      "animationCustom" :
      {
      "animatedParts":
       {
        "parts":
        {
        "sword":
         {
        "properties":
          {
           "zLevel": 0,
           "centered": true,
           "offset": [0.3, -0.3],
           "transformationGroups": ["weapon"],
           "rotationCenter": [0, 0]
          }
         }
        }
       }
      },
    
    // ...
    
    You can see the "animationCustom" is modifying the object "animatedParts/parts/sword/properties" which lies within the "smeeomniblade.animation" file. Here's a snippet of that file:
    Code:
    {
      "globalTagDefaults" : {
      "paletteSwaps" : ""
      },
    
      "animatedParts" : {
        "stateTypes" : {
          "swoosh" : {
            "default" : "idle",
            "states" : {
            "idle" : {  },
            "fire" :
            {
            "frames" : 3,
            "cycle" : 0.1,
            "mode" : "transition",
            "transition" : "idle"
            },
           "fire2" :
           {
            "frames" : 3,
            "cycle" : 0.1,
            "mode" : "transition",
            "transition" : "idle"
           }
         }
        }
      },
    
      "parts" : {
        "sword" : {
          "properties" : {
            "zLevel" : -1,
            "centered" : true,
            "image" : "<partImage><paletteSwaps>?<bladeDirectives>",
            "transformationGroups" : ["weapon"],
            "rotationCenter" : [0, 0]
          }
        },
    
    // ...
    
    In here you can see the offset isn't even defined (just "zLevel", "centered", etc.), so it would get set to whatever the default is ([0,0] maybe?) if the "animationCustom" object wasn't in the ".activeItem".

    Why have two different ways to modify the same thing? Well, it would come in handy if you use the same ".animation" file for multiple weapons, then each weapon could make smaller changes through the "animationCustom" object, and thereby reduce the amount of code you would need to write (as well as making sure certain parts of the weapons' animations stay the same).
     

Share This Page