Jump to content
Maris

How to add custom skill?

Recommended Posts

111.png.b702fe51fbc5aab4fe88e2a7e71be9d5.png

I found a function in the API:

AddPerk(PerkFactory.Perks perk, java.lang.String name, java.lang.String level1, java.lang.String level2, java.lang.String level3, java.lang.String level4, java.lang.String level5, int xp1, int xp2, int xp3, int xp4, int xp5, int xp6, int xp7, int xp8, int xp9, int xp10) 

But I can't use it. It exists in the game code but there is no examples how to use it. What strings are level1, level2, level3 etc? What should I give as first parameter?

So I have to make injection directly into interface in a very strange manner:

local function inject(u)
	local xp = u:getXp()
	local m = getmetatable(xp)
	local old_boost = m.__index.getPerkBoost
	m.__index.getPerkBoost = function(self, perk_type, ...)
		if perk_type == ClassCustomSkill then
			return 0
		end
		return old_boost(self, perk_type, ...)
	end
	local old_mult = m.__index.getMultiplier
	m.__index.getMultiplier = function(self, perk_type, ...)
		if perk_type == ClassCustomSkill then
			return 0
		end
		return old_mult(self, perk_type, ...)
	end
	m = getmetatable(u)
	m.__index.getXp = function(self, ... )
		return xp
	end
	local old_level = m.__index.getPerkLevel
	m.__index.getPerkLevel = function(self, perk_type, ...)
		if perk_type == ClassCustomSkill then
			return perk_type.level
		end
		return old_level(self, perk_type, ...)
	end
	local old_up = m.__index.LevelPerk
	m.__index.LevelPerk = function(self, perk_type, ...)
		if perk_type == ClassCustomSkill then
			return perk_type:LevelUp()
		end
		return old_up(self, perk_type, ...)
	end
end

I'd like to avoid these dirty hacks and to start using normal API.

 

 

Edited by Maris

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...