This repository has been archived on 2024-12-09. You can view files and clone it, but cannot push or open issues or pull requests.
Mineclonia/mods/ENTITIES/mobs_mc/villager_zombie.lua

155 lines
4.3 KiB
Lua
Raw Normal View History

2017-07-05 01:15:46 +00:00
--MCmobs v0.4
--maikerumine
--made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc")
2017-07-05 01:15:46 +00:00
--###################
--################### ZOMBIE VILLAGER
--###################
2021-01-23 14:40:12 +00:00
local professions = {
farmer = "mobs_mc_villager_farmer.png",
fisherman = "mobs_mc_villager_farmer.png",
fletcher = "mobs_mc_villager_farmer.png",
shepherd = "mobs_mc_villager_farmer.png",
librarian = "mobs_mc_villager_librarian.png",
cartographer = "mobs_mc_villager_librarian.png",
armorer = "mobs_mc_villager_smith.png",
leatherworker = "mobs_mc_villager_butcher.png",
butcher = "mobs_mc_villager_butcher.png",
weapon_smith = "mobs_mc_villager_smith.png",
tool_smith = "mobs_mc_villager_smith.png",
cleric = "mobs_mc_villager_priest.png",
nitwit = "mobs_mc_villager.png",
}
2017-07-05 01:15:46 +00:00
mobs:register_mob("mobs_mc:villager_zombie", {
type = "monster",
2020-04-11 00:46:03 +00:00
spawn_class = "hostile",
2017-07-05 01:15:46 +00:00
hp_min = 20,
hp_max = 20,
2020-12-06 14:46:42 +00:00
xp_min = 5,
xp_max = 5,
2019-10-02 16:31:16 +00:00
breath_max = -1,
2020-11-09 17:59:08 +00:00
armor = {undead = 90, fleshy = 90},
2017-07-05 01:15:46 +00:00
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
visual = "mesh",
2017-09-13 21:13:47 +00:00
mesh = "mobs_mc_villager_zombie.b3d",
2017-07-05 01:15:46 +00:00
textures = {
{"mobs_mc_zombie_butcher.png"},
{"mobs_mc_zombie_farmer.png"},
{"mobs_mc_zombie_librarian.png"},
{"mobs_mc_zombie_priest.png"},
{"mobs_mc_zombie_smith.png"},
{"mobs_mc_zombie_villager.png"}
},
visual_size = {x=3, y=3},
makes_footstep_sound = true,
damage = 3,
2017-07-25 22:26:18 +00:00
reach = 2,
2017-07-05 01:15:46 +00:00
walk_velocity = 1.2,
run_velocity = 2.4,
attack_type = "dogfight",
group_attack = true,
drops = {
{name = mobs_mc.items.rotten_flesh,
chance = 1,
min = 0,
2020-12-23 16:41:42 +00:00
max = 2,
looting = "common",},
2017-07-05 01:15:46 +00:00
{name = mobs_mc.items.iron_ingot,
2018-01-23 22:13:55 +00:00
chance = 120, -- 2.5% / 3
2017-07-05 01:15:46 +00:00
min = 1,
2020-12-23 16:41:42 +00:00
max = 1,
looting = "rare",
looting_factor = 0.01 / 3,},
2017-07-05 01:15:46 +00:00
{name = mobs_mc.items.carrot,
2018-01-23 22:13:55 +00:00
chance = 120, -- 2.5% / 3
2017-07-05 01:15:46 +00:00
min = 1,
2020-12-23 16:41:42 +00:00
max = 1,
looting = "rare",
looting_factor = 0.01 / 3,},
2017-07-05 01:15:46 +00:00
{name = mobs_mc.items.potato,
2018-01-23 22:13:55 +00:00
chance = 120, -- 2.5% / 3
2017-07-05 01:15:46 +00:00
min = 1,
2020-12-23 16:41:42 +00:00
max = 1,
looting = "rare",
looting_factor = 0.01 / 3,},
2017-07-05 01:15:46 +00:00
},
sounds = {
2019-01-31 05:56:03 +00:00
random = "mobs_mc_zombie_growl",
war_cry = "mobs_mc_zombie_growl",
2017-07-20 14:34:16 +00:00
death = "mobs_mc_zombie_death",
damage = "mobs_mc_zombie_hurt",
2017-07-05 01:15:46 +00:00
distance = 16,
},
animation = {
speed_normal = 25,
speed_run = 50,
stand_start = 20,
stand_end = 40,
walk_start = 0,
walk_end = 20,
run_start = 0,
run_end = 20,
},
2021-01-23 14:40:12 +00:00
on_rightclick = function(self, clicker)
if not self._curing and clicker and clicker:is_player() then
local wielditem = clicker:get_wielded_item()
-- ToDo: Only cure if zombie villager has the weakness effect
if wielditem:get_name() == "mcl_core:apple_gold" then
wielditem:take_item()
clicker:set_wielded_item(wielditem)
self._curing = math.random(3 * 60, 5 * 60)
self.shaking = true
end
end
end,
do_custom = function(self, dtime)
if self._curing then
self._curing = self._curing - dtime
local obj = self.object
if self._curing <= 0 then
local villager_obj = minetest.add_entity(obj:get_pos(), "mobs_mc:villager")
local villager = villager_obj:get_luaentity()
local yaw = obj:get_yaw()
villager_obj:set_yaw(yaw)
villager.target_yaw = yaw
villager.nametag = self.nametag
local texture = self.base_texture[1]:gsub("zombie", "villager")
if texture == "mobs_mc_villager_villager.png" then
texture = "mobs_mc_villager.png"
end
local textures = {texture}
villager.base_texture = textures
villager_obj:set_properties({textures = textures})
local matches = {}
for prof, tex in pairs(professions) do
if texture == tex then
table.insert(matches, prof)
end
end
villager._profession = matches[math.random(#matches)]
self._curing = nil
mcl_burning.extinguish(obj)
obj:remove()
return false
end
end
end,
sunlight_damage = 2,
ignited_by_sunlight = true,
2017-07-05 01:15:46 +00:00
view_range = 16,
2019-03-08 23:54:49 +00:00
fear_height = 4,
harmed_by_heal = true,
2017-07-05 01:15:46 +00:00
})
2021-01-23 14:40:12 +00:00
mobs:spawn_specific("mobs_mc:villager_zombie", mobs_mc.spawn.village, {"air"}, 0, 7, 30, 4090, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:villager_zombie", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
2017-07-05 01:15:46 +00:00
-- spawn eggs
mobs:register_egg("mobs_mc:villager_zombie", S("Zombie Villager"), "mobs_mc_spawn_icon_zombie_villager.png", 0)