Modding Help Add Weapon Special Attack

Discussion in 'Starbound Modding' started by SuperKrusher, Dec 26, 2015.

  1. SuperKrusher

    SuperKrusher Big Damn Hero

    So I am trying to alter a weapon a bit to make it feel more like I want it to. It currently has no special attack and I was hoping to add one, specifically the "Super Spin Slash" one. What is the code for that?
     
  2. lazarus78

    lazarus78 The Waste of Time

    You need to convert it to the new "*.activeitem" format to make use of the alt abilities.

    This is an example of what it looks like:
    Code:
    {
        "itemName" : "hylotltier10broadsword",
        "price" : 170,
        "level" : 6,
        "maxStack" : 1,
        "rarity" : "common",
        "description" : "Trunkcutter. A sword perfect for slaying Florans.",
        "shortdescription" : "Trunkcutter",
        "tooltipKind" : "sword",
        "weaponType" : "Broadsword",
        "twoHanded" : true,
        "itemTags" : ["weapon","melee","broadsword"],
    
        "inventoryIcon" : "hylotltier10broadsword.png",
    
        "animation" : "/items/active/weapons/melee/broadsword/tieredbroadsword.animation",
        "animationParts" : {
            "sword" : "/items/active/weapons/melee/tiered/broadsword/hylotl/hylotltier10broadsword.png"
        },
        "animationCustom" : {
            "sounds" : {
                "fire" : [ "/sfx/melee/swing_broadsword.ogg" ]
            }
        },
    
        "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType" : "physical",
    
        "primaryAttack" : {
            "fireTime" : 0.83,
            "baseDps" : 11.5,
            "damageConfig" : {
                "damageSourceKind" : "broadsword",
                "statusEffects" : [ ],
                "knockback" : 20,
                "knockbackMode" : "facing",
                "timeoutGroup" : "primary"
            }
        },
    
        "baseWeaponRotation" : 10,
        "stances" : {
            "idle" : {
                "armRotation" : -90,
                "weaponRotation" : -10,
                "allowRotate" : false,
                "allowFlip" : true
            },
            "windup" : {
                "duration" : 0.1,
                "armRotation" : 90,
                "weaponRotation" : -10,
                "twoHanded" : true,
    
                "allowRotate" : false,
                "allowFlip" : true
            },
            "preslash" : {
                "duration" : 0.025,
                "armRotation" : 55,
                "weaponRotation" : -45,
                "twoHanded" : true,
    
                "allowRotate" : false,
                "allowFlip" : false
            },
            "fire" : {
                "duration" : 0.4,
                "armRotation" : -45,
                "weaponRotation" : -55,
                "twoHanded" : true,
    
                "allowRotate" : false,
                "allowFlip" : false
            }
        },
    
        "palette" : "/items/active/weapons/colors/tier10melee.weaponcolors",
    
        "altAbilitySource" : "/items/active/weapons/melee/altabilities/broadsword/spinslash/spinslash.altability",
    
        "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }
    
    
     
  3. SuperKrusher

    SuperKrusher Big Damn Hero

    Hmm, ok so I am having an issue with the weapon causing errors. I am going to copy paste the code in a sec here... Just I want to mention that this uses the old format of coding weapons. It is actually a weapon from a different mod. The mod creator told me that it is totally cool if I go ahead and edit his mod. He even told me to paste this comment in this part of the forum. Anyways, here is the code for what I have. I did edit the damage code and speed so I would want to use it instead of my other top tier weapons.


    Code:
    {
      "itemName" : "redscissorblade",
      "inventoryIcon" : "redscissorbladeicon.png",
      "dropCollision" : [-4.0, -3.0, 4.0, 3.0],
      "maxStack" : 1,
      "level" : 1,
      "rarity" : "legendary",
      "description" : "The red half of the Scissor Blades used to kill Matoi Isshin.",
      "shortdescription" : "Red Scissor Blade",
      "tooltipKind" : "sword",
      "kind" : "Broadsword",
    
      "image" : "redscissorblade.png",
      "firePosition" : [15.5, 4.5],
      "fireTime" : 0.35,
      "fireAfterWindup" : true,
      "soundEffect" : { "fireSound" : [ { "file" : "/sfx/melee/swing_twohanded.wav" } ] },
    
      "colorOptions" : [
        /* GREY */
        { "ffca8a" : "b5b5b5", "e0975c" : "808080", "a85636" : "555555", "6f2919" : "303030" },
        /* BLACK */
        { "ffca8a" : "838383", "e0975c" : "555555", "a85636" : "383838", "6f2919" : "151515" },
        /* GREY */
        { "ffca8a" : "b5b5b5", "e0975c" : "808080", "a85636" : "555555", "6f2919" : "303030" },
        /* WHITE */
        { "ffca8a" : "e6e6e6", "e0975c" : "b6b6b6", "a85636" : "7b7b7b", "6f2919" : "373737" },
        /* RED */
        { "ffca8a" : "f4988c", "e0975c" : "d93a3a", "a85636" : "932625", "6f2919" : "601119" },
        /* ORANGE */
        { "ffca8a" : "ffd495", "e0975c" : "ea9931", "a85636" : "af4e00", "6f2919" : "6e2900" },
        /* YELLOW */
        { "ffca8a" : "ffffa7", "e0975c" : "e2c344", "a85636" : "a46e06", "6f2919" : "642f00" },
        /* GREEN */
        { "ffca8a" : "b2e89d", "e0975c" : "51bd3b", "a85636" : "247824", "6f2919" : "144216" },
        /* BLUE */
        { "ffca8a" : "96cbe7", "e0975c" : "5588d4", "a85636" : "344495", "6f2919" : "1a1c51" },
        /* PURPLE */
        { "ffca8a" : "d29ce7", "e0975c" : "a451c4", "a85636" : "6a2284", "6f2919" : "320c40" },
        /* PINK */
        { "ffca8a" : "eab3db", "e0975c" : "d35eae", "a85636" : "97276d", "6f2919" : "59163f" },
        /* BROWN */
        { "ffca8a" : "ccae7c", "e0975c" : "a47844", "a85636" : "754c23", "6f2919" : "472b13" }
      ],
    
      "primaryStances" : {
        "directional" : false,
        "projectileType" : "broadswordswoosh",
        "projectile" : {
          "speed" : 0,
          "power" : 60.972222222222
        },
        "idle" : {
          "twoHanded" : true,
          "armAngle" : -90,
          "swordAngle" : -90,
          "handPosition" : [1.0, -14.0],
          "duration" : 0.1
        },
        "windup" : {
          "twoHanded" : true,
          "armAngle" : 45,
          "swordAngle" : 45,
          "handPosition" : [1.0, -14.0],
          "duration" : 0.2,
          "statusEffects" : []
        },
        "cooldown" : {
          "twoHanded" : true,
          "armAngle" : -90,
          "swordAngle" : -90,
          "handPosition" : [1.0, -22.5],
          "duration" : 0.4,
          "statusEffects" : []
        }
      },
     
      "parryBlockCooldown" : 0.4,
      "parrySound" : "/sfx/melee/sword_parry.wav",
      "parryParticle" : "shieldspark",
    
      "altStances" : {
        "type" : "parry",
        "rescaleTiming" : false,
        "parryPoly" : [ [12, -14], [12, -2], [28, 6], [28, -38], [12, -26] ],
    
        "idle" : {
          "twoHanded" : true,
          "armAngle" : -90,
          "swordAngle" : -90,
          "handPosition" : [1.0, -17.0],
          "duration" : 0.1
        },
        "windup" : {
          "twoHanded" : true,
          "armAngle" : 45,
          "swordAngle" : 45,
          "handPosition" : [1.0, -17.0],
          "duration" : 1
        },
        "cooldown" : {
          "twoHanded" : true,
          "armAngle" : -90,
          "swordAngle" : -90,
          "handPosition" : [0.0, -17.0],
          "duration" : 0.1
        }
      }
    }
    
     
  4. lazarus78

    lazarus78 The Waste of Time

    Yeah, that is older than old at this point. "dropCollision" has been removed entirly, and all sound effects have been converted to .ogg.

    You can't add the special effect using that format. You have to change it to the one I posted.
     
  5. SuperKrusher

    SuperKrusher Big Damn Hero

    Ok that works... now all that the issue is that the weapon is too low. I am playing a human so is there a way to bring the weapon up closer to her hand?
     
  6. lazarus78

    lazarus78 The Waste of Time

    Doesnt look like belee weapons have it by default, but you might try adding in:
    "baseOffset" : [0.25, 0.25],

    The values are X and Y, which 1 pixel being 0.125 per pixel.
     
  7. SuperKrusher

    SuperKrusher Big Damn Hero

    hmm it doesn't seem to do anything. Where exactly in the code am I to plug this in?
     
  8. lazarus78

    lazarus78 The Waste of Time

    At the end would work... But I guess that option doesnt work with melee weapons... hmm... odd. Is moving the sprite around in the image itself an option?
     
  9. SuperKrusher

    SuperKrusher Big Damn Hero

    I don't believe so. There is no place to give it an offset in the sprite itself...
     
  10. lazarus78

    lazarus78 The Waste of Time

    If the sprite has blank room around it when you load it up in an image editor, you can just shift it around there. The game will load the sprite and position it based on the image's center, not where actual pixles are.

    You could try lining up the weapon with a vanilla weapon. It is weird they didn't include an offset for melee weapons in the new format.
     
  11. SuperKrusher

    SuperKrusher Big Damn Hero

    Alright thanks so much I'll give it a shot[DOUBLEPOST=1451210898][/DOUBLEPOST]Yep got it! Thanks so much!!!
     
    Last edited: Dec 27, 2015
  12. intrepid-explorer

    intrepid-explorer Phantasmal Quasar

    So...to upgrade an existing weapon mod (such as my MiniGuns) to add alternative effects, I would have to:
    • add a line for the active effect to the *.gun files' code as described above
    • rename the *.gun to *.activeitem
    • move the renamed item files to items\active\weapons\ranged
    • make appropriate path changes in any references to the item, such as recipes
    • change the sound to OGG format with appropriate path changes in the *.activeitem file
    That is a lot of changes, so before I get started, I should ask: what other steps am I missing?
     
  13. lazarus78

    lazarus78 The Waste of Time

    Your steps are wrong. If you look at the format of activeitems you will see they are a bit more different than adding a line for the alt abilitiy.
     
  14. intrepid-explorer

    intrepid-explorer Phantasmal Quasar

    I see. To write the mod in the first place I had to study the code, so this will be like starting over again. Maybe I'll just fix the functions that broke with the update for now, instead of adding new ones.
     
  15. lazarus78

    lazarus78 The Waste of Time

    Yeah, it is basically like starting over again, but that is bound to happen when you mod an unfinished game. It becomes an even bigger problem when you have a very big mod needing massive changes to almost everything.
     

Share This Page