Modding Help [SOLVED] Custom Sword Problems

Discussion in 'Starbound Modding' started by SpazDiesFirst360.0, Jul 14, 2017.

  1. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Well, I came up with an idea of a sword that can shoot bullets, or commonly known as "The Gun Sword".

    After a few days of coding, uploading, troubleshooting and the like, I finally had a sword that shot bullets. The alternate works fine, but there is one problem that I just cannot figure out: why I couldn't use the primary ability.

    There appears to be no documentation from the log on why this is happening (so no errors).
    I based the alternate ability on the traveling slash (i don't know much lua, so I didn't tamper with any lua stuff).

    The spoilers contain the files I used.

    Code:
    {
      "itemName" : "wa_rangedbroadsword",
      "price" : 5000,
      "level" : 6,
      "maxStack" : 1,
      "rarity" : "legendary",
      "description" : "Well, what do we have here?",
      "shortdescription" : "Gun Sword",
      "tooltipKind" : "sword",
      "category" : "Sword",
      "twoHanded" : true,
      "itemTags" : ["weapon","melee","broadsword"],
    
      "inventoryIcon" : "wa_rangedbroadsword.png",
    
      "animation" : "wa_rangedbroadsword.animation",
      "animationCustom" : {},
    
      "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],
    
      "elementalType" : "fire",
    
      "primaryAbilityType" : "broadswordcombo",
      "primaryAbility" : {
      "fireTime" : 0.05,
      "baseDps" : 870.0
      },
      "altAbilityType" : "assaultriflemelee",
    
      "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }

    Code:
    {
      "globalTagDefaults" : {
      "paletteSwaps" : ""
      },
    
      "animatedParts" : {
      "stateTypes" : {
      "swoosh" : {
      "default" : "idle",
      "states" : {
      "idle" : {
      },
      "fire" : {
      "frames" : 3,
      "cycle" : 0.1,
      "mode" : "transition",
      "transition" : "idle"
      },
      "fire2" : {
      "frames" : 3,
      "cycle" : 0.1,
      "mode" : "transition",
      "transition" : "idle"
      },
      "fire3" : {
      "frames" : 3,
      "cycle" : 0.1,
      "mode" : "transition",
      "transition" : "idle"
      }
      }
      }
      },
    
      "parts" : {
       "weaponfullbright" : {
      "properties" : {
      "zLevel" : 1,
      "centered" : true,
      "fullbright" : true,
      "image" : "wa_rangedbroadswordfullbright.png<paletteSwaps>?<directives>?<bladeDirectives>",
      "offset" : [0, 1.875],
      "transformationGroups" : ["weapon"],
      "rotationCenter" : [0, 0],
      "damageArea" : [ [-0.7, -1.0], [-0.7, 2.5], [0.5, 2.5], [0.5, -1.0] ]
      }
      },
      "blade" : {
      "properties" : {
      "zLevel" : 0,
      "centered" : true,
      "image" : "wa_rangedbroadsword.png<paletteSwaps>?<directives>?<bladeDirectives>",
      "offset" : [0, 1.875],
      "transformationGroups" : ["weapon"],
      "rotationCenter" : [0, 0],
      "damageArea" : [ [-0.7, -1.0], [-0.7, 2.5], [0.5, 2.5], [0.5, -1.0] ]
      }
      },
      "swoosh" : {
      "properties" : {
      "zLevel" : -1,
      "centered" : true,
      "transformationGroups" : ["swoosh"],
      "rotationCenter" : [0, 0]
      },
    
      "partStates" : {
      "swoosh" : {
      "idle" : {
      "properties" : {
      "image" : ""
      }
      },
      "fire" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh/fireswoosh.png:<frame>",
      "offset" : [-0.25, 2.5],
      "damageArea" : [[-5, 2], [-2.5, 3], [1, 3], [4, 1.75], [5, -0.25], [5, -2.25], [4, -3.25], [0, -2.5]]
      }
      },
      "fire2" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh2/fireswoosh.png:<frame>",
      "offset" : [5.0, 1.0],
      "damageArea" : [[-5, 1], [2.5, 1], [2.5, -2], [-5, -2]]
      }
      },
      "fire3" : {
      "properties" : {
      "image" : "/items/active/weapons/melee/broadsword/swoosh3/fireswoosh.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"],
      "emissionRate" : 1,
      "burstCount" : 1,
      "particles" : []
      },
      "fireswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 4,
      "particles" : [
      { "particle" : "fireswoosh1"},
      { "particle" : "fireswoosh2"},
      { "particle" : "fireswoosh3"}
      ]
      },
      "electricswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "electricswoosh1"},
      { "particle" : "electricswoosh2"},
      { "particle" : "electricswoosh2"}
      ]
      },
      "poisonswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "poisonswoosh1"},
      { "particle" : "poisonswoosh2"},
      { "particle" : "fireswoosh2"}
      ]
      },
      "iceswoosh" : {
      "active" : false,
      "transformationGroups" : ["swoosh"],
      "emissionRate" : 50,
      "burstCount" : 3,
      "particles" : [
      { "particle" : "iceswoosh1"},
      { "particle" : "iceswoosh2"},
      { "particle" : "iceswoosh3"}
      ]
      }
      },
    "lights" : {
      "glow" : {
      "active" : true,
      "position" : [0.0, 0.0],
      "color" : [253, 143, 77],
      "flickerPeriod" : 1,
      "flickerMinIntensity" : 0.20,
      "flickerMaxIntensity" : 0.20,
      "flickerPeriodVariance" : 0.0,
      "flickerIntensityVariance" : 0.0
      }
      },
    
      "sounds" : {
      "fire" : [ ],
      "fire2" : [ ],
      "fire3" : [ ]
      }
    }

    Code:
    {
      "animationParts" : { },
      "animationCustom" : {
        "sounds" : {
          "fireTravelSlash" : [ "/sfx/gun/ar2.ogg" ],
          "iceTravelSlash" : [ "/sfx/gun/ar3.ogg" ],
          // "electricTravelSlash" : [ "/sfx/melee/travelingslash_electric1.ogg", "/sfx/melee/travelingslash_electric2.ogg", "/sfx/melee/travelingslash_electric3.ogg" ],
          "electricTravelSlash" : [ "/sfx/gun/ar4.ogg" ],
          "poisonTravelSlash" : [ "/sfx/gun/ar5.ogg" ]
        }
      },
    
      "ability" : {
        "name" : "Assault Rifle",
        "type" : "assaultriflemelee",
        "scripts" : ["/items/active/weapons/melee/abilities/broadsword/assaultriflemelee/assaultriflemelee.lua"],
        "class" : "AssaultMelee",
    
        "projectileOffset" : [0,0],
        "elementalConfig" : {
          "physical" : { },
          "fire" : {
            "projectileType" : "gunswordbullet"
          },
          "ice" : {
            "projectileType" : "gunswordbullet"
          },
          "poison" : {
            "projectileType" : "gunswordbullet"
          },
          "electric" : {
            "projectileType" : "gunswordbullet"
          }
        },
    
        "baseDamage" : 21.0,
        "energyUsage" : 5,
        "cooldownTime" : 0.1,
    
        "stances" : {
          "windup" : {
            "duration" : 0.02,
            "armRotation" : 5,
            "weaponRotation" : -95,
            "twoHanded" : true,
    
            "allowRotate" : false,
            "allowFlip" : false
          },
          "fire" : {
            "duration" : 0.01,
            "armRotation" : 5,
            "weaponRotation" : -92,
            "twoHanded" : true,
    
            "allowRotate" : false,
            "allowFlip" : false
          }
        }
      }
    }
    

    Code:
    require "/scripts/util.lua"
    require "/items/active/weapons/weapon.lua"
    
    AssaultMelee = WeaponAbility:new()
    
    function AssaultMelee:init()
      self.cooldownTimer = self.cooldownTime
    end
    
    function AssaultMelee:update(dt, fireMode, shiftHeld)
      WeaponAbility.update(self, dt, fireMode, shiftHeld)
    
      self.cooldownTimer = math.max(0, self.cooldownTimer - dt)
    
      if self.weapon.currentAbility == nil and self.fireMode == "alt" and self.cooldownTimer == 0 and status.overConsumeResource("energy", self.energyUsage) then
        self:setState(self.windup)
      end
    end
    
    function AssaultMelee:windup()
      self.weapon:setStance(self.stances.windup)
      self.weapon:updateAim()
    
      util.wait(self.stances.windup.duration)
    
      self:setState(self.fire)
    end
    
    function AssaultMelee:fire()
      self.weapon:setStance(self.stances.fire)
      self.weapon:updateAim()
    
      local position = vec2.add(mcontroller.position(), {self.projectileOffset[1] * mcontroller.facingDirection(), self.projectileOffset[2]})
      local params = {
        powerMultiplier = activeItem.ownerPowerMultiplier(),
        power = self:damageAmount()
      }
      world.spawnProjectile(self.projectileType, position, activeItem.ownerEntityId(), self:aimVector(), false, params)
    
      animator.playSound(self:slashSound())
    
      util.wait(self.stances.fire.duration)
      self.cooldownTimer = self.cooldownTime
    end
    
    function AssaultMelee:slashSound()
      return self.weapon.elementalType.."TravelSlash"
    end
    
    function AssaultMelee:aimVector()
      return {mcontroller.facingDirection(), 0}
    end
    
    function AssaultMelee:damageAmount()
      return self.baseDamage * config.getParameter("damageLevelMultiplier")
    end
    
    function AssaultMelee:uninit()
    end
    
     
    Last edited: Jul 14, 2017
  2. IHart

    IHart Scruffy Nerf-Herder

    Always share a log anyway.
     
  3. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Okay. Here's a log.
     

    Attached Files:

  4. cpeosphoros

    cpeosphoros Orbital Explorer

    (AssetException) No associated frames file found for image '/objects/wired/generatorswitch/paa_particledisplaylit.png' while resolving image frame '/objects/wired/generatorswitch/paa_particledisplaylit.png:default.off'

    You are missing the .frames file for the animation.
     
  5. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    That was an issue with an object. The problem is that the Gun Sword works perfectly fine but you cannot use the primary ability.
    In the recent update I have fixed that issue.
     
  6. IHart

    IHart Scruffy Nerf-Herder

    In general i'd argue that you should be developing in a clean environment but in this case your assessment that there were no related errors and nothing outside interfering was probably accurate.
    The smallest possible firetime for melee appears to be 0.275. Who knew.
     
    Inf_Wolf14 likes this.
  7. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Well, never knew that. Will try: maybe that will fix it.
     
  8. IHart

    IHart Scruffy Nerf-Herder

    I also learned that just now and I must confess that I'm probably wrong about that exact time as daggers can go lower. I think the actual limiting factor is in melee.lua
    Code:
    function MeleeSlash:cooldownTime()
      return self.fireTime - self.stances.windup.duration - self.stances.fire.duration
    end
     
  9. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Oh well. Not everyone will get it right the first time. But your probably right.
     
  10. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Tried the sword now, it works. Thanks for the help! :up:
     
    IHart likes this.
  11. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Is there a way to mark this as solved?
     
  12. IHart

    IHart Scruffy Nerf-Herder

    I think clicking a "best answer" does it.
     
  13. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Will try that.
     
  14. cpeosphoros

    cpeosphoros Orbital Explorer

    You have to edit the thread title
     
  15. SpazDiesFirst360.0

    SpazDiesFirst360.0 Phantasmal Quasar

    Changed the title.
     
    cpeosphoros likes this.

Share This Page