Would there any way to make a weapon or tool impart a status effect on the wielder when held? Like having a heavy weapon with the slow debuff to represent it's size and weight. I've already tried just copy and pasting the effect code used by the Glow clothing set into the activeitem file of a weapon, and that did nothing (literally nothing, no crash, no error, no PGI, the game just ignored the added code entirely), so any ideas on how that might be made to work?
That's going to require calling upon a custom .lua script in the .activeitem file Within the .lua, you can edit movement speed by using something like this: Code: mcontroller.controlModifiers({ groundMovementModifier = 0.2, speedModifier = 0.3}) if you want to call upon an existing status effect, you want to use code like this: Code: status.addEphemeralEffect("burning", 3) Some effects use setPersistentEffects() instead, so do some experimenting. I made an example mod here of a sword that will slow you while wielding it and add a burning effect for 3 seconds when you first equip it. http://www.mediafire.com/download/anudxbavfuxc2qj/heavySword.zip in theory, messing with mcontroller.controlModifiers in any .lua file should impart effects, but be careful how you go about it because a lot of variables come into play.
Alright, made a custom gun .lua with status.addEphemeralEffect("staffslow"), and it actually worked, for a second before it wore off. Now I just need a way to make the status effect persistent. Would there be a way to make status.addEphemeralEffect() loop, or would that be what setPersistentEffects() would be for? In which case, how would I add that to the code? I tried adding it as status.setPersistentEffects() and the game just froze as soon as I crafted the weapon. Also tried copying in the mcontroller.controlModifiers from the effect I want, and got the same thing. Game froze as soon as the weapon was crafted.
The second variable after addEphemeralEffect is the duration, and I'm not sure what the "default" duration is. I'm not sure if you can set it to infinite, either. The best way to get it to stay on forever is to have it add it for x seconds during an update that HAS to occur. read this thing for more information: http://sblaud.net/status.html
Well, that was useful, but unfortunately nothing in there seemed to do what I want to do, which is to have a status effect last (or looped) for as long as the weapon is held, but wear off as soon as the weapon is switched out. I tried setting the duration to math.huge which is supposed to be infinite, but, while that did work, it kept right on working after the weapon was gone. If I could find a way to make the effect loop, to have the weapon constantly inflict a short duration effect, then that would do nicely. I could've sworn I've seen looping effect code before on something, I just can't remember what.
Don't forget to clear the effects in unininit() the code also should only affect you while you're using the weapon since when you switch active items the code should be unloaded.
I have worked with persistent effects, and I think I might be able to help. Could you provide me a pastebin of your lua script?
Here's the different codes I tried as part of a custom gun.lua: Code: 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() status.addEphemeralEffect("staffslow") end ^This added the effect to the weapon, but it wore off after only a second. Code: 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() status.addPersistentEffect("staffslow") end ^PersistentEffect doesn't want to work at all. I don't know why. The effect name is right, the command is right, but the game freezes as soon as I equip the weapon. Doesn't even give me an error for the log. Code: 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() status.addEphemeralEffect("staffslow",math.huge) end ^This added the effect to the weapon, but the effect persisted even after unequipping the weapon. Code: 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 init() effect.addStatModifierGroup({ {stat = "jumpModifier", amount = -0.20} }) end function update(dt) mcontroller.controlModifiers({ groundMovementModifier = 0.5, speedModifier = 0.65, airJumpModifier = 0.80 }) end ^So then I thought I'd just add the functions from the effect to the .lua. This froze the game upon weapon equip as well. Code: 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) mcontroller.controlModifiers({ groundMovementModifier = 0.5, speedModifier = 0.65, airJumpModifier = 0.80 }) end ^Then I tried reducing it to just the mcontroller function. This didn't do anything at all. No freeze, no effect, no nothing.
Try it with this: Code: 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() status.addPersistentEffects("staffDebuff", {"staffslow"}) end function uninit() status.clearPersistentEffects("staffDebuff") end
Well the persistent effect worked at least, that's something, but we run into the same problem as when math.huge is used. The effect persists after the weapon is switched out.
In this case, try this instead. Dunno how it'll work out. Code: function init() activeItem.setCursor("/cursors/reticle0.cursor") animator.setGlobalTag("paletteSwaps", config.getParameter("paletteSwaps", "")) self.weapon = Weapon:new() script.setUpdateDelta(30) 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) status.addEphemeralEffect("staffslow",1) end
One thing that might help would be looking at the files centered on the broadswords, as I know that when you first equip one with flying slash (I think) it gives you the light but for a slight second, and when you use that special, because it launches you high enough to take damage unless that buff is applied. Also when you use a broadsword's special attack, when that special attack is super spin slash, will give you a speed buff until you run out of energy or stop using the special attack.
Nope. Didn't even add the effect, though it made the weapon glitch out like it was lagging. I'm beginning to wonder if the game engine is even capable of supporting such an effect.
Solved! This will give you permanent "Energy regen" ONLY when weapon is equiped: Code: require "/scripts/util.lua" require "/scripts/vec2.lua" require "/items/active/weapons/weapon.lua" function init() animator.setGlobalTag("paletteSwaps", config.getParameter("paletteSwaps", "")) animator.setGlobalTag("directives", "") animator.setGlobalTag("bladeDirectives", "") self.weapon = Weapon:new() self.weapon:addTransformationGroup("weapon", {0,0}, util.toRadians(config.getParameter("baseWeaponRotation", 0))) self.weapon:addTransformationGroup("swoosh", {0,0}, math.pi/2) local primaryAbility = getPrimaryAbility() self.weapon:addAbility(primaryAbility) local secondaryAttack = getAltAbility() if secondaryAttack then self.weapon:addAbility(secondaryAttack) end self.weapon:init() status.setPersistentEffects("onEquiptStatus", { "energyregen" }) end function update(dt, fireMode, shiftHeld) self.weapon:update(dt, fireMode, shiftHeld) end function uninit() self.weapon:uninit() status.clearPersistentEffects("onEquiptStatus") end Enjoy! And thx for the Avali Drone Pet, cutest thing EVER!
Awesome! You, my friend, have just unlocked the way forward for heavy weapons like heavy bolters, lascannons, and the like, as this was the one thing that was required to properly balance them.