Looking for debugging help for my new mod

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

Post Reply
OrderOfTheScribble
Posts: 38
Joined: Wed Apr 05, 2023 7:35 pm
United States of America

Looking for debugging help for my new mod

Post by OrderOfTheScribble » Mon Jul 03, 2023 9:03 pm

About 3 months ago, I mentioned in the Modworked thread that I wanted to make a mod with a proficiencies and subclass system. I have now made such a mod, but I've only been able to playtest it since last night. I've already found several bugs, most of which were typos in the txt files. There are couple though that I don't know how to fix.
  1. Healing and mana potions aren't working. They display 0 points, and when I try to use them from either inventory or belt, nothing happens. The potion doesn't even disappear. In my mod, the potions use a formula to determine how much they heal so I could have certain items and skills improve potions (the items use a pseudostat, while the skill is a stateless passive, and the potion improvement is referenced by a ref skill in the crazy stats section called [potion]). I'm guessing something about the formula (which you can see in Misc.txt) makes the potions unusable, but I'm not why that's the case or how to fix it.
  2. If my character is damaged while having points in a passive that increases % max life using the superstates system, my life will slowly degenerate. I didn't notice any degeneration before taking the passive in question, and it's way too slow to be related to the hpregen stat (it takes as long as 50 seconds to lose a point of life, though it does seem to get a little faster if I've taken more damage, while -1 'hpregen' would drain 1 point of life every 10 seconds). My best guess as to the cause of this bug is that it's related to the superstates system and its timer, as I'm adding the 'item_maxhp_percent' stat through superstates, and the superstate's formula refs both vitality and a ref skill that allows the passive to increase max life without a state.
I'm trying to attach my excel folder as a zip, but the attachment was removed when I previewed this post, and the attachment has an exclamation-mark-in-a-triangle symbol as its status in the posting window, so I won't know until I submit the post whether or not the attachment is successful. If it is, any registered user can download the zip and look at the txt files to see what's wrong with them. Otherwise, I'll edit this post to add the formulas I used for healing and mana potions and hope that and the other content of this post will be enough to give you guys an idea of what's going on.

Edit: The attachment failed, so here are the formulas:

Code: Select all

100+skill('[potion]'.len)
4*(100+skill('[potion]'.len))
9*(100+skill('[potion]'.len))
16*(100+skill('[potion]'.len))
25*(100+skill('[potion]'.len))
(100+skill('[potion]'.len))/5
2*(100+skill('[potion]'.len))/5
3*(100+skill('[potion]'.len))/5
4*(100+skill('[potion]'.len))/5
100+skill('[potion]'.len)
The first 5 rows are for healing potions, while the bottom 5 rows are for mana potions. The "[potion]" skill is a ref skill whose "auralencalc" field sums all of the character's bonuses to potion effect. For example, a Minor Healing Potion in my mod is supposed to heal a base of 100 life before the hardcoded multiplier based on class, so a total of +20% potion effect (i.e. a result of 20 in skill('[potion]'.len)) would increase that to 120, then apply the class multiplier.

Edit 2: To clarify, the formulas are entered in both the "calc1" and "spelldesccalc" fields in Misc.txt. The only other changes I made to healing and mana potions are the "len" field (they all take 4 seconds in my mod, while the time seems to vary in vanilla), and the prices.

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

Re: Looking for debugging help for my new mod

Post by Cypress » Mon Jul 03, 2023 11:50 pm

Hi OrderOfTheScribble:
(1) Potions cannot be quaffed if the calc results in 0. Sounds like you have a broken/invalid reference or an unexpected formula/truncation result somewhere in your [potion] len that is zeroing the outcome. The way to approach this is to work your references backwards to their most basic parts; reference your formula piecewise and find the exact part which is zeroing everything out or otherwise not functioning. Whenever I'm bug testing formula, I set-up skilldesc.txt to display the parts I want to investigate through Attack. So what I do is set a formula calc on Attack's skillbar display, start up my game, check the outcome, repeat. If you copy over the row for [potion] and all of the rows it is referencing, I could find it for you.

(2) I might know what is going on here, but I'll need more information before I make any assumptions. What stats are you changing, and how? What kind of calcs are you using?

OrderOfTheScribble
Posts: 38
Joined: Wed Apr 05, 2023 7:35 pm
United States of America

Re: Looking for debugging help for my new mod

Post by OrderOfTheScribble » Tue Jul 04, 2023 6:41 am

Cypress, thanks for responding.

1) I tried your skilldesc idea and set the calc to the formula used for minor healing potions (the first one in the code block), and the value given in the display is as expected, including when I took a skill that improves potion effect. This suggests that the problem is with the potions themselves, so I decided to try referencing a real stat instead by turning one of the unused stats in ItemStatCost.txt to 'potion_bonus' and changed the 'firelength' stat in the superstates to 'potion_bonus' and set it to skill('[potion]'.len) and then changed all references to skill('[potion]'.len) in Misc.txt to stat('potion_bonus'.accr). The potions then worked as expected, which means the calcs in Misc.txt break if a skill is referenced but work with references to stats. That means anyone who wants to include a way to improve potions in the future should use a real stat instead of a pseudostat.

2) While testing potions and the skill shrine fix, I encountered a dangerous mob and left the game with 6 life out of 166, but when I created a new game with the same character, my life went up to over 20 after the charm auras activated (I have a second one in addition to superstates). This adds an additional hint that something weird is going on with max life. I'll now go through how max life is increased by superstates:
  • The 'item_maxhp_percent' entry in superstates is stat('vitality'.accr)+skill('[maxlife]'.rng), meaning each point in vitality adds 1% to max life, while the rest of the bonus is handled by [maxlife].
  • The formula entered for [maxlife].rng is len*(100+stat('vitality'.accr))/100, which allows me to add bonuses that are multiplicative with the one from vitality and reference those in len.
  • The degeneration doesn't occur if I don't have a skill-based bonus to max life (i.e. when [maxlife].len=0, which would make [maxlife].rng also 0).
  • I also have a non-zero entry in the 'maxhp' stat in superstates, which may be a contributing factor.
Edit: I found a new issue in my mod. I modified the superstate invert ring to also give a bonus to Strength and Dexterity multiplier to increase the stats of mercs, but mercs aren't getting the stat bonus, which means either the ring isn't working on them or merc stats are treated as .mod instead of .base (my mod has multipliers for each stat based on the stat's base value). I can easily modify the ring to give some other stat so I can find out whether the ring is being equipped or not, so I'll do that and edit in the result.

Edit 2: I edited the superstate ring's entry in AutoMagic.txt to add +40 to all resists and then hired a new merc, but the resist bonus didn't appear. This means the merc is not equipping the superstate ring. In case it matters, I'm using the vanilla merc inventory.

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

Re: Looking for debugging help for my new mod

Post by Cypress » Tue Jul 04, 2023 1:01 pm

(1) That's unfortunate, but great job finding that! I can't find any way to get around that issue either. I tried referencing missiles, but all missile references still turn out to 0. Looks like stats are the only valid references with misc calcs.

(2) I'm not able to replicate. I added [maxhp], and gave +5 of it to my character, and while I do have the healing on restart, there is no HP degeneration. The healing on restart is interesting, because it only appears when item_maxhp_percent is increased by a pseudostat, increasing the value of the superstate's item_maxhp_percent directly (like setting it to 100) does not have the same effect.

(3) Thanks, nice find! The ring is definitely not appearing in the hireling inventory, so they'll only have the superstates, not the superstate updater aura. The ring is appearing in other minion inventories: Valkyries, Shadow Warriors, Shadow Masters and Iron Golems get the ring, so it appears that mercs don't like it when you try to force equipment on them through monequip. It seems that hirelings can only gain and keep gear if oninit=1, but if you do that then their gear will glitch out, disappearing cltside at times and replacing anything you put into the slot, which could cause issues in mods where you are allowed to gear hirelings out fully.

I think the best fix here would be to add in at least a minimally expanded hireling inventory to show the left-handed ring slot and make it so the Superstate scroll/jewel recipe also produces the hireling's superstate aura ring, which a player would have to manually equip to their hireling. I'll probably add in the vanilla inventory + left-handed ring to the next version of Modworked, and also an optional plug-in for the full hireling inventory, with the changes necessary to make it so hirelings can equip any gear.

Note that I intentionally do not give the superstate aura through monprops.txt because doing that will make it so the superstate aura gets disabled if the hireling equips any other "aura when equipped" gear.

OrderOfTheScribble
Posts: 38
Joined: Wed Apr 05, 2023 7:35 pm
United States of America

Re: Looking for debugging help for my new mod

Post by OrderOfTheScribble » Tue Jul 18, 2023 1:23 am

I've found a couple new issues with my mod which may or may not be Modworked specific:

1) The Barbarian's weapon masteries aren't working right. I changed them to add a damage bonus that is multiplicative with Melee Mastery (a new skill I gave to all classes, which is essentially a weapon mastery for the 'mele' item type) as well as an attack rating bonus, but once I actually took the mastery after already taking Melee Mastery, the damage bonus of the new mastery didn't work, and the attack rating bonus was less than expected (the formula I used for the AR bonus is 10*lvl, I put 2 points in the mastery, and I had a +1 skill bonus, but I only got a 20% bonus). I'm guessing either masteries can't stack (the mastery I tested uses the 'swor' item type, which is within the 'mele' item type), or moving item types somehow breaks the mastery (I applied the changes of Modworked 14+ that enabled mercs to equip other items by moving the 'swor' item type to row 914 of ItemTypes.txt). The attack rating bonus working on hard points while the damage bonus doesn't work is confusing, so I'll post the relevant formulas, though I'm not convinced it's a formula problem.

2) This is more an FYI to anyone who reads this, but if a property has 21 as its func1 in Properties.txt (this is used for pseudostats) and another stat with 17 in its func (which corresponds to the param value when entered on items), the param is apparently set to the min/max even if the param field itself is empty. I discovered this when trying to boost unarmed damage when no shield is equipped, but the game was treating every item classified as light, medium, or heavy armor as a shield (I'm using the 'shieid' stat to mark shields, but I made it a parameter to the property that marks an item as light, medium, or heavy armor). I've created a separate property for shields and removed the 'shieid' stat from the original light/medium/heavy armor properties, and it works.

Now for the formulas related to weapon masteries:
  • First of all, I'm using the superstates to implement masteries, which means they update in real time. The problem was discovered with Sword Mastery, but whatever fixes that should fix the other masteries as well, so I'll just use Sword Mastery here.
  • Sword Mastery uses superoskill15 with passiveitype 'swor', while Melee Mastery uses superoskill21 with passiveitype 'mele'. In both cases, the AR bonus is in pst1, while the damage bonus is in pst2. Melee Mastery also has a critical strike that's working properly, while Sword Mastery doesn't.
  • Sword Mastery's attack rating bonus is given as skill('sword mastery'.pst1)*(100+skill('[melee]'.len))/100, while its damage bonus is given as skill('sword mastery'.pst2)*(100+skill('[melee]'.len))*skill('physb'.ast3)/10000. Both pst1 and pst2 of Sword Mastery are 10*lvl. I just noticed that refs to Sword Mastery here are in lowercase, while the actual Sword Mastery skill is in uppercase, so perhaps there's a case sensitive issue here.
  • Melee Mastery's attack rating bonus is given as skill('[melee]'.len), while its damage bonus is given as skill('[melee]'.rng). I just noticed that the skill('[melee]'.len) part of Sword Mastery's damage bonus should be skill('[melee]'.rng), and making that change would remove the need for skill('physb'.ast3), since [melee].rng already takes strength into account (in my mod, skill-based bonuses to weapon damage are multiplicative with stat-based bonuses to weapon damage).
  • [melee] is a ref skill used to unify all the Melee Mastery skills since each class needs its own Melee Mastery skill for all classes to be able to put points in it. The mod refs [melee].len for the attack rating bonus, [melee].rng for the damage bonus (which is equal to the attack rating bonus but multiplicative with stat-based damage bonus), and [melee].clc4 for the crit chance.
Edit: I just realized that attack rating bonus of Sword Mastery was written to be multiplicative with Melee Mastery's attack rating bonus. This makes the problem even weirder, as the AR bonus as applied is an additive 20% when it's supposed to be a multiplicative 30%.

Edit 2: After checking, it turns out the old formula for weapon mastery damage is right, as [melee].rng only applies the stat-based damage bonus to [melee].len and not the specific weapon mastery. I've tacked on +skill('[melee]'.rng) at the end per the reply given by Cypress.
Last edited by OrderOfTheScribble on Wed Jul 19, 2023 6:39 am, edited 1 time in total.

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

Re: Looking for debugging help for my new mod

Post by Cypress » Tue Jul 18, 2023 11:06 pm

Did some quick tests:
(1) Sword Mastery is fully working by itself, so maybe not due to itype changes.
(2) Sword Mastery + Melee Mastery (axe mastery with itype changed from axe to mele) used only the highest stats; so if Sword > Melee, then it uses swor; if Melee > Swor, then it uses mele. Seems like the itype masteries are mutually exclusive. Not sure if this is a Modworked issue or if this was always the case. This might explain why +dmg% was applying but not +AR%: one mastery had a higher +dmg% and the other mastery had a higher +AR%.
(3) Tested this in Overworked with vanilla passive masteries. Same issue applies, does not seem to be an issue of Modworked, but rather of masteries.

Fortunately, while this issue cannot be fixed in Overworked, it can be fixed in Modworked. Instead of making it so Melee Mastery buffs all weapons through a mele superstate, make it so Melee Mastery feeds into and adds to the specific weapon mastery states that together cover all weapons. I believe that, with the addition of the dagger superstate in v14, superstates should encompass every melee weapon type in the game.

Let me know if there are any other issues that persist after you apply this fix.

OrderOfTheScribble
Posts: 38
Joined: Wed Apr 05, 2023 7:35 pm
United States of America

Re: Looking for debugging help for my new mod

Post by OrderOfTheScribble » Wed Jul 19, 2023 6:45 am

Cypress, thanks for confirming that the mastery issue was due to overlap. I've changed the 'mele' in one of the superoskills to 'h2h' and applied the dagger mastery, making it match the Melee Mastery. It turns out there can be an itype issue if the item type in question is too far down, but I looked at Modworked v14, and you had moved the bow, swor, and spea itypes between the gems and the non-vanilla types, while I had put bow, swor, and spea at the very bottom of ItemTypes.txt, which led to Melee Mastery not working for spears after the change until I moved the itypes to match Modworked.

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

Re: Looking for debugging help for my new mod

Post by Cypress » Wed Jul 19, 2023 10:41 pm

Mastery stats are probably not working at higher ID values because of itemstatcost limits, the mastery stats have Send Param Bits=8. Also, thanks for making me realize I forgot to synchronize itemtypes with montypes after inserting rows!

Post Reply

Return to “General Mod Making”