Modding Help Sooooo... I was trying to learn how to create a Gun, aaaand...

Discussion in 'Starbound Modding' started by Cen Silver, Apr 16, 2017.

  1. Cen Silver

    Cen Silver Industrial Terraformer

    [​IMG]

    JEEBUS LAWD WHY ARE OFFSETS SO IMPOSSIBRU TO SET.

    WTF DOES REGULAR RNG GUNS USE TO SET THEIR OFFSETS PROPERLY?!? THE MAGICAL COORDINATES OF NARNIA?!?
    ALSO HOW THE HECK DO I SET THE FINAL IMAGE RESULT AS ITS ICON?!?
    AND HOW DO I RECOLOR THE RED PARTS?!?

    THIS IS SO HARD

    *Internal Screams*
     
  2. projectmayhem

    projectmayhem Sandwich Man

    "iconDrawables" : ["butt", "middle", "barrel"]

    What do you mean by recolor the red parts?

    And just keep messing around with the offsets, change one number at a time till you get the direction going the right way.
     
  3. Cen Silver

    Cen Silver Industrial Terraformer

    Do I just type that in "inventoryIcon"...? Or is it a separate variable...? And do I just put Butt Middle Barrel? Or am I supposed to type the images osed in those places...? I'm so confused... o_O"""

    The "colored" parts of the guns are originally all red in the Image files. I wanted to find out how to tell the game what color I want the gun to be...

    Messing around with the offsets would take forever, especially when I don't even know how much does the game consider one Pixel... (The numbers I tried made it very clear that 1.0 is NOT one Pixel... ;-;)
     
  4. G.Xyon

    G.Xyon Cosmic Narwhal

    I suggest perhaps starting with a fully-built item first before delving into segmented one, as the random weapons use a script called buildscript.lua to generate... well, almost everything.

    The buildscript.lua is in charge of nearly everything, including setting the appropriate offsets for each weapon based on the root (or base) image size. Unfortunately I'm not too savvy with lua, so I'm unable to tell you specifically what the code does to set the offset, aside that it takes the original image size and applies it to some formulas to obtain a proper offset based on the "base" of the gun (no idea which part that is). Perhaps you can try to copy some of the vanilla files and see what you get after some experimenting? The script also assembles the random parts as the images, so for RNG weapons, this script is very important.

    To change the colors, the *.activeitem uses a file that stores all of it's colors. You can find it in: "/items/active/weapons/colors/ranged.weaponcolors", but you can make your own for all intents and purposes as long as you change the path in the original file as well. For every pair of "X":"Y", the 'X' represents the existing color in the current image, while 'Y' is the color you wish to replace it with. You'll have to use hex values, so you'll need a decent art program that'll allow you to obtain the hex value of colors (something simple like Paint.net should do the trick).

    As for fully-built items, there's a script that also 'builds' weapons, but it doesn't delve with anything graphical as far as I know, so it's much more simpler to work with if you're starting out. Look for 'unrand' in the ranged folder so you can get an idea of how fully-built guns are done.

    If you need any help, I've no problem giving you a hand!
     
    Cen Silver likes this.
  5. projectmayhem

    projectmayhem Sandwich Man


    Use the iconDrawables instead of inventory icon if you are using a seperate graphic for each. Here is what my E-11 Blaster Rifle file looks like I'll try to explain what I did.

    Code:
    {
      "itemName" : "SWMe11blasterrifle",
      "price" : 900,
      "maxStack" : 1,
      "rarity" : "Common",
      "description" : "A standard Empire Blaster Rifle",
      "shortdescription" : "E11 Blaster Rifle",
      "tooltipKind" : "gun",
      "category" : "assaultRifle",
      "twoHanded" : true,
      "itemTags" : ["weapon","ranged","assaultrifle"],
      "level" : 2,
    
      "animation" : "/items/active/weapons/ranged/gun.animation",
      "animationParts" : { },
      "animationCustom" : { },
      "baseOffset" : [-1.0, 0.25],
      "muzzleOffset" : [0.0, 0.3125],
    
      "scripts" : ["/items/active/weapons/ranged/gun.lua"],
    
      "elementalType" : "physical",
    
      "primaryAbility" : {
        "scripts" : ["/items/active/weapons/ranged/gunfire.lua"],
        "class" : "GunFire",
    
        "fireTime" : [0.44, 0.47],
        "baseDps" : [12, 13],
        "energyUsage" : [27, 30],
        "inaccuracy" : 0.08,
    
        "burstTime" : 1.075,
        "burstCount" : [2,4],
        "fireType" : ["auto", "burst"],
    
        "projectileType" : "blaster",
        "projectileParameters" : {
          "knockbackRange" : [4,8]
        },
    
        "stances" : {
          "idle" : {
            "armRotation" : 0,
            "weaponRotation" : 0,
            "twoHanded" : true,
    
            "allowRotate" : true,
            "allowFlip" : true
          },
          "fire" : {
            "duration" : 0,
            "armRotation" : 3,
            "weaponRotation" : 3,
            "twoHanded" : true,
    
            "allowRotate" : false,
            "allowFlip" : false
          },
          "cooldown" : {
            "duration" : 0.11,
            "armRotation" : 3,
            "weaponRotation" : 3,
            "twoHanded" : true,
    
            "allowRotate" : false,
            "allowFlip" : false
          }
        }
      },
      "fireSounds" : [ "/sfx/ranged/blasterpistol.ogg", "/sfx/ranged/blasterpistol.ogg", "/sfx/ranged/blasterpistol.ogg", "/sfx/ranged/blasterpistol.ogg", "/sfx/ranged/blasterpistol.ogg", "/sfx/ranged/blasterpistol.ogg" ],
    
      "builder" : "/items/buildscripts/buildweapon.lua",
      "builderConfig" : [{
        "animationParts" : {
          "butt" : {
            "path" : "e11butt.png",
            "paletteSwap" : false
          },
          "middle" : {
            "path" : "e11middle.png",
            "paletteSwap" : false
          },
          "barrel" : {
            "path" : "e11barrel.png",
            "paletteSwap" : false
          },
          "muzzleFlash" : "/items/active/ranged/muzzleflash.png"
        },
        "gunParts" : ["butt", "middle", "barrel"],
        "altAbilities" : [
               
        ],
        "palette" : "/items/active/weapons/colors/ranged.weaponcolors",
        "iconDrawables" : ["butt", "middle", "barrel"]
      }]
    }
    


    Since I'm a coding noob and I'm learning as I go, I started by coping over the common assault rifle activeitem file and 1 barrel, butt. middle PNG. Then I renamed them e11butt, e11barrel, e11midle. I took out the variant tag, since I only have one of each. As long as you use the PNG from the assets, the offsets should be good, you may have to change a little, if you make your gun thicker/thinner. It may be easier to do it without separate parts like G.X said, this is how I learned though.
     
  6. Cen Silver

    Cen Silver Industrial Terraformer

    @G.Xyon I know about the Generators... I gave it the "buildunrand" because I saw that was what the non-random weapons did... TTwTT

    Code:
    {
        "itemName": "megarifle",
        "price": 10000,
        "maxStack": 1,
        "rarity": "Legendary",
        "description": "Archezuli's Powerful Action Sniper Rifle. You're not stealing it... are you?",
        "shortdescription": "Mega Rifle 0.5",
        "tooltipKind": "gun",
        "category": "sniperRifle",
        "twoHanded": true,
        "itemTags": [
            "weapon",
            "ranged",
            "sniperrifle"
        ],
        "iconDrawables": [
            "butt",
            "middle",
            "barrel"
        ],
        "level": 8,
        "animation": "/items/active/weapons/ranged/gun.animation",
        "animationParts": {
            "butt": "/items/active/weapons/ranged/sniperrifle/barrel/19.png",
            "middle": "/items/active/weapons/ranged/sniperrifle/barrel/18.png",
            "barrel": "/items/active/weapons/ranged/sniperrifle/barrel/15.png",
            "muzzleFlash": "/items/active/weapons/ranged/muzzleflash.png"
        },
        "animationCustom": {
            "sounds": {
                "fire": [
                    "/sfx/gun/mech_gun3.ogg"
                ]
            }
        },
        "baseOffset": [
            -1.25,
            0.5
        ],
        "muzzleOffset": [
            0,
            0
        ],
        "scripts": [
            "/items/active/weapons/ranged/gun.lua"
        ],
        "elementalType": "physical",
        "primaryAbility": {
            "scripts": [
                "/items/active/weapons/ranged/gunfire.lua"
            ],
            "class": "GunFire",
            "fireTime": 0.25,
            "baseDps": 10,
            "energyUsage": 20,
            "inaccuracy": 0,
            "projectileCount": 1,
            "fireType": "auto",
            "projectileType": "bullet-4",
            "projectileParameters": {
                "knockbackRange": 30
            },
            "stances": {
                "idle": {
                    "armRotation": 0,
                    "weaponRotation": 0,
                    "twoHanded": true,
                    "allowRotate": true,
                    "allowFlip": true
                },
                "fire": {
                    "duration": 0,
                    "armRotation": 5,
                    "weaponRotation": 5,
                    "twoHanded": true,
                    "allowRotate": false,
                    "allowFlip": false
                },
                "cooldown": {
                    "duration": 0.25,
                    "armRotation": 5,
                    "weaponRotation": 5,
                    "twoHanded": true,
                    "allowRotate": false,
                    "allowFlip": false
                }
            }
        },
        "altAbilityType": "grenadelauncher",
        "builder": "/items/buildscripts/buildunrandweapon.lua"
    }
    


    Also, I'm trying to not make anything that adds files, since that would make the Mod unusable in Multiplayer... so making a file specifically to tell the game what color to use is out of question... TTwTT

    @projectmayhem I tried using your
    "iconDrawables" : ["butt", "middle", "barrel"]



    Aaaaaaand it now spawns a Perfectly generic Item... Yaaaayyyy... ;w;

    #killmepls
     
  7. projectmayhem

    projectmayhem Sandwich Man

    you might also need the

    "gunParts" : ["butt", "middle", "barrel"],

    Alot...99%...of what I do is trial and error lol. Learn as I go.
     
    Cen Silver likes this.
  8. Cen Silver

    Cen Silver Industrial Terraformer

    @projectmayhem Nope. Still GenericItem... xwx"""

    Putting "InventoryIcon" back in fixed it tho... ;w;

    This can only mean it's missing something to generate the Icon... but I compared it to the standard .activeitem gun assets and nothing's missing on them... where am I going wrong... ;w;

    @G.Xyon Also sure thing, thanks! ^^

    If you got a Contact you'd like to share, we could use it to help each other with stuff and/or even Play Starbound together if you're interested! ^^
     
  9. projectmayhem

    projectmayhem Sandwich Man

    Did you put the iconDrawable inside the BuilderConfig?
     
    Cen Silver likes this.
  10. lazarus78

    lazarus78 The End of Time

    9 times out of 10, there is a vanilla version of whatever you are trying to make. Reverse engineering is extremely helpful in figuring out how things work. Tinker with them, make tweaks and see how it changes things in game. This will familiarize you with how most things work.
     
    Last edited: Apr 18, 2017
    G.Xyon and projectmayhem like this.
  11. Cen Silver

    Cen Silver Industrial Terraformer

    @projectmayhem Didn't you see the code...? I had replaced the whole Builderconfig part by the unrandgenerator that non-random weapons use... >w>"""

    So... replacing it for the generator again... what do I put in the "palette" and "namegenerator" parts...? to let the game tell I don't want to use random names or colors...? Do I just leave them blank...?

    @lazarus78 The heck you think I've been doing this whole time...?!? >w>"""

    Learning by copying the pattern and variables of already existing assets isn't going as well as I originally Expected... TTwTT"""
    AND NOT BEING ABLE TO USE MY OWN PIXEL ART ISNT HALPING >A<"""
     
    Last edited: Apr 19, 2017
  12. lazarus78

    lazarus78 The End of Time

    Reverse engineering means to take an existing thing and start swapping in your own stuff. IE take an existing weapon, swap in your own sprites, then test. Change the offsets, then test, adjust the damage, then test, etc.

    You take something that you know already works, and you see what happens when you make small changes. From the sound of it, you aren't using an already existing item, but trying to make one from scratch.
     
    G.Xyon likes this.
  13. G.Xyon

    G.Xyon Cosmic Narwhal

    That was your first error my friend. 'Buildunrand' is specifically designed for weapons that are pre-generated graphically, so it only renders one image instead of three unlike RNG weapons. If you still want to build weapons through multiple segments, you're going to need 'buildrand' and work around that instead.

    You can always create a patch file and edit out the colors really! Not much adding as it is editing the standard files, so you should be good there.
     
    Cen Silver likes this.
  14. Cen Silver

    Cen Silver Industrial Terraformer

    @lazarus78 I KNOW WHAT REVERSE ENGINEERING MEANS!!! >A<"""

    I AM DOING THAT.

    How the heck would I even dream of making anything from scratch?!? I don't know a single thing about LUA or JSON and I never programmed anything in my entire life!!! >A<

    @G.Xyon Awww maannn... I was hoping I wouldn't need the Building generator part... oh well... ;3;

    Anyway, I I managed to make it work yesterday, but...

    [​IMG]

    While tweaking the offsets (Or at least desperately trying to, since I have no idea wtf I'm doing...) I realized the gun's Middle and Butt part aren't even appearing... Where the heck are they?!? ;3;"""
     
    Last edited: Apr 19, 2017
  15. L4DTurbozero

    L4DTurbozero Void-Bound Voyager

    So judging by what I've read you would like: a specific gun with certain stats, color, and assembled with parts all from vanilla assets; which will work on multiplayer. It would seem you would have better luck using an inventory editor rather then modding. Modding the game even in the littlest way would require the server you want to connect to to also have your mod. The only exception would be a tiny bit of code that calls information but doesn't edit it, and well, its more of a headache to do then actually modding. save yourself the headache and try that instead.
     
  16. lazarus78

    lazarus78 The End of Time

    Not necessarily. Mods that only alter vanilla content without adding any new assets are generally all multiplayer friendly and compatible. If you alter a vanilla item, like, say make a vanilla set of armor have 99999 on all stats, that item is technically transferable to others without that mod because it doesn't add anything new, just alters existing content. JSON is more akin to a list of settings and not code, so there is no conflict when you alter it, and why spawned in custom items don't break the game.
     
  17. Cen Silver

    Cen Silver Industrial Terraformer

    @L4DTurbozero Whiiiiich is why I want to learn how to use the Drawable Generator I downloaded...

    Also, I couldn't find a single inventory editor up to date...
     
  18. lazarus78

    lazarus78 The End of Time

    Cen Silver likes this.
  19. Cen Silver

    Cen Silver Industrial Terraformer

    @lazarus78 Oh nice. Thanks!!!

    No idea how you got that... Starcheat says it's not up to date to 1.0... 0.o"""
     
  20. lazarus78

    lazarus78 The End of Time

Share This Page