PAYDAY 2

PAYDAY 2

View Stats:
Nate Sep 26, 2017 @ 6:07am
How to return total ammo value?
How do I return the amount of total ammo for a weapon, plus/minus any skills/modifications that reduce it?

I'm picking apart the More Weapons Stats and I see how one can get the total ammo stat:
local base_stats = WeaponDescription._get_stats(name, category, slot, blueprint) totalAmmo = data.base_stats.totalammo.value log('%s', totalAmmo)
That gives the result (150). Now then, how would I account for modifications that lower the ammo count (like DMR Kit) and also skills that raise your total ammo such as Fully Loaded Aced?
Last edited by Nate; Sep 26, 2017 @ 9:00pm
< >
Showing 1-13 of 13 comments
Jet Sep 26, 2017 @ 6:32am 
You might want to ask that question to the users that made difficulty Rebalance mods and mods that Rebalance weapons.
Nate Sep 26, 2017 @ 9:32pm 
Anybody else wanna halp?
Alcat101 Sep 27, 2017 @ 8:20am 
i dont understand what you're trying to do?
the game already does show total ammo weapon value..
what do you want to use on that return total ammo value?
Jet Sep 27, 2017 @ 8:53am 
Maybe the user ment changing the total ammo capacity on some weapons. Like, make the Interceptor carry 135 rounds instead of 90 rounds.
Rokk Sep 27, 2017 @ 9:47am 
Originally posted by D.J. Jetth1576:
Maybe the user ment changing the total ammo capacity on some weapons. Like, make the Interceptor carry 135 rounds instead of 90 rounds.

What? Did you read OP?

He wants to get a weapon's total max ammo after skill calculations.
Jet Sep 27, 2017 @ 10:37am 
Originally posted by Rokk:
Originally posted by D.J. Jetth1576:
Maybe the user ment changing the total ammo capacity on some weapons. Like, make the Interceptor carry 135 rounds instead of 90 rounds.

What? Did you read OP?

He wants to get a weapon's total max ammo after skill calculations.
Oh. Well, there is a website called pd2tools.com that can do that.
Nate Sep 27, 2017 @ 1:33pm 
Originally posted by Alcat101:
i dont understand what you're trying to do?
the game already does show total ammo weapon value..
what do you want to use on that return total ammo value?
Sorry I should have been more clear in my end goal.

I have a mod that gives the user a rough estimation of Total Damage Output. It's a simple measure one can use when considering damage vs endurance, etc. It is not specific ala breakpoints it's more of a general idea of 'this weapon has the potential to do a total of XXX damage' (# of rounds times amount of damage per round).

What I'm trying to do is make a simple calculated field that is Total DMG (weapon base damage + damage from mods + damage bonuses from skills) * total Ammo (weapon's total ammo - mods that subtract ammo [like dmr kit/skins] + skills that grant ammo [like fully loaded]).

I have it working sort of... it does the total damage part correctly, but I'm having trouble with when the amount of ammo changes. I suppose the long way would be to check for if the user has the fully loaded skill, if that returns true then multiply total ammo times the multiplier... but still not sure how to handle ammo reducing mods and/or skins.

Thank you for your response I hope I explained it better.
Nate Sep 27, 2017 @ 1:35pm 
Originally posted by Rokk:
Originally posted by D.J. Jetth1576:
Maybe the user ment changing the total ammo capacity on some weapons. Like, make the Interceptor carry 135 rounds instead of 90 rounds.

What? Did you read OP?

He wants to get a weapon's total max ammo after skill calculations.

This. But also after skill calculations and after any ammo-reducing mods. I'm wondering what the variable for this is, as returning the total ammo for a weapon returns the original (for example returns 150 ammo on the car-4 with the dmr kit, where the ammo is clearly reduced).

Hope that clarifies...
Nate Sep 27, 2017 @ 1:36pm 
Originally posted by D.J. Jetth1576:
Maybe the user ment changing the total ammo capacity on some weapons. Like, make the Interceptor carry 135 rounds instead of 90 rounds.
Negative, I found the blueprints in the WeaponsFactoryTweakData I think for doing that. I'm just not sure how the game handles ammo reductions to crafted weapons... I'm losing the forest through the trees.
Jet Sep 27, 2017 @ 1:52pm 
Oh, well there was a mod called MoreWeaponStats that can do calcuations after any skills and attachemnts that influences a weapon's stats(like Dragon's breath and DMR kit). Unfortunately, that mod does not support the new BLT system. Then again, I don't normally look into in depth calculations on WeaponsFactoryTweakData unfortuntately.
Nate Sep 27, 2017 @ 2:05pm 
Originally posted by D.J. Jetth1576:
Oh, well there was a mod called MoreWeaponStats that can do calcuations after any skills and attachemnts that influences a weapon's stats(like Dragon's breath and DMR kit). Unfortunately, that mod does not support the new BLT system. Then again, I don't normally look into in depth calculations on WeaponsFactoryTweakData unfortuntately.
I appreciate the help. If you see I've updated the original post...
Frankelstner Sep 27, 2017 @ 2:28pm 
weapontweakdata creates this sneaky table:
self.stats.total_ammo_mod = {} for i = -100, 100, 5 do table.insert(self.stats.total_ammo_mod, i / 100) end
That's a table -1.0, -0.95, ... 0.95, 1.0. The element at index 21 has the value 0 which is what weapons are initialized to.

The relevant weapon mods also define e.g. total_ammo_mod = -12, and you just sum over weapon itself plus all of its attached weapon mods. In this case, the -12 means a final index of 21-12=9, i.e. -0.6. The game does that in NewRaycastWeaponBase:_update_stats_values; after summing the indexes it clamps the values to fit inside the table and then looks up the value from the index:

self._current_stats[stat] = stats_tweak_data[stat] and stats_tweak_data[stat][j] or 1.

Actually it looks up the index i instead of j but that makes the rest of this post turn into italics. In the end the result is stored in _total_ammo_mod.

NewRaycastWeaponBase:replenish then multiplies the skill bonuses together and does

ammo_max_multiplier = ammo_max_multiplier + ammo_max_multiplier * (self._total_ammo_mod or 0)

which is equivalent to

ammo_max_multiplier = ammo_max_multiplier*(1 + self._total_ammo_mod)

assuming that _total_ammo_mod is defined (it should be). So the game only ever considers (1 + self._total_ammo_mod), which is why the original table might as well be shifted to 0, 0.05, ..., 1.95, 2.0. Anyway, in the case above the index is shifted by 12, which means the value changes by 0.6. As the starting point is 1, the new value is 0.4. That's the multiplier for the ammo. Or 1.25*0.4 if FL.

Max ammo is then

local ammo_max = math.round((tweak_data.weapon[self._name_id].AMMO_MAX + managers.player:upgrade_value(self._name_id, "clip_amount_increase") * ammo_max_per_clip) * ammo_max_multiplier)

where "clip_amount_increase" is leftover from PDTH I think, so this simplifies to

local ammo_max = math.round(tweak_data.weapon[self._name_id].AMMO_MAX * ammo_max_multiplier).
Last edited by Frankelstner; Sep 27, 2017 @ 2:30pm
Nate Sep 27, 2017 @ 8:55pm 
got it:

function totalDmgStat.tds_get_total_damage(data) return((data.base_stats.damage.value + data.mods_stats.damage.value + data.skill_stats.damage.value) * (data.mods_stats.totalammo.value + data.skill_stats.totalammo.value + data.tweak.AMMO_MAX)) end
< >
Showing 1-13 of 13 comments
Per page: 1530 50

Date Posted: Sep 26, 2017 @ 6:07am
Posts: 13