Jump to content

Photo

Undroppable Ammo - Possible? - Looking into quest items and keys

quest item inventory undroppable ammunition keys

  • Please log in to reply
11 replies to this topic

#1
9raxus

9raxus

    Newbie

  • Members
  • Pip
  • 19 posts

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 by 9raxus, 02 May 2021 - 11:12 AM.


#2
LarannKiar

LarannKiar

    Old hand

  • Members
  • PipPipPipPip
  • 1,155 posts

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.



#3
9raxus

9raxus

    Newbie

  • Members
  • Pip
  • 19 posts

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.



#4
DocClox

DocClox

    Enthusiast

  • Members
  • PipPip
  • 208 posts

How about an OnContainerChanged event? Detect when it's dropped and re-add it to the inventory?



#5
DocClox

DocClox

    Enthusiast

  • Members
  • PipPip
  • 208 posts

accidental double post - please delete


Edited by DocClox, 02 May 2021 - 05:45 PM.


#6
Zorkaz

Zorkaz

    Resident poster

  • Premium Member
  • 4,429 posts

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()

EndEvent

Event

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
akNewContainer.removeitem(MyAmmo)

akoldcontainer.additem(MyAmmo)

EndEvent

 

 

Haven't compiled this but might work



#7
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,740 posts

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
EndEvent

Have the script extend objectReference



#8
9raxus

9raxus

    Newbie

  • Members
  • Pip
  • 19 posts

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.



#9
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,740 posts

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 
EndFunction

Again have the script extend ObjectReference



#10
DocClox

DocClox

    Enthusiast

  • Members
  • PipPip
  • 208 posts

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.

 





Also tagged with one or more of these keywords: quest item, inventory, undroppable, ammunition, keys

IPB skins by Skinbox
Page loaded in: 1.014 seconds