Tutorial Weapon Tutorial v1.3

Discussion in 'Starbound Modding' started by projectmayhem, May 18, 2018.

  1. projectmayhem

    projectmayhem Spaceman Spiff

    When making specific weapons, one of the common things I see is people using the randomly generated weapons as a template for a non-random weapon. And since the guide on the forum is a little out-dated, I figured I'd try to get a new one posted. As with all mods, you want to keep your items in folders that follow the vanilla file system. Below, when I use the term your_mod, it means your mod folder.

    BROADSWORDS


    For this example, we will make a lightsaber. We start by making the following folder path your_mod\items\active\weapons\melee\broadsword\lightsaber

    Inside that folder, we will need a lightsaber.activeitem file and a lightsaber.png

    lightsaber.activeitem
    Code:
    {
      "itemName" : "PMlightsaber",
      "price" : 960,
      "level" : 1,
      "maxStack" : 1,
      "rarity" : "Common",
      "description" : "Weapon used by a force-sensitive.",
      "shortdescription" : "Lightsaber",
      "tooltipKind" : "sword",
      "category" : "broadsword",
      "twoHanded" : true,
      "itemTags" : ["weapon","melee","broadsword"],
    
      "inventoryIcon" : "lightsaber.png",
    
      "animation" : "/items/active/weapons/melee/broadsword/combobroadsword.animation",
      "animationParts" : {
        "handle" : "",
        "blade" : "lightsaber.png"
      },
      "animationCustom" : { },
    
      "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],
    
      "elementalType" : "physical",
    
      "primaryAbilityType" : "broadswordcombo",
      "primaryAbility" : {
        "fireTime" : 0.83,
        "baseDps" : 11.5
      },
    
      "altAbilityType" : "risingslash",
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    
    lightsaber.png

    [​IMG]


    Let's break it down.

    "itemName" - This is what the game references for using commands like /spawnitem or when you add your item to a treasurepool or crafting station. To avoid mod conflicts, your itemName should always include a tag in front. Example - "itemName" : "PMlightsaber" Adding the PM in front (short for ProjectMayhem) ensures that if someone else makes a mod and adds a sword called "lightsaber", the mods wont conflict and crash.

    "price" - The value of the item. Merchants have different buy and sell prices, this is the base price they will use. The merchants coding then determines what % they buy/sell for.

    "level" - This you have to be careful with. It directly affects the weapons damage. It's good if you are making tier weapons. I dont know the formula, but increasing the level takes the baseDps and multiplies it, making the weapon do more damage.

    "maxStack" - how many you can put in one stack. I've never changed this, so I don't know if anything crazy happens if you have a stack of 500 broadswords.

    "rarity" - Determines the border color of your item icon. You can put Common, Uncommon, Rare, and Legendary.

    "description" - the text that shows up under the items preview. Flavor text.

    "shortdescription" - this is the name that shows up at the top of the preview window, and on the left side of crafting interfaces. If you make this too long it WILL take up more than one line and look very weird. Also, be careful of your spelling with this one, unlike other tags, the second word is NOT capitalized.

    "tooltipKind" - determines what type of preview window pops up for the tooltip. I've never changed this either. Whatever I'm using as a template usually has when I want anyways.

    "category" - this sets what type of item you are making and limits what you can put in the coding. You can have a broadsword category item with spear altAbilities.

    "twoHand" - sets if the item requires two hands. Yes, you can have one handed broadswords.

    "itemTags" - Not sure what these are for really, or how they work with other aspects of the game.

    "inventoryIcon" - the image used for your inventory.

    "animation" - the file your weapon uses for its animation. More on that below.

    "animationParts" - the parts of your weapons, unlike random weapons, you can use just one image for specific weapons.

    "animationCustom" - used for changing specific aspects of the animation file, without having to change the animation file.

    "scripts" - the scripts your item will use. I've never changed this one either.

    "elementalType" - What type of damage your weapon does. This also affects what type of altAbility you can use. (From my experience, I could be wrong. Please let me know if I am)

    "primaryAbilityType" - This is your standard attack. This sets all your arm rotations, weapon rotations, durations, etc for the basic combo.

    "primaryAbility" - fireTime and baseDps is usually the only thing here, but you can also mess around with other things like damageConfig to add status effects or change the damage type. Here is an example:
    Code:
    "primaryAbility" : {
         "fireTime" : 0.9,
        "baseDps" : 10.5,
        "damageConfig" : {
          "damageSourceKind" : "bow",
          "statusEffects" : ["weakpoison"]
    
        } 
    Changing the damageSourceKind to "bow" causes monsters with a hunting drop pool to drop those items instead.
    Adding "weakpoison" to the statusEffects will cause the weapon to inflict the weakpoison status effect on anything it hits.

    "altAbilityType" - which of the alternate abilities your weapon will have. You can see which one are available inside items\active\weapons\melee\abilities\broadsword

    "builder" - the script used to build your weapon.

    When we load up the game and use /spawnitem PMlightsaber we get this...
    [​IMG]

    [/spoiler]

    ___________________________________________________________________________________________

    SHORTSWORD

    For this, we will start with creating a folder with the following path. your_mod\items\active\weapons\melee\shortsword\hooksword

    Inside the hooksword folder, we need hooksword.activeitem and hooksword.png files.

    hooksword.activeitem
    Code:
    {
      "itemName" : "PMhooksword",
      "price" : 480,
      "level" : 1,
      "maxStack" : 1,
      "rarity" : "Common",
      "description" : "Hook and enemy and pull them close!",
      "shortdescription" : "Hook Sword",
      "tooltipKind" : "sword",
      "category" : "shortsword",
      "twoHanded" : false,
      "itemTags" : ["weapon","melee","shortsword"],
    
      "inventoryIcon" : "hooksword.png",
    
      "animation" : "/items/active/weapons/melee/shortsword/comboshortsword.animation",
      "animationParts" : {
        "handle": "",
        "blade" : "hooksword.png"
      },
      "animationCustom" : { },
    
      "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],
    
      "elementalType" : "physical",
    
      "primaryAbilityType" : "shortswordcombo",
      "primaryAbility" : {
        "fireTime" : 0.625,
        "baseDps" : 7.5
      },
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    
    hooksword.png
    [​IMG]
    As you can see, much of the coding is the same as for making a broadsword. I'll go over some of the changes though.

    "category" - As above, this sets what the weapon can and can't use. For this weapon, we are using shortsword.
    "twoHanded" - We use false here to set it as a one handed weapon.
    "itemTags" - We are using "shortsword" instead of "broadsword"
    "animation" - With shortswords, we use comboshortsword.animation unless you've made a custom animation file.
    "primaryAbilityType" - We are using shortswordcombo instead of broadswordcombo
    "primaryAbility" - The baseDps is lower, since it's a one handed weapon, and the fireTime is lowered to give it a quicker swing.

    One handed weapons do not get an altAbility since you have another item spot for your right click in your off hand.

    When we load into the game and /spawnitem PMhooksword we get this...
    [​IMG]


    Animated Weapons

    Ok, for animated weapons, we will use lightsabers again for the example. This lightsaber will be a broadsword. So lets create the following folder path - your_mod/items/active/weapons/melee/broadsword/lightsaber

    This example will cover using random generated colors for the lightsaber and random hilts.

    First off, lets create a folder called blade inside our lightsaber folder and create our blade png file inside it. We are going to use animations for extending/retracting and active.

    [​IMG]

    The first 5 frames are the extending frames, the whole bottom row is active. I used a quick 5 frame extend, instead of using all nine frames. After making this color, its a simple task to change the colors to add variant blade colors. For my example, I created 12 colors of lightsabers. Each color is named numerically 1-12.

    Now, the frames file for our lightsabers will look like this...


    Code:
    {
    
      "frameGrid" : {
        "size" : [27, 44],
        "dimensions" : [9, 2],
        "names" : [
          ["extend.1", "extend.2", "extend.3", "extend.4", "extend.5", null, null, null, null],
          ["active.1", "active.2", "active.3", "active.4", "active.5", "active.6", "active.7", "active.8", "active.9"]
        ]
      },
    
      "aliases" : {
        "retract.1" : "extend.5",
        "retract.2" : "extend.4",
        "retract.3" : "extend.3",
        "retract.4" : "extend.2",
        "retract.5" : "extend.1"
      }
    }
    


    Make sure to save this as default.frames so that all the blade files inside the folder use it.

    Now go back to your lightsaber folder and create a new folder called handle. Inside this folder, we will create png files for the handle. Here is an example:
    [​IMG]
    I created 8 handles for the lightsabers, named 1-8. There is no need for a frame file inside this folder. so lets head back to the lightsaber folder.

    Now, lets do our animation file. Here is the animation file for my lightsabers.

    Code:
    {
    
      "itemName" : "SWMlightsaber",
      "price" : 160,
      "level" : 3,
      "maxStack" : 1,
      "rarity" : "Uncommon",
      "description" : "Lightsaber constructed by a Force-Sensitive.",
      "shortdescription" : " Lightsaber",
      "tooltipKind" : "sword",
      "category" : "broadsword",
      "twoHanded" : true,
      "itemTags" : ["weapon", "melee", "broadsword"],
    
    
      "inventoryIcon" : "sabericon.png",
    
      "animation" : "saber.animation",
      "animationParts" : {
        "blade" : "",
        "handle" : ""
      },
      "animationCustom" : {
        "sounds" : {
          "fire" : [ "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg" ],
          "fire2" : [ "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg" ],
          "fire3" : [ "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg", "/sfx/melee/swing_lightsaber.ogg" ]
        }
      },
    
      "scripts" : ["/items/active/weapons/melee/energymeleeweapon.lua"],
    
      "activeTime" : 6.0,
    
      "elementalType" : "physical",
    
      "primaryAbilityType" : "broadswordcombo",
    "primaryAbility" : {
        "fireTime" : 0.83,
        "baseDps" : 12.5,
    
        "stances" : {
          "fire1" : {
            "duration" : 0.05
          },
          "wait1" : {
            "duration" : 0.1
          },
          "fire2" : {
            "duration" : 0.1
          },
          "wait2" : {
            "duration" : 0.1
          }
        }
      },
    
    
      "builder" : "/items/buildscripts/buildweapon.lua",
      "builderConfig" : [{
          "animationParts" : {
          "blade" : {
            "path" : "blade/<variant>.png",
            "variants" : 12,
            "paletteSwap" : false
          },
          "handle" : {
            "path" : "handle/<variant>.png",
            "variants" : 8,
            "paletteSwap" : false
          }
        },
        "altAbilities" : [
          "risingslash",
          "spinslash",
          "superspinslash"
        ],
        "palette" : "/items/active/weapons/colors/melee.weaponcolors",
        "iconDrawables" : [ "blade", "handle" ]
      }]
    
    
    }
    


    Lets go over some important parts.

    "scripts" : ["/items/active/weapons/melee/energymeleeweapon.lua"]
    As far as I know, this is required for animated weapons.

    "activeTime" : 6.0
    This defines how long our animation for "active" last. So with this set to 6, the blade stays out for 6 seconds before retracting back.

    "builder" : "/items/buildscripts/buildweapon.lua"
    We use this to build random weapons, instead of buildunrandweapon.lua

    "builderConfig" : [{
    "animationParts" : {
    "blade" : {
    "path" : "blade/<variant>.png",
    "variants" : 12,
    "paletteSwap" : false
    },
    "handle" : {
    "path" : "handle/<variant>.png",
    "variants" : 8,
    "paletteSwap" : false
    }
    },
    "altAbilities" : [
    "risingslash",

    [​IMG] "spinslash",
    "superspinslash"
    ],
    "palette" : "/items/active/weapons/colors/melee.weaponcolors",
    "iconDrawables" : [ "blade", "handle" ]
    }]


    This is the config for the build script. We are telling it where to look for the blades and handles, how many variants of each there are, and what altAbilities the weapons can generate with. You can easily use just one blade and hilt, and change the variants to 1, or add as many as you like!

    Now, lets create our animation file. Here is mine:


    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"
              }
            }
          },
          "blade" : {
            "default" : "inactive",
            "states" : {
              "inactive" : {
                "properties" : {
                "lightsOff" : ["glow"]    
                }
              },
              "extend" : {
                "frames" : 5,
                "cycle" : 0.30,
                "mode" : "transition",
                "transition" : "active",
                "properties" : {
                "lightsOn" : ["glow"],
                  "immediateSound" : "/sfx/melee/saberon.ogg"
                }
              },
              "active" : {
                "frames" : 9,
                "cycle" : 0.5,
                "mode" : "loop",
                "properties" : {
                "lightsOn" : ["glow"],
                   "persistentSound" : "/sfx/melee/hum.ogg"
                }
              },
              "retract" : {
                "frames" : 5,
                "cycle" : 0.30,
                "mode" : "transition",
                "transition" : "inactive",
                "properties" : {
                "lightsOff" : ["glow"],
                 "immediateSound" : "/sfx/melee/saberoff.ogg"
                }
              }
            }
          }
        },
    
        "parts" : {
          "blade" : {
            "properties" : {
              "zLevel" : 3,
              "centered" : true,
              "offset" : [0, 1.62],
              "transformationGroups" : ["weapon"],
              "rotationCenter" : [0, 0],
              "damageArea" : [[-0.7, -1.0], [-0.7, 2.5], [0.5, 2.5], [0.5, -1.0]]
            },
    
            "partStates" : {
              "blade" : {
                "inactive" : {
                  "properties" : {
                    "image" : ""
                  }
                },
                "extend" : {
                  "properties" : {
                    "image" : "<partImage>:extend.<frame>?<directives>?<bladeDirectives>"
                  }
                },
                "active" : {
                  "properties" : {
                    "image" : "<partImage>:active.<frame>?<directives>?<bladeDirectives>"
                  }
                },
                "retract" : {
                  "properties" : {
                    "image" : "<partImage>:retract.<frame>?<directives>?<bladeDirectives>"
                  }
                }
              }
            }
          },
          "handle" : {
            "properties" : {
              "zLevel" : 1,
              "centered" : true,
              "image" : "<partImage><paletteSwaps>?<directives>",
              "offset" : [0, 1.875],
              "transformationGroups" : ["weapon"],
              "rotationCenter" : [0, 0]
            }
          },
          "swoosh" : {
            "properties" : {
              "zLevel" : -1,
              "centered" : true,
              "transformationGroups" : ["swoosh"],
              "rotationCenter" : [0, 0]
            },
    
            "partStates" : {
              "swoosh" : {
                "idle" : {
                  "properties" : {
                    "image" : ""
                  }
                },
                "fire" : {
                  "properties" : {
                    "image" : "swoosh1/physicalswoosh.png:<frame>",
                    "offset" : [0, 2.5],
                    "damageArea" : [[-5, 2], [-2.5, 3], [1, 3], [4, 1.75], [5.25, -0.25], [5.25, -2.25], [3.75, -3.25], [0.25, -2.75]]
                  }
                },
                "fire2" : {
                  "properties" : {
                    "image" : "swoosh2/physicalswoosh.png:<frame>",
                    "offset" : [5.0, 1.0],
                    "damageArea" : [[-4, 1], [2.5, 1], [2.5, -2], [-4, -2]]
                  }
                },
                "fire3" : {
                  "properties" : {
                    "image" : "swoosh3/physicalswoosh.png:<frame>",
                    "offset" : [3.5, 0],
                    "damageArea" : [[-4.75, 1.5], [3, 1], [3, -1], [-4.75, -1.5]]
                  }
                }
              }
            }
          }
        }
      },
    
      "transformationGroups" : {
        "weapon" : {},
        "swoosh" : {}
      },
    
      "particleEmitters" : {
        "physicalswoosh" : {
          "active" : false,
          "transformationGroups" : ["swoosh"],
          "burstCount" : 4,
          "particles" : [
            { "particle" : "soluskatana1"},
            { "particle" : "soluskatana2"}
          ]
        },
        "blade" : {
          "active" : false,
          "transformationGroups" : ["weapon"],
          "offsetRegion" : [-0.5, 1.5, 0.5, 4.0],
          "emissionRate" : 5,
          "particles" : [
            { "particle" : "soluskatana1"},
            { "particle" : "soluskatana2"}
          ]
        }
      },
    
      "lights" : {
        "glow" : {
          "position" : [0, 2.0],
          "color" : [255, 255, 255],
          "transformationGroups" : ["weapon"]
        }
      },
    
      "sounds" : {
        "fire" : [],
        "fire2" : [],
        "fire3" : []
      }
    }
    



    It's a lot to take in. First off, we have our stateTypes. I have no idea what that means, but I know it includes our swoosh and our blade. (We still need to make our swooshes). Since broadsword combos use 3 attacks, we need fire1 fire2 and fire3 for the swoosh.
    For the blade, we need inactive (no blade) , extend (5 frames of blade extending), active (the 9 frames of the blade at full length) and retract (which is extend in reverse order, which we defined in our frames file.)
    Notice that each section has a "transition", this defines which animation comes after the current one. Extend leads to active, active leads to retract, retract leads to inactive.

    Next we have the "parts" , this is the blade and handle. Here we can change the offset if things aren't lining up with our pngs in game, and set of the damage area. We also have partStates for the blade. This is where we define what image is used for each state (inactive, active, extend and retract).
    inactive we leave blank, since there is no blade when it's inactive.
    for the others we use <partImage>.partState.<frame>?<directives>?<bladeDirectives>


    <partImage> - the png file used. So if it generated with your blade named 3, it would be 3.png
    partState - for our lightsabers, this is active, extend and retract. So for active, it would look at the frame file for the part of the png defined as active (we have 9 parts for active)
    <frame> - this is the frame numbers defined in our frames file and animation file. If you look at the saber.animation above, you see we have "frames" : 9 in our bladeStats for active. So, using active as an example again, it will look for active.1, active.2, active.3, etc all the way to active.9
    ?<directives>?<bladeDirectives> - I have no idea what these are for. But they were in the weapon I used as a template, so I left them

    Handle and swoosh are pretty easy to figure out looking at the example, the swoosh follows much the same way as the blade. The handle is even easier.

    Everything from this point in the animation file and below, was in the template I used, so I kept it all. I'm no pro, just a novice trying to share what I've learned so far for others trying to learn.

    Now, lets go back to our lightsaber folder and create 3 folders called swoosh1 swoosh2 and swoosh3. Each folder will have a png and a frame file, here are the swooshes I used.
    [​IMG]
    [​IMG]

    [​IMG]

    They are yellow and kind of hard to see on here. Since we have the blade color randomized, I went with a basic light yellow, I do not know if there is a way to get the swoosh to match a random color blade.

    Now, when you spawn it in the game, you should get a random blade and hilt (if you made more than 1 of each)

    Hopefully this will help you learn how to make your own animated weapons. You can do things like adding inactive images to your png for a constant animation, you can get rid of the extending and retracting and just have an inactive blade and an animated active blade, etc.


    GUNS (NON RANDOM)


    For this example, we will make an E-11 Blaster Rifle from Star Wars.
    First, create the folder path items/active/weapons/ranged/E11
    Now, use your favorite imaging program to make your weapon. Here is the image for our E11

    [​IMG]
    I named this e11.png and put it in our E11 folder. Now, we make an activeitem file called e11.activeitem

    Code:
    {[/SIZE][/COLOR]
    [SIZE=4]
    [COLOR=rgb(0, 0, 0)]  "itemName" : "PMe11",
      "price" : 200,
      "maxStack" : 1,
      "rarity" : "Common",[/COLOR]
      "description" : "A light but powerful blaster rifle manufactured by BlasTech Industries",
    [COLOR=rgb(0, 0, 0)]  "shortdescription" : " E-11 Blaster Rifle",
      "tooltipKind" : "gun",
      "category" : "assaultRifle",
      "twoHanded" : true,
      "itemTags" : ["weapon","ranged","assaultrifle"],
      "level" : 1,
    
    "inventoryIcon" : "e11.png",
    
      "animation" : "/items/active/weapons/ranged/gun.animation",
      "animationParts" : {
        "butt" : "",
        "middle" : "e11.png",
        "barrel" : "",
        "muzzleFlash" : "/items/active/ranged/muzzleflash2.png"
      },
      "animationCustom" : {
        "sounds" : {
          "fire" : ["/sfx/ranged/blasterrifle.ogg"]
        }
      },
      "baseOffset" : [1.0, 0.25],
      "muzzleOffset" : [1.3, 0.0],
    
      "scripts" : ["/items/active/weapons/ranged/gun.lua"],
    
      "elementalType" : "physical",
    
      "primaryAbility" : {
        "scripts" : ["/items/active/weapons/ranged/gunfire.lua"],
        "class" : "GunFire",
    
        "fireTime" : 0.55,
        "baseDps" : 12,
        "energyUsage" : 27,
        "inaccuracy" : 0.08,
    
        "projectileCount" : 1,
        "fireType" : "auto",
    
        "projectileType" : "blaster",
        "projectileParameters" : {
          "knockback" : 4
        },
    
        "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
          }
        }
      },
      "altAbilityType" : "spray",
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    




    Now, lets go over the important parts of the code above.

    "itemName" : "PMe11" - This is the name we use when referencing our items, players never see this. Like everything else in your mod, you will want to add a "mod tag" to the front, to avoid conflicts with other mods, so instead of just calling it e11, i called mine PMe11, where the PM is short for ProjectMayhem.

    "description" : "A light but powerful blaster rifle manufactured by BlasTech Industries" -- This is the description that appears when you mouse over the item or view the recipe at the crafting station.

    "shortdescription" : " E-11 Blaster Rifle" -- This is the description that appears on the left side of the crafting menus and at the top of your description box.

    "twoHanded" : true -- Sets if our gun needs to be used by both hands, or just one.

    "level" : 1 -- The "baseDps" you set further down, is increased depending upon the level of the item

    "inventoryIcon" : Self-Explanitory

    "animation" : "/items/active/weapons/ranged/gun.animation" -- The animation file we use for our weapon

    "animationParts" : { "butt" : "", "middle" : "e11.png", "barrel" : "", "muzzleFlash" : "/items/active/ranged/muzzleflash2.png"
    } - Defines the animation parts, when making a Non-Random Gun you only need to have one png files, I always put it in the "middle". We also define our muzzle flash here.

    "animationCustom" : { "sounds" : { "fire" : ["/sfx/ranged/blasterrifle.ogg"] } } --- Here we define parts of the animation file we want to change, that way we dont have to use 100 different animation files for the 100 weapons we create. We just use one, and alter small aspects in our activeitem files. Only thing I needed to change is the sound that plays, I downloaded an E-11 sfx, and converted it to ogg, using a website.


    "baseOffset" : [1.0, 0.25], "muzzleOffset" : [1.3, 0.0] -- Use these to tweak your guns position if its not lining up correctly in your hands, and the muzzleOffset will help line up your muzzleflash animation.

    "scripts" : ["/items/active/weapons/ranged/gun.lua"] -- Scripts used for the gun, ive never used anything except the vanilla script for my guns

    "elementalType" : "physical" - Your guns elemental type, I think some altAbilities wont work depending on the elementalType. Or at least I found this to be true for melee weapons, I assume its true for ranged also.

    "primaryAbility" -- This is where we set a lot of stats and information about the weapons, depending on the weapon you make, some of the stuff below isnt needed, like flamethrowers use very little of the tags below

    • "scripts" - the scripts used for the primary ability, ive always used the vanilla script
    • "class" - GunFire is the only thing I've used
    • "fireTime" - the time between shots
    • "baseDps" - the base damage of your gun, the higher the baseDPS, the longer the fireTime generally is. Dont forget this, this value is increased by your weapons "level" we set earlier
    • "energyUsage" - How much energy the gun uses per shot. I think this value is decreased with higher "levels"
    • "inaccuracy" -- How accurate the gun is, with a 0.08 we get a nice Stormtrooper aim feel, without being so bad we make the gun unusable.
    • "projectileCount" - number of projectile shots each time it fires
    • "fireType" - This is almost always "auto". The space plasma rifle is the only gun I've seen that doesn't use auto. It has the following
      Code:
      "burstCount" : 3,
          "burstTime" : 0.1,
          "fireType" : "burst",
    • "projectileType" - This is what projectile you want your gun to shoot. I used a custom projectile, since blaster rifles have a red "beam" kind of bullet.
    • "projectileParameters" - any parameters you want to apply top the projectiles, like on hit effects.
    "stances" - These are your different states of animation while using the gun. Idle for when you are not firing, fire for when you are shooting the gun, and cooldown for the transition from fire to idle (I think) This is mainly to set arm rotations and if you are allowed to Flip/Rotate while shooting.

    "altAbilityType" - This defines your right click ability. We used Spray for this , since thats what Stormtroopers do, spray and pray.

    "builder" - the builder file used to make the weapon, notice we used the unrand builder, since our weapon is un-random.





    CUSTOM PROJECTILES

    For this tutorial, I'm just going to make a random projectile to show all the things I've learned we can do. First off, lets make a projectiles folder inside our mod folder. Second, lets make a new folder inside that called tutorial. (When you make your own projectiles, try to follow the vanilla file system, so its easier for you and others to locate files.)
    Now, we are going to need 4 files in this folder. Our frame file, our projectile file, our png file and a second png file for damage icon.

    I always find it easiest to start with my image, so for this tutorial, I am making a 4 frame projectile that looks like this...

    [​IMG]

    Each of the projectiles is 6 pixels wide and 6 pixels tall. So we will make our frames file next. Make sure to name it the same as your image we make. Mine is named tutorial.frames

    Code:
    {
      "frameGrid" : {
        "size" : [6, 6],
        "dimensions" : [4, 1],
    
        "names" : [
          [ "0", "1", "2", "3" ]
        ]
      }
    }
    
    When filling in your "size" , remember to only include the size of 1 image, and to do Width and then Height.
    The "dimensions" defines how many columns and rows the image has. We have 4 columns, and only 1 row.
    Next, we name the frames, always start with 0.

    Now, we make the projectile file.

    Code:
    {
      "projectileName" : "PMtutorial",
      "physics" : "fireball",
      "bounces" : -1,
      "timeToLive" : 3,
      "image" : "tutorial.png",
      "damageKindImage" : "icon.png",
      "speed" : 19,
      "animationCycle" : 0.5,
      "frameNumber" : 4,
     
    "actionOnReap" : [
        {
          "action" : "config",
          "file" : "/projectiles/explosions/plasmabulletexplosion/plasmabulletexplosion.config"
        }
      ],
      "power" : 50,
      "lightColor" : [78, 78, 78],
      "damageKind" : "plasma",
    "statusEffects" : [
        "colorblue"
      ]
    }
    
    Ok, there is a lot of customization you can do with your projectiles. I'll try to cover everything I know about, which I'm pretty sure barely scratches the surface.

    projectileName - With everything else in your mod, you ALWAYS want to have a special tag you use in front of your item/object/projectiles/etc. I am using PMtutorial for my projectile name.

    physics - This determines how your projectiles acts. Inside your vanilla assets, in the projectiles folder is a physics.config file. Looking at that should help you determine what kind of physics you want. I used fireball, here is what physics.config says about fireballs.

    "fireball" : {
    "mass" : 1.0,
    "gravityMultiplier" : 0.5,
    "bounceFactor" : 0.9,
    "stopOnFirstBounce" : true,
    "maxMovementPerStep" : 0.4,

    "collisionPoly" : [ [-0.25, -0.25], [0.25, -0.25], [0.25, 0.25], [-0.25, 0.25] ],
    "ignorePlatformCollision" : true,

    "airFriction" : 0.0,
    "liquidFriction" : 8.0,
    "groundFriction" : 5.0,
    "maximumCorrection" : 0.75
    }

    bounces - Determines how many times your projectile can bounce. I'm pretty sure -1 means it can bounce till it runs out of "timeToLive"

    timeToLive - How long your projectile stays in the world.

    image - The image used for your projectile

    damageKindImage - an icon representing the damage kind of your projectile. I dont think this is too important.

    speed - How fast your projectile travels.

    animationCycle - How long it takes to play all the frames of your image.

    frameNumber - number of frames in your image

    actionOnReap - things you want to happen when your projectile makes contact with something. The config i used causes a spark and plays a plasma explosion sound. There are many actionOnReaps you can use, check other vanilla projectiles to get ideas for what you can do

    • playing sounds
    • spawning more projectiles
    • spawning particles
    • apply a surface mod
    • more stuff I probably dont know
    power - how much damage your projectile does. I'm not sure how this works with other things.

    damageType - Not really sure what all values this can use.

    damageKind - the kind of damage your projectile does

    lightColor - sets a light color if you want a glow around your projectile

    statusEffects - sets any status effects you want to apply when a target it hit with the projectile. You can find a list of status effects in the /stats/effects folder.

    pointLight - I think this sets the lightColor to shine in a "flashlight" like style. Not sure, I've never used it before

    animationLoops - I think the only reason to use this, is if you want to set it to false so your animation doesnt loop

    piercing - Determines if your projectile stops with the first entity hit, or if it last the entire "timeToLive"

    flippable - determines if the projectile image needs to be flipped when you turn around (I think)

    damagePoly - sets an area for your projectiles damage. I think this is only really needed for large projectiles. I cant really explain damagePoly, other than you put coordinates and "draw" a shape.

    emitters - set any emitters you want your projectile to have

    periodicActions - any actions you want your projectile to do periodically

    onlyHitTerrain - set this to true for your projectile to only hit terrain

    damageTeam - set a damage team for your projectile

    actionOnCollide - set an action to happen on collide. I assume the same things that can happen on reap

    renderLayer - sets what layer the projectile renders on

    This is all I can think of for now.
     
    Last edited: Jul 8, 2018
  2. Magmatico

    Magmatico Void-Bound Voyager

    Very informative and useful! Looking forward to animations :D
     
    projectmayhem likes this.
  3. projectmayhem

    projectmayhem Spaceman Spiff

    Went ahead and did animations using lightsabers again. Hopefully this helps, I'm not pro, but this is what i've learned from poking around in files and asking questions.
     
    Magmatico likes this.
  4. Magmatico

    Magmatico Void-Bound Voyager

    Wow, thats a lot (especially the randomness of colors). Thanks anyway, it was, as i said, informative
     
  5. projectmayhem

    projectmayhem Spaceman Spiff

    No problem, if you have any questions or run into issues, just ask on the forums, there are a lot of great people on here who are very helpful.
     
  6. Magmatico

    Magmatico Void-Bound Voyager

    I actually wonder what does "paletteSwap" mean, do you know it?
     
  7. projectmayhem

    projectmayhem Spaceman Spiff

    I think it changes the colors of the weapons based on a file somewhere. I never really worried about randomly coloring parts of my weapons, i've always had a certain color design ive wanted.
     
  8. bryonsmothers

    bryonsmothers Aquatic Astronaut

    When do you think you will get to guns? I have pulled some mods apart and looked at them but changes I have made almost always end with a weapon that will not fire. Very much looking forward to an up to date tutorial on non-random guns.

    nice work
     
  9. projectmayhem

    projectmayhem Spaceman Spiff

    I will work on it today, in between my off-job hustle. Should have it done by the end of the day.


    EDIT

    Done, for the two handed rifle. Pistols are pretty much the same, just changed the itemTags and twoHanded value to false
     
    Last edited: Jul 5, 2018
    yasha_mikage and bryonsmothers like this.
  10. bryonsmothers

    bryonsmothers Aquatic Astronaut

    Thank you I look forward to messing with this when I have some more free time.
     
  11. yasha_mikage

    yasha_mikage Orbital Explorer

    You've done the community a great service as there seems to be a certain lack of post 1.3 information on weapon modding. Thank you!
     
    Magmatico likes this.
  12. projectmayhem

    projectmayhem Spaceman Spiff

    No problem :) I'll work on custom projectiles tonight.
     
  13. Magmatico

    Magmatico Void-Bound Voyager

    Just saying, the "fireMode" in guns can be customized to either make it a burst-fire or an auto-fire. Yeah, most guns use "auto", but 50% of RNG ones have the "burst" one.
     
  14. projectmayhem

    projectmayhem Spaceman Spiff

    I mentioned burst fire.

     
  15. PseudoGold

    PseudoGold Pangalactic Porcupine

    This guide has helped me so much in getting my mods to work. Thanks for making this mate.
     
  16. projectmayhem

    projectmayhem Spaceman Spiff

    No problem!
     
  17. Magmatico

    Magmatico Void-Bound Voyager

    I know, i just said that 50% of RNG guns have it (unique guns usually dont).
     
  18. Magmatico

    Magmatico Void-Bound Voyager

    I re-read the text now and some fun things:
    - Melee weapons (swords, daggers, spears, hammers etc.) can use each other's ability (i made a spear with broadsword combo and a sword with flurry, at least :p) You only need this to be a melee weapon.
    - For the RNG sabers, im pretty sure that if you will put something in the swoosh "parts" about the palette (something like <paletteSwaps>, i forgot what exactly) you can do this. however you'll have to make it yourself (and i dont think you can really sync them with the RNG ones)
    - ?<directives>?<bladeDirectives> is one of my favourite thing - it allows you to do a one-time change in texture. Lets say you want to have an upwards-slash, but you dont want to use /items/active/weapons/melee/abilities/broadsword/risingslash/risingswoosh.png (physical), but instead want to use, lets say, tearswoosh.png. In the original file its directed downwards, but if you will put ?flipy after the <frame> parameter it will flip the swoosh vertically (other commands i know: ?flipx (flipping horizontally), ?replace;COLOR1=COLOR2 (replaces COLOR1 to COLOR2 (they must be hex values, like FF0000 for bright red)), ?border (not sure how to use it and never did, but you can find it in shield.animation), ?scale=SCALE (obviously, changes scale. 1 for 100%, 0.1 for 10% etc.)). Basically, awesome boi here. not sure what's the ?<bladeDirectives> mean though >.<
    - The descriptions only show if the "tooltipKind" is set to "base", "shield" and "seed" (maybe more).
     
    projectmayhem likes this.
  19. Magmatico

    Magmatico Void-Bound Voyager

    Yeah, i made an energy blade with palette swaps and got a green swoosh. It works :D
    And its synced to the blade (which, to be honest, only exists in the icon. any ideas?)
     
    Last edited: Jul 25, 2018
  20. projectmayhem

    projectmayhem Spaceman Spiff

    Awesome info! Thanks for adding this.
     

Share This Page