Jagged Alliance 3

Jagged Alliance 3

Random Enemy Weapons
LotR[Henchman]  [developer] 24 Nov, 2023 @ 11:29am
Mod Compatibility
------------- Status as of JA3 1.5.xxxx . 06.02.2024 -------------

Somewhat of a rewrite, we're now mostly using function OnMsg.ConflictStart(sector) as a hook to exchange weapons. Which will allow guns to also drop on auto resolve.

Thanks to rato we're now deciding on Unit-Tiers and have implemented Weapon Tiers you can set, to not have strong weapons randomly spawn on the initial enemies.

-------- How to add your own weapons? --------
So you've done your own nice weapons and want enemies to make use of them? Then let me show you how it generally works.

You simply add a code asset. Within that you add to the "SharedModEnv" table. The structure should be:
SharedModEnv.yourModId.rew_LootTable filled with a table holding the values for the guns, who should be able to get it, what it should replace and how rare the weapon should be. Let's see an example:

SharedModEnv[CurrentModId] ={ rew_LootTable = { {Affiliation = "Legion", WeaponType = "Handgun", id = "FG42_1", Rarity = 7, SuperRare = false, Tier = 3}, } }

Affiliation corresponds to the affiliation of units. So a Legion unit is affialited with the Legion. A Thug is affiliated with the Thugs. This is so not everyone gets everything. If you want everyone to be able to use your gun, you can now use "All" as affiliation and it will be available for all groups.
WeaponType is checked to what an enemy was spawned in with ,as our weapon will replace what got spawned by the vanilla system. Please keep this in ine with the type you are going to use.
id = the id of your weapon, which you want to add.
rarity = how rare a weapon is, the lower the rarer. We use values from 1 to 10 in general. Which directly means a rarity 10 weapon is 10-times as likely to get drawn than a rarity 1 weapon. Please don't use negative numbers...
SuperRare - boolean false or true; Determines if a weapon should be super rare. Which means if it's true the weapon normally wouldn't appear on enemies, unless the player switches the respective option.
Tier should present the strength of the Weapon. It will compare it to an Enemy Tier. If the gun tier is lower than Enemy tier but higher than Enemy-Tier - zz_lowerTierDiff (defaults to 3), it should be able to be used by an enemy.

The mod will go through every table in the SharedModEnv, look if there's a "rew_LootTable" and add this to a single table, which it then uses to draw the weapons from.

--how is enemy Tiers decided?--
Two possible ways:
1) If someone used this mod while building his mod, he can set the new "rew_Tier" on units, which should be used as prefered value.
2) By using ratos neat script - which will take base tiers decide in the table "affilation_mod" and add 1 level for stronger enemies, 2 for elite enemies (enemy id that hold those as words) and a potential further 1 if the enemy is a commander.

You can see the results in the "zz_TierList" table. Simply open the mod editor, open the console and type "Inspect(zz_TierList)".

-------- Doing a balance mod and want to change tables? --------
After we've built the table (being triggered by the ClassesBuilt() message) we're firing our custom rew_ListFin message.
You can capture that easily:
function OnMsg.rew_ListFin() print("Okay let's do something.") end

The table we're building ist called:
"zzWeaponLootTable" - it has a numbered index and holds the individual entries which you can access. So far we're not tracking wich mod added which list.

It would be nice, if you also add your own message for other to be able to access the table after you're finished and stop racing conditions to appear.

--new--
we fire a message "rew_tierListFin" after we've built the zz_TierList for enemies, so you can easily change it if you want.

we also added a Msg("rew_ExchangedWeaponRand", unit) after we tried exchanging weapons on an enemy. So if you want you can hook up to that and overwrite what we did or do different things on those units.

zzBuildWeaponLootTable(send_msg) is now a globally available function, send_msg is bool and there to check if we should send a the "rew_ListFin" message or not.
Similarly zzBuildTierList(send_msg) allows one to call the build of the zz_TierList again.

Addes the table: zz_ExchangeGroups = {
Legion = true,Adonis= true, Army= true, Thugs= true, Rebel= true, SiegfriedSuperSoldiers= true,}
It's the table to modify if you want to exchange weapons for other enemy groups. Please note that you might have to rebuilt the zz_TierList after changing something here.

-------- Closing remarks --------
Feel free to make suggestions and contact us if you find any mods - a good place to find us is the official discord in the modding channels.
Last edited by LotR[Henchman]; 6 Feb, 2024 @ 12:35pm