may u help me with this? i tried to change having perk every 3 lvl and changed the code like bellow: if(level > min && (level - min) % 3 == 0) m.PerkPoints++;
but when i reached lvl 11 i only had +1 to all attributes which is weird becuz i was not in veteran lvl yet! is there any bug in my code which u can help pls?
Love this mod. I am enjoining the hell out of it so thank you! I noticed that when I click the level up button (for veteran level) and see some +2s and then change the equipment, the +2s become +1s. Not sure why but it seemed like a bug.
Thanks. I believe it's because the +2s are random, and what probably happens is that the "dice" are being "rerolled" when you open the window again. I think ideally the bonuses would be stored in the save file so that they only get rolled once and players can't exploit this behavior, but I'm not sure I want to introduce the extra complexity that would require. Still, if I get inspired to work on it I'll consider that.
hi! got a question for this mod. im playing on the latest patch with legends mod, and the mod gives me a perk every 2 levels. any way to fix that to have only one every 5 levels? :)
I want to change the perk frequency to every 3rd (i think) level. Is it enough to just change the divisor here, or is there something more? Also are there any side effects i need to take into account, if i decide to change this lines math completely (say some kind of progression like first after 1 vet level, second after 3 more, 3rd after 6 and so on)
I ended up changing it to %5 == 2 This front-loads the first extra point to the second vet level but keeps the rest at one per 5. And the very last perk should be at level 33, which is i believe the final level (tho i don't think i ever seen a bro reaching that).
I saw this was updated? is it working for Blazing Deserts? I installed it in an ongoing game and am still getting +1 only at veteran levels. Does it require a new savegame?
It does not require a new save, but it will only help on new level-ups. It won't retroactively improve existing veteran levels. There is no guarantee of getting +2 for attributes. First, you need talent stars to have any chance of +2, and then it's random (roughly 20% for one star, 33% for two stars, and 50% for three stars, unless your stars are in something like initiative in which case it's more like 25%, 50%, and 100%). (I don't remember the exact details.) If you never get +2 even after many level ups and having three-star talents, then there may be a problem.
I created a veteran group in bbedit and tested it just now, and it seemed to be working properly to me.
Here, let me tell you how to make that change. Unpack the mod and edit the mod_veteranBuffs.nut file. Find the code that says: local extra = function(t, bonus = 0) { if(t == 0) return 0; local max = (t == 1 ? 5 : t == 2 ? 3 : 2) - bonus; return max <= 1 || Math.rand(1, max) == 1 ? 1 : 0; }
And change the line if(t == 0) return 0;
to return 0;
Then zip the mod back up (taking care to keep the same structure as the original) and delete the 'scripts' directory that it created when you unzipped it.
Hi Adam! I'm the guy from Steam forum that had the idea to make stars count for Veteran Level.
After reading the notes, I've not fully understand the code you've used.
"local v = getAttributeLevelUpValues(); local extra = function(t, bonus = 0) { if(t == 0) return 0; local max = (t == 1 ? 5 : t == 2 ? 3 : 2) - bonus; return max <= 1 || Math.rand(1, max) == 1 ? 1 : 0; }"
I imagin, that "t" equals to "star", so that if you have 1 star then you get a value of "max"=5, so in the next line you get 20% chance of getting +1. In case of "t==2", "max" would equal to "3" (33% chance) and in last place, the non written"t==3" would mean "max" of "2" (50% chance). That's correct?
In case i just wannted to implement a flat: 1 star = +0,5 // 2 star = +1 // 3 star = +1,5. How would that look? it's even possible to introduce decimal numbers in here?
Thanks anyways for the mod!
Edit: I thought that putting "local max = (t == 1 ? 1 : t == 2 ? 1 : 1) - bonus;" would ensure that I would have 100% chance of getting the +1 of bonus, but I just got the base +1... No idea what I'm doing
Your understanding is correct. And, it's not possible to have non-integer attributes, but what you could do to implement +0.5 is to give +0 half the time and +1 half the time. So a flat scheme like you describe might look something like:
local extra = function(t) { return t/2 + (t & m.Level & 1); }
You'd have to remove the ", 1" from initiativeIncrease.
The only problem is that the getAttributeLevelUpValues method might not be called in the right context, but I'd expect that for veteran levels it'll probably work okay.
'bonus' in the original code just increases your chance of +1. It doesn't give you +2.
Unless a recent update broke it, it should be working. (I'd probably have gotten a lot of comments if that was the case, since all of my mods use mod_hooks.) Another possibility is a bug in your code.
thank you very much for your mod. I've modified it slightly, so that one perk is gained every 3 levels and talent stars have a slightly higher effect, so having 3 stars in an attribute may yield 2 bonus (1 in any case) points. So far it has worked without problems (until yesterday in any case), but now a brother has reached level 15, and according to the changes to the code he should get at least 2 points in melee attack, since he has 3 stars in MA. But he only gains 1 point in each attribute. I wonder if the latest update has caused the mod to stop working, possibly the underlying hook function. Thanks again for your work.
yep, I have made some additional tests, and it has stopped working now, every veteran brother gets the default 1 point at levelup regardless of talents. I suppose the function is not executed anymore for whatever reason. It's strange because it was still working today morning.
ok, I let steam verify the data ingetrity and though it reported that it succeded, now it is working again. No idea why it didn't before. in any case, thanks again for your work. Cheers.
Very neat mod! I'm trying to understand your script hooks so that I don't have to keep updating mine for each of the post-DLC patches, it's really cool what you've come up with.
Looking at the code here, I think you can simplify the modified updateLevel to be something like below:
The main problem with that code is that if you're eligible for a perk point, you'll keep getting another perk point every time you gain XP, until you reach the next level. It also doesn't handle the possibility of gaining multiple levels in a single call to updateLevel. Though it's admittedly unlikely to happen by the time you're a veteran, it's still theoretically possible. Still, subtracting MaxLevelWithPerkPoints and comparing to zero is nicer than computing the remainder and comparing against that.
I updated it to: { // give a perk point every 5 veteran levels local level = m.Level; updateLevel(); for(local min = Const.XP.MaxLevelWithPerkpoints, newLevel = m.Level; ++level <= newLevel; ) { if(level > min && (level - min) % 5 == 0) m.PerkPoints++; } }
If I'm not too tired to think straight, you could get rid of the loop with something like m.PerkPoints += (m.Level-min)/5 - (level-min)/5 (which can't be algebraically simplified because we're depending on integer truncation). You'd need to be careful with the cases where level < min, though.
I'm not very literate with coding and i just cannot figure out what to edit (even though you have left clear instructions in your comments lol)
i changed this local v = getAttributeLevelUpValues(); local extra = function(t, bonus = 1) but i dont see any change
And this
local level = m.Level; updateLevel(); // give a perk point every 5 veteran levels for(local n = 3, min = Const.XP.MaxLevelWithPerkpoints + n, d = min % n, newLevel = m.Level; ++level <= newLevel; )
Basically i was aiming at 3 levels for perks and slight increase on non star stats
40 comments
if(level > min && (level - min) % 3 == 0) m.PerkPoints++;
but when i reached lvl 11 i only had +1 to all attributes which is weird becuz i was not in veteran lvl yet! is there any bug in my code which u can help pls?
I noticed that when I click the level up button (for veteran level) and see some +2s and then change the equipment, the +2s become +1s. Not sure why but it seemed like a bug.
Is it enough to just change the divisor here, or is there something more?
Also are there any side effects i need to take into account, if i decide to change this lines math completely (say some kind of progression like first after 1 vet level, second after 3 more, 3rd after 6 and so on)
if(level > min && (level - min) % 5 == 0) m.PerkPoints++;
This front-loads the first extra point to the second vet level but keeps the rest at one per 5. And the very last perk should be at level 33, which is i believe the final level (tho i don't think i ever seen a bro reaching that).
I installed it in an ongoing game and am still getting +1 only at veteran levels. Does it require a new savegame?
I created a veteran group in bbedit and tested it just now, and it seemed to be working properly to me.
local extra = function(t, bonus = 0)
{
if(t == 0) return 0;
local max = (t == 1 ? 5 : t == 2 ? 3 : 2) - bonus;
return max <= 1 || Math.rand(1, max) == 1 ? 1 : 0;
}
And change the line
if(t == 0) return 0;
to
return 0;
Then zip the mod back up (taking care to keep the same structure as the original) and delete the 'scripts' directory that it created when you unzipped it.
After reading the notes, I've not fully understand the code you've used.
"local v = getAttributeLevelUpValues();
local extra = function(t, bonus = 0)
{
if(t == 0) return 0;
local max = (t == 1 ? 5 : t == 2 ? 3 : 2) - bonus;
return max <= 1 || Math.rand(1, max) == 1 ? 1 : 0;
}"
I imagin, that "t" equals to "star", so that if you have 1 star then you get a value of "max"=5, so in the next line you get 20% chance of getting +1. In case of "t==2", "max" would equal to "3" (33% chance) and in last place, the non written"t==3" would mean "max" of "2" (50% chance). That's correct?
In case i just wannted to implement a flat: 1 star = +0,5 // 2 star = +1 // 3 star = +1,5. How would that look? it's even possible to introduce decimal numbers in here?
Thanks anyways for the mod!
Edit: I thought that putting "local max = (t == 1 ? 1 : t == 2 ? 1 : 1) - bonus;" would ensure that I would have 100% chance of getting the +1 of bonus, but I just got the base +1... No idea what I'm doing
Your understanding is correct. And, it's not possible to have non-integer attributes, but what you could do to implement +0.5 is to give +0 half the time and +1 half the time. So a flat scheme like you describe might look something like:
local extra = function(t) { return t/2 + (t & m.Level & 1); }
You'd have to remove the ", 1" from initiativeIncrease.
The only problem is that the getAttributeLevelUpValues method might not be called in the right context, but I'd expect that for veteran levels it'll probably work okay.
'bonus' in the original code just increases your chance of +1. It doesn't give you +2.
I ended up changing the code with:
" local extra = function(t, bonus = 0)
{
if(t == 0) return 0;
if(t == 1) return Math.rand(1, 2) == 1 ? 1 : 0;
if(t == 2) return 1;
if(t == 3) return Math.rand(1, 2) == 1 ? 2 : 1;
}"
It actually worked fine!
Yesterday, with a guy over lvl 11 and with 3 stars on MD and 2 in Fatigue, i just got the regular +1 on both.
According to my code, that should not be an option.
It's possible that mod_hooks is not working right?
(No other mod installed apart from this two ones, by the way)
As always, thank you mate!
Looking at the code here, I think you can simplify the modified updateLevel to be something like below:
{
updateLevel();
local vetLevels = m.Level - Const.XP.MaxLevelWithPerkpoints;
if(vetLevels > 0 && vetLevels % 5 == 0){
m.PerkPoints++;
}
I updated it to:
{
// give a perk point every 5 veteran levels
local level = m.Level;
updateLevel();
for(local min = Const.XP.MaxLevelWithPerkpoints, newLevel = m.Level; ++level <= newLevel; )
{
if(level > min && (level - min) % 5 == 0) m.PerkPoints++;
}
}
i changed this
local v = getAttributeLevelUpValues();
local extra = function(t, bonus = 1) but i dont see any change
And this
local level = m.Level;
updateLevel();
// give a perk point every 5 veteran levels
for(local n = 3, min = Const.XP.MaxLevelWithPerkpoints + n, d = min % n, newLevel = m.Level; ++level <= newLevel; )
Basically i was aiming at 3 levels for perks and slight increase on non star stats
local extra = function(t, bonus = 0) { return Math.rand(1, 5) == 1 ? 1 : 0; }
for a flat 1-in-5 chance of +2.