Jump to content

Remove all skill levels and xp boosts


Colin

Recommended Posts

I'd like to reset character skill levels and xp through lua. I have found the function LoseLevel, but this would require lots of checking current level and various other wasteful calls. Is it possible to do a full reset of skill levels? Or will I need to build a custom function to run through all skills.

 

-Colin

Link to comment
Share on other sites

Temporarily I have written the following function to perform more or less what I want.

 

--//
--// Clear all skills and xp
--// Author: Colin J.D. Stewart | Updated: 14.08.2022
--// 
local function clearSkillLevels(player)
    local pl = PerkFactory.PerkList;
    local xp = player:getXp();
    
    for i = 0, pl:size()-1 do
        local info = pl:get(i);
        local pk = info:getType();        
        local curLevel = player:getPerkLevel(pk);
        
        if curLevel > 0 then
            for i = curLevel, 0, -1 do
                player:LoseLevel(pk);
            end;
        end;
        
        xp:setXPToLevel(pk, player:getPerkLevel(pk));
    end;
end;

 

If there is no better way, then if someone can point me in right direction to also clear xp boosts for each skill. Thanks.

Edited by Colin
spoiler bbcode ruins code formatting
Link to comment
Share on other sites

Great, level0 is ideal

        if curLevel > 0 then
            player:level0(pk);
        end;

 

However, it still does not clear the xp boosts, the api docs don't have much info filled unfortunately.... Once I get home later tonight I will check through all the apis for what I need. Thanks.

Link to comment
Share on other sites

CharacterSave mod does it.

Beware it is easy to confuse XpBoost and XpMultiplier.

The first is related to profession and traits.

--remove all previous profession, traits [..] (incldues XpBoost removal)
character:getDescriptor():setProfession("unemployed");
character:getTraits():clear();

--alternative selective XpBoost removal (not tested)
character:getXp():setPerkBoost(perk, 0)

 

The second is related to skill books.

--add
player:getXp():addXpMultiplier(perk, multiplier, levelMin, levelMax);

--remove
player:getXp():getMultiplierMap():remove(perk)

--alternative remove functional equivalent with current vanilla state (not tested)
player:getXp():addXpMultiplier(perk, 1, levelMin, levelMax);

 

Edited by Tchernobill
add XpBoost removal exemple.
Link to comment
Share on other sites

Thanks guys, this will do the job for now :)

 

--//
--// Clear all skills and xp
--// Author: Colin J.D. Stewart | Updated: 15.08.2022
--// 
local function clearSkills(player)
	local pl = PerkFactory.PerkList;
	local xp = player:getXp();
	
	for i = 0, pl:size()-1 do
		local pk = pl:get(i):getType();		
		
		player:level0(pk);	--// Thanks Hugo Qwerty		
		xp:setXPToLevel(pk, player:getPerkLevel(pk));
		
		--//Thanks Tchernobill
		xp:setPerkBoost(pk, 0);
		xp:getMultiplierMap():remove(pk);
	end;
end;

 

Edited by Colin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...