2017-07-02 06:31:26 -07:00
|
|
|
-- intllib
|
|
|
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
local S, NS = dofile(MP.."/intllib.lua")
|
2017-05-22 19:27:00 -07:00
|
|
|
|
|
|
|
--###################
|
|
|
|
--################### LLAMA
|
|
|
|
--###################
|
|
|
|
|
2017-05-23 16:03:37 -07:00
|
|
|
mobs:register_mob("mobs_mc:llama", {
|
2017-05-22 19:27:00 -07:00
|
|
|
type = "animal",
|
2017-06-14 16:47:33 -07:00
|
|
|
hp_min = 15,
|
|
|
|
hp_max = 30,
|
2017-05-28 20:16:44 -07:00
|
|
|
passive = false,
|
2017-06-27 10:02:52 -07:00
|
|
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.86, 0.45},
|
2017-05-22 19:27:00 -07:00
|
|
|
visual = "mesh",
|
2017-06-26 15:32:05 -07:00
|
|
|
mesh = "mobs_mc_llama.b3d",
|
2017-11-03 11:08:53 -07:00
|
|
|
textures = { -- 1: chest -- 2: decor (carpet) -- 3: llama base texture
|
2017-09-06 08:46:28 -07:00
|
|
|
{"blank.png", "blank.png", "mobs_mc_llama_brown.png"},
|
|
|
|
{"blank.png", "blank.png", "mobs_mc_llama_creamy.png"},
|
|
|
|
{"blank.png", "blank.png", "mobs_mc_llama_gray.png"},
|
|
|
|
{"blank.png", "blank.png", "mobs_mc_llama_white.png"},
|
|
|
|
{"blank.png", "blank.png", "mobs_mc_llama.png"},
|
2017-11-03 11:08:53 -07:00
|
|
|
-- TODO: Implement carpet (aka decor) on llama
|
|
|
|
},
|
2017-05-23 16:03:37 -07:00
|
|
|
visual_size = {x=3, y=3},
|
2017-05-22 19:27:00 -07:00
|
|
|
makes_footstep_sound = true,
|
2017-05-25 17:39:12 -07:00
|
|
|
runaway = true,
|
2017-05-22 19:27:00 -07:00
|
|
|
walk_velocity = 1,
|
2017-05-25 17:39:12 -07:00
|
|
|
run_velocity = 4.4,
|
2017-06-27 10:02:52 -07:00
|
|
|
floats = 1,
|
2017-05-22 19:27:00 -07:00
|
|
|
drops = {
|
2017-06-23 09:26:00 -07:00
|
|
|
{name = mobs_mc.items.leather,
|
2017-05-22 19:27:00 -07:00
|
|
|
chance = 1,
|
2017-05-28 20:16:44 -07:00
|
|
|
min = 0,
|
|
|
|
max = 2,},
|
2017-05-22 19:27:00 -07:00
|
|
|
},
|
2017-05-28 20:16:44 -07:00
|
|
|
water_damage = 0,
|
2017-06-27 10:02:52 -07:00
|
|
|
lava_damage = 4,
|
2017-05-22 19:27:00 -07:00
|
|
|
light_damage = 0,
|
2017-06-27 10:02:52 -07:00
|
|
|
fear_height = 4,
|
2017-05-22 19:27:00 -07:00
|
|
|
sounds = {
|
2017-06-29 15:51:50 -07:00
|
|
|
random = "mobs_mc_llama",
|
|
|
|
-- TODO: Death and damage sounds
|
2017-06-27 10:02:52 -07:00
|
|
|
distance = 16,
|
2017-05-22 19:27:00 -07:00
|
|
|
},
|
|
|
|
animation = {
|
|
|
|
speed_normal = 24,
|
|
|
|
stand_start = 0,
|
2017-06-06 16:13:16 -07:00
|
|
|
stand_end = 0,
|
|
|
|
walk_start = 0,
|
|
|
|
walk_end = 40,
|
2017-05-22 19:27:00 -07:00
|
|
|
hurt_start = 118,
|
|
|
|
hurt_end = 154,
|
|
|
|
death_start = 154,
|
|
|
|
death_end = 179,
|
|
|
|
eat_start = 49,
|
|
|
|
eat_end = 78,
|
|
|
|
look_start = 78,
|
|
|
|
look_end = 108,
|
|
|
|
},
|
2017-06-23 09:26:00 -07:00
|
|
|
follow = mobs_mc.items.horse,
|
2017-06-27 10:02:52 -07:00
|
|
|
view_range = 16,
|
2017-05-25 17:39:12 -07:00
|
|
|
do_custom = function(self, dtime)
|
|
|
|
|
|
|
|
-- set needed values if not already present
|
|
|
|
if not self.v2 then
|
|
|
|
self.v2 = 0
|
2017-06-29 08:19:48 -07:00
|
|
|
self.max_speed_forward = 4
|
|
|
|
self.max_speed_reverse = 2
|
2017-05-25 17:39:12 -07:00
|
|
|
self.accel = 4
|
|
|
|
self.terrain_type = 3
|
2017-06-29 08:19:48 -07:00
|
|
|
self.driver_attach_at = {x = 0, y = 7.5, z = -1.5}
|
2017-05-25 17:39:12 -07:00
|
|
|
self.driver_eye_offset = {x = 0, y = 3, z = 0}
|
2017-06-29 08:19:48 -07:00
|
|
|
self.driver_scale = {x = 1/self.visual_size.x, y = 1/self.visual_size.y}
|
2017-05-25 17:39:12 -07:00
|
|
|
end
|
|
|
|
|
2017-06-30 08:41:58 -07:00
|
|
|
-- if driver present allow control of llama
|
2017-05-25 17:39:12 -07:00
|
|
|
if self.driver then
|
|
|
|
|
|
|
|
mobs.drive(self, "walk", "stand", false, dtime)
|
|
|
|
|
|
|
|
return false -- skip rest of mob functions
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_die = function(self, pos)
|
|
|
|
|
2017-06-29 08:38:27 -07:00
|
|
|
-- detach from llama properly
|
2017-05-25 17:39:12 -07:00
|
|
|
if self.driver then
|
|
|
|
mobs.detach(self.driver, {x = 1, y = 0, z = 1})
|
|
|
|
end
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
2017-05-22 19:27:00 -07:00
|
|
|
on_rightclick = function(self, clicker)
|
2017-05-25 17:39:12 -07:00
|
|
|
|
2017-06-30 08:41:58 -07:00
|
|
|
-- Make sure player is clicking
|
2017-05-22 19:27:00 -07:00
|
|
|
if not clicker or not clicker:is_player() then
|
|
|
|
return
|
|
|
|
end
|
2017-05-25 17:39:12 -07:00
|
|
|
|
2017-07-03 10:40:19 -07:00
|
|
|
local item = clicker:get_wielded_item()
|
|
|
|
if item:get_name() == mobs_mc.items.hay_bale then
|
|
|
|
-- Breed with hay bale
|
|
|
|
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
|
|
|
else
|
|
|
|
-- Feed with anything else
|
|
|
|
if mobs:feed_tame(self, clicker, 1, false, true) then return end
|
|
|
|
end
|
2017-07-03 10:32:16 -07:00
|
|
|
if mobs:protect(self, clicker) then return end
|
2017-05-25 17:39:12 -07:00
|
|
|
|
2017-06-30 08:41:58 -07:00
|
|
|
-- Make sure tamed llama is mature and being clicked by owner only
|
|
|
|
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
2017-05-25 17:39:12 -07:00
|
|
|
|
|
|
|
local inv = clicker:get_inventory()
|
|
|
|
|
2017-06-30 08:41:58 -07:00
|
|
|
-- detatch player already riding llama
|
2017-05-25 17:39:12 -07:00
|
|
|
if self.driver and clicker == self.driver then
|
|
|
|
|
|
|
|
mobs.detach(clicker, {x = 1, y = 0, z = 1})
|
|
|
|
|
2017-06-29 08:38:27 -07:00
|
|
|
-- attach player to llama
|
|
|
|
elseif not self.driver then
|
2017-05-25 17:39:12 -07:00
|
|
|
|
|
|
|
self.object:set_properties({stepheight = 1.1})
|
|
|
|
mobs.attach(self, clicker)
|
2017-05-22 19:27:00 -07:00
|
|
|
end
|
|
|
|
|
2017-07-03 10:32:16 -07:00
|
|
|
-- Used to capture llama
|
2017-06-30 08:50:25 -07:00
|
|
|
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
|
2017-07-03 10:32:16 -07:00
|
|
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
2017-06-30 08:50:25 -07:00
|
|
|
end
|
2017-05-25 17:39:12 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
})
|
2017-05-22 19:27:00 -07:00
|
|
|
|
2017-05-25 17:39:12 -07:00
|
|
|
--spawn
|
2017-08-16 12:35:46 -07:00
|
|
|
mobs:spawn_specific("mobs_mc:llama", mobs_mc.spawn.savanna, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 5, mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max)
|
2017-05-22 19:27:00 -07:00
|
|
|
|
|
|
|
-- spawn eggs
|
2017-07-02 06:31:26 -07:00
|
|
|
mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)
|
2017-05-22 19:27:00 -07:00
|
|
|
|
2017-06-20 21:20:06 -07:00
|
|
|
if minetest.settings:get_bool("log_mods") then
|
2017-05-23 16:03:37 -07:00
|
|
|
minetest.log("action", "MC Llama loaded")
|
2017-06-06 16:13:16 -07:00
|
|
|
end
|