9raxus Posted May 2, 2021 Share Posted May 2, 2021 (edited) I am attempting to make an undroppable ammunition type. Whenever you receive the ammunition, it stays in your inventory until you fire a weapon that uses the ammunition. Despite my best efforts, I have been unable to achieve this effect. I know of quest aliases and how they are used to create quest items (which can't be dropped). However, I have been unable to make the ammunition type a quest item despite researching how to create quest items. I also know of the entire category of keys and how you can't drop them from your inventory. However, I've been unable to determine exactly how that mechanism works, whether it is hard-coded into the game or some type of form list or some of them are quest items or some combination of those three (or something else entirely different). Any assistance would be appreciated. Thank you. Edited May 2, 2021 by 9raxus Link to comment Share on other sites More sharing options...
LarannKiar Posted May 2, 2021 Share Posted May 2, 2021 As far as I know, weapons and ammo which are not flagged as "Playable" can't be dropped. The interface can detect whether you want to drop a key or ammo.. and keys can't be dropped. Link to comment Share on other sites More sharing options...
9raxus Posted May 2, 2021 Author Share Posted May 2, 2021 I apologize but I should have mentioned in the original post that I had also looked into the "playable" flag in the ammo interface. Unfortunately, although making the ammo "unplayable" gives the effect of not being able to drop it & but also being able to fire it from a weapon, you can not see the amount of ammo that you possess in your inventory or the ammo count when you are firing your weapon. Link to comment Share on other sites More sharing options...
DocClox Posted May 2, 2021 Share Posted May 2, 2021 How about an OnContainerChanged event? Detect when it's dropped and re-add it to the inventory? Link to comment Share on other sites More sharing options...
DocClox Posted May 2, 2021 Share Posted May 2, 2021 (edited) accidental double post - please delete Edited May 2, 2021 by DocClox Link to comment Share on other sites More sharing options...
Zorkaz Posted May 2, 2021 Share Posted May 2, 2021 To make it undroppable you could add a script to the item like Ammo Property MyAmmo Auto Event Onload()Self.disable()Game.Getplayer().AddItem (MyAmmo)Self.delete()EndEventEvent Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)akNewContainer.removeitem(MyAmmo)akoldcontainer.additem(MyAmmo)EndEvent Haven't compiled this but might work Link to comment Share on other sites More sharing options...
dylbill Posted May 2, 2021 Share Posted May 2, 2021 Yes using a script would work, but I think you need to add some conditions, or it might add the ammo back when you fire the weapon as well. The OnContainerChanged event might trigger when you fire your weapon and ammo is removed, although I haven't tested that. Here's my take on it: Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akOldContainer == Game.GetPlayer() ;was it removed from the players inventory? Utility.Wait(0.1) If Self.Is3DLoaded() ;if has 3d, assume dropped to the world. If no 3d, it was probably shot from a weapon. akOldContainer.AddItem(Self.GetBaseObject()) Self.Disable() Self.Delete() Elseif akNewContainer != None ;is the player trying to move this ammo to another container? akNewContainer.RemoveItem(Self.GetBaseObject(), 1, True, akOldContainer) ;Add self object back to player from new container silently. Endif Endif EndEventHave the script extend objectReference Link to comment Share on other sites More sharing options...
9raxus Posted May 2, 2021 Author Share Posted May 2, 2021 Hi guys and thanks for all of the helpful suggestions so far. It's probably fair to reveal a bit more about why I asked about undroppable ammo to provide more context; The ultimate goal is to build a serviceable enough "recharger" weapon such as what was in Fallout New Vegas. I'm not really interested in a 1:1 recreation just so much as to get the 'spirit' of that weapon realized. For the most part, I believe that I've done that: A weapon that generates ammunition when it is in your possession and only to a certain quantity. How quickly the ammunition generates and to what amount are inconsequential and can always be adjusted later. When given the "Never Ending" legendary mod, the weapon acts reasonably close to how a F:NV "recharger" weapon functions. That part of the project, in my view, is complete. Unfortunately, a by-product of my results is that I now have ammunition in my inventory that can be dropped from the inventory. It's not exactly a game-breaking "bug" but it is an annoying artifact from how the ammunition regeneration process occurs. I've attempted to neutralize this feature in two ways: Make the ammunition monetarily worthless so that there's no incentive to sell it. And, in the meanwhile, I've utilized a timer for the ammunition generation to also check the inventory to see if the inventory is above a set limit; If it is above that limit, reset it to the maximum limit, thereby "deleting" the excess ammunition (although, now that I think about it, I've envisioned a really neat way to "penalize" the player for having excess ammunition by possibly irradiating the player for every moment that the player has excess inventory... Hmmmm....) Pardon my lack of understanding with Papyrus but how would one attach a script to an ammunition object? I don't see a place in the ammunition window to attach a script (as opposed to a weapon or miscellaneous object). Thank you. Link to comment Share on other sites More sharing options...
dylbill Posted May 2, 2021 Share Posted May 2, 2021 Hey, sorry I didn't realize you couldn't attach scripts to ammo. For this case I would maybe attach a script to the weapon. You can make it so you only have a certain amount of ammo and check every time the weapon is fired with an animation event. Example script: Ammo Property WeaponAmmo Auto Event OnEquipped(Actor akActor) RegisterForAnimationEvent(akActor, "weaponFire") CheckAmmo(akActor, WeaponAmmo) Endevent Event OnAnimationEvent(ObjectReference akSource, string asEventName) CheckAmmo(akSource, WeaponAmmo) EndEvent Event OnUnequipped(Actor akActor) UnRegisterForAnimationEvent(akActor, "weaponFire") EndEvent Function CheckAmmo(ObjectReference akSource, Ammo akAmmo) If akSource.GetItemCount(akAmmo) < 10 akSource.AddItem(akAmmo, 1, True) ;add 1 ammo silently Endif EndFunctionAgain have the script extend ObjectReference Link to comment Share on other sites More sharing options...
DocClox Posted May 3, 2021 Share Posted May 3, 2021 You could perhaps have ammunition that only existed while the weapon was equipped. So if they have the weapon drawn, they get an ammo count. Catch OnMenuOpenCloseEvent and you can remove it when they open the inventory or talk to a shopkeeper. Combine that with your idea of monetarily worthless ammo, and you should get more or less what you want. Link to comment Share on other sites More sharing options...
Recommended Posts