Jump to content

Make OMOD for weapon to use multiple types of ammo?


Recommended Posts

Good evening everybody!

 

So, I was reading about some stuff and came across this:

 

The .308 and the 7.62 rounds are basically interchangeable.

(Source)

 

That gave me an idea for a little mod:

 

Create a mod that adds a craftable weapon modification that allows both 308 and 7.62 to be used with a weapon.

 

 

 

This would basically require a script that "checks" what ammo that player has in the inventory and applies a OMOD to the currently equipped weapon if either the 308 or the 7.62 ammo reaches 0.

When the player reloads the next time (after one type of ammo reaches 0) the other type would be used.

 

Sound do-able, right?

Link to comment
Share on other sites

If you're referring to the vanilla/Nuka World ammo types, .308 Winchester and 7.62x39mm aren't at all related, realistically.

 

The easiest way to accomplish this would probably be to write a script that converts the ammo in your inventory instead, i.e.

int diff = (PlayerRef.GetItemCount(Ammo308Caliber) - PlayerRef.GetItemCount(Ammo762)) / 2
if (diff > 0)
	PlayerRef.RemoveItem(Ammo308Caliber, diff)
	PlayerRef.AddItem(Ammo762, diff)
else
	diff = -diff
	PlayerRef.RemoveItem(Ammo762, diff)
	PlayerRef.AddItem(Ammo308Caliber, diff)
endif
to just average the amount of both you're carrying out, which would work fine until you get very low on the ammo anyway.

 

If you really want to go down the complicated route, take a look at https://forums.nexusmods.com/index.php?/topic/8844713-attatch-omod-to-equipped-weapon/&do=findComment&comment=83497518

and maybe https://www.nexusmods.com/fallout4/mods/24225/?

The first of which is relatively straightforward to reverse engineer and/or tweak, and shows a basic method of attaching arbitrary mods to the currently equipped weapon.

The second is a more fully-fledged (and many times more complex) implementation that changes the mods of equipped weapons based on their keywords/base ammo type, usually automatically, triggered by animation events. Most of the relevant code is in idek:gac:WeaponControlScript, and you can find examples of most of the sort of things you'd need somewhere in there if you want to dig.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...