re-enabled rotting dropped meat via meat_raw_item

This commit is contained in:
Hildigerr Vergaray 2020-04-20 18:05:50 -07:00
parent c0affdc1c2
commit 6fcf674c72
5 changed files with 96 additions and 80 deletions

View File

@ -15,7 +15,7 @@ Upstream contributions have been included from:
- **Notify of Spawns** for debugging, *disabled* by default
- **Spawn Interval** will determine how often the spawning ABM is executed, *30* seconds by default
- **Drop Litter** if mobs should drop dropps when dying naturally, *disabled* by default
- **Meat Rots** if raw meat should rot periodically, *disabled* by default
- **Meat Rots** if raw meat should rot periodically, *enabled* by default
- **Rats**, **Sheep**, and **monsters** can be drawn with a default 3D *mesh*, a 2D sprite, or be disabled.
## The Mobs ##
@ -52,9 +52,8 @@ Upstream contributions have been included from:
## Miscellaneous ##
- [x] Raw and Cooked Meat
- [ ] Meat spoilage if it remains uncooked (untested)
-- [X] Raw meet can be preserved through "cheating" or using a refridgerator provided
by VanessaE's [Home Decor](https://gitlab.com/VanessaE/homedecor_modpack) Mod
- [x] Meat spoilage if it remains uncooked
-- [ ] Raw meet can be preserved using VanessaE's [Home Decor](https://gitlab.com/VanessaE/homedecor_modpack) refridgerator. (Not re-tested)
- [x] Overcooking and using the result to make dye
- [ ] Cages for Pet Rodents (TODO: move into separate mod)
-- They must be fed apples and have a bucket of water available to survive

View File

@ -5,8 +5,8 @@
-- rabbits mesh is backwards
--HIGH PRIORITY:
-- support more food, --check balance-- [cheese]
-- refactor rotten meat, add fresh meat, and remove rotten meat litter eventually:
-- "fresh meat" --> "meat" --> "rotten meat" --> ""
-- add fresh meat, and remove rotten meat litter eventually:
-- "fresh meat" --> "raw meat" --> "cooked meat" | ("rotten meat" --> "")
-- update images (including texture pack)
--MED PRIORITY:
-- add more animals: (continue pulling)

View File

@ -5,8 +5,6 @@ local use_homedecor = minetest.get_modpath("homedecor")
----CONFIG OPTIONS:
--Chances of meat rotting [1-100]
--if math.random(1,100) <= CHANCE then it will rot
local ROT_IN_WATER_CHANCE = 1 --DEFAULT:50
local ROT_ON_GROUND_CHANCE = 1 --DEFAULT:33
local ROT_IN_POCKET_CHANCE = 33 --DEFAULT:33
local ROT_IN_STORAGE_CHANCE = 33 --DEFAULT:33
local ROT_WHILE_COOKING_CHANCE = 33 --DEFAULT:33
@ -112,75 +110,4 @@ minetest.register_globalstep( function(dtime)
end)
end
--Rot Droped Meat
if ROT_ON_GROUND_CHANCE > 0 then
minetest.register_abm({
nodenames = {"air"},
neighbors = { "group:stone", "group:sand",
--"group:soil" :
"default:dirt_with_grass", "default:dirt_with_grass_footsteps", "default:dirt",
--etc:
"default:gravel", "default:sandstone", "default:clay",
"default:brick", "default:wood",
},
interval = GROUND_TIMER, -- (operation interval)
chance = 1, -- (chance of trigger is 1.0/this)
action = function(pos, node)
local objs = minetest.get_objects_inside_radius(pos, 1)
if objs then
for i,j in ipairs(objs) do
local k = j:get_luaentity()
if k then
local str = k.itemstring
if str ~= nil then
if str == "mobs:meat_raw" then
if math.random(1,100) <= ROT_ON_GROUND_CHANCE then -- about 1/3 chance --TESTING
objs[i]:remove()
minetest.add_item(pos, "mobs:meat_rotten")
end -- if by chance
end -- if is meat
end -- itemstring exists
end -- luaidentity exists
end -- for objs
end -- objects exist
end -- func
})
end
if ROT_IN_WATER_CHANCE > 0 then
minetest.register_abm({
nodenames = {"default:water_source", "default:water_flowing"},
neighbors = { "group:stone", "group:sand",
--"group:soil" :
"default:dirt_with_grass", "default:dirt_with_grass_footsteps", "default:dirt",
--etc:
"default:gravel", "default:sandstone", "default:clay",
"default:brick", "default:wood",
},
interval = WATER_TIMER, -- (operation interval)
chance = 1, -- (chance of trigger is 1.0/this)
action = function(pos, node)
local objs = minetest.get_objects_inside_radius(pos, 1)
if objs then
for i,j in ipairs(objs) do
local k = j:get_luaentity()
if k then
local str = k.itemstring
if str ~= nil then
-- if str == "mobs:meat_rotten" then
-- objs[i]:remove()
-- else
if str == "mobs:meat_raw" then
if math.random(1,100) <= ROT_IN_WATER_CHANCE then
objs[i]:remove()
minetest.add_item(pos, "mobs:meat_rotten")
end -- if by chance
end -- if is meat
end -- itemstring exists
end -- luaidentity exists
end -- for objs
end -- objects exist
end -- func
})
end
-------------------------------------EOF----------------------------------------

View File

@ -4,12 +4,102 @@
minetest.register_craftitem("mobs:meat_raw", {
description = "Raw Meat",
inventory_image = "mobs_meat_raw.png",
on_drop = function(itemstack, dropper, pos)
local data = {
timer = 0,
quantity = itemstack:get_count(),
}
if dropper and dropper:is_player() then
pos.y = pos.y + 1.2
data.velocity = dropper:get_look_dir()
data.velocity.x = data.velocity.x * 2.9
data.velocity.y = data.velocity.y * 2.9 + 2
data.velocity.z = data.velocity.z * 2.9
end
minetest.add_entity(pos, "mobs:meat_raw_item", minetest.serialize(data))
itemstack:clear()
return itemstack
end,
on_use = function(itemstack, user, pointed_thing)
minetest.do_item_eat(math.random(-4,2), nil, itemstack, user, pointed_thing)
end,
groups = { eatable=1, meat=1 },
})
minetest.register_entity("mobs:meat_raw_item", {
physical = true,
visual = "item",
wield_item = "mobs:meat_raw",
visual_size = {x=0.25, y=0.25},
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
automatic_rotate = math.pi/2,
staticdata = {
timer = 0,
quantity = 1,
},
get_staticdata = function(self)
return minetest.serialize(self.staticdata)
end,
on_activate = function(self, staticdata, dtime_s)
self.object:set_armor_groups({punch_operable=1})
if staticdata then
self.staticdata = minetest.deserialize(staticdata)
end
if self.quantity == 0 then
self.object:remove()
return
end
if self.staticdata.velocity then
self.object:set_velocity(self.staticdata.velocity)
end
self.object:set_acceleration({x=0, y=-10, z=0})
self:on_step(dtime_s)
end,
on_step = minetest.settings:get_bool("mobs.meat_rots", true) and
function(self, dtime)
if self.object:get_velocity().y == 0 then
self.object:set_velocity({x=0, y=0, z=0})
end
self.staticdata.timer = self.staticdata.timer+dtime
if self.staticdata.timer > 360 then -- GROUND_TIMER
if math.random(1, 100) <= 33 then -- ROT_ON_GROUND_CHANCE
pos = self.object:get_pos()
quantity_string = tostring(self.staticdata.quantity)
if minetest.add_item(pos, "mobs:meat_rotten "..quantity_string) then
mobs.barf("info", "meat", "rotted", minetest.pos_to_string(pos), quantity_string)
self.object:remove()
return
end
end
self.staticdata.timer = self.staticdata.timer+dtime
end
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if puncher and puncher:is_player() and puncher:get_inventory() then
stack = ItemStack("mobs:meat_raw "..tostring(self.staticdata.quantity))
leftovers = puncher:get_inventory():add_item("main", stack)
mobs.barf("mobs:meat_raw", tostring(self.staticdata.quantity), "remainder", tostring(leftovers:get_count()))
self.staticdata.quantity = leftovers:get_count()
if self.staticdata.quantity == 0 then
self.object:remove()
end
end
end,
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if item:get_name() == "mobs:meat_raw" then
item:take_item()
clicker:set_wielded_item(item)
self.staticdata.quantity = self.staticdata.quantity+1
end
end,
})
minetest.register_craftitem("mobs:meat", {
description = "Meat",
inventory_image = "mobs_meat.png",

View File

@ -10,7 +10,7 @@ mobs.interval (Spawn Interval) int 30 30 300
mobs.drop_litter (Drop Litter) bool false
# Meat will rot if not cooked or refridgerated
mobs.meat_rots (Meat Rots) bool false
mobs.meat_rots (Meat Rots) bool true
[animals]