Modding Help How do you switch a Spear's Alt Abilities?

Discussion in 'Starbound Modding' started by InvaderXYZ, Feb 13, 2017.

  1. InvaderXYZ

    InvaderXYZ Space Hobo

    Hi!
    I've been making a spear mod, using the Titanium Spear as a base to go off of. Unfortunately, I got stuck at the Alt Abilities part. No matter what I do, the spear either somehow reverts to the Spear Spin it started with it becomes entirely unusable. How would I go about swapping its' alt ability with a preexisting one?

    Also: Is it possible to make an alt ability where the spear is thrown?

    Thanks!
     
  2. Cyel

    Cyel Scruffy Nerf-Herder

    Changing the alt ability should be as easy as setting the right one in the "altAbilityType" string, what is your .activeitem so far?

    Yes, I't be possible, but it'd require Lua scripting, and I don't think any of the vanilla stuff does that
     
  3. IHart

    IHart Scruffy Nerf-Herder

    I want this.
     
  4. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    I had a similar problem, perhaps a look through the thread where some people helped me out to fix it, may help you. =)
    http://community.playstarbound.com/threads/elemental-alt-abilities-solved.130099/
     
  5. InvaderXYZ

    InvaderXYZ Space Hobo


    {
    "itemName" : "longinusLance",
    "price" : 9600,
    "level" : 3,
    "maxStack" : 1,
    "rarity" : "Legendary",
    "description" : "Retrieved from the White Moon, this ancient sentient spear can destroy anything.",
    "shortdescription" : "Lance of Longinus",
    "tooltipKind" : "sword",
    "category" : "spear",
    "twoHanded" : true,
    "itemTags" : ["weapon","melee","spear"],

    "inventoryIcon" : "longinusLance.png",

    "animation" : "/items/active/weapons/melee/spear/spear.animation",
    "animationParts" : {
    "handle" : "",
    "blade" : "longinusLance.png"
    },
    "animationCustom" : {
    "sounds" : {
    "fire" : [ "/sfx/melee/swing_spear.ogg" ]
    }
    },

    "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],

    "elementalType" : "electric",

    "aimOffset" : -1.0,

    "primaryAbilityType" : "spearstab",
    "primaryAbility" : {
    "fireTime" : 0.5,
    "baseDps" : 1000
    },

    "altAbilityType" : "spearcharge",
    "altAbility" : {
    "chargeTime" : 2.0,
    "minChargeTime" : 0.5,
    "chargeLevels" : 4,
    // [width, forks, branching, color]
    "lightningChargeLevels" : [
    [1.15, 0, 0.05, [255, 255, 150, 50]],
    [1.15, 0, 0.07, [255, 255, 185, 50]],
    [1.15, 0, 0.09, [255, 255, 215, 50]],
    [1.15, 0, 0.12, [255, 255, 255, 50]]
    ],
    "dashLightning" : [1, 0, 0.12, [255, 255, 255, 50]],

    "dashMaxSpeed" : 200,
    "dashControlForce" : 1600,
    "maxDashTime" : 0.20,
    "maxEnergyUsage" : 50,

    "freezeTime" : 0.1,

    "damageConfig" : {
    "baseDamage" : 6,
    "timeout" : 0.25,
    "timeoutGroup" : "alt"
    },
    "baseDps" : 6, // overrides baseDamage in damageConfig

    "cycleRotationOffsets" : [0, 7.5, -7.5],
    "stances" : {
    "charge" : {
    "armRotation" : -135,
    "weaponRotation" : 45,
    "twoHanded" : true,
    "weaponOffset" : [0.0, 0.0],

    "allowRotate" : true,
    "allowFlip" : true
    },
    "dash" : {
    "armRotation" : -25,
    "weaponRotation" : -65,
    "twoHanded" : true,
    "weaponOffset" : [0.0, 2.0],

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

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



    This is what I have for my active item. Currently, the spear is broken and can only be held. If I change the altAbility thing only, nothing happens.
    I'm kinda just trying to figure out how to switch out altAbilities, then maybe I can try to figure out how to get it to throw. I'm thinking having it spawn a projectile, but I have no idea how to make it spawn a projectile, just how to make a projectile...

    Thanks! I saw it a bit earlier and it helped me a bit with the understanding, but I still can't seem to get it to work?
     
  6. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    I found that sometimes by going to : assets\_unpacked\items\active\weapons\melee\abilities\spear\charge
    and looking at what is inside charge.weaponability it helped me understand it a bit, how it works.

    Usually it seems you can copy some of the code there for tweaking to your mod. Usually under the altability part. Or, so I found.

    May take a closer look at your code in a bit, see if I can see anything, but I'm not all that experienced. Ha.

    http://jsonlint.com/ is also useful to make sure it's valid. And the game log.

    All your filepaths seem correct though.

    And, that's pretty much all I know. For now.
     
    Last edited: Feb 14, 2017
  7. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Perhaps a look at a couple of my .activeitem files may help.

    This one, is for spearspin ability :
    Code:
    {
        "itemName": "aviantier3spearbasic",
        "price": 160,
        "level": 3,
        "maxStack": 1,
        "rarity": "Uncommon",
        "description": "Migrator. A decorated, sturdy spear.",
        "shortdescription": "Migrator",
        "tooltipKind": "sword",
        "category": "spear",
        "twoHanded": true,
        "itemTags": ["weapon", "melee", "spear"],
    
        "inventoryIcon": "spearicon3.png",
    
        "animation": "/items/active/weapons/melee/spear/spear.animation",
        "animationParts": {
            "handle": "",
            "blade": "aviantier3spear.png"
        },
        "animationCustom": {
            "animatedParts": {
                "parts": {
                    "swoosh": {
                        "properties": {
                            "offset": [2.2, 0.05]
                        }
                    }
                }
            },
            "sounds": {
                "fire": ["/sfx/melee/swing_spear.ogg"]
            }
        },
    
        "scripts": ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType": "physical",
    
        "aimOffset": -0.7,
    
        "primaryAbilityType": "spearstab",
        "primaryAbility": {
            "fireTime": 0.54,
            "baseDps": 10.5
        },
        "stances" : {
          "idle" : {
            "armRotation" : -45,
            "weaponRotation" : -10,
            "weaponOffset" : [0.3, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : true
          },
          "windup" : {
            "duration" : 0.05,
            "armRotation" : -20,
            "weaponRotation" : -20,
            "weaponOffset" : [0.5, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : false
          },
          "fire" : {
            "duration" : 0.2,
            "armRotation" : -135,
            "weaponRotation" : 40,
            "weaponOffset" : [0.5, 2.5],
    
            "allowFlip" : true,
            "allowRotate" : false
          }
        },
    
    
        "altAbilityType": "spearspin",
        "altAbility": {
        "name" : "Blade Whirl",
        "type" : "spearspin",
        "scripts" : ["/items/active/weapons/melee/abilities/spear/spin/spin.lua"],
        "class" : "Spin",
      
           "energyUsage" : 60,
        "cooldownTime" : 0.2,
    
      "damageConfig" : {
          "damageSourceKind" : "spear",
          "statusEffects" : [ ],
            "baseDamage" : 6,
            "knockbackMode" : "none",
            "knockback" : 30,
            "timeout" : 0.5,
            "timeoutGroup" : "alt"
        }
    
      },
    
        "builder": "/items/buildscripts/buildunrandweapon.lua",
        "critChance": 2,
        "critBonus": 6,
      
            "learnBlueprintsOnPickup" : [ "aviantier4spearbasic"]
    }
    and this one has rocketspear ability. Seems, to me, that some abilities are specific to certain element types. Like, rocket spear needs an element type that isn't physical.

    Code:
    {
        "itemName": "aviantier7spearbasic",
        "price": 160,
        "level": 7,
        "maxStack": 1,
        "rarity": "Legendary",
        "description": "The Roaster. A spear shaped like a Christmas turkey.",
        "shortdescription": "The Roaster",
        "tooltipKind": "sword",
        "category": "spear",
        "twoHanded": true,
        "itemTags": ["weapon", "melee", "spear"],
    
        "inventoryIcon": "spearicon7.png",
    
        "animation": "/items/active/weapons/melee/spear/spear.animation",
        "animationParts": {
            "handle": "",
            "blade": "aviantier7spear.png"
        },
        "animationCustom": {
            "animatedParts": {
                "parts": {
                    "swoosh": {
                        "properties": {
                            "offset": [2.2, 0.05]
                        }
                    }
                }
            },
            "sounds": {
                "fire": ["/sfx/melee/swing_spear.ogg"]
            }
        },
    
        "scripts": ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType": "ice",
    
        "aimOffset": -0.7,
    
        "primaryAbilityType": "spearstab",
        "primaryAbility": {
            "fireTime": 0.55,
            "baseDps": 18.5
        },
        "stances" : {
          "idle" : {
            "armRotation" : -45,
            "weaponRotation" : -10,
            "weaponOffset" : [0.3, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : true
          },
          "windup" : {
            "duration" : 0.05,
            "armRotation" : -20,
            "weaponRotation" : -20,
            "weaponOffset" : [0.5, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : false
          },
          "fire" : {
            "duration" : 0.2,
            "armRotation" : -135,
            "weaponRotation" : 40,
            "weaponOffset" : [0.5, 2.5],
    
            "allowFlip" : true,
            "allowRotate" : false
          }
        },
    
    
                "altAbilityType": "rocketspear",
        "altAbility": {
        "scripts" : ["/items/active/weapons/melee/abilities/spear/rocketspear/rocketspear.lua"],
         "energyPerSecond" : 15,
    
      "projectileOffset" : [1, 0],
      "projectileType" : "icespinswoosh",
      "baseDamage" : 20,
    
            "damageConfig": {
                "damageSourceKind": "spear",
                "knockback": 27,
                "knockbackMode": "facing",
                "timeoutGroup": "primary"
            }
    
      },
    
        "builder": "/items/buildscripts/buildunrandweapon.lua",
        "critChance": 2,
        "critBonus": 6,
      
            "learnBlueprintsOnPickup" : [ "aviantier8spearbasic"]
    }
    Afraid I never used the charge ability, but these examples may help some, maybe.

    One more example, with elementalspin ability.

    Code:
    {
        "itemName": "aviantier9spearbasic",
        "price": 160,
        "level": 9,
        "maxStack": 1,
        "rarity": "Legendary",
        "description": "Sunguard. A spear reportedly carried by the guardians of the Sunborn.",
        "shortdescription": "Sunguard",
        "tooltipKind": "sword",
        "category": "spear",
        "twoHanded": true,
        "itemTags": ["weapon", "melee", "spear"],
    
        "inventoryIcon": "spearicon9.png",
    
        "animation": "/items/active/weapons/melee/spear/spear.animation",
        "animationParts": {
            "handle": "",
            "blade": "aviantier9spear.png"
        },
        "animationCustom": {
            "animatedParts": {
                "parts": {
                    "swoosh": {
                        "properties": {
                            "offset": [2.2, 0.05]
                        }
                    }
                }
            },
            "sounds": {
                "fire": ["/sfx/melee/swing_spear.ogg"]
            }
        },
    
        "scripts": ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType": "ice",
    
        "aimOffset": -0.7,
    
        "primaryAbilityType": "spearstab",
        "primaryAbility": {
            "fireTime": 0.51,
            "baseDps": 34.5
        },
        "stances" : {
          "idle" : {
            "armRotation" : -45,
            "weaponRotation" : -10,
            "weaponOffset" : [0.3, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : true
          },
          "windup" : {
            "duration" : 0.05,
            "armRotation" : -20,
            "weaponRotation" : -20,
            "weaponOffset" : [0.5, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : false
          },
          "fire" : {
            "duration" : 0.2,
            "armRotation" : -135,
            "weaponRotation" : 40,
            "weaponOffset" : [0.5, 2.5],
    
            "allowFlip" : true,
            "allowRotate" : false
          }
        },
    
    
            "altAbilityType": "elementalspin",
        "altAbility": {
        "scripts" : ["/items/active/weapons/melee/abilities/spear/elementalspin/elementalspin.lua"],
         "energyPerSecond" : 15,
    
      "projectileOffset" : [1, 0],
      "projectileType" : "icespinswoosh",
      "baseDamage" : 65,
    
            "damageConfig": {
                "damageSourceKind": "spear",
                "knockback": 45,
                "knockbackMode": "facing",
                "timeoutGroup": "primary"
            }
    
      },
    
    
        "builder": "/items/buildscripts/buildunrandweapon.lua",
        "critChance": 2,
        "critBonus": 6,
      
            "learnBlueprintsOnPickup" : [ "aviantier10spearbasic"]
    }
    Hope this helps, a bit.
     
  8. InvaderXYZ

    InvaderXYZ Space Hobo

    Thanks!! It really helped a lot! I got it to work!

    The only thing now is, I tried to create a duplicate ability that spawns a projectile version of the Spear instead of the Spin Projectile... but it breaks the item despite being a copied from from the original (modified to be a new ability).

    The only error I get is this:
    Code:
     [Error] Exception while calling script init: (LuaException) Error code 2, [string "/items/active/weapons/weapon.lua"]:288: attempt to index a nil value (local 'class')
    stack traceback:
        [C]: in metamethod '__index'
        [string "/items/active/weapons/weapon.lua"]:288: in function <[string "/items/active/weapons/weapon.lua"]:282>
        (...tail calls...)
        [string "/items/active/weapons/melee/meleeweapon.lua"]:18: in function <[string "/items/active/weapons/melee/meleeweapon.lua"]:5>
    I haven't touched either of those files so... any idea what went wrong?
     
  9. InvaderXYZ

    InvaderXYZ Space Hobo

    I changed the Class parameter of the .weaponability file and the item is no longer broken... but it's reverted back to using the original spin file?? Somehow??
     
  10. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Hmm, very odd, did you change the lua file's filepaths?
     
  11. InvaderXYZ

    InvaderXYZ Space Hobo

    Yep!

    {
    "itemName" : "longinusLance",
    "price" : 9600,
    "level" : 3,
    "maxStack" : 1,
    "rarity" : "Legendary",
    "description" : "Retrieved from the White Moon, this ancient sentient spear can destroy anything.",
    "shortdescription" : "Lance of Longinus",
    "tooltipKind" : "sword",
    "category" : "spear",
    "twoHanded" : true,
    "itemTags" : ["weapon","melee","spear"],

    "inventoryIcon" : "longinusLance.png",

    "animation" : "/items/active/weapons/melee/spear/spear.animation",
    "animationParts" : {
    "handle" : "",
    "blade" : "longinusLance.png"
    },
    "animationCustom" : {
    "sounds" : {
    "fire" : [ "/sfx/melee/swing_spear.ogg" ]
    }
    },

    "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],

    "elementalType" : "electric",

    "aimOffset" : -1.0,

    "primaryAbilityType" : "spearstab",
    "primaryAbility" : {
    "fireTime" : 0.5,
    "baseDps" : 1000
    },

    "altAbilityType": "throwlance",
    "altAbility": {
    "scripts" : ["/items/active/weapons/melee/abilities/spear/throwlance/throwlance.lua"],
    "energyPerSecond" : 15,

    "projectileOffset" : [1, 0],
    "projectileType" : "throwlance",
    "baseDamage" : 65,

    "damageConfig": {
    "damageSourceKind": "spear",
    "knockback": 45,
    "knockbackMode": "facing",
    "timeoutGroup": "primary"
    }

    },

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



    {
    "animationParts" : { },
    "animationCustom" : {
    "animatedParts" : {
    "stateTypes" : {
    "spinSwoosh" : {
    "default" : "idle",
    "states" : {
    "idle" : {
    },
    "spin" : {
    "frames" : 1,
    "cycle" : 0.5,
    "properties" : {
    "persistentSound" : "/sfx/melee/spear_twirl_loop.ogg"
    }
    }
    }
    }
    },
    "parts" : {
    "spinSwoosh" : {
    "properties" : {
    "zLevel" : 1,
    "centered" : true,
    "transformationGroups" : ["swoosh"],
    "offset" : [0, 0],
    "damageArea" : [ [-3.75, 1.75], [-1.75, 3.75], [1.75, 3.75], [3.75, 1.75], [3.75, -1.75], [1.75, -3.75], [-1.75, -3.75], [-3.75, -1.75] ]
    },
    "partStates" : {
    "spinSwoosh" : {
    "idle" : {
    "properties" : {
    "image" : ""
    }
    },
    "spin" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/abilities/spear/throwlance/throwlance.png:<frame>"
    }
    }
    }
    }
    }
    }
    },
    "sounds" : {
    "fireSpin" : ["/sfx/melee/elemental_spin_fire.ogg" ],
    "fireSpinFire" : ["/sfx/melee/travelingslash_fire2.ogg" ],
    "iceSpin" : ["/sfx/melee/elemental_spin_ice.ogg" ],
    "iceSpinFire" : ["/sfx/melee/travelingslash_ice2.ogg" ],
    "electricSpin" : [ "/sfx/melee/elemental_spin_electric.ogg" ],
    "electricSpinFire" : [ "/sfx/melee/travelingslash_electric7.ogg" ],
    "poisonSpin" : ["/sfx/melee/elemental_spin_poison.ogg" ],
    "poisonSpinFire" : ["/sfx/melee/travelingslash_poison1.ogg" ]
    },
    "particleEmitters" : {
    "fireSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"},
    { "particle" : "fireswoosh3"},
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"},
    { "particle" : "fireswoosh3"}
    ]
    },
    "electricSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "electricswoosh1"},
    { "particle" : "electricswoosh2"},
    { "particle" : "electricswoosh2"}
    ]
    },
    "poisonSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisonswoosh2"},
    { "particle" : "fireswoosh2"},
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisonswoosh2"},
    { "particle" : "fireswoosh2"}
    ]
    },
    "iceSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"},
    { "particle" : "iceswoosh3"},
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"},
    { "particle" : "iceswoosh3"}
    ]
    }
    }
    },

    "ability" : {
    "name" : "Throw Lance",
    "type" : "throwlance",
    "scripts" : ["/items/active/weapons/melee/abilities/spear/throwlance/throwlance.lua"],
    "class" : "ThrowLance",

    "energyUsage" : 60,
    "projectileEnergyCost" : 30,
    "cooldownTime" : 1.0,

    "spinRate" : -1750,

    "elementalConfig" : {
    "fire" : {
    "projectileType" : "firespinswoosh",
    "damageConfig" : { "statusEffects" : [ "burning" ] }
    },
    "ice" : {
    "projectileType" : "icespinswoosh",
    "damageConfig" : { "statusEffects" : [ "frostslow" ] }
    },
    "poison" : {
    "projectileType" : "poisonspinswoosh",
    "damageConfig" : { "statusEffects" : [ "weakpoison" ] }
    },
    "electric" : {
    "projectileType" : "electricspinswoosh",
    "damageConfig" : { "statusEffects" : [ "electrified" ] }
    }
    },

    "damageConfig" : {
    "damageSourceKind" : "<elementalType>spear",
    "statusEffects" : [ ],
    "baseDamage" : 6,
    "knockbackMode" : "none",
    "knockback" : 30,
    "timeout" : 0.5,
    "timeoutGroup" : "alt"
    },
    "projectileParameters" : {
    "power" : 6,
    "knockback" : 15
    },

    "stances" : {
    "windup" : {
    "duration" : 0.35,
    "armRotation" : -160,
    "weaponRotation" : -40,
    "twoHanded" : false,
    "weaponOffset" : [0, 0],

    "allowRotate" : false,
    "allowFlip" : true
    },
    "fire" : {
    "duration" : 0.25,
    "armRotation" : -20,
    "weaponRotation" : -50,
    "twoHanded" : false,
    "weaponOffset" : [0, 1.5],

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


    This is what I have for my files. Right now is basically defaults back to the original elemental spin, despite me using different sprites to indicate to myself it's using the right ability.
     
  12. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Hm... I'm not too sure what to make of that... but, do all your "itemName" parts match up, across all files?
    I know I had this problem, sorta forget how I fixed it...
    hm.

    Take a look at that though.
     
  13. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Okay, just looking again, at your active item and the weaponability file...

    It seems in your active item file you have the bit :

    Code:
    "projectileOffset" : [1, 0],
    "projectileType" : "throwlance",
    "baseDamage" : 65,
    but, if we look in the weaponability file, we don't see anything like that code you used, so that could be it.
    Closest we see to that in the weaponability file is :

    Code:
    "energyUsage" : 60,
    "projectileEnergyCost" : 30,
    "cooldownTime" : 1.0,
    
    "spinRate" : -1750,
    
    "projectileParameters" : {
    "power" : 6,
    "knockback" : 15
    },
    Those parts.

    Maybe try replacing what you got with, what's shown in the weaponability file, and see how that works out. But be sure to validate it. http://jsonlint.com/

    So that could be part of it, maybe.
    Not totally sure.
    I ain't no expert.

    Like, maybe :
    Code:
    {
        "itemName": "longinusLance",
        "price": 9600,
        "level": 3,
        "maxStack": 1,
        "rarity": "Legendary",
        "description": "Retrieved from the White Moon, this ancient sentient spear can destroy anything.",
        "shortdescription": "Lance of Longinus",
        "tooltipKind": "sword",
        "category": "spear",
        "twoHanded": true,
        "itemTags": ["weapon", "melee", "spear"],
    
        "inventoryIcon": "longinusLance.png",
    
        "animation": "/items/active/weapons/melee/spear/spear.animation",
        "animationParts": {
            "handle": "",
            "blade": "longinusLance.png"
        },
        "animationCustom": {
            "sounds": {
                "fire": ["/sfx/melee/swing_spear.ogg"]
            }
        },
    
        "scripts": ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType": "electric",
    
        "aimOffset": -1.0,
    
        "primaryAbilityType": "spearstab",
        "primaryAbility": {
            "fireTime": 0.5,
            "baseDps": 1000
        },
    
        "altAbilityType": "throwlance",
        "altAbility": {
            "scripts": ["/items/active/weapons/melee/abilities/spear/throwlance/throwlance.lua"],
            "energyPerSecond": 15,
    
    
            "damageConfig": {
                "damageSourceKind": "spear",
                "statusEffects": [],
                "baseDamage": 6,
                "knockbackMode": "none",
                "knockback": 30,
                "timeout": 0.5,
                "timeoutGroup": "alt"
            },
            "projectileParameters": {
                "power": 6,
                "knockback": 15
            }
    
        },
    
    
    
    
    
    
    
        "builder": "/items/buildscripts/buildunrandweapon.lua"
    }
     
    Last edited: Feb 15, 2017
  14. InvaderXYZ

    InvaderXYZ Space Hobo

    Hmm, well I tried both and they certainly both work... but it still uses the original elemental spear files and appears as normal despite the alt ability being listed as "Throw Spear"?

    So maybe it's something with the weaponability file, or the lua file?

    (Also, thanks for all the help! c:)
     
  15. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Looking again, actually, the ability you listed seems to be almost identical to elemental spin, in fact it could be. What version are you modding this for?
    (I can't find throwlance ability, for 1.2.2)
    Because, here is the elemental spin code:
    Code:
    {
      "animationParts" : { },
      "animationCustom" : {
        "animatedParts" : {
          "stateTypes" : {
            "spinSwoosh" : {
              "default" : "idle",
              "states" : {
                "idle" : {
                },
                "spin" : {
                  "frames" : 1,
                  "cycle" : 0.5,
                  "properties" : {
                    "persistentSound" : "/sfx/melee/spear_twirl_loop.ogg"
                  }
                }
              }
            }
          },
          "parts" : {
            "spinSwoosh" : {
              "properties" : {
                "zLevel" : 1,
                "centered" : true,
                "transformationGroups" : ["swoosh"],
                "offset" : [0, 0],
                "damageArea" : [ [-3.75, 1.75], [-1.75, 3.75], [1.75, 3.75], [3.75, 1.75], [3.75, -1.75], [1.75, -3.75], [-1.75, -3.75], [-3.75, -1.75] ]
              },
              "partStates" : {
                "spinSwoosh" : {
                  "idle" : {
                    "properties" : {
                      "image" : ""
                    }
                  },
                  "spin" : {
                    "properties" : {
                      "image" : "/items/active/weapons/melee/abilities/spear/elementalspin/<elementalType>spinswoosh.png:<frame>"
                    }
                  }
                }
              }
            }
          }
        },
        "sounds" : {
          "fireSpin" : ["/sfx/melee/elemental_spin_fire.ogg" ],
          "fireSpinFire" : ["/sfx/melee/travelingslash_fire2.ogg" ],
          "iceSpin" : ["/sfx/melee/elemental_spin_ice.ogg" ],
          "iceSpinFire" : ["/sfx/melee/travelingslash_ice2.ogg" ],
          "electricSpin" : [ "/sfx/melee/elemental_spin_electric.ogg" ],
          "electricSpinFire" : [ "/sfx/melee/travelingslash_electric7.ogg" ],
          "poisonSpin" : ["/sfx/melee/elemental_spin_poison.ogg" ],
          "poisonSpinFire" : ["/sfx/melee/travelingslash_poison1.ogg" ]
        },
        "particleEmitters" : {
          "fireSpin" : {
            "active" : false,
            "emissionRate" : 12,
            "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
            "particles" : [
              { "particle" : "fireswoosh1"},
              { "particle" : "fireswoosh2"},
              { "particle" : "fireswoosh3"},
              { "particle" : "fireswoosh1"},
              { "particle" : "fireswoosh2"},
              { "particle" : "fireswoosh3"}
            ]
          },
          "electricSpin" : {
            "active" : false,
            "emissionRate" : 12,
            "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
            "particles" : [
              { "particle" : "electricswoosh1"},
              { "particle" : "electricswoosh2"},
              { "particle" : "electricswoosh2"}
            ]
          },
          "poisonSpin" : {
            "active" : false,
            "emissionRate" : 12,
            "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
            "particles" : [
              { "particle" : "poisonswoosh1"},
              { "particle" : "poisonswoosh2"},
              { "particle" : "fireswoosh2"},
              { "particle" : "poisonswoosh1"},
              { "particle" : "poisonswoosh2"},
              { "particle" : "fireswoosh2"}
            ]
          },
          "iceSpin" : {
            "active" : false,
            "emissionRate" : 12,
            "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
            "particles" : [
              { "particle" : "iceswoosh1"},
              { "particle" : "iceswoosh2"},
              { "particle" : "iceswoosh3"},
              { "particle" : "iceswoosh1"},
              { "particle" : "iceswoosh2"},
              { "particle" : "iceswoosh3"}
            ]
          }
        }
      },
    
      "ability" : {
        "name" : "Energy Whirl",
        "type" : "elementalspin",
        "scripts" : ["/items/active/weapons/melee/abilities/spear/elementalspin/elementalspin.lua"],
        "class" : "ElementalSpin",
    
        "energyUsage" : 60,
        "projectileEnergyCost" : 30,
        "cooldownTime" : 1.0,
    
        "spinRate" : -1750,
    
        "elementalConfig" : {
          "fire" : {
            "projectileType" : "firespinswoosh",
            "damageConfig" : { "statusEffects" : [ "burning" ] }
          },
          "ice" : {
            "projectileType" : "icespinswoosh",
            "damageConfig" : { "statusEffects" : [ "frostslow" ] }
          },
          "poison" : {
            "projectileType" : "poisonspinswoosh",
            "damageConfig" : { "statusEffects" : [ "weakpoison" ] }
          },
          "electric" : {
            "projectileType" : "electricspinswoosh",
            "damageConfig" : { "statusEffects" : [ "electrified" ] }
          }
        },
    
        "damageConfig" : {
          "damageSourceKind" : "<elementalType>spear",
          "statusEffects" : [ ],
          "baseDamage" : 6,
          "knockbackMode" : "none",
          "knockback" : 30,
          "timeout" : 0.5,
          "timeoutGroup" : "alt"
        },
        "projectileParameters" : {
          "power" : 6,
          "knockback" : 15
        },
    
        "stances" : {
          "windup" : {
            "duration" : 0.35,
            "armRotation" : -160,
            "weaponRotation" : -40,
            "twoHanded" : false,
            "weaponOffset" : [0, 0],
    
            "allowRotate" : false,
            "allowFlip" : true
          },
          "fire" : {
            "duration" : 0.25,
            "armRotation" : -20,
            "weaponRotation" : -50,
            "twoHanded" : false,
            "weaponOffset" : [0, 1.5],
    
            "allowRotate" : false,
            "allowFlip" : false
          }
        }
      }
    }
    
    and here is yours : (throwlance)
    Code:
    {
    "animationParts" : { },
    "animationCustom" : {
    "animatedParts" : {
    "stateTypes" : {
    "spinSwoosh" : {
    "default" : "idle",
    "states" : {
    "idle" : {
    },
    "spin" : {
    "frames" : 1,
    "cycle" : 0.5,
    "properties" : {
    "persistentSound" : "/sfx/melee/spear_twirl_loop.ogg"
    }
    }
    }
    }
    },
    "parts" : {
    "spinSwoosh" : {
    "properties" : {
    "zLevel" : 1,
    "centered" : true,
    "transformationGroups" : ["swoosh"],
    "offset" : [0, 0],
    "damageArea" : [ [-3.75, 1.75], [-1.75, 3.75], [1.75, 3.75], [3.75, 1.75], [3.75, -1.75], [1.75, -3.75], [-1.75, -3.75], [-3.75, -1.75] ]
    },
    "partStates" : {
    "spinSwoosh" : {
    "idle" : {
    "properties" : {
    "image" : ""
    }
    },
    "spin" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/abilities/spear/throwlance/throwlance.png:<frame>"
    }
    }
    }
    }
    }
    }
    },
    "sounds" : {
    "fireSpin" : ["/sfx/melee/elemental_spin_fire.ogg" ],
    "fireSpinFire" : ["/sfx/melee/travelingslash_fire2.ogg" ],
    "iceSpin" : ["/sfx/melee/elemental_spin_ice.ogg" ],
    "iceSpinFire" : ["/sfx/melee/travelingslash_ice2.ogg" ],
    "electricSpin" : [ "/sfx/melee/elemental_spin_electric.ogg" ],
    "electricSpinFire" : [ "/sfx/melee/travelingslash_electric7.ogg" ],
    "poisonSpin" : ["/sfx/melee/elemental_spin_poison.ogg" ],
    "poisonSpinFire" : ["/sfx/melee/travelingslash_poison1.ogg" ]
    },
    "particleEmitters" : {
    "fireSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"},
    { "particle" : "fireswoosh3"},
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"},
    { "particle" : "fireswoosh3"}
    ]
    },
    "electricSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "electricswoosh1"},
    { "particle" : "electricswoosh2"},
    { "particle" : "electricswoosh2"}
    ]
    },
    "poisonSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisonswoosh2"},
    { "particle" : "fireswoosh2"},
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisonswoosh2"},
    { "particle" : "fireswoosh2"}
    ]
    },
    "iceSpin" : {
    "active" : false,
    "emissionRate" : 12,
    "offsetRegion" : [-3.5, -3.5, 3.5, 3.5],
    "particles" : [
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"},
    { "particle" : "iceswoosh3"},
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"},
    { "particle" : "iceswoosh3"}
    ]
    }
    }
    },
    
    "ability" : {
    "name" : "Throw Lance",
    "type" : "throwlance",
    "scripts" : ["/items/active/weapons/melee/abilities/spear/throwlance/throwlance.lua"],
    "class" : "ThrowLance",
    
    "energyUsage" : 60,
    "projectileEnergyCost" : 30,
    "cooldownTime" : 1.0,
    
    "spinRate" : -1750,
    
    "elementalConfig" : {
    "fire" : {
    "projectileType" : "firespinswoosh",
    "damageConfig" : { "statusEffects" : [ "burning" ] }
    },
    "ice" : {
    "projectileType" : "icespinswoosh",
    "damageConfig" : { "statusEffects" : [ "frostslow" ] }
    },
    "poison" : {
    "projectileType" : "poisonspinswoosh",
    "damageConfig" : { "statusEffects" : [ "weakpoison" ] }
    },
    "electric" : {
    "projectileType" : "electricspinswoosh",
    "damageConfig" : { "statusEffects" : [ "electrified" ] }
    }
    },
    
    "damageConfig" : {
    "damageSourceKind" : "<elementalType>spear",
    "statusEffects" : [ ],
    "baseDamage" : 6,
    "knockbackMode" : "none",
    "knockback" : 30,
    "timeout" : 0.5,
    "timeoutGroup" : "alt"
    },
    "projectileParameters" : {
    "power" : 6,
    "knockback" : 15
    },
    
    "stances" : {
    "windup" : {
    "duration" : 0.35,
    "armRotation" : -160,
    "weaponRotation" : -40,
    "twoHanded" : false,
    "weaponOffset" : [0, 0],
    
    "allowRotate" : false,
    "allowFlip" : true
    },
    "fire" : {
    "duration" : 0.25,
    "armRotation" : -20,
    "weaponRotation" : -50,
    "twoHanded" : false,
    "weaponOffset" : [0, 1.5],
    
    "allowRotate" : false,
    "allowFlip" : false
    }
    }
    }
    }
    
    
    Seem very similar. If you're using v1.2.2, try changing the ability type to elemental spin.

    I've got an example for elemental spin too : (activeitem)
    Code:
    {
        "itemName": "aviantier9spearbasic",
        "price": 160,
        "level": 9,
        "maxStack": 1,
        "rarity": "Legendary",
        "description": "Sunguard. A spear reportedly carried by the guardians of the Sunborn.",
        "shortdescription": "Sunguard",
        "tooltipKind": "sword",
        "category": "spear",
        "twoHanded": true,
        "itemTags": ["weapon", "melee", "spear"],
    
        "inventoryIcon": "spearicon9.png",
    
        "animation": "/items/active/weapons/melee/spear/spear.animation",
        "animationParts": {
            "handle": "",
            "blade": "aviantier9spear.png"
        },
        "animationCustom": {
            "animatedParts": {
                "parts": {
                    "swoosh": {
                        "properties": {
                            "offset": [2.2, 0.05]
                        }
                    }
                }
            },
            "sounds": {
                "fire": ["/sfx/melee/swing_spear.ogg"]
            }
        },
    
        "scripts": ["/items/active/weapons/melee/meleeweapon.lua"],
    
        "elementalType": "ice",
    
        "aimOffset": -0.7,
    
        "primaryAbilityType": "spearstab",
        "primaryAbility": {
            "fireTime": 0.51,
            "baseDps": 34.5
        },
        "stances" : {
          "idle" : {
            "armRotation" : -45,
            "weaponRotation" : -10,
            "weaponOffset" : [0.3, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : true
          },
          "windup" : {
            "duration" : 0.05,
            "armRotation" : -20,
            "weaponRotation" : -20,
            "weaponOffset" : [0.5, 2.25],
    
            "allowFlip" : true,
            "allowRotate" : false
          },
          "fire" : {
            "duration" : 0.2,
            "armRotation" : -135,
            "weaponRotation" : 40,
            "weaponOffset" : [0.5, 2.5],
    
            "allowFlip" : true,
            "allowRotate" : false
          }
        },
    
    
            "altAbilityType": "elementalspin",
        "altAbility": {
        "scripts" : ["/items/active/weapons/melee/abilities/spear/elementalspin/elementalspin.lua"],
         "energyPerSecond" : 15,
    
      "projectileOffset" : [1, 0],
      "projectileType" : "icespinswoosh",
      "baseDamage" : 65,
    
            "damageConfig": {
                "damageSourceKind": "spear",
                "knockback": 45,
                "knockbackMode": "facing",
                "timeoutGroup": "primary"
            }
    
      },
    
    
        "builder": "/items/buildscripts/buildunrandweapon.lua",
        "critChance": 2,
        "critBonus": 6,
    
            "learnBlueprintsOnPickup" : [ "aviantier10spearbasic"]
    }
    No problem, for the help, really.
    Hopefully it's helpful.
     
  16. InvaderXYZ

    InvaderXYZ Space Hobo

    Thanks!! I finally got it to work, by making it more specific within the code.
    So I guess one last thing, is it possible to make the spear invisible for a bit after it was "thrown" (maybe by transparent frame), or not really?
     
  17. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    I guess you could try a transparent frame, tbh, I don't know much about doing that, but another thing you may be able to do is change the weapon offset to something ridiculous during that frame, that way during that frame, (im guessing) the spear would bo so far offscreen / out of view, that it couldn't be see. It would be visible, technically, (as in the texture is showing somewhere) but you wouldn't be able to see it, since it'd be so far away from you .

    That's just a theroy anyway, idk though .
     
  18. IHart

    IHart Scruffy Nerf-Herder

    Boomerangs do this through part states:
    Code:
    /items/active/weapons/boomerang/
    {
      "animatedParts" : {
      "stateTypes" : {
      "weapon" : {
      "default" : "visible",
      "states" : {
      "visible" : {},
      "hidden" : {}
      }
      }
      },
    
      "parts" : {
      "boomerang" : {
      "properties" : {
      "centered" : true,
      "offset" : [0.625, 0.75],
      "transformationGroups" : [ "weapon" ]
      },
    
      "partStates" : {
      "weapon" : {
      "visible" : {
      "properties" : {
      "image" : "<partImage>"
      }
      },
      "hidden" : {
      "properties" : {
      "image" : ""
      }
      }
      }
      }
      }
      }
      },
    
      "transformationGroups" : {
      "weapon" : {}
      },
    
      "sounds" : {
      "throw" : [ "/sfx/melee/swing_dagger.ogg" ]
      }
    }
     

Share This Page