Modding Help Need Help Creating Custom Rocket Launcher .activeitem

Discussion in 'Starbound Modding' started by Ulithium_Dragon, Apr 29, 2016.

  1. Ulithium_Dragon

    Ulithium_Dragon Space Kumquat

    So I came back from a rather long (over a year) hiatus away from Starbound and decided I wanted to make some mods again.

    Anyways, (once again) I wanted to create something that the Avali Race was lacking, so I decided to make a custom Rocket Launcher sprite:

    [​IMG]

    ...And I got a basic .gun version working (by cloning the Ferozium Rocket Launcher's code):

    [​IMG]
    ...But I wanted to create an .activeitem version so it could have one of the new "Special Abilities".

    Trouble is that there really aren't any "vanilla" .activeitem Rocket Launchers for me to look at the coding for and reverse engineer off of, as all of the vanilla stuff uses generator code that create a randomized Rocket Launcher from a wide range of options.

    So I used a combination of the vanilla randomizer code script "rarerocketlauncher.activeitem" and the Avali Gun .activeitem that seemed closest to a Rocket Launcher in terms of functionality - the sniper rifle ("avalitier6sniper.activeitem") to try and write my own script.

    I ended up not being able to get it to work using just those two resources (neither fire mode was working), so I went looking for any mods that had .activeitem Rocket Launchers, and found only one: "RenTek-ProjectArmoury".
    I then tried to clone what they had set up for their "Swarm Launcher" (which seemed like the closest fit to me) into my own script, and I got it partially working:

    For some bizarre reason, the special ability is working even though the normal fire mode is not, and I am completely out of ideas as to WTF I am doing wrong here.

    Additionally, the special ability's projectile is spawning WAY too far up in the rocket's tube (towards the player - nowhere near the muzzle), and I was unable to decipher which variable controls this either. Far too many of these new functions and variables are not well documented (at least from what I could search up)...

    Soooo anyways, I figured I'd post a "plea for help" here in the hopes that someone could tell me what I did wrong with my script lol:


    Code:
    {
      "itemName" : "avalitier6rpg",
      "price" : 750,
      "inventoryIcon" : "avalirocketlauncher.png",
      "maxStack" : 1,
      "rarity" : "Legendary",
      "description" : "A standard Avali military-issue RPG. Not to be used on squirrels!",
      "shortdescription" : "^#A35CFF;RL6 Plasmastorm",
      "level" : 6,
      "tooltipKind" : "gun",
      "weaponType" : "Rocket Launcher",
      "itemTags" : ["weapon","ranged","rocketlauncher"],
      "twoHanded" : true,
    
      "animation" : "/items/active/weapons/ranged/gun.animation",
      "animationParts" : {
        "butt" : "",
        "middle" : "avalirocketlauncher.png",
        "barrel" : "",
        "muzzleFlash" : "/animations/muzzleflash/rifle/riflemuzzle.png"
      },
      "animationCustom" : {
        "sounds" : {
          "fire" : [ "/sfx/gun/rocket_electric1.ogg" ]
        }
      },
    
      "baseOffset" : [-1.2, 0.225],
      "muzzleOffset" : [0.0, 0.125],
         
      "scripts" : ["/items/active/weapons/ranged/gun.lua"],
      "elementalType" : "electric",
      "primaryAttack" : {
        "fireTime" : 1.0,
        "baseDps" : 250,
        "energyUsage" : 45,
        "projectileCount" : 1,
        "inaccuracy" : 0.01,
    
        "projectileType" : "electricplasmarocketstatus",
        "projectileParameters" : { 
          "knockback" : 40
        }
      },
      "stances" : {
        "idle" : {
          "armRotation" : 0,
          "weaponRotation" : 0,
          "weaponOffset" : [0, 0],
          "twoHanded" : true,
    
          "allowRotate" : true,
          "allowFlip" : true
        },
        "fire" : {
          "duration" : 0,
          "armRotation" : 0,
          "weaponRotation" : 0,
          "weaponOffset" : [-0.2, 0],
          "twoHanded" : true,
    
          "allowRotate" : false,
          "allowFlip" : false
        },
        "cooldown" : {
          "duration" : 0.5,
          "armRotation" : 0,
          "weaponRotation" : 0,
          "weaponOffset" : [-0.2, 0],
          "twoHanded" : true,
    
          "allowRotate" : false,
          "allowFlip" : false
        }
      },
      "altAbilitySource" : "/items/active/weapons/ranged/altabilities/guidedrocket/guidedrocket.altability",
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    

    Any help would be VERY much appreciated! n.nU
     
  2. C0bra5

    C0bra5 Oxygen Tank

    I have a bunch of them in my modpack, I think it's in items/racial weapons/(whatever)/(whatever)/rocket launcher.activeitem

    Also (whatever) means any folder, they will all lead you to the rocket launcher active item
     
  3. Ulithium_Dragon

    Ulithium_Dragon Space Kumquat

    Heh. I'll try to glean what I did wrong from some more examples then.
    I honestly wouldn't care if the gun was a gigantic pretzel that shot little sentient turds with faces if I could use it to look at the code lol.

    EDIT: What is the "TMPgun" tooltip type? Everything I've seen all uses "gun".
     
    Last edited: Apr 29, 2016
  4. C0bra5

    C0bra5 Oxygen Tank

    It's a custom tooltip I made to display descriptions on active items it stands for ThePonyModpackGun
     
  5. Ulithium_Dragon

    Ulithium_Dragon Space Kumquat

    Okkkk... It's working now, and i still have ZERO clue WTF I did! n.nU

    However, I'm still having issues with the projectile spawn offset. I have no clue what variable controls this, but all my projectiles (as well as the smoke effect, but I know how to edit that) are spawning WAY too far up inside the rocket tube, near my character's head:

    GIF.gif

    Anyone know what variable I need to edit/add to change the projectile spawn offset...?

    EDIT2: Nevermind, I found the projectile spawn variable - apparently it's "muzzleOffset", cuz that's a GREAT name for it...
    Ug, why do so many programmers not choose variable names that actually make flipping sense!? Why not "projectilespawnoffset"? -.-

    EDIT:
    How the heck did you do that? I was wondering myself how to get them to show the full description lol... =.=
     
    Last edited: Apr 29, 2016
  6. lazarus78

    lazarus78 The Waste of Time

    The point at which a projectile leaves the barrel is called the "muzzle". So the name is very fitting, since you are adjusting where the muzzle is, not the projectile. The projectiles spawn at the muzzle.
     
  7. Ulithium_Dragon

    Ulithium_Dragon Space Kumquat

    Um... "Muzzle" is the name of the end of a gun. In Starbound at least, most (almost all) guns are comprised of 3 parts: muzzle, barrel, and butt. Each has it's own sprite and they are put together in random combinations at runtime.
    So excuse me if I assumed that this had to do with the system that puts together the gun. That would make a lot more logical sense than "because the bullets come out of the end, muzzle means where it shoots from"...
    Occam's' Razor anyone? >_<

    ---
    BTW, why do you feel the need to comment on everything man? I only mentioned that as a subnote to vent my frustration on trying to figure out which variable controlled the projectile spawn point - it has NOTHING to do with this thread or it's subject matter...

    In any case, I very much appreciate your help @C0bra5 - I got it working (still have no idea what was wrong lol):

    GIF.gif
     
  8. Ulithium_Dragon

    Ulithium_Dragon Space Kumquat

    I consider my issue solved - thank you guys for the help!
     
  9. lazarus78

    lazarus78 The Waste of Time

    Muzzle is where the projectile comes out. So if you want to change where the projectile spawns, basic logic says to move the position of the muzzle. Just like a real gun. They used the appropriate name for the appropriate part. You are frustrated over proper terminology, which is silly. You don't move the projectile, you move the muzzle, which is where the projectile is released.

    Because I can.
     
  10. C0bra5

    C0bra5 Oxygen Tank

    I basically just got my hand on the novakid tired rifle file and replicated the stats to match the ones of a rocket launcher and extrapolated from there

    my best guess is because "projectilespawnoffset" is 1 longer and 2 muzzle

    i just created a new tooltip and item description called the files the name of the tooltipkind and done
     

Share This Page