Tutorial Weapons Tutorial

Discussion in 'Starbound Modding' started by Tremerion, Aug 30, 2016.

  1. Tremerion

    Tremerion Existential Complex

    Hi. I will try to explain as simply as i can how to make your own weapons. This are things I have learned so far, note tham I am still learning new stuff about it. You can always take for ex. TSW Weapos Mod and change it and learn from it.

    START:
    Create folder for your mod in your mods.
    1. You will need player.config.patch file. With lines like:
    [{"op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : { "item" : "your_weapons_name" }}]
    If you will add more items, you will need to add , after each line. [] stands for starting and closing coding.
    2. YourModName.modinfo file. And this code. I think this is self explenatory.
    Code:
    {
       "name" : " ",
       "metadata" : {
       "displayName" : " ",
       "author" : " ",
       "description" : " ",
       "support_url" : "N/A",
       "version" : "1.0"
       }
    }
    3. Folders: items, projectiles and recipes. And objects if you want to add like crafting table for your weapons. But let focus on weapons modding.
    In items you will keep your weapons files. In projectiles you will keep your bullets for weapons, if you want to use your own types. Recipes for crafting recipes, so your weapons will be visible in crafting table of your choosing.
    In items you will also need to make .patch file for alt abilities, I will explain it later on, or you can find info in forums.
    Remember: This is a learning process, feel free to experiment with coding. Also, you can always study how weapons are made by devs in unpacked files. I hope you unpacked them already, it is vital for modding.

    Weapons file format is .activeitem.

    RANGED : (notes from me for you, do not place them in file)

    Code:
    {
      "itemName" : "youweaponsname", (remember, this will serve as your id weapons name, for /spawn, recipes and patch file.)
      "price" : 100, (set worth of your weapon, this will change according to level and rarity)
      "maxStack" : 1, (how many weapons can be in one inventory slot)
      "rarity" : "common", (common - white, uncommon - green, rare - blue, legendary - purple)
      "description" : "It will crush the will of your enemies.", (self explenatory)
      "shortdescription" : "Your Weapon Name", (Name of your weapon, visible in game)
      "tooltipKind" : "gun", (keep this line if you want to see DPS, enerhy usage and rate of fire info. Without it you will see description text)
      "category" : "Rifle", (you can write here what ever you like)
      "twoHanded" : true, (true - two handed, false - one handed, ex. pistols, but you can make your rifle one handed if you like)
      "itemTags" : ["weapon","ranged","assaultrifle"], (tags for search, besides your weapon name)
      "level" : 1, (from 1 to what ever you want, the higher - the more powerful weapon)
    
      "learnBlueprintsOnPickup" : [ (you can use this line or not, it depends if you want to make higher tiers of this weapon to be learned by picking up this level, or anything else, imagination is the key)
      ""
      ],
    
      "inventoryIcon" : "yourweapon.png", (you can use your weapon picture as icon in inventory, or use any other picture)
    
      "animation" : "gun.animation", (you can use your own animation file, for ex. if you want to add fullbright aka glowing pixels to your weapon, I will explain it later on)
      "animationParts" : {
      "butt" : "",
      "middle" : "yourweapon.png", (if you want to use whole picture for weapon, not to be completed by game from different parts)
       "middlefullbright" : "yourweaponfullbright.png",(You will need .animation file for it to work. Look below. Picture will be used for glowing pixels, you will need to take original weapon picture and leave only visible pixels for glowing, you decide what pixels. Do not use this line if you dont want it. )
      "barrel" : "",
      "muzzleFlash" : "/animations/muzzleflash/plasmamuzzlefire.png" (animation using for firing)
      },
      "animationCustom" : {
      "sounds" : {
      "fire" : ["/sfx/gun/ar1.ogg"] (game can read .ogg and .wav files, you can use your own sounds)
      }
      },
    
      "baseOffset" : [0.0, 0.0], ( x and y for your character hands, where he/she will hold weapon, you will need to experiment with it.)
      "muzzleOffset" : [0.0, 0.0],(x and y for firing place, from where projectiles will fly)
    
      "scripts" : ["/items/active/weapons/ranged/gun.lua"], (do not change unless you want to)
    
      "elementalType" : "physical", (types are: physical, fire, electric, poison and ice)
    
      "primaryAbility" : {
      "scripts" : ["/items/active/weapons/ranged/gunfire.lua"],
      "class" : "GunFire",
    
      "fireTime" : 0.0, (how fast weapon will be firing, the lower - the faster)
      "baseDps" : 0.0, (base samage of your weapon, it will change accordingly to level and rarity)
      "energyUsage" : 0.0, (how much energy will be used for each shot, again, it depends on level and rarity)
      "inaccuracy" : 0.02,
    
      "projectileCount" : 1, (how many projectiles will be shot)
      "fireType" : "auto",
    
      "projectileType" : "standardbullet", (you can find projectiles in unpacked game files)
      "projectileParameters" : {
    "damageKind" : "shotgunbullet",(use this line if your weapon will be like shotgun, or change it to any other damage kind, you can find them in unpacked files in damage folder)
      "knockback" : 5 (how far enemies will be pushed when hit by projectiles)
      },(change below lines as you see fit)
      "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
      }
      }
      },
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua" (used by game to build ranged weapon)
    }
    
    Animation for ranged - Glowing pixels:

    Code:
    {
      "globalTagDefaults" : {
      "paletteSwaps" : ""
      },
    
      "animatedParts" : {
      "stateTypes" : {
      "firing" : {
      "default" : "off",
      "states" : {
      "off" : {},
      "fire" : {
      "frames" : 2,
      "cycle" : 0.07,
      "mode" : "transition",
      "transition" : "off"
      }
      }
      }
      },
    
      "parts" : {
      "butt" : {
      "properties" : {
      "centered" : true,
      "image" : "<partImage><paletteSwaps>",
      "offset" : [0, 0], // x offset is set dynamically
      "transformationGroups" : ["weapon"]
      }
      },
      "middle" : {
      "properties" : {
      "centered" : true,
      "image" : "<partImage><paletteSwaps>",
      "offset" : [0, 0], // x offset is set dynamically
      "transformationGroups" : ["weapon"]
      }
      },(fullbright part need to be added to the file if it is not there from start, used only for glowing pixels)
        "middlefullbright" : {
      "properties" : {
         "zLevel" : 1,
      "centered" : true,
          "fullbright" : true, (this line means that whole picture will be glowing)
      "image" : "<partImage><paletteSwaps>",
      "offset" : [0.0, 0.0], // x offset is set dynamically (must be same as baseoffset line in yourweapon.activeitem)
      "transformationGroups" : ["weapon"]
      }
      },
      "barrel" : {
      "properties" : {
      "centered" : true,
      "image" : "<partImage><paletteSwaps>",
      "offset" : [0, 0], // x offset is set dynamically
      "transformationGroups" : ["weapon"]
      }
      },
      "muzzleFlash" : {
      "properties" : {
      "zLevel" : -1,
      "centered" : true,
      "offset" : [0.75, 0],
      "fullbright" : true,
      "transformationGroups" : ["muzzle"]
      },
    
      "partStates" : {
      "firing" : {
      "fire" : {
      "properties" : {
      "image" : "<partImage>:<variant>.<frame>"
      }
      }
      }
      }
      }
      }
      },
    
      "rotationGroups" : {
      "weapon" : {
      "angularVelocity" : 0
      }
      },
    
      "transformationGroups" : {
      "weapon" : {},
      "muzzle" : {}
      },
    
      "particleEmitters" : {
      "muzzleFlash" : {
      "transformationGroups" : ["muzzle"],
      "offsetRegion" : [0, 0, 0, 0],
      "particles" : [ ]
      }
      },
    
      "lights" : {
      "muzzleFlash" : {
      "active" : false,
      "position" : [0, 0],
      "color" : [90, 90, 0]
      }
      },
    
      "sounds" : {
      "fire" : [ ]
      }
    }
    
    VISUAL EXAMPLE:
    Whole rifle picture communionofpain.png
    Glowing pixels picture communionofpainfullbright.png

    SWORDS/HAMMERS: (yes, they use the same files, just change one value and it is sword or hammer, see below)

    Code:
    {
      "itemName" : "yourweaponname",
      "price" : 100,
      "level" : 1,
      "maxStack" : 1,
      "rarity" : "common",
      "description" : "",
      "shortdescription" : Your Weapon Name",
      "tooltipKind" : "sword",
      "category" : "Sword",
      "twoHanded" : true,
      "itemTags" : ["weapon","melee","broadsword"],
    
      "inventoryIcon" : "yourweapon.png",
    
      "animation" : "yourweapon.animation", (you will need to have .animation file for your sword, cause it contains picture used for look in game)
      "animationCustom" : {},
    
      "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],
    
      "elementalType" : "physical",
    
      "primaryAbilityType" : "broadswordcombo", (change it to "hammersmash: and you will get hammer)
      "primaryAbility" : {
      "fireTime" : 0.0,
      "baseDps" : 0.0
      },
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    

    Animation for swords/hammers:

    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"
      },
      "fire3" : {
      "frames" : 3,
      "cycle" : 0.1,
      "mode" : "transition",
      "transition" : "idle"
      }
      }
      }
      },
    
      "parts" : {
       "weaponfullbright" : {
      "properties" : {
      "zLevel" : 1,
      "centered" : true,
      "fullbright" : true,
      "image" : "yourweaponfullbright.png<paletteSwaps>?<directives>?<bladeDirectives>", (used if you want to have glowing pixels, the same as in ranged weapons)
      "offset" : [0, 1.875],(must be the same as values in .png for sword look)
      "transformationGroups" : ["weapon"],
      "rotationCenter" : [0, 0],
      "damageArea" : [ [-0.7, -1.0], [-0.7, 2.5], [0.5, 2.5], [0.5, -1.0] ]
      }
      },
      "blade" : {
      "properties" : {
      "zLevel" : 0,
      "centered" : true,
      "image" : "yourweapon.png<paletteSwaps>?<directives>?<bladeDirectives>",(here add name of your sword .png file, it will be used in game as look for it)
      "offset" : [0, 1.875],(where character will hold it)
      "transformationGroups" : ["weapon"],
      "rotationCenter" : [0, 0],
      "damageArea" : [ [-0.7, -1.0], [-0.7, 2.5], [0.5, 2.5], [0.5, -1.0] ](range for picture to pinpoint area capable of doing damage)
      }
      },
      "swoosh" : {
      "properties" : {
      "zLevel" : -1,
      "centered" : true,
      "transformationGroups" : ["swoosh"],
      "rotationCenter" : [0, 0]
      },
    
      "partStates" : {
      "swoosh" : {
      "idle" : {
      "properties" : {
      "image" : ""
      }
      },
      "fire" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh/tearswoosh.png:<frame>",
      "offset" : [-0.25, 2.5],
      "damageArea" : [[-5, 2], [-2.5, 3], [1, 3], [4, 1.75], [5, -0.25], [5, -2.25], [4, -3.25], [0, -2.5]]
      }
      },
      "fire2" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh2/tearswoosh.png:<frame>",
      "offset" : [5.0, 1.0],
      "damageArea" : [[-5, 1], [2.5, 1], [2.5, -2], [-5, -2]]
      }
      },
      "fire3" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh3/tearswoosh.png:<frame>",
      "offset" : [3.5, 0],
      "damageArea" : [[-4.75, 1.5], [3, 1], [3, -1], [-4.75, -1.5]]
      }
      }
      }
      }
      }
      }
      },
    
      "transformationGroups" : {
      "weapon" : {},
      "swoosh" : {}
      },
    (below you can change what particles will be used for different elemental types of your sword)
      "particleEmitters" : {
      "physicalswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 1,
      "burstCount" : 1,
      "particles" : []
      },
      "fireswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 4,
      "particles" : [
      { "particle" : "fireswoosh1"},
      { "particle" : "fireswoosh2"},
      { "particle" : "fireswoosh3"}
      ]
      },
      "electricswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "electricswoosh1"},
      { "particle" : "electricswoosh2"},
      { "particle" : "electricswoosh2"}
      ]
      },
      "poisonswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "poisonswoosh1"},
      { "particle" : "poisonswoosh2"},
      { "particle" : "fireswoosh2"}
      ]
      },
      "iceswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "iceswoosh1"},
      { "particle" : "iceswoosh2"},
      { "particle" : "iceswoosh3"}
      ]
      }
      },
    "lights" : {
      "glow" : {
      "active" : true,
      "position" : [0.0, 0.0],
      "color" : [253, 143, 77],
      "flickerPeriod" : 1,
      "flickerMinIntensity" : 0.20,
      "flickerMaxIntensity" : 0.20,
      "flickerPeriodVariance" : 0.0,
      "flickerIntensityVariance" : 0.0
      }
      },
    
      "sounds" : {
      "fire" : [ ],
      "fire2" : [ ],
      "fire3" : [ ]
      }
    }
    
    VISUAL EXAMPLE:
    Whole sword picture haemophage.png
    Glowing pixels picture haemophagefullbright.png

    ALTERNATIVE ABILITIES:

    You will need to make: weaponabilities.config.patch
    It needs to be placed i /items/buildscripts, otherwise it will not work. Great thanks goes to Ulithium Dragon for poiting this.
    Code line to add ability:
    [{"op" : "add", "path" : "/youraltname", "value" : "/items/active/abilities/youraltname/youraltname.weaponability"}]

    .weaponability is file format for alt abilities.

    To add ability to weapon add this line in yourweaponname.activeitem:
    "altAbilityType" : "youraltname",

    This part is tricky, I am still learning how it works. So far I was making copy of vanilla abilities and changing them for my use.
    Most important change in files to make, so the game will read your ability:
    Ex. Inside butstshot.weaponability search for:
    "ability" : {
    "name" : "Burst Shot", (This is name visible in game in weapon description, under stats.)
    "type" : "burstshot", (this is id name, used to add it to weapons and inside weaponabilities.config.patch)
    Change this and game will read your ability. They also use particles, you can set them to act differently based on elemental type. Lots of things.
    Many abilities will only work with one type of weapons. Ex. From my testing, staff abilities will crash game if used with any other weapon type. Experiment with care.

    FISTS:
    (They have no alt abilities, instead they use finishers. Glowing pixels also does not seems to work, or I cannot make them to work now.)

    You need to have these files for your fist weapon folder to work: .activeitem, .animation, .frames and .lua.
    Remember to set same name for all these files.

    Code:
    {
      "itemName" : "yourfistname",
      "price" : 100,
      "level" : 1,
      "maxStack" : 1,
      "rarity" : "common",
      "description" : "",
      "shortdescription" : "Your Fist Name",
      "tooltipKind" : "fistweapon",
      "category" : "Fist",
      "twoHanded" : false,(fists are best as one handed, cause when you use two of them at once you can make combo and finisher, two handed fist would brake it.)
      "itemTags" : ["weapon"],
     
      "inventoryIcon" : "yourfistname.png:front",
      "animation" : "yourfistname.animation",
      "animationParts" : {
      "weapon" : "yourfistname.png",
      "swoosh" : "swoosh/dashswoosh.png"
      },
      "animationCustom" : {
      "animatedParts" : { "parts" : { "swoosh" : { "partStates" : { "attack" : { "fire" : { "properties" : {
      "damageArea" : [[-1, -1.1], [2.1, -0.6], [2.1, 0.8], [-1, 1.3]]
      }}}}}}},
      "sounds" : {
      "fire" : [ "/sfx/melee/swing_dagger.ogg" ]
      }
      },
      "scripts" : [ "yourfistname.lua" ],
    
      "needsEdgeTrigger" : true,
      "edgeTriggerGrace" : 0.1,
    (below lines: all about combo, how long it takes to finish it and what finisher is used. You can find finishers inside fist weapons folder in upacked game files.)
      "comboSteps" : 3,
      "comboTiming" : [0.2, 0.5],
      "comboCooldown" : 0.2,
      "comboFinisherSource" : "/items/active/weapons/fist/combofinishers/dashslash.combofinisher",
    
      "freezeLimit" : 2,
    
      "primaryAbility" : {
      "scripts" : ["/items/active/weapons/fist/punch.lua"],
      "class" : "Punch",
    (fists do not use energy for attacks)
      "freezeTime" : 0.0,
      "fireTime" : 0.0,
      "baseDps" : 0.0,
      "damageConfig" : {
      "statusEffects" : [ ],(here you can add what effect will be inflicted on target, like burning, poison)
      "damageSourceKind" : "dagger",
      "knockback" : [0, 15],
      "timeoutGroup" : "primary",
      "timeout" : 0.1
      },
      "stances" : {
      "idle" : {
      "armRotation" : 0,
      "weaponRotation" : 45,
      "weaponRotationCenter" : [-1.0, 0.0],
      "weaponOffset" : [-0.25, -0.575],
    
      "allowRotate" : false,
      "allowFlip" : true,
    
      "frontArmFrame" : "run.2",
      "backArmFrame" : "jump.3"
      },
      "windup" : {
      "duration" : 0.05,
      "armRotation" : 0,
      "weaponRotation" : 0,
      "weaponRotationCenter" : [-1.0, 0.0],
      "weaponOffset" : [-0.625, -0.125],
    
      "allowRotate" : false,
      "allowFlip" : false,
    
      "frontArmFrame" : "swimIdle.1",
      "backArmFrame" : "swim.1"
      },
      "windup2" : {
      "duration" : 0.05,
      "armRotation" : 0,
      "weaponRotation" : 0,
      "weaponRotationCenter" : [-1.0, 0.0],
      "weaponOffset" : [-0.75, -0.125],
    
      "allowRotate" : false,
      "allowFlip" : false,
    
      "frontArmFrame" : "swimIdle.1",
      "backArmFrame" : "swim.1",
    
      "recoil" : true
      },
      "fire" : {
      "duration" : 0.1,
      "armRotation" : 0,
      "weaponRotation" : 0,
      "weaponRotationCenter" : [-1.0, 0.0],
      "weaponOffset" : [0.125, -0.25],
    
      "allowRotate" : false,
      "allowFlip" : false,
    
      "frontArmFrame" : "rotation",
      "backArmFrame" : "rotation"
      }
      }
      },
    
      "builder" : "/items/buildscripts/buildfist.lua"
    }
    
    Picture for fists:
    Picture file is best to copy from vanilla and edit it. It uses front and back.
     
    Last edited: Aug 30, 2016
  2. FrAndromeda

    FrAndromeda Subatomic Cosmonaut

    thanks for laying it out like this, very much appreciated!
     
  3. MetalArrow

    MetalArrow Subatomic Cosmonaut

    How do you modify damage done by arrows?
     
  4. KhaosHiDef

    KhaosHiDef Void-Bound Voyager

    D'ya have any tips for modifying projectiles, i have a weapon using a modified projectile file but none of the changes i made to the projectile are used such as a retexture :/ Screenshot_856.png
     
  5. IHart

    IHart Scruffy Nerf-Herder

    You made changes to something but its not that projectile. Tell us how you have this set up.
     
  6. KhaosHiDef

    KhaosHiDef Void-Bound Voyager

  7. IHart

    IHart Scruffy Nerf-Herder

    Your 'mechweld - copy' was registering as a valid projectile and for some reason not pushing a duplicate id error. That's the projectile it was using, deleted it.
    I took the liberty of also fixing your frames file which was breaking up a 128x16 image into 8 16x16 pieces, which does not match your custom projectile image.
     

    Attached Files:

  8. KhaosHiDef

    KhaosHiDef Void-Bound Voyager

    -facepalm- this is what i get for backing things up, cheers for that :)
    EDIT: hmm, despite this change it still seems to be using the default projectile, perhaps a script change is in order..
    2nd Edit: another facepalm moment, it works, i just forgot to remove the backup, much love <3
    [​IMG]
     
    Last edited: Jul 14, 2017
  9. IHart

    IHart Scruffy Nerf-Herder

    That's what you get for backing things up...twice...
    If you append .txt to the end the game won't read it.
    If you want to hide an entire folder append a single period to the front, this will mark it as hidden. (which may require you to turn on 'show hidden' in your file browser.)
     
  10. SlipyB

    SlipyB Void-Bound Voyager

    Where do i put the images to put the name of them in the code? Also this is json right?
     
  11. IndraShuna

    IndraShuna Void-Bound Voyager

    hi uhmm idk if anyone would respond to this but im confused about this
    [{"op" : "add", "path" : "/youraltname", "value" : "/items/active/abilities/youraltname/youraltname.weaponability"}]
    idk what to put
     
  12. projectmayhem

    projectmayhem Ketchup Robot

    items/buildscripts/weaponability.config is the file for weaponabilities.
    your file would need to be items/buildscripts/weaponability.config.patch

    And that is if you are making a custom alternate fire.


    this guide is a little outdated though, I'll make a new one later in the week.
     
    DrPvtSkittles likes this.
  13. Kiyo Haribusa

    Kiyo Haribusa Void-Bound Voyager

    is there a way to hide an existing fullbright? like on the Aegisalt pistol?
     
  14. Tremerion

    Tremerion Existential Complex

    Only by editing this weapons files. By deleting line for fullbright in .activeitem file
     

Share This Page