Modding Help Custom Weapon ability

Discussion in 'Starbound Modding' started by projectmayhem, Mar 8, 2017.

  1. projectmayhem

    projectmayhem Spaceman Spiff

    I'm using the flamethrower files as a template for Force Lightning. I have a weaponability filed named forcelightning but whenever I changed the primaryAbilityType from flamethrower to forcelightning, I can no longer aim or fire. If I leave it as flamethrower, for some reason it isn't reading my png file for the lightning, it still uses the flamethrower projectile. Been messing with it all day and I can't figure it out, any help would be appreciated. I left all the image files the same except the project in the .projectile file, i changed it to my forcelightningammo.png. I really thought just changing the projectile image would cause it to change to the lightning, but for some reason it still comes out as fire like a normal flamethrower. All these files are in the same folder, along with the image files.

    SWMforcelightning.activeitem

    {
    "itemName" : "SWMforcelightning",
    "level" : 2,
    "price" : 1500,
    "maxStack" : 1,
    "rarity" : "Legendary",
    "description" : "Love the smell of napalm, any time of day.",
    "shortdescription" : "Force Lightning",
    "tooltipKind" : "gun",
    "category" : "uniqueWeapon",
    "twoHanded" : true,
    "itemTags" : ["weapon","ranged","upgradeableWeapon"],

    "inventoryIcon" : "flamethrower.png",

    "animation" : "/items/active/weapons/ranged/gun.animation",
    "animationParts" : {
    "butt" : "",
    "middle" : "/items/active/weapons/ranged/flamethrower/flamethrower.png",
    "barrel" : "",
    "muzzleFlash" : ""
    },
    "animationCustom" : {
    "sounds" : {
    "fireStart" : [ "forcelightning.ogg" ],
    "fireLoop" : [ "forcelightning.ogg" ],
    "fireEnd" : [ "forcelightningstop.ogg" ]
    }
    },
    "baseOffset" : [0.75, 0],
    "muzzleOffset" : [2.5, 0.4],

    "scripts" : ["/items/active/weapons/ranged/gun.lua"],

    "elementalType" : "electric",

    "primaryAbilityType" : "flamethrower",
    "primaryAbility" : {
    "baseDps" : 10,
    "energyUsage" : 30
    },

    "altAbilityType" : "fuelairtrail",
    "altAbility" : {},

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

    "upgradeParameters" : {
    "inventoryIcon" : "flamethrower_l6.png",
    "animationParts" : {
    "middle" : "/items/active/weapons/ranged/flamethrower/flamethrower_l6.png"
    },
    "shortdescription" : "Flamethrower ^yellow;^reset;"
    }
    }


    forcelightning.projectile

    {
    "projectileName" : "forcelightning",
    "image" : "forcelightningammo.png",
    "physics" : "flame",
    "animationCycle" : 1,
    "animationLoops" : false,
    "frameNumber" : 12,
    "winddownFrames" : 3,
    "intangibleWinddown" : true,
    "power" : 50,
    "speed" : 25,
    "timeToLive" : 1.0,
    "bounces" : 4,
    "piercing" : true,
    "damagePoly" : [ [-9, 0], [-6, -6], [0, -9], [6, -6], [9, 0], [6, 6], [0, 9], [-6, 6] ],
    "lightColor" : [235, 126, 2],
    "damageKind" : "electric",
    "damageKindImage" : "/interface/statuses/electric.png",
    "statusEffects" : [
    "electrified"
    ]
    }


    forcelightning2.lua

    require "/items/active/weapons/ranged/gunfire.lua"

    FlamethrowerAttack = GunFire:new()

    function FlamethrowerAttack:init()
    GunFire.init(self)

    self.active = false
    end

    function FlamethrowerAttack:update(dt, fireMode, shiftHeld)
    GunFire.update(self, dt, fireMode, shiftHeld)

    if self.weapon.currentAbility == self then
    if not self.active then self:activate() end
    elseif self.active then
    self:deactivate()
    end
    end

    function FlamethrowerAttack:muzzleFlash()
    --disable normal muzzle flash
    end

    function FlamethrowerAttack:activate()
    self.active = true
    animator.playSound("fireStart")
    animator.playSound("fireLoop", -1)
    end

    function FlamethrowerAttack:deactivate()
    self.active = false
    animator.stopAllSounds("fireStart")
    animator.stopAllSounds("fireLoop")
    animator.playSound("fireEnd")
    end


    forcelightning.weaponability

    {
    "ability" : {
    "name" : "Forcelightning",
    "type" : "forcelightning",
    "scripts" : ["forcelightning.lua"],
    "class" : "FlamethrowerAttack",

    "baseDps" : 10,
    "energyUsage" : 30,
    "fireTime" : 0.065,
    "inaccuracy" : 0.05,

    "projectileCount" : 1,
    "fireType" : "auto",

    "projectileType" : "forcelightning",
    "projectileParameters" : { },

    "stances" : {
    "idle" : {
    "armRotation" : 0,
    "weaponRotation" : 0,
    "twoHanded" : true,

    "allowRotate" : true,
    "allowFlip" : true
    },
    "fire" : {
    "duration" : 0,
    "armRotation" : 0,
    "weaponRotation" : 0,
    "twoHanded" : true,

    "allowRotate" : true,
    "allowFlip" : true
    },
    "cooldown" : {
    "duration" : 0.05,
    "armRotation" : 0,
    "weaponRotation" : 0,
    "twoHanded" : true,

    "allowRotate" : true,
    "allowFlip" : true
    }
    }
    }
    }


    forcelightning.lua

    require "/scripts/util.lua"
    require "/scripts/vec2.lua"
    require "/scripts/interp.lua"
    require "/items/active/weapons/weapon.lua"

    function init()
    activeItem.setCursor("/cursors/reticle0.cursor")
    animator.setGlobalTag("paletteSwaps", config.getParameter("paletteSwaps", ""))

    self.weapon = Weapon:new()

    self.weapon:addTransformationGroup("weapon", {0,0}, 0)
    self.weapon:addTransformationGroup("muzzle", self.weapon.muzzleOffset, 0)

    self.weapon:addAbility(getPrimaryAbility())

    local secondaryAttack = getAltAbility()
    if secondaryAttack then
    self.weapon:addAbility(secondaryAttack)
    end

    self.weapon:init()
    end

    function update(dt, fireMode, shiftHeld)
    self.weapon:update(dt, fireMode, shiftHeld)
    end

    function uninit()
    self.weapon:uninit()
    end
     
  2. projectmayhem

    projectmayhem Spaceman Spiff

    So..I think I'm getting better results looking off the Tesla Staff file. it already uses lightning, I just have to get rid of the staff graphic and lower the offset so its not head level, then change a little of the animation. I would much prefer the flamethrower style where it can be used constantly though, but this is a good work around till I figure it out
     
  3. Zanderfel

    Zanderfel Big Damn Hero

    your primary ability is still set for flamethrower instead of forcelightning in the activeitem
     
    IHart likes this.
  4. Zanderfel

    Zanderfel Big Damn Hero

    i dont see any path to forcelightning2.lua, in the weaponability the script is looking for forcelightning.lua.... that could be it?
     
  5. Zanderfel

    Zanderfel Big Damn Hero

    and the script in activeitem is still the default gun.lua....i think you meant to use your forcelightning.lua there
     
  6. projectmayhem

    projectmayhem Spaceman Spiff

    The primary ability was set to flamethrower when i posted it because changing it to forcelightning causes the gun to stop shooting and aiming in the direction of my mouse. I also tried adding the 2 to the .lua file. When I was looking at the flamethrower.active item file, in the same folder there is flamethrower.lua but the activeitem file never makes mention of the lua file.

    flamethrower.activeitem

    {
    "itemName" : "flamethrower",
    "level" : 2,
    "price" : 1500,
    "maxStack" : 1,
    "rarity" : "Legendary",
    "description" : "Love the smell of napalm, any time of day.",
    "shortdescription" : "Flamethrower",
    "tooltipKind" : "gun",
    "category" : "uniqueWeapon",
    "twoHanded" : true,
    "itemTags" : ["weapon","ranged","upgradeableWeapon"],

    "inventoryIcon" : "flamethrower.png",

    "animation" : "/items/active/weapons/ranged/gun.animation",
    "animationParts" : {
    "butt" : "",
    "middle" : "/items/active/weapons/ranged/flamethrower/flamethrower.png",
    "barrel" : "",
    "muzzleFlash" : ""
    },
    "animationCustom" : {
    "sounds" : {
    "fireStart" : [ "/sfx/gun/flamethrower_start.ogg" ],
    "fireLoop" : [ "/sfx/gun/flamethrower_loop.ogg" ],
    "fireEnd" : [ "/sfx/gun/flamethrower_stop.ogg" ]
    }
    },
    "baseOffset" : [0.75, 0],
    "muzzleOffset" : [2.5, 0.4],

    "scripts" : ["/items/active/weapons/ranged/gun.lua"],

    "elementalType" : "fire",

    "primaryAbilityType" : "flamethrower",
    "primaryAbility" : {
    "baseDps" : 10,
    "energyUsage" : 30
    },

    "altAbilityType" : "fuelairtrail",
    "altAbility" : {},

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

    "upgradeParameters" : {
    "inventoryIcon" : "flamethrower_l6.png",
    "animationParts" : {
    "middle" : "/items/active/weapons/ranged/flamethrower/flamethrower_l6.png"
    },
    "shortdescription" : "Flamethrower ^yellow;^reset;"
    }
    }



    ill try messing around with the pathing to gun.lua like you suggested. Right now, I modified the Telsa Staff, which its primary ability looks alot like force lightning, I just dont like that you can move while using it, causing the lightning to originate from your starting point, rather than where you are when you release. But, considering im a modding newb, i'll settle for it if i can't get the flamethrower style working. I think it would be better since you can walk around while the flamethrower style animation plays and it still orginates from your offset point
     
  7. projectmayhem

    projectmayhem Spaceman Spiff

    Changed the lua to forcelightning and no luck, then tried forcelightning2 lua, and tried switching the weapon ability file from forcelightning2 lua to forcelightning, none of that worked. if it doesnt stop the gun from working all together, then it still shoots the default fireball animation instead of my forcelightningammo.png I think, somehow its still pulling info from the starbound default folders.
     
  8. projectmayhem

    projectmayhem Spaceman Spiff

    I've tried patching the weaponability.config also, to add the ability. not sure if i did it correctly.

    [
    { "op" : "add", "path" : "/forcelightning", "value" : "/items/active/forcepowers/ForceLightningalt/forcelightning.weaponability" }
    ]
     
  9. projectmayhem

    projectmayhem Spaceman Spiff

    I think my problem is in the weaponability.config , I cant seem to get it to register my weaponability, I tried using forcelightning as the alt and it just says "unknown" on the weapon and wont shoot primary or secondary. Gonna keep messing around with trying to patch my ability into the config
     
  10. projectmayhem

    projectmayhem Spaceman Spiff

    Ok I forgot to put the weaponability.config patch file into the items/buildscripts folder, once I did, I was able to get Force Lightning to show up as an altAbility. The gun still wont fire though, Primary or Alt. But I'm one step in the right direction
     
  11. projectmayhem

    projectmayhem Spaceman Spiff

    ok, modified the weaponability to look like this...


    {
    "ability" : {
    "name" : "Force Lightning",
    "type" : "forcelightning",
    "scripts" : ["/items/active/weapons/ranged/abilities/altfire.lua"],
    "class" : "AltFireAttack",

    "baseDps" : 10,
    "energyUsage" : 30,
    "fireTime" : 0.065,
    "inaccuracy" : 0.05,

    "projectileCount" : 1,
    "fireType" : "auto",
    "usePrimaryFireSound" : true,
    "projectileType" : "forcelightning",
    "projectileParameters" : { },

    "useParticleEmitter" : false,
    "stances" : {
    "fire" : {
    "duration" : 0.02,
    "armRotation" : 2,
    "weaponRotation" : 2,
    "twoHanded" : true
    },
    "cooldown" : {
    "duration" : 0.02,
    "armRotation" : 2,
    "weaponRotation" : 2,
    "twoHanded" : true
    }
    }
    }
    }



    The main attack is still working, the altFire now works as well, and reads as Force Lightning on the weapons tooltip. It even damages enemies, its just not displaying the projectile. Soon as I get that worked out, I'll have it all done
     
  12. Zanderfel

    Zanderfel Big Damn Hero

    how do you have the projectile setup? did you just edit the flames picture and just put lightning in its place? this might be the issue visually, if you dont have the right .frames file so the game can read the tiles in the animation picture correctly then that would cause you to not see the projectile
     
  13. projectmayhem

    projectmayhem Spaceman Spiff

    Yeah, I took the frames file and just made lightning over-top the fire, matching each frames fireball size with my lightning. Then I deleted the fireball layer and kept the lightning layer above it and saved it. As long as I used the frame file from flamethrower, and the PNG, then everything should match up right?
     
  14. Zanderfel

    Zanderfel Big Damn Hero

    is the frame file named the same as your tiled image? thats how i do it... that way you know that there is nothing left of the default ability, in fact i would make sure everything has been renamed by you, that would rule out those causing issues
     
  15. projectmayhem

    projectmayhem Spaceman Spiff

    I always rename :) I think im going to leave it as a modified Tesla Staff, flamethrower style would have allowed better movement. But I dont want to get hung up on it too long. Too much stuff to do with the mod. Made my wookies last night and bowcaster this morning :)
     

Share This Page