get xp from mobs
This commit is contained in:
parent
967b6fedd8
commit
64c3d0a643
@ -1,2 +1,3 @@
|
||||
classes
|
||||
default
|
||||
xp
|
||||
|
@ -27,6 +27,15 @@ function mobs.register_mob(name, def)
|
||||
speed = 0,
|
||||
anim = "",
|
||||
t = 0.0,
|
||||
|
||||
on_punch = function(self, player)
|
||||
if self.object:get_hp() <= 0 then
|
||||
if player and player:is_player() then
|
||||
xp.add_xp(player, def.xp or xp.get_xp(def.lvl, 10))
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.t = self.t + dtime
|
||||
if self.t > 1 then
|
||||
|
@ -8,6 +8,10 @@ xp.level_hud = {}
|
||||
xp.xp_file = minetest.get_worldpath() .. "/xp"
|
||||
xp.lvl_file = minetest.get_worldpath() .. "/levels"
|
||||
|
||||
function xp.get_xp(lvl, x)
|
||||
return (xp.lvl * lvl) / x
|
||||
end
|
||||
|
||||
function xp.add_xp(player, num)
|
||||
if xp.player_xp[player:get_player_name()] then
|
||||
xp.player_xp[player:get_player_name()] = xp.player_xp[player:get_player_name()] + num
|
||||
|
Loading…
x
Reference in New Issue
Block a user