Skip to content

Commit 78e5f21

Browse files
committed
update
1 parent 804801c commit 78e5f21

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

description.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"Bring Me The Head Mod" by thefamilygrog66
22
Modified by Jozet
33

4-
Mod provide simple possibility to add endless quantity of heads, depends on your skins mod
4+
Killer can get a head of killed player. Probability 30%. Conditions: only using sword.
55

6-
An example if your skin mod has 129 skins, so heads mod will use all this skin textures (edit init.lua before using)
6+
Before using change 'headnumber' value.

init.lua

+46-19
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ headnumber = 129
44

55
for i = 1, headnumber do
66

7-
local x = i + 1
8-
local y = i - 1
9-
if x > headnumber then x = 1 end
10-
if y < 1 then y = headnumber end
11-
127
minetest.register_node("heads:head_"..i, {
138
description = "Head Number "..i,
149
wield_scale = {x=1.5, y=1.5, z=1.5},
@@ -37,8 +32,9 @@ for i = 1, headnumber do
3732
fixed = { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
3833
},
3934
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
40-
drop = "heads:head_"..i,
41-
35+
sounds = default.node_sound_wood_defaults(),
36+
drop = "",
37+
stack_max = 1,
4238
after_place_node = function(pos, placer, itemstack)
4339

4440
local item = placer:get_wielded_item():to_string()
@@ -53,33 +49,64 @@ for i = 1, headnumber do
5349

5450
after_dig_node = function(pos, oldnode, oldmetadata, digger)
5551

52+
if not digger then return end
53+
5654
local meta = minetest.get_meta(pos)
55+
meta:from_table(oldmetadata)
5756
local description = meta:get_string("description")
5857

5958
local stack = ItemStack(oldnode.name)
6059
local meta2 = stack:get_meta()
6160
meta2:set_string("description", description)
62-
63-
minetest.add_item({x = pos.x, y = pos.y + 1, z = pos.z}, stack)
64-
61+
62+
if digger:get_inventory():room_for_item("main", stack) then
63+
digger:get_inventory():add_item('main', stack)
64+
else
65+
minetest.add_item({x = pos.x, y = pos.y + 1, z = pos.z}, stack)
66+
end
67+
6568
end,
6669

6770
})
6871

6972
end
7073

7174

72-
minetest.register_on_dieplayer(function(player)
73-
74-
local name = player:get_player_name()
75+
minetest.register_on_punchplayer(function(player, hitter, _, _, _, damage)
76+
if not (hitter and hitter:is_player()) then
77+
return
78+
end
79+
80+
local hp = player:get_hp()
81+
if hp - damage > 0 or hp <= 0 then
82+
return
83+
end
84+
85+
local hitter_name = hitter:get_player_name()
86+
local player_name = player:get_player_name()
87+
88+
local item = hitter:get_wielded_item():to_string()
89+
90+
local name = player_name
91+
7592
local pos = vector.round(player:getpos())
7693
local skin_num = string.match(skins.skins[name],"%d+")
7794

7895
local stack = ItemStack("heads:head_"..skin_num)
7996
local meta = stack:get_meta()
80-
meta:set_string("description", "Head of "..name)
81-
82-
minetest.sound_play("head_drop", {pos, gain = 1.0, })
83-
minetest.add_item({x = pos.x, y = pos.y + 1, z = pos.z}, stack)
84-
85-
end)
97+
98+
local rand
99+
100+
rand = math.random(1,100)
101+
102+
if string.match(item, "sword") and rand < 20 then
103+
--minetest.chat_send_all("*** Server: "..hitter_name.." killed " .. player_name ..""..item)
104+
105+
meta:set_string("description", "Head of "..name)
106+
minetest.sound_play("head_drop", {pos, gain = 1.0, })
107+
minetest.add_item({x = pos.x, y = pos.y + 1, z = pos.z}, stack)
108+
109+
end
110+
111+
112+
end)

0 commit comments

Comments
 (0)