Weapon stats modding for dummies?
Avatar

I'm hesitant to post this as I worry it might be considered poor taste or else "cheating," but I was wondering if anyone knows of a simple way to tweak weapon stats for someone who's not really knowledgeable about modding in general. The reason I asked is I tried the DMCWO mod and - while I'm not a huge fan of most of what it does - I did enjoy some of the changes to some of the weapons, specifically some of the ones I don't really use. I was wondering if I can make my own MUUUCH simpler mod to tweak just one or two stats on just one or two weapons. Not for multiplayer, obviously - I have a number of mods that I keep either for personal use or for private lobbies.

However, it occurs to me that it's useful to mod guns and try them out for real if I'm going to make actual suggestions on the official forums. Last one I suggested was an 80-damage, 180-RPM machinegun with a 50-round mag and 150 total ammo. Underpowered? Overpowered? Just plain stupid? I think it's pretty cool, but I'm guessing. Being able to test this out on my own and see just how far out of whack it is would be awesome, but I'd need to pick and existing gun and mod it to those stats to see. Is there a simple way to do that? I can kind of tell how DMCWO is doing it - messing with tweak_data - but I'm sure there's more to it than just making a lua file with tweak_data.gun.stat = new_stat, right?

So... Am I out of line asking for this?

Avatar

I've done some weapon tweaking of my own regarding LMGs and Battle Rifles. The hook_id for modifying weapon stats would be ''lib/tweak_data/weapontweakdata'' for BLT (it's called PostRequire with the old PD2hook.yml)

I've done only some basic changes, here's some of my code that makes LMGs have a bit more Damage/Stability (note, these are not all of the stats a weapon has, these are just the basic ones that are easy to understand and modify):

   local old_init = WeaponTweakData.init
     
    function WeaponTweakData:init(tweak_data)
        old_init(self, tweak_data)
     
     self.hk21.stats = {
 damage = 17,
 spread = 6,
 recoil = 6,
 spread_moving = 8,
 zoom = 3,
 concealment = 2,
 suppression = 2,
 alert_size = 8,
 extra_ammo = 6,
 total_ammo_mod = 21,
 value = 9
 }
        self.m249.stats = {
 damage = 15,
 spread = 4,
 recoil = 8,
 spread_moving = 9,
 zoom = 1,
 concealment = 2,
 suppression = 4,
 alert_size = 8,
 extra_ammo = 6,
 total_ammo_mod = 21,
 value = 9
 }
    end

--Feel free to use different weapon names and numbers, these are just examples. Brenner originally has 14 damage and 5 recoil, being able to reach 34 damage and 19 stability (if modded for 18 accuracy). I modified it to 17 damage and 6 recoil, which lets it reach 42 damage and 20 stability.

Here's some info regarding statistics:
Statistics in the code are not equivalent to the actual statistics in game, there's a certain multiplier for each one that I don't really know (2x or so for damage, not sure for the other stats). The higher the spread, the higher the accuracy of the weapon in-game, the higher the recoil, the higher the stability of the weapon is in-game, etc... etc... I haven't really tried modifying any of the other stats such as spread_moving or ammo, so play around with those and check the in-game statistics with Better Stats GUI.

Some extra, modifying the number of ammo in a magazine and the total ammo of the weapon:

self.hk21.CLIP_AMMO_MAX = 150
 self.hk21.NR_CLIPS_MAX = 2

The weapon's total ammo is CLIP_AMMO_MAX multiplied by NR_CLIPS_MAX, with that 150x2=300 total ammo (without the fully loaded skill, if you also wish to modify this, add it somewhere in the code above)

Regarding rate of fire, there are 2 lines of code which numbers can be different for certain weapons like the KSP, so you'll have to experiment with those:

	self.m249.fire_mode_data.fire_rate = 0.066
	self.m249.auto.fire_rate = 0.076

Here is the source code for all the weapons, their file names, other hidden spread modifiers and etc...
https://bitbucket.org/YaPh1l/payday-2-lua/src/8f6fd49d0c9beb0d9f952b8c2a586f04fafb8766/lib/tweak_data/weapontweakdata.lua?at=master&fileviewer=file-view-default

Have fun.

30 856