Like the title says. I know that weapons can launch projectiles randomly when pooling them, but is there a way to launch them out in a specific order?
You can duplicate the gunfire.lua and change a few spots with the following code. Code: function init() ... self.projectileIterator = config.getParameter("projectileIterator", 0) ... end function GunFire:fireProjectile(projectileType, projectileParams, inaccuracy, firePosition, projectileCount) ... if type(projectileType) == "table" then projectileType = projectileType[math.min(#projectileType, self.projectileIterator))] self.projectileIterator = math.max(1, self.projectileIterator + 1) if self.projectileIterator >= #projectileType then self.projectileIterator = 1 end activeItem.setInstanceValue("projectileIterator", self.projectileIterator) end ... end (The ... stand for the rest in the function. Only change/add the stuff from my example) Then in your .activeItem you would have to change "scritps" (under "primaryAbility" not the one bellow "muzzleOffset") to the path of your new gunfire.lua (note that you should rename it if its in the same folder as the original gunfire.lua) Also change "projectileType" to an array like this Code: "projectileType" : ["bullet-01", "standardbullet"], This way, every shot would iterate through the array inthe order they are placed in the array and when it reaches the last one, loops back to the first. (Also using InstanceValue, this iterator is preserved when the weapon is stowed) Disclaimer: The syntax may not be 100% correct as I dont have a way to test it until i get home. config.getParameter("projectileIterator", 0) -> 0 should be a 1 (note for why a second comment: I cannot edit my previous answer again. If an admin sees this, please add the change as stated in this comment into my previous comment)
i'll give er a test when im at my computer. if this works out, you'll definitely get credit for helping with my Gungeon weapon mod (trying to get back into it, at least). up til now, i've just been putting meant-to-be-sequent projectiles as random chances. sort of ruined the motivation a bit. that and shop making it seems i am unable to locate what to replace with function init() ... self.projectileIterator = config.getParameter("projectileIterator", 0) ... end unless it's something to straight up add assuming it was meant to be straight up added, i did so. the results i received were the gun not being able to be aimed or fired.
Yes, you just have to add that line within the init function. It declares an initial value for that variable throughout the script. Like this Code: function GunFire:init() self.weapon:setStance(self.stances.idle) self.cooldownTimer = self.fireTime self.projectileIterator = config.getParameter("projectileIterator", 1) self.weapon.onLeaveAbility = function() self.weapon:setStance(self.stances.idle) end end Yeah I tested it today and there was a small mistake. This should be correct. Code: if type(projectileType) == "table" then local projectileVariants = #projectileType projectileType = projectileType[math.min(projectileVariants, self.projectileIterator)] self.projectileIterator = math.max(1, self.projectileIterator + 1) if self.projectileIterator >= math.max(projectileVariants,1) then self.projectileIterator = 1 end activeItem.setInstanceValue("projectileIterator", self.projectileIterator) end Attached is the full modified gunfire.lua I used to check if it works. (.txt extention as .lua is not allowed for upload)
alrighty, newest results: the gun can be aimed and fires, but only one projectile before locking its position and not shooting. it seems to be attempting to go in a sequence, but in an 8 round sequence, it's skipping one of the bullets. finally, whenever it does fire, instead of the firing noise i assigned to it, it plays the inventory 'pop' sound instead. copied the error code and placed it in a txt attached to this post
From th error you are getting, I assume you modified the call of math.random(...) to something like math.random(1, <yourvalue>) If that is the case, add the following parts to it Code: math.random(1, math.max(1, <yourvalue>)) Background info: math.random requires the second parameter to be greater or equal to the first. math.random(1,1) -> works but always returns 1 math.random(2,1) -> does not work and returns "Invalid argument #1 to ‘random’ (interval is empty)" math.random(1) -> is equal to writing math.random(0, 1)
actually, all i did was add your lua. changed the name of the file and changed the script in the example weapon to match so would i just add this line of code to the lua as its own thing, or change another line of code?
Sorry for being silent for so long. I've added the random function stuff to this file and corrected the iterator. For some reason it did not work quite as I remembered it (the previous version caused errors on my end, but not the one you are encoutnering) Try out this gunfire.lua
youre fine; you likely have a life this lua is 99% perfect. the only thing im noticing is there being an occasional collection "pop" noise. 0 clue where that would come from
A pop sound like when you pickup items? If so, are you using the weapon while holding it in your cursor (like when moving items around in the inventory)?
affirmative dont think ive heard it happen with weapons before, but in the case that i missed it those numerous times, and that it doesnt happen when actually holding it, then that 99% will become a 100%
after (finally) testing it as a loadout weapon instead, it works exactly as intended. many thanks, and i shall include your name in the credits if/when this mod is released. before i abandon this thread, you wouldnt happen to know of a way to apply a handgrip to a boomerang would you? just adding it to the activeitem file does nothing.
handGrip is the layering of how a weapon appears in comparison to your character's hand; more noticeable with 1 handed weapons. setting it to "wrap" makes it so the weapon is always in the foremost layer (closer to you irl). "embed" makes your arm foremost. "inside" makes it look like your character is holding the weapon normally. "outside" makes it look like the outside of your hand is holding it. that all being said, i'll assume you don't know a solution. however, you solved my much harder issue. thank you so very much