Unable to use stat formulae for innate passives

Weekly updated column for helping skill development. Users can't directly post requests but a PM or mail can be sent to Skill-Clinician.

Moderator: Skill Clinician

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Unable to use stat formulae for innate passives

Post by SponTen » Thu Sep 03, 2020 3:31 pm

Hey everyone, really losing my mind here. D2X v1.13c.

I've used this guide to create a new innate passive for all classes that provides bonuses based on Strength. I followed exactly as it says, and thought I'd test by setting the passivestat1 to fireresist and passivecalc1 to 1, just to test.

I created a new Barbarian, zero fire res (as expected; the guide advised you have to save and exit once first). Saved and exited, loaded the Barb again, and fire res is now 1. Great!

So then I thought I'd change passivecalc1 to stat('strength'.accr) to test. As a Barb, he should have 30 fire res, because he has 30 strength, right? Well nope, he has zero fire res. I changed passivecalc1 to stat('strength'.accr)+1, and now he has 1 fire res. I level him up to 2 and bump strength to 35; still 1 fire res. Doesn't work with stat('strength'.base)+1 either; still 1.

What's weird is, I checked Hydra, and its calculation is stat('passive_fire_mastery'.accr), so the "stat" function should be working fine. Additionally, when I change passivecalc1 to lvl+1, my Barb has 2 fire res at level 2, instead of 3 fire res. I've also tried stat('str'.accr) just to be safe, but didn't change anything.

Anyone have any ideas what is going on?

Edit: I tested changing passivestat1 to energy and passivecalc1 to 50, and it does increase my Energy, but I can't restore my mana to the full value; it maxes out at 10 despite the max appearing as 110. I tested changing passivestat1 to item_fastermovevelocity but no movement speed appears to be applying. What on earth is going on?

Edit2: I tested on a level 2 Sorc, changing Warmth's passivestat1 to fireresist and passivecalc1 to stat('strength'.base)*10. Didn't work. But then I changed passivestat1 to item_fastermovementvelocity and it did work, though I don't think it increased my movement speed by 100; more like 30. I then tried changing my innate passive's passivestat1 to passive_fire_mastery and its passivecalc1 to 500. The character screen displayed the updated damage, but I was still taking 2-3 hits to kill a zombie in the Blood Moor. I feel like I've done something wrong with my D2 installation, patch 1.13c, or use of MPQEditor or AFJ Sheet | 0.61 Beta, as none of this makes any sense.

Any ideas?
Last edited by SponTen on Thu Sep 03, 2020 3:55 pm, edited 1 time in total.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Unable to use stat formulae for innate passives

Post by HarvestWombs » Thu Sep 03, 2020 3:45 pm

Unfortunately you can't use strength in passive calcs.
Firehawk wrote:They check if the stat is greater than 0 (strength) erroneously when applying passivestats to aurastate
That's done in a number of different places
It should work correctly if you use a different stat.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Cypress
Moderator
Champion of the Light
Posts: 448
Joined: Fri Dec 01, 2017 2:08 am

Re: Unable to use stat formulae for innate passives

Post by Cypress » Thu Sep 03, 2020 3:50 pm

"lvl" specifically refers to the skill's total level, not of the user (and "blvl" is the base level of the skill, meaning only hard points count). If you want character/monster level to be used, use "ulvl".

As for stat('strength'.accr), there is nothing wrong. It is possible you made a single error in formatting which will make it equal to zero (this is an especially annoying issue when you work with really, really, really long formulae that stretch over multiple cells). If that isn't the case, then could you copy and paste your entire skill like so? Following is what I added to Fire Mastery to make it give fireresist equivalent to strength and it is working as expected; in my case, I used passivestat3/passivecalc3=fireresist stat('strength'.accr).

Code: Select all

Fire Mastery	61	sor	fire mastery																																											firemastery		passive_fire_mastery	ln12	skill_pierce	dm34	fireresist	stat('strength'.accr)																																																								1	3		none												SC	SC	xx																	1									30	20													1						0	8	0	0	1						1												30	% Damage bonus	7	% Damage bonus per level	0	piercebase	30	piercemax									1								8															fire																					896	64000
But do note that passivecalcs only update if one of the following occurs:
(1) You level up
(2) The specific skill goes up or down one or more levels
(3) You die
(4) You start a new game
(5) The passivestat is given by an aura, and one of the aurastats of that aura have updated (or in other words, an aura's aurastats updating also updates the aura's passivestats)

As such, I would recommend adding a unique charm to your characters that gives a 100% chance to cast +1 or -1 to all skills when struck for 1 frame so that it'll update occasionally without significantly impacting the game otherwise.

Also worth noting that clcs do not update if the value calculated on the next update is equal to 0, so in some cases you'll want to make sure the lowest possible value is -1 or 1.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Unable to use stat formulae for innate passives

Post by HarvestWombs » Thu Sep 03, 2020 3:59 pm

Cypress wrote:
Thu Sep 03, 2020 3:50 pm
Also worth noting that clcs do not update if the value calculated on the next update is equal to 0, so in some cases you'll want to make sure the lowest possible value is -1 or 1.
Calc fields can calculate to zero, the parser returns -1 if the field is empty, however... in all of Blizzard's genius, in aura they check if stat > 0.
And the kicker is that it only requires a small code edit to fix.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Re: Unable to use stat formulae for innate passives

Post by SponTen » Thu Sep 03, 2020 4:10 pm

HarvestWombs wrote:
Thu Sep 03, 2020 3:45 pm
Unfortunately you can't use strength in passive calcs.
Firehawk wrote:They check if the stat is greater than 0 (strength) erroneously when applying passivestats to aurastate
That's done in a number of different places
It should work correctly if you use a different stat.
That's strange; Cypress said it works for him?
Cypress wrote:
Thu Sep 03, 2020 3:50 pm
"lvl" specifically refers to the skill's total level, not of the user (and "blvl" is the base level of the skill, meaning only hard points count). If you want character/monster level to be used, use "ulvl".
Oops, thank you!
Cypress wrote:
Thu Sep 03, 2020 3:50 pm
As for stat('strength'.accr), there is nothing wrong. It is possible you made a single error in formatting which will make it equal to zero (this is an especially annoying issue when you work with really, really, really long formulae that stretch over multiple cells). If that isn't the case, then could you copy and paste your entire skill like so? Following is what I added to Fire Mastery to make it give fireresist equivalent to strength and it is working as expected; in my case, I used passivestat3/passivecalc3=fireresist stat('strength'.accr).

Code: Select all

Fire Mastery	61	sor	fire mastery																																											firemastery		passive_fire_mastery	ln12	skill_pierce	dm34	fireresist	stat('strength'.accr)																																																								1	3		none												SC	SC	xx																	1									30	20													1						0	8	0	0	1						1												30	% Damage bonus	7	% Damage bonus per level	0	piercebase	30	piercemax									1								8															fire																					896	64000
Sure:

Code: Select all

Strength Bonus	357																																													strengthbonus		fireresist	stat('strength'.base)*3																																																												1	0		none												S1	S1	xx																										1																				0	8	0	0	1	1					1																												1								8																																				512	8000
Cypress wrote:
Thu Sep 03, 2020 3:50 pm
But do note that passivecalcs only update if one of the following occurs:
(1) You level up
(2) The specific skill goes up or down one or more levels
(3) You die
(4) You start a new game
(5) The passivestat is given by an aura, and one of the aurastats of that aura have updated (or in other words, an aura's aurastats updating also updates the aura's passivestats)
I've tried levelling up and starting a new game, but neither seemed to amend the values as long as my passivecalc1 contains a formula. I added some extra edits to my original comment, but it seems some weird stuff is going on, like my mana being stuck at a lower value than max when I provide bonus to Energy.
Cypress wrote:
Thu Sep 03, 2020 3:50 pm
As such, I would recommend adding a unique charm to your characters that gives a 100% chance to cast +1 or -1 to all skills when struck for 1 frame so that it'll update occasionally without significantly impacting the game otherwise.
I can do this, but shouldn't it update on save/exit and reload?
Cypress wrote:
Thu Sep 03, 2020 3:50 pm
Also worth noting that clcs do not update if the value calculated on the next update is equal to 0, so in some cases you'll want to make sure the lowest possible value is -1 or 1.
I don't think I've been working with zeros. My Strength is always >0 and I'm just multiplying it to try to output a test value.

User avatar
HarvestWombs
Senior Moderator
Arch-Angel
Posts: 1019
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Unable to use stat formulae for innate passives

Post by HarvestWombs » Thu Sep 03, 2020 4:23 pm

SponTen wrote:
Thu Sep 03, 2020 4:10 pm
I don't think I've been working with zeros. My Strength is always >0 and I'm just multiplying it to try to output a test value.
You can keep testing values all day, but you can also test a different stat as well.
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

User avatar
Cypress
Moderator
Champion of the Light
Posts: 448
Joined: Fri Dec 01, 2017 2:08 am

Re: Unable to use stat formulae for innate passives

Post by Cypress » Thu Sep 03, 2020 4:32 pm

HarvestWombs wrote:
Thu Sep 03, 2020 3:45 pm
Unfortunately you can't use strength in passive calcs.
Firehawk wrote:They check if the stat is greater than 0 (strength) erroneously when applying passivestats to aurastate
That's done in a number of different places
It should work correctly if you use a different stat.
I tested this, and it seems to only be an issue if you choose to use an aurastate and a passivestate simultaneously. Auras can use passivestats just fine without a passivestate (unless there is some bigger issue that I haven't realized yet with doing that). And in SponTen's case, he isn't using an aurastate at all, so this interaction shouldn't be a problem here. Good to know, though.

SponTen wrote:
Thu Sep 03, 2020 4:10 pm
I can do this, but shouldn't it update on save/exit and reload?
Yes, if you are fine with it only updating at that point then there is no issue.
SponTen wrote:
Thu Sep 03, 2020 4:10 pm
Strength Bonus
I noticed that you are using a custom state. This is likely the problem. I never bothered figuring out exactly what causes this issue, but states require certain settings and/or stats or otherwise they will not actually give the stats they say they give. Could you post your state line as well? Likely if you change the state to resistfire, or input the stat "fireresist" into the stat column of states.txt, then it will probably work.

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Re: Unable to use stat formulae for innate passives

Post by SponTen » Fri Sep 04, 2020 9:04 am

Cypress wrote:
Thu Sep 03, 2020 4:32 pm
I tested this, and it seems to only be an issue if you choose to use an aurastate and a passivestate simultaneously. Auras can use passivestats just fine without a passivestate (unless there is some bigger issue that I haven't realized yet with doing that). And in SponTen's case, he isn't using an aurastate at all, so this interaction shouldn't be a problem here. Good to know, though.
Thanks, this is good to know, as I plan to rebalance a bunch of auras too.
Cypress wrote:
Thu Sep 03, 2020 4:32 pm
SponTen wrote:
Thu Sep 03, 2020 4:10 pm
I can do this, but shouldn't it update on save/exit and reload?
Yes, if you are fine with it only updating at that point then there is no issue.
I think I'm going to need something to update it periodically, as some people might assign attributes after assigning their skill point, or without assigning a skill point at all that level. So good to know when they update, cheers.
Cypress wrote:
Thu Sep 03, 2020 4:32 pm
I noticed that you are using a custom state. This is likely the problem. I never bothered figuring out exactly what causes this issue, but states require certain settings and/or stats or otherwise they will not actually give the stats they say they give. Could you post your state line as well? Likely if you change the state to resistfire, or input the stat "fireresist" into the stat column of states.txt, then it will probably work.
I had a feeling it was something to do with this, but I dismissed it because integers worked fine in the passivecalc field... for some passivestats.

I actually didn't change any stat field in the States.txt file due to the aforementioned guide not mentioning them. Unless I missed it; I read it several times to make sure because it felt like there had to be some reason to add a custom state. So this might be the problem. I'm at work atm so can't test for a few hours, but here's my current custom State:

Code: Select all

strengthbonus	185			1																																																																			0
I'm guessing it should be this instead:

Code: Select all

strengthbonus	185			1																																															fireresist																				0
I'll test that as soon as I can, but that makes sense. Weird that both my custom skill and Warmth were still providing the bonuses some of the time though, right?

Edit: Now the Strength bonus isn't working at all. I'm going to just delete my whole data folder and re-unpackage the mpq. Failing that, I'll probably try a reinstall + patch officially (instead of just dragging files from a zip on the PlugY website), and maybe even test with packaged mpqs instead of just using the data folder.

User avatar
Cypress
Moderator
Champion of the Light
Posts: 448
Joined: Fri Dec 01, 2017 2:08 am

Re: Unable to use stat formulae for innate passives

Post by Cypress » Fri Sep 04, 2020 3:00 pm

I tested it out and it seems like nosend causes the stat to not update properly, but only cltside. Srvside the stat was still working fine, even providing resistances while the LCS was saying I had 0% (I always test with coldresist for possibly not working states/stats since it is easy to confirm if you or something else gets slowed for 100% of the duration or only 25%). I have no idea what nosend actually does, but you shouldn't need it. Otherwise, your skill works as expected.

Here are the exact lines I used:

Code: Select all

Strength Bonus	1257																																													strengthbonus		coldresist	stat('strength'.base)*3																																																												1	0		none												S1	S1	xx																										1																				0	8	0	0	1	1					1																												1								8																																				512	8000

Code: Select all

strengthbonus	199																																																																						0
I didn't even need to modify the "stat" column despite my prior guessing, so I'm probably wrong about it mattering.

You shouldn't need to full re-install either, if the vanilla skills are working properly then your install should still be fine. From my experience, the easiest way to tell if I bricked my skills.txt is if vanilla curses apply to targets or not (if they do not, then skills.txt is broken; although this only really happens if you save the txt file in the wrong way).

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Re: Unable to use stat formulae for innate passives

Post by SponTen » Sat Sep 05, 2020 1:25 am

Thanks for that man. I re-unpacked the mpq, made the edits you suggested; still not showing on the LCS. Tried repacking into a new d2_patch.mpq; still not showing.

Is this just a LCS bug? So with a clvl 1 Sorc, I'd have 30% cold res even if it's not showing on the LCS? If so, is there any way to fix this, or does that require some solid CE? Sorry to take up so much of your time; I haven't modded in years and my mind mind kind of explodes when a change I make doesn't work for me yet works for others :lol:

User avatar
Cypress
Moderator
Champion of the Light
Posts: 448
Joined: Fri Dec 01, 2017 2:08 am

Re: Unable to use stat formulae for innate passives

Post by Cypress » Sat Sep 05, 2020 2:49 pm

The LCS display should be correct for this. And you shouldn't need to repack anything, just run the Data folder directly via -dir -txt. How exactly are you running your mod?

As a test, run this: http://www.mediafire.com/file/jvxmkkpw9 ... ck.7z/file. It is a D2SE mod (if you don't use D2SE for some reason, you can instead just dump the Data folder into your directory and run Diablo 2 via -dir -txt) based on the fixed 1.13c txt files (viewtopic.php?t=56033), all I did was copy-paste the skill/state I listed above to the end of skills.txt and states.txt, adjust the ID to be +1 of the previous row, set zombies/fallens to give much more experience so I could quickly get to level 7 and add in a super common magicprefix with the Strength Bonus oskill so that I can easily test it. The save included with the mod has a sorceress with the item already equipped, all you need to do is check if you gain coldresist (the Strength Bonus skill has the same description as Delirium). If you do gain coldresist from this mod, then I recommend downloading the fixed 1.13c txt files above and trying to implement the skill/state changes as I did in this mod.

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Re: Unable to use stat formulae for innate passives

Post by SponTen » Sun Sep 06, 2020 1:27 pm

Thanks, I tested with the files you provided and they worked! But I then tried to amend CharStats.txt to give Strength Bonus as an innate passive to the Sorc, and it stopped working. Even un/re-equipping the cap didn't change the Sorc's cold res.

I wonder if innate character passives just aren't possible with this method?

Edit: I thought I might just put my stat changes on a small charm instead, which will also fix the issue with re-applying them; you can just pick up and put down the small charm any time you want to update your stats.

I've managed to copy and modify the Charm Small row from Misc.txt, and the Annihilus row from UniqueItems.txt. I've modified them respectively, as below.

Charm Small -> Attribute Bonuses from Misc.txt:

Code: Select all

Attribute Bonuses	Attribute Bonuses		0	100	1	1	999	0	0	1	1			atb	rld	atb	16	1	1	0	0	0	flpchm1	invmss			0	xxx			0	0	scha		item_charm	12	item_charm	1	0	5	0	0	0	0	0	0	0			0	-1												1	**		0	0	0	non	0					255					255					255					255					255					255					255					255					255					255					255					255					255					255					255					255					255			0	0	0	xxx	xxx						0
Annihilus -> Attribute Bonuses from UniqueItems.txt:

Code: Select all

Attribute Bonuses	100	1		1		1	1	atb	charm		1	1	1			flpmss	invmss	item_gem	12	item_gem	oskill	Strength Bonus	1	1	oskill	Dexterity Bonus	1	1	oskill	Energy Bonus	1	1																																					0
I created the skills and states, basically copying your Strength Bonus / strengthbonus ones.

I then added a new Attribute Bonuses key in patchstring.tbl and set all classes to receive item5/6 as atb.

Here's the weird part; the item only spawns on new Sorcs, not any other class. It's indeed always a unique small charm with the Annihilus graphics/sounds, correctly called Attribute Bonuses, but its type is just An Evil Force, nor does it show any mods on it, nor do any mods apply, even if I change the prop#/par# to an in-built stat or skill. Trying to change the code value in UniqueItems.txt to cm1 successfully makes it a unique small charm with the respective randomised graphic, but the name just becomes An Evil Force with nothing else on it.

Here's my CharStats.txt for reference:

Code: Select all

Amazon	20	25	15	20	80	84	30	30	35	15	20	120	5	6	9	20	The following are in fourths	8	4	6	12	4	6	5	6	4	16	20	6	14	25		Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Unsummon				ModStr3a	StrSklTabItem3	StrSklTabItem2	StrSklTabItem1	AmaOnly	hth	jav	rarm	1	buc	larm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0
Sorceress	10	25	35	10	80	74	30	25	30	30	15	120	-15	6	9	20	The following are in fourths	4	4	8	8	4	8	5	8	5	20	14	8	18	20	Fire Bolt	Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Unsummon				ModStr3d	StrSklTabItem15	StrSklTabItem14	StrSklTabItem13	SorOnly	hth	sst	rarm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0	0		0
Necromancer	15	25	25	15	80	79	30	20	30	30	20	120	-10	6	9	20	The following are in fourths	6	4	8	8	4	8	5	9	5	19	16	7	17	20	Raise Skeleton	Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Unsummon				ModStr3c	StrSklTabItem8	StrSklTabItem7	StrSklTabItem9	NecOnly	hth	wnd	rarm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0	0		0
Paladin	25	20	15	25	85	89	30	30	20	20	30	120	20	6	9	20	The following are in fourths	8	4	6	12	4	6	5	8	5	17	18	4	17	30		Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Unsummon				ModStr3b	StrSklTabItem6	StrSklTabItem5	StrSklTabItem4	PalOnly	hth	ssd	rarm	1	buc	larm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0
Barbarian	30	20	10	25	85	92	30	35	30	10	25	120	20	6	9	20	The following are in fourths	8	4	4	16	4	4	5	7	4	15	22	5	16	25		Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Left Hand Throw	Left Hand Swing	Unsummon		ModStr3e	StrSklTabItem11	StrSklTabItem12	StrSklTabItem10	BarOnly	hth	hax	rarm	1	buc	larm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0
Expansion																																																																														0
Druid	15	20	20	25	80	84	30	20	30	30	20	120	5	6	9	20	The following are in fourths	6	4	8	8	4	8	5	9	5	19	16	7	17	20		Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Unsummon				ModStre8a	StrSklTabItem16	StrSklTabItem17	StrSklTabItem18	DruOnly	hth	clb	rarm	1	buc	larm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0
Assassin	20	20	25	20	85	95	30	25	15	35	25	120	15	6	9	15	The following are in fourths	8	5	6	12	5	7	5	6	4	16	20	6	14	25		Throw	Kick	Scroll of Identify	Book of Identify	Scroll of Townportal	Book of Townportal	Left Hand Swing	Unsummon			ModStre8b	StrSklTabItem19	StrSklTabItem20	StrSklTabItem21	AssOnly	hth	ktr	rarm	1	buc	larm	1	hp1		4	tsc		1	isc		1	atb		1	0		0	0		0	0		0	0		0
Did I completely miss something here, or am I breaking thing?

User avatar
Cypress
Moderator
Champion of the Light
Posts: 448
Joined: Fri Dec 01, 2017 2:08 am

Re: Unable to use stat formulae for innate passives

Post by Cypress » Sun Sep 06, 2020 2:28 pm

As far as I know, you can only reference the item codes of weapons.txt, misc.txt, armor.txt (read: kb/viewarticle?a=389) so as to spawn a normal version of an item. The starting items can't even have properties from automagic.txt (despite normal white items being able to have them), so there is no way to apply properties. From the many mods I've experienced, modders usually get around this by having Corpsefire drop the desired item or starting the player with the Horadric Cube and an item that can be cubed into the desired item.

SponTen
Posts: 13
Joined: Thu Sep 03, 2020 2:42 pm
Australia

Re: Unable to use stat formulae for innate passives

Post by SponTen » Mon Sep 07, 2020 12:26 am

Ahh that makes sense, thank you! Guess I'll go the cube route then. Sorry for all the questions; there are so many little quirks with how D2 is technically designed.

Return to “Skill Clinic”