Jagged Alliance 3

Jagged Alliance 3

Zulib Weapons Core - OUTDATED!
LotR[Henchman]  [developer] 9 Mar, 2024 @ 7:57am
Infos for fellow modders
-edited-
fixed the bad instruction on how to use the script to change calibers - thanks Grinch91
----------

Hello there fellow modders!

Here are a few short infos, you might want.

First of all, this was mostly created to allow for better compatibility between different Weapon mods, as otherwise every modder would have to write some code to make sure that Modders-A 5.45 can also be used in Modders-B weapons.

So why not do a caliber library?
But after starting to do the necessary calibers and ammos for Tons of Guns and Masters of War, i also needed a way to switch vanilla weapon calibers, and then also have those ammos spawn with the enemies. Then it made sense to try fixing running games... yadda yadda, here we are.

So a few infos.

################### Slot Dependency Table ###################
As you might have noticed vanilla JA3 uses the function:

FirearmBase:UpdateVisualObj(vis)

to decide how to draw attachments onto the weapon models. Now it saddly uses a global table indepentend of what gun we're looking at. This means if a modder changes the table, it might mess up all guns. This lead to some incompatibilities for Masters of War and Tons of Guns.

My solution is overwriting the function on the firearm classes, and adding the ability to have both individual guns, or whole mods define their own table. The mod then tests first for individual tables for the gun and then if the mod got a specific one. Meaning even within one mod you could have individual guns using a differen table.

> To define a table for a gun, simply open your mod in the editor and you should find a new property field on the ItemDef:
"Slot Dependency Settings"
-> If you add something you get the a dropdown menu to choose between slots. First the Slot than what's mapped to it. Just like the dependency table (Barrel = "Handguard" ; Meaning Slot = Barrel; Dependant = Handguard).

> If you want a Mod Slot Dependency table simply use:
We want to put a table into the SharedModEnv for your mod id. To do that we best use a message hook that runs before ModsReloaded (at which point most of this mods scripts run):
so:
function OnMsg.ClassesBuilt()
SharedModEnv[CurrentModId].zzChangeList ={}
SharedModEnv[CurrentModId].zzChangeList = {
gunID = "caliber_id",
--eg. MoW_AR_AK103 = "5_45x39",
}
end

To know from which mod each weapon comes, i'm using a table called:
SharedModEnv["Tc3ajdY"].ItemSource
So if you want to change something about the slots of a gun, it might be a good idea change that list or the individual list for the specific mod. To be able to easily do that i've added two messages:

"zCore_WeaponSourceListFin" -> Which will fire after the script has finished the ItemSource list.
"zCore_SlotDepFin" -> Which will fire after the script has built the modSlotDependencies table.


################### Changing calibers of weapon through script ###################

You can simply add another table in one of your scripts:
SharedModEnv[CurrentModId].zzChangeList = {[Gun_1_Id = "Caliber_1_Id", Gun_2_Id = "Caliber_2_Id"}
The mod should automatically change the Caliber of the guns with the id given.

################### Vanilla Renaming (optional) ###################
- It renames a few vanilla calibers:
762WP becomes 7.62x39
5.56 becomes 5.56x45mm
7.62 Nato becomes 7.62x51 Nato
9mm becomes 9x19 mm

As i'm adding .50AE - it's also renaming the reference of the .50BMG on the Desert Eagle component mod and changes it for that.

################### Vanilla Caliber changes(optional) ###################
AK74 = "5_45x39",
AKSU = "5_45x39",
RPK74 = "5_45x39",
DragunovSVD = "7_62x54R",
ColtAnaconda = "44MAG",
DesertEagle = "44MAG",
MG42 = "7_92x57",
Gewehr98 = "7_92x57",
Winchester1894 = "44MAG",

################### Closing Words ###################

Let me know if you've got any more questions or want me to add any more messages, or have another good idea for changes ;)
Last edited by LotR[Henchman]; 11 Mar, 2024 @ 11:08pm