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

Hmm... I'm having some degree of trouble tweaking anything in upgradestweakdata. I found the stat in question - "self.weapon_movement_penalty.minigun = 0.6" which is in the function "UpgradesTweakData:_init_pd2_values()". However, I'm unable to do anything with that function, since none of the changes I attempt to make seem to have any effect. I don't see any obvious errors in the BLT logs, the game doesn't crash - it's almost like my changes just aren't changing anything. I was able to replicate B Dawg's example code (thank you kindly, by the way) for messing with "WeaponTweakData : init" but I'm not able to replicate the same apporach for "UpgradesTweakData : _init_pd2_values()".

Now, you're probably going to laugh at me as I legitimately do not understand the intricacies of Lua beyond what I know from other languages and what I assume to be the case, but here's what I'm trying to do:

local old_init = UpgradesTweakData:_init_pd2_values

function UpgradesTweakData:_init_pd2_values()
	old_init(self)
	
	self.weapon_movement_penalty.minigun = 0.8
end

I'm still not sure what the deal with "self" is, but I see it done all over the place in other mods and it appears to be some kind of global variable. I even read an article about using "self" as a means of abstracting a function such that it doesn't depend on a specific object, which I'm not entirely sure how that works. Obviously this is a different case, but I don't know which part of my assumption is mistaken. I'm really not trying to do anything major, just reduce the Minigun movement penalty down from 0.6 to 0.8 - the same as LMGs. With all the other tweaks I've done to it, it really doesn't need that penalty, but I can't seem to disable it and I'm running out of options.

edit
So after reading a few articles, it seems like "self" is a reference to a function's parent class (or I'm guessing parent context of some description - not that familiar with Lua), and it's good practice to use that parameter in function calls to specify context. The colon operator : obfuscates the "self" reference (in a way that really reminds me of C++) for convenience. I'm starting to follow the logic here. But unless method names which start with an underscore _ are somehow special, then it seems to me like my code should work. I create a local variable to hold the original function from the original class, I create a new function within the context of the original class and then call the original function within the context of the class I'm currently in so it can do all its housekeeping first, then I can follow after it and change a few of the things it changed. Presuming this function gets called by the game where appropriate (I'm guessing on startup?), it's good to have any changes to do with that function happen inside it.

Still don't know what I'm missing here, however.

40 1055