add treatable cut wound
lotta stuff, don't feel like explaining, cheers
This commit is contained in:
parent
1e6f040bc8
commit
7797ad5d40
72
body.lua
72
body.lua
@ -1,3 +1,4 @@
|
||||
|
||||
minetest.register_entity("medical:body", {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
@ -10,62 +11,63 @@ minetest.register_entity("medical:body", {
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if not staticdata or staticdata == "" then staticdata = "Elkien" end--return end
|
||||
--self.object:set_acceleration({x=0, y=-10, z=0})
|
||||
self.owner = staticdata
|
||||
self.object:set_animation({x=162,y=167}, 1)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_yaw(math.random(-math.pi, math.pi))
|
||||
self.object:set_yaw(math.random(-math.pi, math.pi)) --todo: have a set rotation value
|
||||
medical.init_injuries(self)
|
||||
end,
|
||||
--[[get_staticdata = function(self)
|
||||
--return
|
||||
end,--]]
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
if not puncher:is_player() then return end
|
||||
local name = puncher:get_player_name()
|
||||
local wielditem = puncher:get_wielded_item()
|
||||
local wieldname = wielditem:get_name()
|
||||
local hitloc, local_hitloc = medical.gethitloc(self.object, puncher, tool_capabilities, dir)
|
||||
if medical.attachedtools[wieldname] then
|
||||
medical.attachedtools[wieldname](self, puncher, wielditem, hitloc, local_hitloc)
|
||||
local hitlimb = medical.getlimb(self.object, puncher, tool_capabilities, dir, hitloc)
|
||||
if not puncher:get_player_control(puncher).sneak and medical.attachedtools[wieldname] and medical.attachedtools[wieldname](self, puncher, wielditem, hitloc, local_hitloc) then
|
||||
|
||||
elseif medical.data[name].injuries and medical.data[name].injuries[hitlimb] then
|
||||
medical.injury_handle(self.owner, puncher, false, wieldname, hitlimb)
|
||||
end
|
||||
-- attach things
|
||||
end,
|
||||
on_rightclick = function(self, clicker)
|
||||
if not clicker:is_player() then return end
|
||||
local name = clicker:get_player_name()
|
||||
local wielditem = clicker:get_wielded_item()
|
||||
local wieldname = wielditem:get_name()
|
||||
local hitloc, local_hitloc = medical.gethitloc(self.object, clicker, nil, nil)
|
||||
if medical.usedtools[wieldname] then
|
||||
medical.usedtools[wieldname](self, clicker, wielditem, hitloc, local_hitloc)
|
||||
local hitlimb = medical.getlimb(self.object, clicker, tool_capabilities, dir, hitloc)
|
||||
if not clicker:get_player_control(clicker).sneak and medical.usedtools[wieldname] and medical.usedtools[wieldname](self, clicker, wielditem, hitloc, local_hitloc) then
|
||||
|
||||
elseif medical.data[name].injuries and medical.data[name].injuries[hitlimb] then
|
||||
medical.injury_handle(self.owner, clicker, true, wieldname, hitlimb)
|
||||
end
|
||||
-- use things
|
||||
end
|
||||
})
|
||||
|
||||
--open fracture test
|
||||
minetest.register_entity("medical:fracturetest", {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
weight = 5,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual = "mesh",
|
||||
mesh = "bone.b3d",
|
||||
visual_size = {x=1, y=1},--{x=.211, y=.211},
|
||||
textures = {"default_clay.png","default_clay.png","default_clay.png","default_clay.png","default_clay.png","default_clay.png"}, -- number of required textures depends on visual
|
||||
colors = {}, -- number of required colors depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
minetest.after(1, function()
|
||||
local all_objects = minetest.get_objects_inside_radius(self.object:get_pos(), 10)
|
||||
local _,obj
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:get_entity_name() == "medical:body" then
|
||||
minetest.chat_send_all(obj:get_entity_name())
|
||||
self.object:set_attach(obj, "Arm_Right", {x=0,y=4,z=0}, {x=1,y=0,z=math.random(-10, 10)})
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
local injuryflip = {Arm_Right = 180, Arm_Left = 180, Leg_Right = 180, Leg_Left = 180}
|
||||
local injurypos = {Head = -1.2}
|
||||
|
||||
function medical.init_injuries(self)
|
||||
local name = self.owner
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local data = medical.data[name]
|
||||
local pos = self.object:get_pos()
|
||||
if medical.data[name].injuries then
|
||||
for bone, injury in pairs (medical.data[name].injuries) do
|
||||
local injurydef = medical.injuries[injury.name]
|
||||
local ent = minetest.add_entity(pos, injurydef.entity, minetest.serialize({owner = name, bone = bone}))
|
||||
local rot = injuryflip[bone] or 0
|
||||
local pos = injurypos[bone] or 0
|
||||
ent:set_attach(self.object, bone, {x=0, y=2, z=pos}, {x=rot,y=0,z=math.random(-10, 10)})
|
||||
medical.data[name].injuries[bone].ent = ent
|
||||
end
|
||||
end
|
||||
end
|
42
hitloc.lua
42
hitloc.lua
@ -1,32 +1,20 @@
|
||||
local limb_location = {}
|
||||
--standing locations
|
||||
local limb = {}
|
||||
limb["standing"]= {Head = {x=0,y=1.6,z=0}, Body = {x=0,y=1,z=0}, Arm_Right = {x=.3,y=1,z=0}, Arm_Left = {x=-.3,y=1,z=0}, Leg_Right = {x=.1,y=.4,z=0}, Leg_Left = {x=-.1,y=.4,z=0}}
|
||||
|
||||
-- sitting locations
|
||||
limb["sitting"] = {Head = {x=0,y=.9,z=0}, Body = {x=0,y=.4,z=0}, Arm_Right = {x=.3,y=.4,z=0}, Arm_Left = {x=-.3,y=.4,z=0}, Leg_Right = {x=.1,y=.1,z=.35}, Leg_Left = {x=-.1,y=.1,z=.35}}
|
||||
|
||||
--todo: make these change depending on what state the patient is in.
|
||||
--[[ standing locations
|
||||
limb_location.head = {x=0,y=1.6,z=0}
|
||||
limb_location.torso = {x=0,y=1,z=0}
|
||||
limb_location.rightarm = {x=.3,y=1,z=0}
|
||||
limb_location.leftarm = {x=-.3,y=1,z=0}
|
||||
limb_location.rightleg = {x=.1,y=.4,z=0}
|
||||
limb_location.leftleg = {x=-.1,y=.4,z=0}
|
||||
--]]
|
||||
--[[ sitting locations
|
||||
limb_location.head = {x=0,y=.9,z=0}
|
||||
limb_location.torso = {x=0,y=.4,z=0}
|
||||
limb_location.rightarm = {x=.3,y=.4,z=0}
|
||||
limb_location.leftarm = {x=-.3,y=.4,z=0}
|
||||
limb_location.rightleg = {x=.1,y=.1,z=.35}
|
||||
limb_location.leftleg = {x=-.1,y=.1,z=.35}
|
||||
--]]
|
||||
-- laying locations
|
||||
limb_location.head = {x=0,y=.1,z=-.65}
|
||||
limb_location.torso = {x=0,y=.1,z=-.2}
|
||||
limb_location.rightarm = {x=.4,y=.1,z=-.125}
|
||||
limb_location.leftarm = {x=-.4,y=.1,z=-.125}
|
||||
limb_location.rightleg = {x=.2,y=.1,z=.5}
|
||||
limb_location.leftleg = {x=-.2,y=.1,z=.5}
|
||||
limb["laying"] = {Head = {x=0,y=.1,z=-.65}, Body = {x=0,y=.1,z=-.2}, Arm_Right = {x=.4,y=.1,z=-.125}, Arm_Left = {x=-.4,y=.1,z=-.125}, Leg_Right = {x=.2,y=.1,z=.5}, Leg_Left = {x=-.2,y=.1,z=.5}}
|
||||
|
||||
local DEBUG_WAYPOINT = true
|
||||
local DEBUG_CHAT = true
|
||||
function medical.get_limb_locations(self)
|
||||
--todo: make these change depending on what state the patient is in.
|
||||
return limb["laying"]
|
||||
end
|
||||
|
||||
local DEBUG_WAYPOINT = false
|
||||
local DEBUG_CHAT = false
|
||||
|
||||
local function rotateVector(x, y, a)
|
||||
local c = math.cos(a)
|
||||
@ -131,7 +119,7 @@ function medical.getlimb(player, hitter, tool_capabilities, dir, hitloc)
|
||||
else
|
||||
playeryaw = player:get_yaw()
|
||||
end
|
||||
for id, pos in pairs(limb_location) do
|
||||
for id, pos in pairs(medical.get_limb_locations(player)) do
|
||||
local x, z = rotateVector(pos.x, pos.z, playeryaw)
|
||||
local rot_pos = {x=x,y=pos.y,z=z}
|
||||
local adj_pos = vector.add(playerpos, rot_pos)
|
||||
|
14
init.lua
14
init.lua
@ -2,17 +2,17 @@ medical = {}
|
||||
medical.mod_storage = minetest.get_mod_storage()
|
||||
medical.usedtools = {}
|
||||
medical.attachedtools = {}
|
||||
medical.data = medical.mod_storage:to_table() or {}
|
||||
if not medical.data.vitals then medical.data.vitals = {} end
|
||||
if not medical.data.injuries then medical.data.injuries = {} end
|
||||
|
||||
--mod_storage:from_table(medical)
|
||||
medical.data = minetest.deserialize(medical.mod_storage:get_string("data")) or {}
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
dofile(modpath.."/timers.lua")
|
||||
dofile(modpath.."/controls.lua")
|
||||
dofile(modpath.."/timers.lua")
|
||||
dofile(modpath.."/vitals.lua")
|
||||
dofile(modpath.."/hitloc.lua")
|
||||
dofile(modpath.."/body.lua")
|
||||
dofile(modpath.."/tools.lua")
|
||||
dofile(modpath.."/tools.lua")
|
||||
dofile(modpath.."/injuries.lua")
|
||||
|
||||
medical.data["Elkien"] = {}
|
||||
medical.data["Elkien"].injuries = {Arm_Left = {name = "cut"}}
|
111
injuries.lua
Normal file
111
injuries.lua
Normal file
@ -0,0 +1,111 @@
|
||||
medical.injuries = {}
|
||||
|
||||
function medical.injury_handle(owner, player, rightclick, tool, hitlimb, finish)
|
||||
local name = player:get_player_name()
|
||||
local injury = medical.data[owner].injuries[hitlimb]
|
||||
local injurydef = medical.injuries[injury.name]
|
||||
if not injury.step then injury.step = 1 end
|
||||
local stepdef = injurydef.steps[injury.step]
|
||||
if finish then
|
||||
injury.step = injury.step + 1
|
||||
if not injurydef.steps[injury.step] then
|
||||
if injury.ent then
|
||||
injury.ent:remove()
|
||||
medical.data[owner].injuries[hitlimb] = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
if tool ~= stepdef.tool or rightclick ~= stepdef.rightclick then
|
||||
return end
|
||||
end
|
||||
local stopfunc
|
||||
local stoparg
|
||||
if stepdef.hud then
|
||||
medical.hud[name] = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = 0.5, y = 0.55},
|
||||
offset = {x = 0, y = 0},
|
||||
text = stepdef.hud,
|
||||
scale = { x = 10, y = 10},
|
||||
alignment = { x = 0, y = 0 },
|
||||
})
|
||||
player:hud_set_flags({wielditem=false})
|
||||
stoparg = name
|
||||
stopfunc = function(stoparg)
|
||||
local player = minetest.get_player_by_name(stoparg)
|
||||
if medical.hud[stoparg] then
|
||||
player:hud_remove(medical.hud[stoparg])
|
||||
medical.hud[stoparg] = nil
|
||||
player:hud_set_flags({wielditem=true})
|
||||
end
|
||||
end
|
||||
end
|
||||
if stepdef.time then
|
||||
medical.start_timer(owner, stepdef.time, false, {owner, player, rightclick, tool, hitlimb, true}, medical.injury_handle, stoparg, stopfunc, "RMB", name)
|
||||
else
|
||||
medical.injury_handle(owner, player, rightclick, tool, hitlimb, true)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("medical:cut", {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
weight = 5,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual = "cube",
|
||||
visual_size = {x=.211, y=.211},
|
||||
textures = {"invis.png", "invis.png", "invis.png", "invis.png", "invis.png", "medical_cut.png"}, -- number of required textures depends on visual -- number of required textures depends on visual
|
||||
colors = {}, -- number of required colors depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if not staticdata or staticdata == "" then self.object:remove() return end
|
||||
local data = minetest.deserialize(staticdata)
|
||||
self.owner = data.owner
|
||||
self.bone = data.bone
|
||||
end
|
||||
})
|
||||
|
||||
medical.injuries["cut"] = {
|
||||
entity = "medical:cut",
|
||||
steps = {{tool = "", rightclick = true, time = 5, hud = "applypressure.png"}},--steps = {"medical:dressing", "", "medical:dressing", "", "medical:tourniquet", ""},-- maybe make the optional steps removed if the initial severety of the wound is less severe. would need a way to make sure the player knows thta in real life tourniquets should only be applied in real situation only if neccisary and you know how, and should only be removed by professionals, lest bleeding start again.
|
||||
--vitals = {depends on severity and current treatment},
|
||||
healtime = nil,-- maybe make a severity value that starts at 1 or something, and goes down as you treat, or if the wound is less severe to start with.
|
||||
medical_step = nil,
|
||||
}
|
||||
|
||||
|
||||
--open fracture test
|
||||
minetest.register_entity("medical:fracturetest", {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
weight = 5,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual = "mesh",
|
||||
mesh = "bone.b3d",
|
||||
visual_size = {x=1, y=1},--{x=.211, y=.211},
|
||||
textures = {"default_clay.png","default_clay.png","default_clay.png","default_clay.png","default_clay.png","default_clay.png"}, -- number of required textures depends on visual
|
||||
colors = {}, -- number of required colors depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
minetest.after(1, function()
|
||||
self.object:remove()
|
||||
local all_objects = minetest.get_objects_inside_radius(self.object:get_pos(), 10)
|
||||
local _,obj
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:get_entity_name() == "medical:body" then
|
||||
minetest.chat_send_all(obj:get_entity_name())
|
||||
self.object:set_attach(obj, "Arm_Right", {x=0,y=4,z=0}, {x=1,y=0,z=math.random(-10, 10)})
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
BIN
textures/applypressure.png
Normal file
BIN
textures/applypressure.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
textures/blackline.png
Normal file
BIN
textures/blackline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 546 B |
BIN
textures/bpcuff.png
Normal file
BIN
textures/bpcuff.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
textures/bpcuffbladder.png
Normal file
BIN
textures/bpcuffbladder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
textures/medical_cut.png
Normal file
BIN
textures/medical_cut.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 855 B |
51
timers.lua
51
timers.lua
@ -1,6 +1,6 @@
|
||||
medical.timers = {}
|
||||
|
||||
function medical.start_timer(name, length, loop, arg, func)
|
||||
function medical.start_timer(name, length, loop, arg, func, stoparg, stopfunc, cancel_on_release, cancel_owner)
|
||||
local index
|
||||
if name then
|
||||
index = name
|
||||
@ -20,13 +20,32 @@ function medical.start_timer(name, length, loop, arg, func)
|
||||
medical.timers[index].loop = loop
|
||||
medical.timers[index].arg = arg
|
||||
medical.timers[index].func = func
|
||||
medical.timers[index].stoparg = stoparg
|
||||
medical.timers[index].stopfunc = stopfunc
|
||||
if cancel_owner and cancel_on_release then
|
||||
medical.timers[index].cancel_on_release = cancel_on_release
|
||||
medical.timers[index].cancel_owner = cancel_owner
|
||||
local player = minetest.get_player_by_name(cancel_owner)
|
||||
if player and not medical.lookingplayer[cancel_owner] then medical.lookingplayer[cancel_owner] = {dir = player:get_look_dir(), pos = player:get_pos()} end
|
||||
end
|
||||
return index
|
||||
end
|
||||
|
||||
function medical.stop_timer(name, runonce)
|
||||
local timer = medical.timers[name]
|
||||
if runonce then
|
||||
timer.func(timer.arg)
|
||||
if type(timer.arg) == "table" then
|
||||
timer.func(unpack(timer.arg))
|
||||
else
|
||||
timer.func(timer.arg)
|
||||
end
|
||||
end
|
||||
if timer.stopfunc then
|
||||
if type(timer.stoparg) == "table" then
|
||||
timer.stopfunc(unpack(timer.stoparg))
|
||||
else
|
||||
timer.stopfunc(timer.stoparg)
|
||||
end
|
||||
end
|
||||
medical.timers[name] = nil
|
||||
end
|
||||
@ -35,12 +54,32 @@ minetest.register_globalstep(function(dtime)
|
||||
for index, timer in pairs (medical.timers) do
|
||||
timer.timeleft = timer.timeleft - dtime
|
||||
if timer.timeleft <= 0 then
|
||||
timer.func(timer.arg)
|
||||
if timer.loop then
|
||||
medical.start_timer(index, timer.length, timer.loop, timer.arg, timer.func)
|
||||
if type(timer.arg) == "table" then
|
||||
timer.func(unpack(timer.arg))
|
||||
else
|
||||
medical.stoptimer(name)
|
||||
timer.func(timer.arg)
|
||||
end
|
||||
if timer.loop then
|
||||
medical.start_timer(index, timer.length, timer.loop, timer.arg, timer.func, timer.stoparg, timer.stopfunc, timer.cancel_on_release, timer.cancel_owner)
|
||||
else
|
||||
medical.stop_timer(index)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
controls.register_on_release(function(player, key, time)
|
||||
local name = player:get_player_name()
|
||||
for index, timer in pairs (medical.timers) do
|
||||
if name == timer.cancel_owner and timer.cancel_on_release == key then
|
||||
medical.stop_timer(index)
|
||||
end
|
||||
end
|
||||
end)
|
||||
medical.register_on_lookaway(function(player, name)
|
||||
for index, timer in pairs (medical.timers) do
|
||||
if name == timer.cancel_owner and timer.cancel_on_release then
|
||||
medical.stop_timer(index)
|
||||
end
|
||||
end
|
||||
end)
|
147
tools.lua
147
tools.lua
@ -9,10 +9,10 @@ medical.usedtools[""] = function(self, clicker, wielditem, hitloc, local_hitloc)
|
||||
vitalpoints.pedalright = {x=.20,y=.1,z=.7}
|
||||
vitalpoints.pedalleft = {x=-.20,y=.1,z=.7}
|
||||
local distance, hitpart = medical.getclosest(vitalpoints, local_hitloc)
|
||||
if distance > .15 then return end
|
||||
if distance > .15 then return false end
|
||||
local cname = clicker:get_player_name()
|
||||
local sname = self.owner
|
||||
if medical.hud[cname] then clicker:hud_remove(medical.hud[cname]) medical.hud[cname] = nil end
|
||||
if not medical.lookingplayer[cname] then medical.lookingplayer[cname] = {dir = clicker:get_look_dir(), pos = clicker:get_pos()} end
|
||||
medical.hud[cname] = clicker:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = 0.5, y = 0.55},
|
||||
@ -21,7 +21,8 @@ medical.usedtools[""] = function(self, clicker, wielditem, hitloc, local_hitloc)
|
||||
scale = { x = 10, y = 10},
|
||||
alignment = { x = 0, y = 0 },
|
||||
})
|
||||
medical.start_timer(cname.."pulsecheck", 60/medical.data.vitals[cname].pulse, true, cname, --todo: change this to give the patient's pulse instead of yours
|
||||
clicker:hud_set_flags({wielditem=false})
|
||||
medical.start_timer(sname.."pulsecheck", 60/medical.data[sname].vitals.pulse, true, sname,
|
||||
function(arg)
|
||||
minetest.sound_play("human-heartbeat-daniel_simon", {
|
||||
pos = hitloc,
|
||||
@ -41,23 +42,133 @@ medical.usedtools[""] = function(self, clicker, wielditem, hitloc, local_hitloc)
|
||||
hitter:hud_remove(circle)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end,
|
||||
cname,
|
||||
function(stoparg)
|
||||
local player = minetest.get_player_by_name(stoparg)
|
||||
if medical.hud[stoparg] then
|
||||
player:hud_remove(medical.hud[stoparg])
|
||||
medical.hud[stoparg] = nil
|
||||
player:hud_set_flags({wielditem=true})
|
||||
end
|
||||
end, "RMB", cname
|
||||
)
|
||||
return true
|
||||
end
|
||||
medical.attachedtools[""] = function(self, clicker, wielditem, hitloc, local_hitloc)
|
||||
--local limb = medical.getlimb(self.object, clicker, nil, nil, hitloc)
|
||||
local all_objects = minetest.get_objects_inside_radius(hitloc, 10)
|
||||
local cname = clicker:get_player_name()
|
||||
for _,obj in ipairs(all_objects) do
|
||||
local pos = obj:get_pos()
|
||||
local marker = clicker:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
name = obj:get_entity_name(),
|
||||
number = 0xFF0000,
|
||||
world_pos = obj:get_pos()
|
||||
})
|
||||
minetest.after(5, function()
|
||||
local hitter = minetest.get_player_by_name(cname)
|
||||
if hitter then
|
||||
hitter:hud_remove(marker)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
controls.register_on_release(function(player, key, time)
|
||||
local name = player:get_player_name()
|
||||
if key == "RMB" and medical.hud[name] then
|
||||
player:hud_remove(medical.hud[name]) medical.hud[name] = nil
|
||||
medical.lookingplayer[name] = nil
|
||||
medical.stop_timer(name.."pulsecheck", false)
|
||||
minetest.register_tool("medical:bpcuff", {
|
||||
description = "Blood Pressure Cuff",
|
||||
inventory_image = "bpcuff.png",
|
||||
})
|
||||
|
||||
minetest.register_tool("medical:bpbladder", {
|
||||
description = "Blood Pressure Cuff",
|
||||
inventory_image = "bpcuffbladder.png",
|
||||
on_use = function(itemstack, player, pointed_thing)
|
||||
--inflate bp cuff
|
||||
end
|
||||
end)
|
||||
medical.register_on_lookaway(function(player, name)
|
||||
if medical.hud[name] then
|
||||
player:hud_remove(medical.hud[name])
|
||||
medical.hud[name] = nil
|
||||
medical.lookingplayer[name] = nil
|
||||
medical.stop_timer(name.."pulsecheck", false)
|
||||
})
|
||||
|
||||
minetest.register_entity("medical:bpcuff", {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
weight = 5,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual = "cube",
|
||||
visual_size = {x=.25, y=.25},--{x=.211, y=.211},
|
||||
textures = {"default_coal_block.png", "default_coal_block.png", "default_coal_block.png", "default_coal_block.png", "default_coal_block.png", "default_coal_block.png"}, -- number of required textures depends on visual
|
||||
colors = {}, -- number of required colors depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if not staticdata or staticdata == "" then self.object:remove() end
|
||||
self.owner = staticdata
|
||||
end
|
||||
end)
|
||||
})
|
||||
|
||||
minetest.register_entity("medical:line", {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
weight = 5,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual = "cube",
|
||||
visual_size = {x=.05, y=.1},
|
||||
textures = {"blackline.png", "blackline.png", "blackline.png", "blackline.png", "blackline.png", "blackline.png"}, -- number of required textures depends on visual
|
||||
colors = {}, -- number of required colors depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_step = function(self, dtime)
|
||||
if not self.target or not self.owner then self.object:remove() return end
|
||||
local player = minetest.get_player_by_name(self.owner)
|
||||
local op = player:get_pos()
|
||||
op.y = op.y + 1
|
||||
op = vector.add(op, vector.multiply(player:get_player_velocity(), .1))
|
||||
if self.lastpos and vector.equals(self.lastpos, op) then return end
|
||||
local tp = self.target
|
||||
|
||||
if vector.distance(op, tp) > 1.5 then
|
||||
local inv = player:get_inventory()
|
||||
local list = "main"
|
||||
return
|
||||
end
|
||||
|
||||
local delta = vector.subtract(op, tp)
|
||||
local yaw = math.atan2(delta.z, delta.x) - math.pi / 2
|
||||
local pitch = math.atan2(delta.y, math.sqrt(delta.z*delta.z + delta.x*delta.x))
|
||||
pitch = pitch + math.pi/2
|
||||
|
||||
self.object:move_to({x=(op.x+tp.x)/2, y=(op.y+tp.y)/2, z=(op.z+tp.z)/2, })
|
||||
self.object:set_rotation({x=pitch, y=yaw, z=0})
|
||||
self.object:set_properties({visual_size = {x=.05, y=vector.distance(tp, op)}})
|
||||
self.lastpos = op
|
||||
end,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if not staticdata or staticdata == "" then self.object:remove() end
|
||||
self.owner = staticdata
|
||||
self.target = self.object:get_pos()
|
||||
end
|
||||
})
|
||||
|
||||
medical.attachedtools["medical:bpcuff"] = function(self, clicker, wielditem, hitloc, local_hitloc)
|
||||
local limb = medical.getlimb(self.object, clicker, nil, nil, hitloc)
|
||||
local bone
|
||||
if limb == "rightarm" then bone = "Arm_Right" elseif limb == "leftarm" then bone = "Arm_Left" else return end
|
||||
local pos = self.object:get_pos()
|
||||
local obj = minetest.add_entity(pos, "medical:bpcuff", clicker:get_player_name())
|
||||
minetest.after(0, function()
|
||||
local marker = clicker:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
name = "hit",
|
||||
number = 0xFF0000,
|
||||
world_pos = obj:get_pos()
|
||||
}) end)
|
||||
obj:set_attach(self.object, bone, {x=0,y=.5,z=0}, {x=0,y=0,z=0})
|
||||
--local obj = minetest.add_entity(hitloc, "medical:line", clicker:get_player_name())
|
||||
minetest.after(0, function() clicker:set_wielded_item({name = ""})end)
|
||||
end
|
34
vitals.lua
34
vitals.lua
@ -8,22 +8,36 @@ default_vitals.volume = 5000 --milliliters
|
||||
default_vitals.systolic = 110 --mmHg
|
||||
default_vitals.diastolic = 70 --mmHg
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if not medical.data[name] then
|
||||
medical.data[name] = {}
|
||||
end
|
||||
if not medical.data[name].vitals then
|
||||
medical.data[name].vitals = default_vitals
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 5 then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
--player:set_bone_position("Head", {x=0,y=10,z=0}, {x=0,y=180,z=0})
|
||||
--local bonepos = player:get_bone_position("Head")
|
||||
--[[local text = ""
|
||||
for id, data in pairs (bonepos) do
|
||||
text = text.." "..tostring(id)..":"..dump(data)
|
||||
end
|
||||
minetest.chat_send_all(text)--]]
|
||||
local name = player:get_player_name()
|
||||
if not medical.data.vitals[name] then medical.data.vitals[name] = default_vitals end
|
||||
|
||||
if medical.data.injuries[name] then
|
||||
if medical.data[name].injuries then
|
||||
--handle loss of vital signs due to injuries
|
||||
for index, injury in pairs (medical.data[name].injuries) do
|
||||
local injurydef = medical.injuries[injury.name]
|
||||
if injurydef.medical_step then
|
||||
injurydef.medical_step()
|
||||
end
|
||||
if injury.vitals then
|
||||
for vital, amount in pairs (injury.vitals) do
|
||||
medical.data[name].vitals[vital] = medical.data[name].vitals[vital] - amount
|
||||
end
|
||||
end
|
||||
--handle loss of vital signs due to injuries
|
||||
end
|
||||
end
|
||||
|
||||
if hunger then
|
||||
@ -34,7 +48,7 @@ minetest.register_globalstep(function(dtime)
|
||||
--handle thirst things
|
||||
end
|
||||
|
||||
mv = medical.data.vitals[name]
|
||||
local mv = medical.data[name].vitals
|
||||
local perfusion = ((mv.oxygen-60)/34) * ((mv.pulse-30)/40) * ((mv.volume-2000)/3000) * ((mv.temp-70)/28)
|
||||
|
||||
if perfusion < .9 then --compensate by raising pulse and respiratory rate
|
||||
|
Loading…
x
Reference in New Issue
Block a user