Modding Help Removing Default Grenade Launcher from Modded Weapon?

Discussion in 'Starbound Modding' started by shootyshooty, Oct 14, 2017.

  1. shootyshooty

    shootyshooty Scruffy Nerf-Herder

    I'm currently in the process of making a mod that has 4 versions of a M4A1 assault rifle, two with M203 grenade launchers and two without. The two with are the trouble though, how do I remove the grenade launcher that Starbound keeps inserting on my rifle?
    [​IMG]
    [​IMG]
    Proof the .png sprite I made for this gun does not have the grenade launcher attachment shown in the picture and instead will be using its own custom graphic. Is there any offsets I need to mess with or anything I can do to hide this grenade launcher attachment?

    Here's the .activeitem info for the rifle:
    {
    "itemName" : "m4rifle2",
    "price" : 1500,
    "maxStack" : 1,
    "rarity" : "Legendary",
    "description" : "An old 20th century assault rifle with a grenade launcher, sling not included.",
    "shortdescription" : "M4A1 M203",
    "tooltipKind" : "gun",
    "category" : "assaultRifle",
    "twoHanded" : true,
    "itemTags" : ["weapon","ranged","assaultrifle"],
    "level" : 6,

    "inventoryIcon" : "m4rifle2.png",

    "animation" : "/items/active/weapons/ranged/gun.animation",
    "animationParts" : {
    "butt" : "",
    "middle" : "m4rifle2.png",
    "barrel" : "",
    "muzzleFlash" : "/items/active/weapons/ranged/muzzleflash.png"
    },
    "animationCustom" : {
    "sounds" : {
    "fire" : ["/sfx/gun/m4rifle1.ogg"]
    }
    },

    "baseOffset" : [0.8, 0.1],
    "muzzleOffset" : [2.5, 0.4],

    "scripts" : ["/items/active/weapons/ranged/gun.lua"],

    "elementalType" : "physical",

    "primaryAbility" : {
    "scripts" : ["/items/active/weapons/ranged/gunfire.lua"],
    "class" : "GunFire",

    "fireTime" : 0.068,
    "baseDps" : 12,
    "energyUsage" : 40,
    "inaccuracy" : 0.04,

    "projectileCount" : 1,
    "fireType" : "auto",

    "projectileType" : "standardbullet",
    "projectileParameters" : {
    "knockback" : 2
    },
    "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.068,
    "armRotation" : 3,
    "weaponRotation" : 3,
    "twoHanded" : true,

    "allowRotate" : false,
    "allowFlip" : false
    }
    }
    },

    "altAbilityType" : "grenadelauncher",

    "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
     
  2. GonDragon

    GonDragon Pangalactic Porcupine

    Try adding this under "altAbilityType":

    Code:
    "altAbility" : {
      "animationCustom" : {
        "animatedParts" : { "parts" : {
          "grenadelauncher" : {
            "properties" : {
              "zLevel" : -1,
              "centered" : true,
              "offset" : [-0.75, -0.375],
              "transformationGroups" : ["muzzle"],
              "firePosition" : [0.75, -0.125],
              "image" : ""
            }
          }
        }},
        "sounds" : {
          "altFire" : [ "/sfx/gun/grenade1.ogg" ]
        },
        "particleEmitters" : {
          "altMuzzleFlash" : {
            "active" : false,
            "emissionRate" : 8,
            "transformationGroups" : ["muzzle"],
            "offsetRegion" : [-0.25, -0.5, -0.25, -0.5],
            "particles" : [
              { "particle" : "rocketbarrelpuff", "offset" : [0.0, 0.0] },
              { "particle" : "rocketbarrelpuff", "offset" : [0.0, 0.0] },
              { "particle" : "rocketbarrelpuff", "offset" : [0.0, 0.0] }
            ]
          }
        }
      }
    }
    You can overwrite any parametter of an Ability Type in "altAbility". Here, I just overwrite the animation of the grenadelauncher to not have an image.
     
  3. shootyshooty

    shootyshooty Scruffy Nerf-Herder

    I'm not understanding if I'm doing anything wrong or whatnot but now my game is immediately crashing on startup when I made this change to the rifles. Is it possible you could take the above .activeitem text and merge it with your fix to rule out any errors on my end? I might've just made an error placing the parameters and whatnot, I'm kinda new to this, so if you could merge your fix and the existing code that'd be amazing.
     
  4. GonDragon

    GonDragon Pangalactic Porcupine

    I didn't test my fix, so it may not work. Could you share your Starbound.log ?
     
  5. projectmayhem

    projectmayhem Spaceman Spiff

    Are you wanting the launcher off the ones that do NOT have a launcher, or are you wanting it off all 4, even the ones with the launcher?
     
  6. shootyshooty

    shootyshooty Scruffy Nerf-Herder

    While I'm not able to get my .log file since my computer is KIA'd becauae the GPU is all sorts of screwed, I said the two rifles that WILL have the grenade launchers are the only two with issues. GonDragon, while I'm not able to use my main computer to get the .logs, could you in the meanwhile join the two bits of code together so I could test it when I get back? It might just be an error on where I pasted the parameters to in the .activeitem file. Once that's all done and I can test it we can troubleshoot from there.
     
  7. GonDragon

    GonDragon Pangalactic Porcupine

    Oh, well, I tested it on my PC, and my fix didn't remove the grenade launcher muzzle... But I discovered how to remove it, here it is the final file:

    Code:
    {
      "itemName": "m4rifle2",
      "price": 1500,
      "maxStack": 1,
      "rarity": "Legendary",
      "description": "An old 20th century assault rifle with a grenade launcher, sling not included.",
      "shortdescription": "M4A1 M203",
      "tooltipKind": "gun",
      "category": "assaultRifle",
      "twoHanded": true,
      "itemTags": [
        "weapon",
        "ranged",
        "assaultrifle"
      ],
      "level": 6,
      "inventoryIcon": "m4rifle2.png",
      "animation": "/items/active/weapons/ranged/gun.animation",
      "animationParts": {
        "butt": "",
        "middle": "m4rifle2.png",
        "barrel": "",
        "muzzleFlash": "/items/active/weapons/ranged/muzzleflash.png"
      },
      "animationCustom": {
        "sounds": {
          "fire": [
            "/sfx/gun/m4rifle1.ogg"
          ],
          "altFire": [
            "/sfx/gun/grenade1.ogg"
          ]
        },
        "animatedParts": {
          "parts": {
            "grenadelauncher": {
              "properties": {
                "zLevel": -1,
                "centered": true,
                "offset": [
                  -0.75,
                  -0.375
                ],
                "transformationGroups": [
                  "muzzle"
                ],
                "firePosition": [
                  0.75,
                  -0.125
                ],
                "image": ""
              }
            }
          }
        },
        "particleEmitters": {
          "altMuzzleFlash": {
            "active": false,
            "emissionRate": 8,
            "transformationGroups": [
              "muzzle"
            ],
            "offsetRegion": [
              -0.25,
              -0.5,
              -0.25,
              -0.5
            ],
            "particles": [
              {
                "particle": "rocketbarrelpuff",
                "offset": [
                  0,
                  0
                ]
              },
              {
                "particle": "rocketbarrelpuff",
                "offset": [
                  0,
                  0
                ]
              },
              {
                "particle": "rocketbarrelpuff",
                "offset": [
                  0,
                  0
                ]
              }
            ]
          }
        }
      },
      "baseOffset": [
        0.8,
        0.1
      ],
      "muzzleOffset": [
        2.5,
        0.4
      ],
      "scripts": [
        "/items/active/weapons/ranged/gun.lua"
      ],
      "elementalType": "physical",
      "primaryAbility": {
        "scripts": [
          "/items/active/weapons/ranged/gunfire.lua"
        ],
        "class": "GunFire",
        "fireTime": 0.068,
        "baseDps": 12,
        "energyUsage": 40,
        "inaccuracy": 0.04,
        "projectileCount": 1,
        "fireType": "auto",
        "projectileType": "standardbullet",
        "projectileParameters": {
          "knockback": 2
        },
        "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.068,
            "armRotation": 3,
            "weaponRotation": 3,
            "twoHanded": true,
            "allowRotate": false,
            "allowFlip": false
          }
        }
      },
      "altAbilityType": "grenadelauncher",
      "builder": "/items/buildscripts/buildunrandweapon.lua"
    }
    It's the same, but instead of trying to remove the muzzle overwriting the ability, it removes the muzzle overwriting it's animation.
     
  8. shootyshooty

    shootyshooty Scruffy Nerf-Herder

    Thanks for the help. Would it be possible to make it where when you upgrade this rifle to Tier 6 at an upgrade anvil, it changes from the version I made without a grenade launcher that just has spray and pray to the version with a grenade launcher and...well...shoots grenades as the alt? The version without grenades is titled m4rifle1, of course.
     
  9. GonDragon

    GonDragon Pangalactic Porcupine

    Yes, just add to the m4rifle1 this:

    Code:
    "upgradeParameters" : {
        "inventoryIcon" : "m4rifle2.png",
        "animationParts" : {     
            "middle": "m4rifle2.png"
        },
        "altAbilityType": "grenadelauncher"
    }
    You can overwrite any parameter of the old item in a upgrade, just writing it in "upgradeParameters".
     
  10. shootyshooty

    shootyshooty Scruffy Nerf-Herder

    Oh, sweet! Thanks, man! I was looking to make a weapon pack of weapons from the twentieth century that can be refurbished and then upgraded. That also helps my question on how to change other weapon parameters. Now I can make the Tier 5 Uzi I have planned a two handed weapon until you upgrade it to tier 6, where it can be dual wielded.
     

Share This Page