So, I have a weapon idea (laser rifle) where the secondary fire is an extreme power beam... that disables the weapon entirely for 120 seconds. My idea is to make a custom "weapon recharging" status effect that lasts for that time, but I have two problems. I'm fairly new to modding, so I mostly know how to modify existing things. I have no idea how I'd have a weapon apply status effects to the user, and how I'd add a conditional to both firing modes so that it won't fire at all as long as the status effect is active. My second idea if there isn't a convenient way to make a weapon conditionally nonfunctional is to swap the weapon with a non-functional version that has one fire mode - a "recharge core" ability that takes all your energy and swaps the weapon back to the functional version, functionally meaning the special fire mode of the first, real gun would take two full recharges of energy to regain functionality. This would have the added benefit of making me able to have the "depleted" gun have a different fullbright animation to reflect this. Not sure how to do that either.
I think I figured out how to apply a status effect to the user with a projectile that goes backwards and applies the effect, but not how to disable the weapon based on having that status effect.
For that you have to customize the gunfire.lua for your weapon. Copy the file from \items\active\weapons\ranged\gunfire.lua into your weapons folder and rename it. Inside your weapon (.activeitem) you then change the path to match your custom gunfire.lua Code: "primaryAbility" : { "scripts" : ["/items/active/weapons/ranged/gunfire.lua"], ... Inside your custom gunfire.lua you then adjust the following: Code: function GunFire:init() ... self.overchargeLock = false ... end function GunFire:update(dt, fireMode, shiftHeld) ... self:CheckOvercharge() ... if self.fireMode == (self.activatingFireMode or self.abilitySlot) and not self.weapon.currentAbility and self.cooldownTimer == 0 and not status.resourceLocked("energy") and not world.lineTileCollision(mcontroller.position(), self:firePosition()) and not self.overchargeLock then ... end function GunFire:CheckOvercharge() -- search through all active status effects and serach for your effect local cdEffect = util.filter(status.activeUniqueStatusEffectSummary(), function(effect) return effect[1] == "Status effect name" end) -- #cdEffect -> number of entries that matched the filter if #cdEffect == 0 then self.overchargeLock = false else self.overchargeLock = true end end