2017-07-05 03:15:46 +02:00
|
|
|
--MCmobs v0.4
|
|
|
|
--maikerumine
|
|
|
|
--made for MC like Survival game
|
|
|
|
--License for code WTFPL and otherwise stated in readmes
|
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
local S = minetest.get_translator("mobs_mc")
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
--###################
|
|
|
|
--################### OCELOT AND CAT
|
|
|
|
--###################
|
|
|
|
|
|
|
|
local pr = PseudoRandom(os.time()*12)
|
|
|
|
|
|
|
|
local default_walk_chance = 70
|
|
|
|
|
2022-05-25 23:25:15 +02:00
|
|
|
local follow = {
|
|
|
|
"mcl_fishing:fish_raw",
|
|
|
|
"mcl_fishing:salmon_raw",
|
|
|
|
"mcl_fishing:clownfish_raw",
|
|
|
|
"mcl_fishing:pufferfish_raw",
|
|
|
|
}
|
|
|
|
|
|
|
|
local function is_food(itemstring)
|
|
|
|
return table.indexof(follow, itemstring) ~= -1
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Ocelot
|
|
|
|
local ocelot = {
|
2021-04-25 17:30:15 +02:00
|
|
|
description = S("Ocelot"),
|
2017-07-05 03:15:46 +02:00
|
|
|
type = "animal",
|
2020-04-11 02:46:03 +02:00
|
|
|
spawn_class = "passive",
|
2018-09-14 14:48:48 +02:00
|
|
|
can_despawn = true,
|
2022-07-17 02:20:51 +02:00
|
|
|
spawn_in_group = 3,
|
|
|
|
spawn_in_group_min = 1,
|
2017-07-05 03:15:46 +02:00
|
|
|
hp_min = 10,
|
|
|
|
hp_max = 10,
|
2020-12-06 15:46:42 +01:00
|
|
|
xp_min = 1,
|
|
|
|
xp_max = 3,
|
2022-10-06 23:40:06 +02:00
|
|
|
head_swivel = "head.control",
|
|
|
|
head_eye_height = 0.4,
|
Adjust bones, animations slightly from b3d data.
Initialize bones on spawn.
Note: to obatin bone values, try in Blender
"%.3f, %.3f, %.3f" % tuple((bpy.context.object.pose.bones["head.control"].head - bpy.context.object.pose.bones["head.control"].tail) * Vector((1,-1,1)))
or
"{0:.3f}, {1:.3f}, {2:.3f}".format(*(bpy.context.object.pose.bones["head.control"].head - bpy.context.object.pose.bones["head.control"].tail) @ bpy.context.object.pose.bones["head.control"].matrix * Vector((1,-1,1)))
2024-11-19 21:48:21 +01:00
|
|
|
head_bone_position = vector.new( 0, 6.44, -0.42 ), -- for minetest <= 5.8
|
2022-10-06 23:40:06 +02:00
|
|
|
head_yaw="z",
|
|
|
|
curiosity = 4,
|
2017-07-05 03:15:46 +02:00
|
|
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.69, 0.3},
|
|
|
|
visual = "mesh",
|
|
|
|
mesh = "mobs_mc_cat.b3d",
|
|
|
|
textures = {"mobs_mc_cat_ocelot.png"},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
walk_chance = default_walk_chance,
|
|
|
|
walk_velocity = 1,
|
2022-02-13 21:40:12 +01:00
|
|
|
run_velocity = 3,
|
2020-08-03 15:37:58 +02:00
|
|
|
follow_velocity = 1,
|
2017-07-05 03:15:46 +02:00
|
|
|
floats = 1,
|
|
|
|
runaway = true,
|
|
|
|
fall_damage = 0,
|
|
|
|
fear_height = 4,
|
|
|
|
sounds = {
|
2018-09-18 21:21:05 +02:00
|
|
|
damage = "mobs_mc_ocelot_hurt",
|
|
|
|
death = "mobs_mc_ocelot_hurt",
|
2020-12-05 23:37:12 +01:00
|
|
|
eat = "mobs_mc_animal_eat_generic",
|
2017-07-05 03:15:46 +02:00
|
|
|
distance = 16,
|
|
|
|
},
|
|
|
|
animation = {
|
2022-09-28 21:16:01 +02:00
|
|
|
stand_start = 0, stand_end = 0,
|
|
|
|
walk_start = 0, walk_end = 40, walk_speed = 40,
|
|
|
|
run_start = 0, run_end = 40, run_speed = 50,
|
|
|
|
sit_start = 50, sit_end = 50,
|
|
|
|
},
|
|
|
|
child_animations = {
|
|
|
|
stand_start = 51, stand_end = 51,
|
|
|
|
walk_start = 51, walk_end = 91, walk_speed = 60,
|
|
|
|
run_start = 51, run_end = 91, run_speed = 75,
|
|
|
|
sit_start = 101, sit_end = 101,
|
2017-07-05 03:15:46 +02:00
|
|
|
},
|
2022-05-25 23:25:15 +02:00
|
|
|
follow = follow,
|
2017-07-05 03:15:46 +02:00
|
|
|
view_range = 12,
|
2017-11-04 00:37:02 +01:00
|
|
|
passive = true,
|
2017-07-05 03:15:46 +02:00
|
|
|
attack_type = "dogfight",
|
|
|
|
pathfinding = 1,
|
|
|
|
damage = 2,
|
2017-07-26 00:26:18 +02:00
|
|
|
reach = 1,
|
2017-07-05 03:15:46 +02:00
|
|
|
attack_animals = true,
|
|
|
|
specific_attack = { "mobs_mc:chicken" },
|
|
|
|
on_rightclick = function(self, clicker)
|
|
|
|
if self.child then return end
|
|
|
|
-- Try to tame ocelot (mobs:feed_tame is intentionally NOT used)
|
|
|
|
local item = clicker:get_wielded_item()
|
|
|
|
if is_food(item:get_name()) then
|
2020-07-10 16:08:40 +02:00
|
|
|
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
2017-07-05 03:15:46 +02:00
|
|
|
item:take_item()
|
|
|
|
clicker:set_wielded_item(item)
|
|
|
|
end
|
|
|
|
-- 1/3 chance of getting tamed
|
|
|
|
if pr:next(1, 3) == 1 then
|
|
|
|
local yaw = self.object:get_yaw()
|
2019-02-01 06:33:07 +01:00
|
|
|
local cat = minetest.add_entity(self.object:get_pos(), "mobs_mc:cat")
|
2017-07-05 03:15:46 +02:00
|
|
|
cat:set_yaw(yaw)
|
|
|
|
local ent = cat:get_luaentity()
|
|
|
|
ent.owner = clicker:get_player_name()
|
|
|
|
ent.tamed = true
|
|
|
|
self.object:remove()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_mob("mobs_mc:ocelot", ocelot)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- Cat
|
|
|
|
local cat = table.copy(ocelot)
|
2021-04-25 17:30:15 +02:00
|
|
|
cat.description = S("Cat")
|
2017-07-05 03:15:46 +02:00
|
|
|
cat.textures = {{"mobs_mc_cat_black.png"}, {"mobs_mc_cat_red.png"}, {"mobs_mc_cat_siamese.png"}}
|
2018-09-14 14:48:48 +02:00
|
|
|
cat.can_despawn = false
|
2017-07-05 03:15:46 +02:00
|
|
|
cat.owner = ""
|
|
|
|
cat.order = "roam" -- "sit" or "roam"
|
|
|
|
cat.owner_loyal = true
|
|
|
|
cat.tamed = true
|
|
|
|
cat.runaway = false
|
2020-08-03 15:37:58 +02:00
|
|
|
cat.follow_velocity = 2.4
|
2017-07-05 03:15:46 +02:00
|
|
|
-- Automatically teleport cat to owner
|
|
|
|
cat.do_custom = mobs_mc.make_owner_teleport_function(12)
|
2018-09-18 21:21:05 +02:00
|
|
|
cat.sounds = {
|
|
|
|
random = "mobs_mc_cat_idle",
|
|
|
|
damage = "mobs_mc_cat_hiss",
|
|
|
|
death = "mobs_mc_ocelot_hurt",
|
2020-12-05 23:37:12 +01:00
|
|
|
eat = "mobs_mc_animal_eat_generic",
|
2018-09-18 21:21:05 +02:00
|
|
|
distance = 16,
|
|
|
|
}
|
2017-07-05 03:15:46 +02:00
|
|
|
cat.on_rightclick = function(self, clicker)
|
2022-11-09 04:57:48 +01:00
|
|
|
if self:feed_tame(clicker, 1, true, false) then return end
|
2022-05-25 14:44:49 +02:00
|
|
|
if mcl_mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
|
|
|
|
if mcl_mobs:protect(self, clicker) then return end
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
if self.child then return end
|
|
|
|
|
|
|
|
-- Toggle sitting order
|
|
|
|
|
|
|
|
if not self.owner or self.owner == "" then
|
|
|
|
-- Huh? This cat has no owner? Let's fix this! This should never happen.
|
|
|
|
self.owner = clicker:get_player_name()
|
|
|
|
end
|
|
|
|
|
|
|
|
if not self.order or self.order == "" or self.order == "sit" then
|
|
|
|
self.order = "roam"
|
|
|
|
self.walk_chance = default_walk_chance
|
|
|
|
self.jump = true
|
|
|
|
else
|
|
|
|
-- “Sit!”
|
|
|
|
-- TODO: Add sitting model
|
|
|
|
self.order = "sit"
|
|
|
|
self.walk_chance = 0
|
|
|
|
self.jump = false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2022-10-10 14:43:08 +02:00
|
|
|
cat.on_spawn = function(self)
|
|
|
|
if self.owner == "!witch!" then
|
|
|
|
self._texture = {"mobs_mc_cat_black.png"}
|
|
|
|
end
|
|
|
|
if not self._texture then
|
|
|
|
self._texture = cat.textures[math.random(#cat.textures)]
|
|
|
|
end
|
2023-01-15 03:32:32 +01:00
|
|
|
self.object:set_properties({textures = self._texture})
|
2022-10-10 14:43:08 +02:00
|
|
|
end
|
|
|
|
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_mob("mobs_mc:cat", cat)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
local base_spawn_chance = 5000
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- Spawn ocelot
|
2021-04-07 18:47:40 +02:00
|
|
|
--they get the same as the llama because I'm trying to rework so much of this code right now -j4i
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:spawn_specific(
|
2021-04-25 17:30:15 +02:00
|
|
|
"mobs_mc:ocelot",
|
|
|
|
"overworld",
|
2021-04-08 13:39:18 +02:00
|
|
|
"ground",
|
|
|
|
{
|
|
|
|
"Jungle",
|
|
|
|
"JungleEdgeM",
|
|
|
|
"JungleM",
|
|
|
|
"JungleEdge",
|
|
|
|
},
|
2021-04-25 17:30:15 +02:00
|
|
|
0,
|
|
|
|
minetest.LIGHT_MAX+1,
|
|
|
|
30,
|
2023-11-27 10:47:55 +01:00
|
|
|
300,
|
2021-04-25 17:30:15 +02:00
|
|
|
5,
|
2022-05-25 23:25:15 +02:00
|
|
|
mobs_mc.water_level+15,
|
|
|
|
mcl_vars.mg_overworld_max)
|
2021-04-07 18:47:40 +02:00
|
|
|
--[[
|
2017-07-05 03:15:46 +02:00
|
|
|
mobs:spawn({
|
|
|
|
name = "mobs_mc:ocelot",
|
2022-05-25 23:25:15 +02:00
|
|
|
nodes = { "mcl_core:jungletree", "mcl_core:jungleleaves", "mcl_flowers:fern", "mcl_core:vine" },
|
2017-08-16 22:08:17 +02:00
|
|
|
neighbors = {"air"},
|
2017-07-05 03:15:46 +02:00
|
|
|
light_max = minetest.LIGHT_MAX+1,
|
|
|
|
light_min = 0,
|
|
|
|
chance = math.ceil(base_spawn_chance * 1.5), -- emulates 1/3 spawn failure rate
|
|
|
|
active_object_count = 12,
|
2022-05-25 23:25:15 +02:00
|
|
|
min_height = mobs_mc.water_level+1, -- Right above ocean level
|
|
|
|
max_height = mcl_vars.mg_overworld_max,
|
2017-07-05 03:15:46 +02:00
|
|
|
on_spawn = function(self, pos)
|
2021-04-07 18:47:40 +02:00
|
|
|
Note: Minecraft has a 1/3 spawn failure rate.
|
2021-04-25 17:30:15 +02:00
|
|
|
In this mod it is emulated by reducing the spawn rate accordingly (see above).
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- 1/7 chance to spawn 2 ocelot kittens
|
|
|
|
if pr:next(1,7) == 1 then
|
|
|
|
-- Turn object into a child
|
|
|
|
local make_child = function(object)
|
|
|
|
local ent = object:get_luaentity()
|
|
|
|
object:set_properties({
|
|
|
|
visual_size = { x = ent.base_size.x/2, y = ent.base_size.y/2 },
|
|
|
|
collisionbox = {
|
|
|
|
ent.base_colbox[1]/2,
|
|
|
|
ent.base_colbox[2]/2,
|
|
|
|
ent.base_colbox[3]/2,
|
|
|
|
ent.base_colbox[4]/2,
|
|
|
|
ent.base_colbox[5]/2,
|
|
|
|
ent.base_colbox[6]/2,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
ent.child = true
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Possible spawn offsets, two of these will get selected
|
|
|
|
local k = 0.7
|
|
|
|
local offsets = {
|
|
|
|
{ x=k, y=0, z=0 },
|
|
|
|
{ x=-k, y=0, z=0 },
|
|
|
|
{ x=0, y=0, z=k },
|
|
|
|
{ x=0, y=0, z=-k },
|
|
|
|
{ x=k, y=0, z=k },
|
|
|
|
{ x=k, y=0, z=-k },
|
|
|
|
{ x=-k, y=0, z=k },
|
|
|
|
{ x=-k, y=0, z=-k },
|
|
|
|
}
|
|
|
|
for i=1, 2 do
|
|
|
|
local o = pr:next(1, #offsets)
|
|
|
|
local offset = offsets[o]
|
|
|
|
local child_pos = vector.add(pos, offsets[o])
|
|
|
|
table.remove(offsets, o)
|
|
|
|
make_child(minetest.add_entity(child_pos, "mobs_mc:ocelot"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2021-04-07 18:47:40 +02:00
|
|
|
]]--
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- spawn eggs
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_egg("mobs_mc:ocelot", S("Ocelot"), "#efde7d", "#564434", 0)
|