Victor14 Posted April 15, 2021 Posted April 15, 2021 2021-04-17 - See post below; In summary, changed the method of how the delay works from "utility.wait" to timers and it works better. Shared code. 2021-04-15 - I have developed, what I feel, is the finale of what I have been searching for: A lightweight, modular system to replicate the "recharger" weapons from "Fallout: New Vegas" in "Fallout 4." The system is Power-Armor friendly and it does contain a Papyrus script fragment (for those people who are sensitive towards having scripts in their mods). You may reload whenever you desire (as opposed to a recent mod that I released here where the weapon's ammunition regeneration system was disrupted by the process of reloading). In summary, the player acquires a device (placed in the miscellaneous or "junk" category) that, when in the player's inventory, generates ammunition at a certain rate and up to a certain quantity. As the player fires a weapon that uses that ammunition, should the level of ammunition go below the regenerating threshold, more ammunition is then created until it goes back up to the threshold quantity. My question to the community is what kind of mod would you like to see released? Do you want a bare-bones "console command" type of mod? Do you want a mod that has backstory or lore? Do you want to create the AGS at a workbench or simply find the object somewhere? Do you want plasma, laser and/or gamma ammunition (I suppose any ammunition can be generated although those three are the most realistic to be auto-magically generated)? How quickly do you want the ammunition to generate? I am hesitant to remove a limitation on how much ammunition is generated simply because I do not want your game to crash for when the ammunition continues to generate without being used in a while. I understand that anyone with a fair amount of Creation Kit experience can simply alter whatever I place onto here for their own play style. However, there are also a lot of people who do not feel comfortable with the Creation Kit (or might not be able to use it, or might not have the time to make such alterations). I would like to release a mod that addresses the needs of those people for whom the use of the Creation Kit is either restricted, intimidating or just not available... Or maybe those people simply want to utilize the mod as it is as a challenge for a new playthrough. At any rate, please respond below with your thoughts as I am interested in seeing them and adjusting the mod accordingly. Thank you.
Victor14 Posted April 17, 2021 Author Posted April 17, 2021 2021-04-17 - OK. I'm just putting the code here because I feel as though I have achieved my goal in creating a pretty good "recharger"-like gameplay mechanic. When I wrote the earlier post, I had used a "Utility.Wait" method for doling out the ammunition in my code. "Utility.Wait" is apparently a not-so-good (read: bad) method for creating a delay of any kind. I switched over (in the last day) to timers and, after a lot of testing, the timers won. No delays that I could perceive (the "utility.wait" method had some 'slight' delays at certain points during the test combat run; the timer method had no such perceivable delays). Yes, there's a bit of Construction Kit wiki code in there; I could've hidden it but I won't. We all stand on the shoulders of giants; We may as well just acknowledge it. Without further ado... Scriptname [whatever you want your script to be called] extends Quest Ammo Property pAmmoPlasmaCartridge Auto MiscObject Property pZZZ_PlasmaGen Auto Const Mandatory int myCoolTimerID = 10 ; Give our timer an ID we can remember Function SomeFunction() StartTimer(3, myCoolTimerID) ; Create the timer with a 3 second duration EndFunction Event OnQuestInit() SomeFunction() EndEvent Event OnTimer(int aiTimerID) If aiTimerID == myCoolTimerID ; The 3 second timer we started just expired If (Game.GetPlayer().GetItemCount(pZZZ_PlasmaGen) == 1) && (Game.GetPlayer().GetItemCount(pAmmoPlasmaCartridge) <= 59) Game.GetPlayer().AddItem(pAmmoPlasmaCartridge, 1, true) EndIf SomeFunction() ; Start the timer again because we want things to repeat... EndIf EndEvent Obviously, a little assembly required; I'm not going to elaborate on how to place a script into a quest or anything like that but the code above is the heart of the accomplishment. Some notes: "pZZZ_PlasmaGen" is a misc object but, I suppose, you could attach it to an unique weapon; I tried giving a weapon a "limitless" legendary property to see if the ammo would go straight to the weapon and it didn't so you still have to reload regardless. I know that there are complicated ways around the reload animation and things like that. However, that's a bit above my expertise and I like lightweight solutions to things so what this code accomplishes is perfectly fine with me. The ammo limitation (the "<= 59" part) can obviously be changed or even removed(!) (just eliminate everything past the "&&") but it's there to make the code more "lore & gameplay friendlier" and to also potentially keep the game from crashing. Enjoy.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.