aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/skills/sh_skillcommon.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-07-21 19:08:34 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-07-21 19:08:34 -0400
commit81d3d4eb333e226432a591461b84ed12f5ac9a3f (patch)
treed802983c3caf6683f1fd8eb881c7df65afa0d27b /gamemode/inventorysystem/skills/sh_skillcommon.lua
parentbfdf805676684a838dde5d4cdeb3d8c972d5003d (diff)
downloadartery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.gz
artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.bz2
artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.zip
Various updates
* Animation api now allows sequences to be played * items now have a .inv attribute that is set when they are added to shaped or equipment inventories * Refactored the way skill inventory is structured * Added some more methods to cl_common to move items around on a player * Minor update to nrequire to display purple message when asked to include a file that dosn't exist.
Diffstat (limited to 'gamemode/inventorysystem/skills/sh_skillcommon.lua')
-rw-r--r--gamemode/inventorysystem/skills/sh_skillcommon.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/gamemode/inventorysystem/skills/sh_skillcommon.lua b/gamemode/inventorysystem/skills/sh_skillcommon.lua
index 9c022eb..e0db95a 100644
--- a/gamemode/inventorysystem/skills/sh_skillcommon.lua
+++ b/gamemode/inventorysystem/skills/sh_skillcommon.lua
@@ -73,4 +73,21 @@ function lib.SkillList()
return skills
end
+local xpmult = 1.5 --the lower, the more lvl per xp
+function lib.levelfunc(val)
+ local curlvl = math.log(val,xpmult)
+ local prevlvlxp = xpmult ^ math.floor(curlvl)
+ local nextlvlxp = xpmult ^ (math.floor(curlvl) + 1)
+ local sp = nextlvlxp - prevlvlxp
+ local frac = (val - prevlvlxp) / ((sp ~= 0) and sp or 1) --don't divide by 0
+ return math.floor(curlvl), frac
+end
+
+function pmeta:GetSkill(name)
+ local loc = self:HasItem(name)
+ if not loc then return 0 end
+ local item = self:GetItem(loc)
+ return lib.levelfunc(item.ammt)
+end
+
return lib