... so does this work on some script with a very high chance or what ...
IIRC correctly it something like a 1 in 3 chance of resetting each time you level up. I guess you were just rather lucky from levels 5-10.
The main advantage of smithing for Thorik is not the small XP reward, but opening up access to the anvil in his store that you can use to modify your gear if your crafting skills are high enough, and getting it restocked when you smith for him on subsequent occasions. Your description of what you were doing was a little confusing so I am not sure whether the issues are some sort of bug or you doing something wrong or what.
from your guide
Work becomes available again after the following events:
a. You have gained access to both the Docks and the Slums.
which I qualify for 2nd smithing
I smithed first time long ago and upgraded my equips
I just cannot be sure if it is a bug or I simply rebuffed cause smithing passes time
thing is gold is so plentiful that I easily chug dozens of potions for every stat for max rolls
so maybe I didn't reload and simply rebuffed and 2nd smithing already happened
can't say for sure but I would say 99 percent I think It's a bug
but if you maybe explain how that thorik script works maybe we could pinpoint something
only thing I know 2nd smithing was available before I've gone to the slums for the 1st time
so maybe entering slums breaks it
but only you could check
if I can describe it better just ask
actually maybe it says on the anvil times remaining I'm gonna check right now if it reset than I would know if I've got 2nd smithing maybe
TLDR EDIT
ok so I checked I smithed the shapechanger upgrade and it said 7 out of 10 remaining before I smithed armor fully which should be 3 and weapon twice so I guess 2nd smithing definitely happened how many does it restore anyway but total would be over 10 12 it seems so I just forgot that I smithed so ignore above I'm dumb