So, I've been trying to make some powerful guns for Starbound. But to balance them out they will be disposable and will have limited uses. The problem is that I can't seem to figure out how to do that. Adding durability doesn't seem to work, nor does trying to make the gun consumable. If anyone can help me out, that'd be great.
I've looked into it and throwable items are a separate type of item and the tags that cause them to be consumed don't seem to work on guns.
(note to self: 'tab' sends post) you'll need to make a copy of the script that guns use, and modify the activate function function activate(<your args here>) if <requirements for gun to shoot> then activeItem.setInstanceValue("supredude11_gunUses",config.getParameter("supredude11_gunUses",5)-1) if config.getParameter("supredude11_gunUses") <= 0 then item.consume(1) end end in the item file, add a new parameter called "supredude11_gunUses" and set it to the number of times the gun can be shot "supredude11_gunUses" : 5 means the gun can be shot 5 times before it vanishes from the players hands
in the line activeItem.setInstanceValue("supredude11_gunUses",config.getParameter("supredude11_gunUses",5)-1) what does the 5 at the very end mean? also if possible could you break down the bit of code that you posted? I'm a bit new and don't quite understand whats happening
So I put in the code into an copied gun.lua and this is what it looks like: Code: require "/scripts/util.lua" require "/scripts/vec2.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) local primaryAbility = getPrimaryAbility() self.weapon:addAbility(primaryAbility) local secondaryAbility = getAltAbility(self.weapon.elementalType) if secondaryAbility then self.weapon:addAbility(secondaryAbility) end self.weapon:init() end function update(dt, fireMode, shiftHeld) self.weapon:update(dt, fireMode, shiftHeld) end function uninit() self.weapon:uninit() end function activate() if primaryAbility then activeItem.setInstanceValue("supredude11_gunUses",config.getParameter("supredude11_gunUses",5)-1) if config.getParameter("supredude11_gunUses") <= 0 then item.consume(1) end end also note that the function at the very end is the only thing that I added/changed
Now, in the game, without the function you posted, the script works fine. With the function though, the gun will not aim or shoot and instead just points horizontally.
Where does the modified lua file go after modifying it? Back into the base files? Into a mod that you want it to be a part of? As I said in another thread, I don't fully understand lua, and any tips would be greatly appreciated.
that should be an easy fix. can you tell me what ability the weapon uses, though? I think we'll have to edit the ability script
it uses a standard gunfire ability. here is the code for the ability, which is in the item file directly Code: "primaryAbility" : { "scripts" : ["/items/active/weapons/ranged/gunfire.lua"], "class" : "GunFire", "fireTime" : 0.1, "baseDps" : 8.0, "energyUsage" : 10.0, "inaccuracy" : 0.05, "projectileCount" : 1, "burstCount" : 4, "burstTime" : 0.1, "fireType" : "burst", "projectileType" : "hmgbullet", "projectileParameters" : { "knockback" : 10 }, "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.10, "armRotation" : 3, "weaponRotation" : 3, "twoHanded" : true, "allowRotate" : false, "allowFlip" : false } } },
as well with the modified lua file, you put into the mod folder. somewhere where the item file can reference it without problems.
sort of. it's like when making a new item. It doesn't interfere with the base game however your mod adds it so that your other things can use it. this applies to weapon abilities, projectiles, sfx, etc.