Skip to content

Commit

Permalink
add police baton and medical support for taser
Browse files Browse the repository at this point in the history
  • Loading branch information
Elkien3 committed Dec 13, 2022
1 parent 78bfec1 commit d875b73
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mods/medical/body.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ minetest.register_on_rightclickplayer(function(player, clicker)
local wielditem = clicker:get_wielded_item()
local wieldname = wielditem:get_name()

if wieldname == "" and medical.data[name].unconscious and clicker:get_player_control().sneak then--use sneak to drag
if wieldname == "" and (medical.data[name].unconscious or (is_player_tased and is_player_tased(name))) and clicker:get_player_control().sneak then--use sneak to drag
local isdragged = false
for cname2, name2 in pairs(dragging_tbl) do
if name == name2 then
Expand All @@ -199,7 +199,7 @@ minetest.register_on_rightclickplayer(function(player, clicker)
elseif medical.data[name].injuries and medical.data[name].injuries[hitlimb] and medical.injury_handle(player, clicker, true, wieldname, hitlimb) then
--lol nothin
else
if wieldname == "" and medical.data[name].unconscious then--inventory access
if wieldname == "" and (medical.data[name].unconscious or (is_player_tased and is_player_tased(name))) then--inventory access
local allowfunc = function(inv, listname, index, stack, player2, count)
if not minetest.get_player_by_name(name) or vector.distance(player:get_pos(), clicker:get_pos()) > 10 then return 0 end
if count then
Expand Down
2 changes: 1 addition & 1 deletion mods/medical/hitloc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function medical.gethitloc(player, hitter, tool_capabilities, dir)
if player:is_player() then
local parent, bone, attachpos, attachrot = player:get_attach()
if parent and not parent:is_player() then
playeryaw = parent:get_yaw()
playeryaw = math.rad(parent:get_yaw())
playeryaw = playeryaw+math.rad(attachrot.y)
else
playeryaw = player:get_look_horizontal()
Expand Down
4 changes: 3 additions & 1 deletion mods/policetools/depends.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ basic_materials?
mesecons_pressureplates?
character_anim?
player_api?
unified_inventory?
unified_inventory?
interacthandler
medical?
70 changes: 67 additions & 3 deletions mods/policetools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ minetest.register_craft({
}
})

if knockout then
if knockout or medical then
local tasertbl = {}

local is_tased = {}
function is_player_tased(name)
if not name then return end
return is_tased[name] ~= nil
end
local probe = {
initial_properties = {
physical = true,
Expand All @@ -84,7 +88,34 @@ if knockout then
if math.random(math.ceil(vector.distance(target:get_pos(), minetest.get_player_by_name(self.owner):get_pos()))) ~= 1 then
local droppedstack = minetest.item_drop(target:get_wielded_item(), target, target:get_pos())
target:set_wielded_item(droppedstack or ItemStack())
knockout.knockout(target:get_player_name(), 7)
if knockout then
knockout.knockout(target:get_player_name(), 7)
else
local tname = target:get_player_name()
interacthandler.revoke(tname)
is_tased[tname] = self.owner
player_api.set_animation(target, "lay")
target:set_eye_offset({x=0, y=-13, z=0}, {x=0, y=0, z=0})
if not default.player_attached[tname] then
minetest.add_entity(target:get_pos(), "medical:unconsciousattach", tname)
end
minetest.after(7, function()
if is_tased[tname] and is_tased[tname] == self.owner then
target:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
is_tased[tname] = nil
interacthandler.grant(tname)
if target and target:get_player_name() then
local parent = target:get_attach()
if parent and parent:get_luaentity() and parent:get_luaentity().name == "medical:unconsciousattach" then
parent:remove()
else
medical.detach(tname)
end
end
player_api.set_animation(target, "stand")
end
end)
end
end
end
else
Expand Down Expand Up @@ -297,6 +328,39 @@ if minetest.get_modpath("character_anim") and minetest.get_modpath("player_api")
end
end

minetest.register_tool("policetools:baton", {
description = "Baton",
inventory_image = "policetools_baton.png",--https://www.tynker.com/minecraft/items/view/wood_sword/police-baton/5870bc8c1c36d1c7578b4569/
tool_capabilities = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
snappy={times={[2]=1.4, [3]=0.40}, uses=20, maxlevel=1},
},
damage_groups = {fleshy=4},
},
sound = {breaks = "default_tool_breaks"},
})
if minetest.get_modpath("basic_materials") then
minetest.register_craft({
output = 'policetools:baton',
recipe = {
{'', '', 'basic_materials:steel_bar'},
{'', 'basic_materials:steel_bar', ''},
{'basic_materials:steel_bar', 'dye_black','default:steel_ingot'},
}
})
else
minetest.register_craft({
output = 'policetools:baton',
recipe = {
{'', '', 'default:steel_ingot'},
{'', 'default:steel_ingot', ''},
{'default:steel_ingot', 'dye:black','default:steel_ingot'},
}
})
end

if jobs then
dofile(minetest.get_modpath("policetools").."/computer.lua")
end
Binary file added mods/policetools/textures/policetools_baton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d875b73

Please sign in to comment.