Project Zomboid

Project Zomboid

69 ratings
Udderly Attachments
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
152.314 KB
17 Aug, 2022 @ 1:34pm
15 Sep, 2023 @ 8:13pm
11 Change Notes ( view )

Subscribe to download
Udderly Attachments

Description

If this gains traction it will eliminate the need to make patch mods for guns and attachments to be intercompatible. Either way, I will be using this for my own gun releases.

This supports VFE and Vanilla calibers and attachments out of the box! If a gun is set up in a group but is not present, or if an attachment is set up in the list but is not present, it will be skipped harmlessly. That said, due to the nature of this mod it may assign attachments to a different (wider) selection of guns than in Vanilla or VFE out of the box since it does it by caliber/type of gun rather than one-by-one.

You must run at least one database (UdderlyAttachmentsLiteDatabase or UdderlyAttachmentsFullDatabase) as well as UdderlyAttachments. The Lite database doesn't expand upon VFE, the Full database expands access to attachments to anything sensible to have said access - things in the same group as things that have it but different calibers, or different types of guns in UA that aren't in VFE like LMGs. If there is interest, I will add other databases, but mind that it is more work to maintain as I add more.

How It Works

At runtime UA will scan through its table of functions added by other mods, and run the gun ones first, followed by the attachment ones. It will then go through all attachments in its database and for each one:
  • Iterate the guns in the groups it is assigned to and add them to a list of strings.
  • Build the MountOn list and reassign it to this list on the spot.

    How Do I Use It? (for modders)
    UA.Guns

    To use UA, add your guns to the UA.Guns table in the following way:
    UA.Guns.Type.Caliber
    Both Type and Caliber (or Barrel Count/Length, for shotguns) are tables. The reason for this is so that mods can change what groups are assigned to what attachments, as well as what guns are assigned to what groups independently, and everything will all mesh up and support the right attachments.

    The Types in UA by default:
    • Pistols
    • Revolvers
    • SARs
    • SMGs
    • Shotguns
    • BoltActions
    • ARs
    • LMGs

    The calibers available (for non-shotguns) by default:
    • Bullets22
    • Bullets223
    • Bullets308
    • Bullets44
    • Bullets45
    • Bullets556
    • Bullets762
    • Bullets9

    If you add new calibers to UA with one of your mods, please follow this naming convention. If you plan to use cartridge sizes (e.g., 7.62x54 rather than just 7.62), then write them as Bullets76254. If we all use the same naming convention then everything will stay compatible.

    The types for shotguns:
    • NoStock
    • ShortBarrel
    • DoubleShortBarrel
    • LongBarrel
    • DoubleLongBarrel
    • Military

    Military shotgun here means metal/fiberglass stock (e.g., not one that makes sense to replace with a fiberglass stock attachment) tactical shotguns like the SPAS12 that allow things like lasers to mount.

    In order to have your gun strings added to the relevant tables, you need to make a tiny LUA script for it, like this:
    print("[SomebodyGuns Big Chonker] Initializing.") UA = UA or {} UA.GunAddingFunctions = UA.GunAddingFunctions or {} table.insert(UA.GunAddingFunctions, "table.insert(UA.Guns.BoltActions.Bullets308, \"SomebodyGuns.BigChonker\")")
    We do this instead of just running the code on the spot because UA has to set up its tables prior to you adding to it, and it has to run its code after every other mod has added to it - this facilitates that.

    Remember that if you want to set up a customized list of attachments for your gun and not inherit any from other mods/etc. (keep in mind this costs you in compatibility!) you can make a custom group for *just* your gun.

    Once you've got that in place, you're done if you're just adding one or more guns. If you want to assign a custom group to an attachment, or you have new attachments to add, then you need to mess with the UA.Attachments table.

    UA.Attachments

    The UA.Attachments table is pretty simple - under the main table is a table for each attachment with the same name as the name from the item script, e.g., "x2Scope". Inside this table are a string and three more tables with no name. The first contains the groups of guns that are assigned to it, the second contains one-off additions to the list (not groups, just gun name strings), and the third contains exceptions to the groups, e.g, add all guns from the group unless on this list.

    If you want to insert a new attachment for only 9mm Pistols called "Potato", you could do this:
    print("[Potato Attachment] Initializing.") UA = UA or {} UA.AttachmentAddingFunctions = UA.AttachmentAddingFunctions or {} table.insert(UA.AttachmentAddingFunctions, "table.insert(UA.Attachments, { \"PotatoAttachment.Potato\", { UA.Guns.Pistols9 }, { "PotatoGuns.PotatoPistol" }, { "PotatoGuns.NoPotatoPistol" } })"

    If you want to assign a gun group to an attachment, you can do:
    print("[OPGuns 308 Pistol LMAO] Initializing.") UA = UA or {} UA.AssignmentFunctions = UA.AssignmentFunctions or {} table.insert(UA.AssignmentFunctions, "table.insert(UA.Attachments.x8Scope[2], UA.Guns.Pistols.Bullets308)") --Assigning all 308 pistols to x8Scope.
    Note the "[2]" - the table you want to insert into is at this index, it will not vary, so just always include it. If you want to attach a single gun to an attachment without assigning other guns from the group to it, you can add it to index [3] as a string. If you wish to add a group but not one (or more) member of it, you can add the guns to exclude to index [4] as strings.

    A real world example for my PPSh mod combines some of these:
    print("[UdderlyGuns PPSh] Initializing.") UA = UA or {} UA.GunAddingFunctions = UA.GunAddingFunctions or {} UA.GroupAssignmentFunctions = UA.GroupAssignmentFunctions or {} table.insert(UA.GunAddingFunctions, "table.insert(UA.Guns.SMGs.Bullets762, /"UdderlyGuns.PPSh/")") table.insert(UA.AssignmentFunctions, "table.insert(UA.Attachments.Sling[3], "/UdderlyGuns.PPSh/")")

    Future Plans
    • Other groupings built into UdderlyAttachments for other purposes, like stock material, intended range, etc. for ease of assignment.
    If you have ideas let me know!

    Like my mods? Help me survive, lol.
    Venmo: @UdderlyEvelyn
    Paypal: yushatak@gmail.com (I do not check this email, do not contact me through it!)
    Ko-Fi: http://ko-fi.com/UdderlyEvelyn

    Workshop ID: 2850431623
    Mod ID: UdderlyAttachments
    Mod ID: UdderlyAttachmentsFullDatabase
    Mod ID: UdderlyAttachmentsLiteDatabase
19 Comments
sebastian_93 7 Feb, 2024 @ 11:59am 
Where should I put this script? it doesn't work with Server/Lua
Leo5 11 Nov, 2023 @ 9:00am 
otherwise had the mod with fulldatabase for the last month on my server and works great!
Leo5 11 Nov, 2023 @ 8:58am 
there is an issue where the shellholder for shotguns doesn't work for the spas 12
Maxene 15 Oct, 2023 @ 9:19am 
I'm in agreement with 2Dimm.
Dimm 26 Sep, 2023 @ 4:10pm 
i'll be honest, i don't quite get what this does, is this solely a mod resource for mod creators or does it actually do something out of the box?
UdderlyEvelyn  [author] 15 Sep, 2023 @ 8:16pm 
Does anyone make use of the lite database? I have limited time and I did not fully update it this time. If there is interest I will get around to doing the rest sooner.
STENDO_CLIP 2 Aug, 2023 @ 5:32pm 
It would have been wicked cool to know this existed when I made the VFE STALKER pack lol.
NeinDao 12 Apr, 2023 @ 9:10pm 
sorry, i got sever dyslexia. what does this mod do?
g_BonE 3 Apr, 2023 @ 8:29am 
i wonder if this will conflict with Noir's Attachments somehow?
dragonsphotoworks 7 Dec, 2022 @ 5:17pm 
Cant find UdderlyAttachmentsFullDatabase is it a separate mod? Discription says need it or lite but cant find them.