Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mt-mods/xp_redo
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS committed Apr 18, 2024
2 parents 90f420d + 143c088 commit 7a129a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions areas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
-- id -> { max=1000, min=100 }
local xp_areas = {}

function xp_redo.get_area_xp_limits(id)
return xp_areas[id] or {}
end

-- protection check
local old_is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
Expand Down
39 changes: 20 additions & 19 deletions mobs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,32 @@ local increase_inflicted_damage = function(player, value)
meta:set_int("inflicted_damage", count + value)
end

minetest.register_on_mods_loaded(function()
for _,entity in pairs(minetest.registered_entities) do
if entity.on_punch ~= nil and entity.hp_min ~= nil and entity.hp_min > 0 then

for _,entity in pairs(minetest.registered_entities) do
if entity.on_punch ~= nil and entity.hp_min ~= nil and entity.hp_min > 0 then
local originalPunch = entity.on_punch

local originalPunch = entity.on_punch
entity.on_punch = function(self, hitter,time_from_last_punch, tool_capabilities, direction)

entity.on_punch = function(self, hitter,time_from_last_punch, tool_capabilities, direction)
if tool_capabilities.damage_groups ~= nil and
tool_capabilities.damage_groups.fleshy ~= nil and
self.health ~= nil then
local rest = tool_capabilities.damage_groups.fleshy

if tool_capabilities.damage_groups ~= nil and
tool_capabilities.damage_groups.fleshy ~= nil and
self.health ~= nil then
local rest = tool_capabilities.damage_groups.fleshy

if hitter:is_player() then
-- xp_redo.add_xp(hitter:get_player_name(), rest * 2)
xp_redo.add_xp(hitter:get_player_name(), 1)
increase_inflicted_damage(hitter, rest * 2)
increment_punch_count(hitter)
if hitter:is_player() then
-- xp_redo.add_xp(hitter:get_player_name(), rest * 2)
xp_redo.add_xp(hitter:get_player_name(), 1)
increase_inflicted_damage(hitter, rest * 2)
increment_punch_count(hitter)
end
end
end

-- print(tool_capabilities.damage_groups.fleshy)
-- print(self.health)
-- print(tool_capabilities.damage_groups.fleshy)
-- print(self.health)

return originalPunch(self, hitter, time_from_last_punch, tool_capabilities, direction)
return originalPunch(self, hitter, time_from_last_punch, tool_capabilities, direction)
end
end
end
end
end)

0 comments on commit 7a129a5

Please sign in to comment.