forked from MineClone5/MineClone5
Compare commits
18 Commits
master
...
villager_i
Author | SHA1 | Date |
---|---|---|
cora | 92d4e31740 | |
cora | cda23513d8 | |
cora | 29aa8f8816 | |
cora | 0b35f3ad62 | |
cora | 693345fb27 | |
cora | dd7af3b746 | |
cora | f61036092b | |
cora | b037c51ecc | |
cora | 6a85350364 | |
cora | 83fcf0dfd7 | |
cora | 2241697bb0 | |
cora | b96406c3dc | |
cora | 8e38a7d761 | |
cora | 9eab701dcb | |
cora | c4fdab8ab4 | |
cora | d51f820d26 | |
cora | 32003abfbd | |
cora | 583819b8ef |
|
@ -1715,9 +1715,591 @@ local do_env_damage = function(self)
|
|||
damage_effect(self, dmg)
|
||||
self.health = self.health - dmg
|
||||
end
|
||||
if check_for_death(self, "drowning", {type = "environment",
|
||||
pos = pos, node = self.standing_in}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- swimmers flop when out of their element, and swim again when back in
|
||||
if self.fly then
|
||||
local s = self.object:get_pos()
|
||||
if not flight_check(self, s) then
|
||||
|
||||
self.state = "flop"
|
||||
self.object:set_acceleration({x = 0, y = DEFAULT_FALL_SPEED, z = 0})
|
||||
|
||||
local sdef = minetest.registered_nodes[self.standing_on]
|
||||
-- Flop on ground
|
||||
if sdef and sdef.walkable then
|
||||
mob_sound(self, "flop")
|
||||
self.object:set_velocity({
|
||||
x = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
||||
y = FLOP_HEIGHT,
|
||||
z = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
||||
})
|
||||
end
|
||||
|
||||
set_animation(self, "stand", true)
|
||||
|
||||
return
|
||||
elseif self.state == "flop" then
|
||||
self.state = "stand"
|
||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||
set_velocity(self, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- dogshoot attack switch and counter function
|
||||
local dogswitch = function(self, dtime)
|
||||
|
||||
-- switch mode not activated
|
||||
if not self.dogshoot_switch
|
||||
or not dtime then
|
||||
return 0
|
||||
end
|
||||
|
||||
self.dogshoot_count = self.dogshoot_count + dtime
|
||||
|
||||
if (self.dogshoot_switch == 1
|
||||
and self.dogshoot_count > self.dogshoot_count_max)
|
||||
or (self.dogshoot_switch == 2
|
||||
and self.dogshoot_count > self.dogshoot_count2_max) then
|
||||
|
||||
self.dogshoot_count = 0
|
||||
|
||||
if self.dogshoot_switch == 1 then
|
||||
self.dogshoot_switch = 2
|
||||
else
|
||||
self.dogshoot_switch = 1
|
||||
end
|
||||
end
|
||||
|
||||
return self.dogshoot_switch
|
||||
end
|
||||
|
||||
local function go_to_pos(entity,b)
|
||||
if not entity then return end
|
||||
local s=entity.object:get_pos()
|
||||
if vector.distance(b,s) < 1 then
|
||||
--set_velocity(entity,0)
|
||||
return true
|
||||
end
|
||||
local v = { x = b.x - s.x, z = b.z - s.z }
|
||||
local yaw = (math.atan(v.z / v.x) + math.pi / 2) - entity.rotate
|
||||
if b.x > s.x then yaw = yaw + math.pi end
|
||||
entity.object:set_yaw(yaw)
|
||||
set_velocity(entity,entity.follow_velocity)
|
||||
mobs:set_animation(entity, "walk")
|
||||
end
|
||||
|
||||
-- execute current state (stand, walk, run, attacks)
|
||||
-- returns true if mob has died
|
||||
local do_states = function(self, dtime)
|
||||
local yaw = self.object:get_yaw() or 0
|
||||
|
||||
if self.state == "stand" then
|
||||
if random(1, 4) == 1 then
|
||||
|
||||
local s = self.object:get_pos()
|
||||
local objs = minetest.get_objects_inside_radius(s, 3)
|
||||
|
||||
for n = 1, #objs do
|
||||
|
||||
if objs[n]:is_player() then
|
||||
lp = objs[n]:get_pos()
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- look at any players nearby, otherwise turn randomly
|
||||
if self.look_at_players then
|
||||
|
||||
local vec = {
|
||||
x = lp.x - s.x,
|
||||
z = lp.z - s.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||
|
||||
if lp.x > s.x then yaw = yaw + pi end
|
||||
else
|
||||
yaw = yaw + random(-0.5, 0.5)
|
||||
end
|
||||
|
||||
yaw = set_yaw(self, yaw, 8)
|
||||
end
|
||||
|
||||
set_velocity(self, 0)
|
||||
set_animation(self, "stand")
|
||||
|
||||
-- npc's ordered to stand stay standing
|
||||
if self.type ~= "npc"
|
||||
or self.order ~= "stand" then
|
||||
|
||||
if self.walk_chance ~= 0
|
||||
and self.facing_fence ~= true
|
||||
and random(1, 100) <= self.walk_chance
|
||||
and is_at_cliff_or_danger(self) == false then
|
||||
|
||||
set_velocity(self, self.walk_velocity)
|
||||
self.state = "walk"
|
||||
set_animation(self, "walk")
|
||||
end
|
||||
end
|
||||
|
||||
elseif self.state == "gowp" then
|
||||
local p = self.object:get_pos()
|
||||
if not p or not self._target then return end
|
||||
if vector.distance(p,self._target) < 2 or #self.waypoints == 0 then
|
||||
self.waypoints = nil
|
||||
self._target = nil
|
||||
self.current_target = nil
|
||||
self.state = "walk"
|
||||
if self.callback_arrived then return self.callback_arrived(self) end
|
||||
return true
|
||||
end
|
||||
if not self.current_target or vector.distance(p,self.current_target) < 1.5 then
|
||||
self.current_target = table.remove(self.waypoints, 1)
|
||||
--minetest.log("nextwp:".. tostring(self.current_target) )
|
||||
elseif self.current_target then
|
||||
go_to_pos(self,self.current_target)
|
||||
end
|
||||
|
||||
if self.current_target and not minetest.line_of_sight(self.object:get_pos(),self.current_target) then
|
||||
self.waypoints=minetest.find_path(p,self._target,150,1,4)
|
||||
self.current_target = nil
|
||||
return
|
||||
end
|
||||
if not self.current_target then
|
||||
--minetest.log("no path")
|
||||
self.state = "walk"
|
||||
end
|
||||
|
||||
elseif self.state == "walk" then
|
||||
local s = self.object:get_pos()
|
||||
local lp = nil
|
||||
|
||||
-- is there something I need to avoid?
|
||||
if (self.water_damage > 0
|
||||
and self.lava_damage > 0)
|
||||
or self.breath_max ~= -1 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:water", "group:lava"})
|
||||
|
||||
elseif self.water_damage > 0 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:water"})
|
||||
|
||||
elseif self.lava_damage > 0 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:lava"})
|
||||
|
||||
elseif self.fire_damage > 0 then
|
||||
|
||||
lp = minetest.find_node_near(s, 1, {"group:fire"})
|
||||
|
||||
end
|
||||
|
||||
local is_in_danger = false
|
||||
if lp then
|
||||
-- If mob in or on dangerous block, look for land
|
||||
if (is_node_dangerous(self, self.standing_in) or
|
||||
is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) and (not self.fly) then
|
||||
is_in_danger = true
|
||||
|
||||
-- If mob in or on dangerous block, look for land
|
||||
if is_in_danger then
|
||||
-- Better way to find shore - copied from upstream
|
||||
lp = minetest.find_nodes_in_area_under_air(
|
||||
{x = s.x - 5, y = s.y - 0.5, z = s.z - 5},
|
||||
{x = s.x + 5, y = s.y + 1, z = s.z + 5},
|
||||
{"group:solid"})
|
||||
|
||||
lp = #lp > 0 and lp[random(#lp)]
|
||||
|
||||
-- did we find land?
|
||||
if lp then
|
||||
|
||||
local vec = {
|
||||
x = lp.x - s.x,
|
||||
z = lp.z - s.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||
|
||||
|
||||
if lp.x > s.x then yaw = yaw + pi end
|
||||
|
||||
-- look towards land and move in that direction
|
||||
yaw = set_yaw(self, yaw, 6)
|
||||
set_velocity(self, self.walk_velocity)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- A danger is near but mob is not inside
|
||||
else
|
||||
|
||||
-- Randomly turn
|
||||
if random(1, 100) <= 30 then
|
||||
yaw = yaw + random(-0.5, 0.5)
|
||||
yaw = set_yaw(self, yaw, 8)
|
||||
end
|
||||
end
|
||||
|
||||
yaw = set_yaw(self, yaw, 8)
|
||||
|
||||
-- otherwise randomly turn
|
||||
elseif random(1, 100) <= 30 then
|
||||
|
||||
yaw = yaw + random(-0.5, 0.5)
|
||||
yaw = set_yaw(self, yaw, 8)
|
||||
end
|
||||
|
||||
-- stand for great fall or danger or fence in front
|
||||
local cliff_or_danger = false
|
||||
if is_in_danger then
|
||||
cliff_or_danger = is_at_cliff_or_danger(self)
|
||||
end
|
||||
if self.facing_fence == true
|
||||
or cliff_or_danger
|
||||
or random(1, 100) <= 30 then
|
||||
|
||||
set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
set_animation(self, "stand")
|
||||
local yaw = self.object:get_yaw() or 0
|
||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||
else
|
||||
|
||||
set_velocity(self, self.walk_velocity)
|
||||
|
||||
if flight_check(self)
|
||||
and self.animation
|
||||
and self.animation.fly_start
|
||||
and self.animation.fly_end then
|
||||
set_animation(self, "fly")
|
||||
else
|
||||
set_animation(self, "walk")
|
||||
end
|
||||
end
|
||||
|
||||
-- runaway when punched
|
||||
elseif self.state == "runaway" then
|
||||
|
||||
self.runaway_timer = self.runaway_timer + 1
|
||||
|
||||
-- stop after 5 seconds or when at cliff
|
||||
if self.runaway_timer > 5
|
||||
or is_at_cliff_or_danger(self) then
|
||||
self.runaway_timer = 0
|
||||
set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
set_animation(self, "stand")
|
||||
local yaw = self.object:get_yaw() or 0
|
||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||
else
|
||||
set_velocity(self, self.run_velocity)
|
||||
set_animation(self, "run")
|
||||
end
|
||||
|
||||
-- attack routines (explode, dogfight, shoot, dogshoot)
|
||||
elseif self.state == "attack" then
|
||||
|
||||
local s = self.object:get_pos()
|
||||
local p = self.attack:get_pos() or s
|
||||
|
||||
-- stop attacking if player invisible or out of range
|
||||
if not self.attack
|
||||
or not self.attack:get_pos()
|
||||
or not object_in_range(self, self.attack)
|
||||
or self.attack:get_hp() <= 0
|
||||
or (self.attack:is_player() and mobs.invis[ self.attack:get_player_name() ]) then
|
||||
|
||||
self.state = "stand"
|
||||
set_velocity(self, 0)
|
||||
set_animation(self, "stand")
|
||||
self.attack = nil
|
||||
self.v_start = false
|
||||
self.timer = 0
|
||||
self.blinktimer = 0
|
||||
self.path.way = nil
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- calculate distance from mob and enemy
|
||||
local dist = vector.distance(p, s)
|
||||
|
||||
if self.attack_type == "explode" then
|
||||
|
||||
local vec = {
|
||||
x = p.x - s.x,
|
||||
z = p.z - s.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||
|
||||
if p.x > s.x then yaw = yaw + pi end
|
||||
|
||||
yaw = set_yaw(self, yaw, 0, dtime)
|
||||
|
||||
local node_break_radius = self.explosion_radius or 1
|
||||
local entity_damage_radius = self.explosion_damage_radius
|
||||
or (node_break_radius * 2)
|
||||
|
||||
-- start timer when in reach and line of sight
|
||||
if not self.v_start
|
||||
and dist <= self.reach
|
||||
and line_of_sight(self, s, p, 2) then
|
||||
|
||||
self.v_start = true
|
||||
self.timer = 0
|
||||
self.blinktimer = 0
|
||||
mob_sound(self, "fuse", nil, false)
|
||||
|
||||
-- stop timer if out of reach or direct line of sight
|
||||
elseif self.allow_fuse_reset
|
||||
and self.v_start
|
||||
and (dist >= self.explosiontimer_reset_radius
|
||||
or not line_of_sight(self, s, p, 2)) then
|
||||
self.v_start = false
|
||||
self.timer = 0
|
||||
self.blinktimer = 0
|
||||
self.blinkstatus = false
|
||||
remove_texture_mod(self, "^[brighten")
|
||||
end
|
||||
|
||||
-- walk right up to player unless the timer is active
|
||||
if self.v_start and (self.stop_to_explode or dist < self.reach) then
|
||||
set_velocity(self, 0)
|
||||
else
|
||||
set_velocity(self, self.run_velocity)
|
||||
end
|
||||
|
||||
if self.animation and self.animation.run_start then
|
||||
set_animation(self, "run")
|
||||
else
|
||||
set_animation(self, "walk")
|
||||
end
|
||||
|
||||
if self.v_start then
|
||||
|
||||
self.timer = self.timer + dtime
|
||||
self.blinktimer = (self.blinktimer or 0) + dtime
|
||||
|
||||
if self.blinktimer > 0.2 then
|
||||
|
||||
self.blinktimer = 0
|
||||
|
||||
if self.blinkstatus then
|
||||
remove_texture_mod(self, "^[brighten")
|
||||
else
|
||||
add_texture_mod(self, "^[brighten")
|
||||
end
|
||||
|
||||
self.blinkstatus = not self.blinkstatus
|
||||
end
|
||||
|
||||
if self.timer > self.explosion_timer then
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
if mod_explosions then
|
||||
if mobs_griefing and not minetest.is_protected(pos, "") then
|
||||
mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { drop_chance = 1.0 }, self.object)
|
||||
else
|
||||
minetest.sound_play(self.sounds.explode, {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = self.sounds.distance or 32
|
||||
}, true)
|
||||
|
||||
entity_physics(pos, entity_damage_radius)
|
||||
effect(pos, 32, "mcl_particles_smoke.png", nil, nil, node_break_radius, 1, 0)
|
||||
end
|
||||
end
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
elseif self.attack_type == "dogfight"
|
||||
or (self.attack_type == "dogshoot" and dogswitch(self, dtime) == 2)
|
||||
or (self.attack_type == "dogshoot" and dist <= self.reach and dogswitch(self) == 0) then
|
||||
|
||||
if self.fly
|
||||
and dist > self.reach then
|
||||
|
||||
local p1 = s
|
||||
local me_y = floor(p1.y)
|
||||
local p2 = p
|
||||
local p_y = floor(p2.y + 1)
|
||||
local v = self.object:get_velocity()
|
||||
|
||||
if flight_check(self, s) then
|
||||
|
||||
if me_y < p_y then
|
||||
|
||||
self.object:set_velocity({
|
||||
x = v.x,
|
||||
y = 1 * self.walk_velocity,
|
||||
z = v.z
|
||||
})
|
||||
|
||||
elseif me_y > p_y then
|
||||
|
||||
self.object:set_velocity({
|
||||
x = v.x,
|
||||
y = -1 * self.walk_velocity,
|
||||
z = v.z
|
||||
})
|
||||
end
|
||||
else
|
||||
if me_y < p_y then
|
||||
|
||||
self.object:set_velocity({
|
||||
x = v.x,
|
||||
y = 0.01,
|
||||
z = v.z
|
||||
})
|
||||
|
||||
elseif me_y > p_y then
|
||||
|
||||
self.object:set_velocity({
|
||||
x = v.x,
|
||||
y = -0.01,
|
||||
z = v.z
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- rnd: new movement direction
|
||||
if self.path.following
|
||||
and self.path.way
|
||||
and self.attack_type ~= "dogshoot" then
|
||||
|
||||
-- no paths longer than 50
|
||||
if #self.path.way > 50
|
||||
or dist < self.reach then
|
||||
self.path.following = false
|
||||
return
|
||||
end
|
||||
|
||||
local p1 = self.path.way[1]
|
||||
|
||||
if not p1 then
|
||||
self.path.following = false
|
||||
return
|
||||
end
|
||||
|
||||
if abs(p1.x-s.x) + abs(p1.z - s.z) < 0.6 then
|
||||
-- reached waypoint, remove it from queue
|
||||
table.remove(self.path.way, 1)
|
||||
end
|
||||
|
||||
-- set new temporary target
|
||||
p = {x = p1.x, y = p1.y, z = p1.z}
|
||||
end
|
||||
|
||||
local vec = {
|
||||
x = p.x - s.x,
|
||||
z = p.z - s.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||
|
||||
if p.x > s.x then yaw = yaw + pi end
|
||||
|
||||
yaw = set_yaw(self, yaw, 0, dtime)
|
||||
|
||||
-- move towards enemy if beyond mob reach
|
||||
if dist > self.reach then
|
||||
|
||||
-- path finding by rnd
|
||||
if self.pathfinding -- only if mob has pathfinding enabled
|
||||
and enable_pathfinding then
|
||||
|
||||
smart_mobs(self, s, p, dist, dtime)
|
||||
end
|
||||
|
||||
if is_at_cliff_or_danger(self) then
|
||||
|
||||
set_velocity(self, 0)
|
||||
set_animation(self, "stand")
|
||||
local yaw = self.object:get_yaw() or 0
|
||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||
else
|
||||
|
||||
if self.path.stuck then
|
||||
set_velocity(self, self.walk_velocity)
|
||||
else
|
||||
set_velocity(self, self.run_velocity)
|
||||
end
|
||||
|
||||
if self.animation and self.animation.run_start then
|
||||
set_animation(self, "run")
|
||||
else
|
||||
set_animation(self, "walk")
|
||||
end
|
||||
end
|
||||
|
||||
else -- rnd: if inside reach range
|
||||
|
||||
self.path.stuck = false
|
||||
self.path.stuck_timer = 0
|
||||
self.path.following = false -- not stuck anymore
|
||||
|
||||
set_velocity(self, 0)
|
||||
|
||||
if not self.custom_attack then
|
||||
|
||||
if self.timer > 1 then
|
||||
|
||||
self.timer = 0
|
||||
|
||||
if self.double_melee_attack
|
||||
and random(1, 2) == 1 then
|
||||
set_animation(self, "punch2")
|
||||
else
|
||||
set_animation(self, "punch")
|
||||
end
|
||||
|
||||
local p2 = p
|
||||
local s2 = s
|
||||
|
||||
p2.y = p2.y + .5
|
||||
s2.y = s2.y + .5
|
||||
|
||||
if line_of_sight(self, p2, s2) == true then
|
||||
|
||||
-- play attack sound
|
||||
mob_sound(self, "attack")
|
||||
|
||||
-- punch player (or what player is attached to)
|
||||
local attached = self.attack:get_attach()
|
||||
if attached then
|
||||
self.attack = attached
|
||||
end
|
||||
self.attack:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = self.damage}
|
||||
}, nil)
|
||||
end
|
||||
end
|
||||
else -- call custom attack every second
|
||||
if self.custom_attack
|
||||
and self.timer > 1 then
|
||||
|
||||
self.timer = 0
|
||||
|
||||
self.custom_attack(self, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
self.breath = math_min(self.breath_max, self.breath + 1)
|
||||
|
@ -1819,8 +2401,20 @@ local do_jump = function(self)
|
|||
return false
|
||||
end
|
||||
|
||||
if self.walk_chance == 0
|
||||
or minetest_registered_items[nod.name].walkable then
|
||||
local function check_item_pickup(self)
|
||||
if self.pick_up and #self.pick_up > 0 then
|
||||
for _,o in pairs(minetest.get_objects_inside_radius(self.object:get_pos(),2)) do
|
||||
local l=o:get_luaentity()
|
||||
if l and l.name == "__builtin:item" then
|
||||
for k,v in pairs(self.pick_up) do
|
||||
if self.on_pick_up and l.itemstring:find(v) then
|
||||
if self.on_pick_up(self,l) == nil then o:remove() end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest_get_item_group(nod.name, "fence") == 0
|
||||
and minetest_get_item_group(nod.name, "fence_gate") == 0
|
||||
|
@ -2236,9 +2830,12 @@ function do_states(self)
|
|||
|
||||
lp = minetest_find_node_near(s, 1, {"group:lava"})
|
||||
|
||||
elseif self.fire_damage > 0 then
|
||||
|
||||
lp = minetest_find_node_near(s, 1, {"group:fire"})
|
||||
-- main mob function
|
||||
local mob_step = function(self, dtime)
|
||||
check_item_pickup(self)
|
||||
if not self.fire_resistant then
|
||||
mcl_burning.tick(self.object, dtime, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -2553,7 +3150,161 @@ function do_states(self)
|
|||
z = p.z - s.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + math_pi / 2) - self.rotate
|
||||
minetest.register_entity(name, {
|
||||
|
||||
use_texture_alpha = def.use_texture_alpha,
|
||||
stepheight = def.stepheight or 0.6,
|
||||
name = name,
|
||||
description = def.description,
|
||||
type = def.type,
|
||||
attack_type = def.attack_type,
|
||||
fly = def.fly,
|
||||
fly_in = def.fly_in or {"air", "__airlike"},
|
||||
owner = def.owner or "",
|
||||
order = def.order or "",
|
||||
on_die = def.on_die,
|
||||
spawn_small_alternative = def.spawn_small_alternative,
|
||||
do_custom = def.do_custom,
|
||||
jump_height = def.jump_height or 4, -- was 6
|
||||
rotate = math.rad(def.rotate or 0), -- 0=front, 90=side, 180=back, 270=side2
|
||||
lifetimer = def.lifetimer or 57.73,
|
||||
hp_min = scale_difficulty(def.hp_min, 5, 1),
|
||||
hp_max = scale_difficulty(def.hp_max, 10, 1),
|
||||
xp_min = def.xp_min or 0,
|
||||
xp_max = def.xp_max or 0,
|
||||
xp_timestamp = 0,
|
||||
breath_max = def.breath_max or 15,
|
||||
breathes_in_water = def.breathes_in_water or false,
|
||||
physical = true,
|
||||
collisionbox = collisionbox,
|
||||
selectionbox = def.selectionbox or def.collisionbox,
|
||||
visual = def.visual,
|
||||
visual_size = def.visual_size or {x = 1, y = 1},
|
||||
mesh = def.mesh,
|
||||
makes_footstep_sound = def.makes_footstep_sound or false,
|
||||
view_range = def.view_range or 16,
|
||||
walk_velocity = def.walk_velocity or 1,
|
||||
run_velocity = def.run_velocity or 2,
|
||||
damage = scale_difficulty(def.damage, 0, 0),
|
||||
light_damage = def.light_damage or 0,
|
||||
sunlight_damage = def.sunlight_damage or 0,
|
||||
water_damage = def.water_damage or 0,
|
||||
lava_damage = def.lava_damage or 8,
|
||||
fire_damage = def.fire_damage or 1,
|
||||
suffocation = def.suffocation or true,
|
||||
fall_damage = def.fall_damage or 1,
|
||||
fall_speed = def.fall_speed or DEFAULT_FALL_SPEED, -- must be lower than -2
|
||||
drops = def.drops or {},
|
||||
armor = def.armor or 100,
|
||||
on_rightclick = create_mob_on_rightclick(def.on_rightclick),
|
||||
arrow = def.arrow,
|
||||
shoot_interval = def.shoot_interval,
|
||||
sounds = def.sounds or {},
|
||||
animation = def.animation,
|
||||
follow = def.follow,
|
||||
jump = def.jump ~= false,
|
||||
walk_chance = def.walk_chance or 50,
|
||||
attacks_monsters = def.attacks_monsters or false,
|
||||
group_attack = def.group_attack or false,
|
||||
passive = def.passive or false,
|
||||
knock_back = def.knock_back ~= false,
|
||||
shoot_offset = def.shoot_offset or 0,
|
||||
floats = def.floats or 1, -- floats in water by default
|
||||
floats_on_lava = def.floats_on_lava or 0,
|
||||
replace_rate = def.replace_rate,
|
||||
replace_what = def.replace_what,
|
||||
replace_with = def.replace_with,
|
||||
replace_offset = def.replace_offset or 0,
|
||||
on_replace = def.on_replace,
|
||||
timer = 0,
|
||||
env_damage_timer = 0,
|
||||
tamed = false,
|
||||
pause_timer = 0,
|
||||
horny = false,
|
||||
hornytimer = 0,
|
||||
gotten = false,
|
||||
health = 0,
|
||||
reach = def.reach or 3,
|
||||
htimer = 0,
|
||||
texture_list = def.textures,
|
||||
child_texture = def.child_texture,
|
||||
docile_by_day = def.docile_by_day or false,
|
||||
time_of_day = 0.5,
|
||||
fear_height = def.fear_height or 0,
|
||||
runaway = def.runaway,
|
||||
runaway_timer = 0,
|
||||
pathfinding = def.pathfinding,
|
||||
immune_to = def.immune_to or {},
|
||||
explosion_radius = def.explosion_radius, -- LEGACY
|
||||
explosion_damage_radius = def.explosion_damage_radius, -- LEGACY
|
||||
explosiontimer_reset_radius = def.explosiontimer_reset_radius,
|
||||
explosion_timer = def.explosion_timer or 3,
|
||||
allow_fuse_reset = def.allow_fuse_reset ~= false,
|
||||
stop_to_explode = def.stop_to_explode ~= false,
|
||||
custom_attack = def.custom_attack,
|
||||
double_melee_attack = def.double_melee_attack,
|
||||
dogshoot_switch = def.dogshoot_switch,
|
||||
dogshoot_count = 0,
|
||||
dogshoot_count_max = def.dogshoot_count_max or 5,
|
||||
dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5),
|
||||
attack_animals = def.attack_animals or false,
|
||||
specific_attack = def.specific_attack,
|
||||
runaway_from = def.runaway_from,
|
||||
owner_loyal = def.owner_loyal,
|
||||
facing_fence = false,
|
||||
_cmi_is_mob = true,
|
||||
pushable = def.pushable or true,
|
||||
|
||||
|
||||
-- MCL2 extensions
|
||||
teleport = teleport,
|
||||
do_teleport = def.do_teleport,
|
||||
spawn_class = def.spawn_class,
|
||||
ignores_nametag = def.ignores_nametag or false,
|
||||
rain_damage = def.rain_damage or 0,
|
||||
glow = def.glow,
|
||||
can_despawn = can_despawn,
|
||||
child = def.child or false,
|
||||
texture_mods = {},
|
||||
shoot_arrow = def.shoot_arrow,
|
||||
sounds_child = def.sounds_child,
|
||||
pick_up = def.pick_up,
|
||||
explosion_strength = def.explosion_strength,
|
||||
suffocation_timer = 0,
|
||||
follow_velocity = def.follow_velocity or 2.4,
|
||||
instant_death = def.instant_death or false,
|
||||
fire_resistant = def.fire_resistant or false,
|
||||
fire_damage_resistant = def.fire_damage_resistant or false,
|
||||
ignited_by_sunlight = def.ignited_by_sunlight or false,
|
||||
-- End of MCL2 extensions
|
||||
|
||||
on_spawn = def.on_spawn,
|
||||
|
||||
on_blast = def.on_blast or do_tnt,
|
||||
|
||||
on_step = mob_step,
|
||||
|
||||
do_punch = def.do_punch,
|
||||
|
||||
on_punch = mob_punch,
|
||||
|
||||
on_breed = def.on_breed,
|
||||
|
||||
on_grown = def.on_grown,
|
||||
|
||||
on_pick_up = def.on_pick_up,
|
||||
|
||||
on_detach_child = mob_detach_child,
|
||||
|
||||
on_activate = function(self, staticdata, dtime)
|
||||
--this is a temporary hack so mobs stop
|
||||
--glitching and acting really weird with the
|
||||
--default built in engine collision detection
|
||||
self.object:set_properties({
|
||||
collide_with_objects = false,
|
||||
})
|
||||
return mob_activate(self, staticdata, def, dtime)
|
||||
end,
|
||||
|
||||
if p.x > s.x then yaw = yaw + math_pi end
|
||||
|
||||
|
|
|
@ -61,10 +61,38 @@ if minetest.get_mapgen_setting("mg_name") == "v6" then
|
|||
TRADE_V6_BIRCH_SAPLING = { { "mcl_core:emerald", 8, 11 }, { "mcl_core:birchsapling", 1, 1 } }
|
||||
end
|
||||
|
||||
local tiernames = {
|
||||
"Novice",
|
||||
"Apprentice",
|
||||
"Journeyman",
|
||||
"Expert",
|
||||
"Master",
|
||||
}
|
||||
|
||||
local badges = {
|
||||
"mcl_core:wood",
|
||||
"mcl_core:stone",
|
||||
"mcl_core:goldblock",
|
||||
"mcl_core:emeraldblock",
|
||||
"mcl_core:diamondblock",
|
||||
}
|
||||
|
||||
local professions = {
|
||||
unemployed = {
|
||||
name = N("Unemployed"),
|
||||
textures = {
|
||||
"mobs_mc_villager.png",
|
||||
"mobs_mc_villager.png",
|
||||
},
|
||||
trades = nil,
|
||||
},
|
||||
farmer = {
|
||||
name = N("Farmer"),
|
||||
texture = "mobs_mc_villager_farmer.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_farmer.png",
|
||||
"mobs_mc_villager_farmer.png",
|
||||
},
|
||||
jobsite = "mcl_composters:composter",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_farming:wheat_item", 18, 22, }, E1 },
|
||||
|
@ -76,16 +104,19 @@ local professions = {
|
|||
{
|
||||
{ { "mcl_farming:pumpkin_face", 8, 13 }, E1 },
|
||||
{ E1, { "mcl_farming:pumpkin_pie", 2, 3} },
|
||||
{ E1, { "mcl_core:apple", 2, 3} },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_farming:melon", 7, 12 }, E1 },
|
||||
{ E1, { "mcl_core:apple", 5, 7 }, },
|
||||
{ E1, {"mcl_farming:cookie", 5, 7 }, },
|
||||
},
|
||||
|
||||
{
|
||||
{ E1, { "mcl_farming:cookie", 6, 10 } },
|
||||
{ E1, { "mcl_cake:cake", 1, 1 } },
|
||||
{ E1, { "mcl_mushrooms:mushroom_stew", 6, 10 } }, --FIXME: expert level farmer is supposed to sell sus stews.
|
||||
},
|
||||
{
|
||||
{ E1, { "mcl_farming:carrot_item_gold", 3, 10 } },
|
||||
{ E1, { "mcl_potions:speckled_melon", 4, 1 } },
|
||||
TRADE_V6_BIRCH_SAPLING,
|
||||
TRADE_V6_DARK_OAK_SAPLING,
|
||||
TRADE_V6_ACACIA_SAPLING,
|
||||
|
@ -94,33 +125,91 @@ local professions = {
|
|||
},
|
||||
fisherman = {
|
||||
name = N("Fisherman"),
|
||||
texture = "mobs_mc_villager_farmer.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_farmer.png",
|
||||
"mobs_mc_villager_farmer.png",
|
||||
},
|
||||
jobsite = "mcl_chests:barrel",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_fishing:fish_raw", 6, 6, "mcl_core:emerald", 1, 1 }, { "mcl_fishing:fish_cooked", 6, 6 } },
|
||||
{ { "mcl_fishing:fish_raw", 6, 6, "mcl_core:emerald", 1, 1 },{ "mcl_fishing:fish_cooked", 6, 6 } },
|
||||
{ { "mcl_mobitems:string", 15, 20 }, E1 },
|
||||
{ { "mcl_core:emerald", 3, 11 }, { "mcl_fishing:fishing_rod_enchanted", 1, 1} },
|
||||
{ { "mcl_core:coal_lump", 15, 10 }, E1 },
|
||||
-- FIXME missing: bucket of cod + fish should be cod.
|
||||
},
|
||||
{
|
||||
{ { "mcl_fishing:fish_raw", 6, 15,}, E1 },
|
||||
{ { "mcl_fishing:salmon_raw", 6, 6, "mcl_core:emerald", 1, 1 },{ "mcl_fishing:salmon_cooked", 6, 6 } },
|
||||
-- FIXME missing campfire
|
||||
-- {{ "mcl_core:emerald", 1, 2 },{"mcl_campfires:campfire",1,1} },
|
||||
},
|
||||
{
|
||||
{ { "mcl_fishing:salmon_raw", 6, 13,}, E1 },
|
||||
{ { "mcl_core:emerald", 7, 22 }, { "mcl_fishing:fishing_rod_enchanted", 1, 1} },
|
||||
},
|
||||
{
|
||||
{ { "mcl_fishing:clownfish_raw", 6, 6,}, E1 },
|
||||
},
|
||||
{
|
||||
{ { "mcl_fishing:pufferfish_raw", 4, 4,}, E1 },
|
||||
|
||||
{ { "mcl_boats:boat", 1, 1,}, E1 },
|
||||
{ { "mcl_boats:boat_acacia", 1, 1,}, E1 },
|
||||
{ { "mcl_boats:boat_spruce", 1, 1,}, E1 },
|
||||
{ { "mcl_boats:boat_dark_oak", 1, 1,}, E1 },
|
||||
{ { "mcl_boats:boat_birch", 1, 1,}, E1 },
|
||||
},
|
||||
},
|
||||
},
|
||||
fletcher = {
|
||||
name = N("Fletcher"),
|
||||
texture = "mobs_mc_villager_farmer.png",
|
||||
texture = {
|
||||
"mobs_mc_villager_farmer.png",
|
||||
"mobs_mc_villager_farmer.png",
|
||||
},
|
||||
jobsite = "mcl_fletching_table:fletching_table",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_mobitems:string", 15, 20 }, E1 },
|
||||
{ E1, { "mcl_bows:arrow", 8, 12 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:gravel", 10, 10, "mcl_core:emerald", 1, 1 }, { "mcl_core:flint", 6, 10 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:flint", 26, 26 }, E1 },
|
||||
{ { "mcl_core:emerald", 2, 3 }, { "mcl_bows:bow", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_mobitems:string", 14, 14 }, E1 },
|
||||
{ { "mcl_core:emerald", 3, 3 }, { "mcl_bows:crossbow", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_mobitems:string", 24, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 7, 21 } , { "mcl_bows:bow_enchanted", 1, 1 } },
|
||||
},
|
||||
{
|
||||
--FIXME: supposed to be tripwire hook{ { "tripwirehook", 24, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 8, 22 } , { "mcl_bows:crossbow_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:healing_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:harming_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:night_vision_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:swiftness_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:slowness_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:leaping_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:poison_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:regeneration_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:invisibility_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:water_breathing_arrow", 5, 5 } },
|
||||
{ { "mcl_core:emerald", 2, 2, "mcl_bows:arrow", 5, 5 }, { "mcl_potions:fire_resistance_arrow", 5, 5 } },
|
||||
},
|
||||
}
|
||||
},
|
||||
shepherd ={
|
||||
name = N("Shepherd"),
|
||||
texture = "mobs_mc_villager_farmer.png",
|
||||
texture = {
|
||||
"mobs_mc_villager_farmer.png",
|
||||
"mobs_mc_villager_farmer.png",
|
||||
},
|
||||
jobsite = "mcl_loom:loom",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_wool:white", 16, 22 }, E1 },
|
||||
|
@ -149,180 +238,287 @@ local professions = {
|
|||
},
|
||||
librarian = {
|
||||
name = N("Librarian"),
|
||||
texture = "mobs_mc_villager_librarian.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_librarian.png",
|
||||
"mobs_mc_villager_librarian.png",
|
||||
},
|
||||
jobsite = "mcl_villages:stonebrickcarved", --FIXME: lectern
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_core:paper", 24, 36 }, E1 },
|
||||
{ { "mcl_books:book", 8, 10 }, E1 },
|
||||
{ { "mcl_core:emerald", 10, 12 }, { "mcl_compass:compass", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 3, 4 }, { "mcl_books:bookshelf", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 5, 64 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 9, 9 }, { "mcl_books:bookshelf", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 5, 64, "mcl_books:book", 1, 1 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_books:written_book", 2, 2 }, E1 },
|
||||
{ { "mcl_core:emerald", 10, 12 }, { "mcl_clock:clock", 1, 1 } },
|
||||
{ E1, { "mcl_core:glass", 3, 5 } },
|
||||
{ { "mcl_core:emerald", 5, 64 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 5, 64, "mcl_books:book", 1, 1 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ E1, { "mcl_lanterns:lantern_floor", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ E1, { "mcl_core:glass", 3, 5 } },
|
||||
{ { "mcl_core:emerald", 5, 64 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ { "mcl_dye:black", 5, 5 }, E1 },
|
||||
{ { "mcl_core:emerald", 5, 64, "mcl_books:book", 1, 1 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ E1, { "mcl_core:glass", 4, 4 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:emerald", 5, 64 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ E1, { "mcl_books:writable_book", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 5, 64, "mcl_books:book", 1, 1 }, { "mcl_enchanting:book_enchanted", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 4, 4 }, { "mcl_compass:compass", 1 ,1 }},
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_clock:clock", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:emerald", 20, 22 }, { "mcl_mobs:nametag", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 20, 20 }, { "mcl_mobs:nametag", 1, 1 } },
|
||||
}
|
||||
},
|
||||
},
|
||||
cartographer = {
|
||||
name = N("Cartographer"),
|
||||
texture = "mobs_mc_villager_librarian.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_librarian.png",
|
||||
"mobs_mc_villager_librarian.png",
|
||||
},
|
||||
jobsite = "mcl_cartography_table:cartography_table",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_core:paper", 24, 36 }, E1 },
|
||||
{ { "mcl_core:paper", 24, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_maps:empty_map", 1, 1 } },
|
||||
},
|
||||
{
|
||||
-- compass subject to special checks
|
||||
{ { "xpanes:pane_natural_flat", 1, 1 }, E1 },
|
||||
--{ { "mcl_core:emerald", 13, 13, "mcl_compass:compass", 1, 1 }, { "FIXME:ocean explorer map" 1, 1} },
|
||||
},
|
||||
|
||||
{
|
||||
-- subject to special checks
|
||||
{ { "mcl_compass:compass", 1, 1 }, E1 },
|
||||
--{ { "mcl_core:emerald", 13, 13, "mcl_compass:compass", 1, 1 }, { "FIXME:woodland explorer map" 1, 1} },
|
||||
},
|
||||
|
||||
{
|
||||
-- TODO: replace with empty map
|
||||
{ { "mcl_core:emerald", 7, 11}, { "mcl_maps:empty_map", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_itemframes:item_frame", 1, 1 }},
|
||||
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_white", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_grey", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_silver", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_black", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_red", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_green", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_cyan", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_blue", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_magenta", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_orange", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_purple", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_brown", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_pink", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_lime", 1, 1 }},
|
||||
{ { "mcl_core:emerald", 7, 7}, { "mcl_banners:banner_item_light_blue", 1, 1 }},
|
||||
},
|
||||
{
|
||||
--{ { "mcl_core:emerald", 8, 8}, { "FIXME: globe banner pattern", 1, 1 } },
|
||||
},
|
||||
|
||||
-- TODO: special maps
|
||||
},
|
||||
},
|
||||
armorer = {
|
||||
name = N("Armorer"),
|
||||
texture = "mobs_mc_villager_smith.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_smith.png",
|
||||
"mobs_mc_villager_smith.png",
|
||||
},
|
||||
jobsite = "mcl_blast_furnace:blast_furnace",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_core:coal_lump", 16, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 4, 6 }, { "mcl_armor:helmet_iron", 1, 1 } },
|
||||
{ { "mcl_core:coal_lump", 15, 15 }, E1 },
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_armor:helmet_iron", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 9, 9 }, { "mcl_armor:chestplate_iron", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 7, 7 }, { "mcl_armor:leggings_iron", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 4, 4 }, { "mcl_armor:boots_iron", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:iron_ingot", 7, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 10, 14 }, { "mcl_armor:chestplate_iron", 1, 1 } },
|
||||
{ { "mcl_core:iron_ingot", 4, 4 }, E1 },
|
||||
--{ { "mcl_core:emerald", 36, 36 }, { "FIXME: Bell", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 3, 3 }, { "mcl_armor:leggings_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 1, 1 }, { "mcl_armor:boots_chain", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_buckets:bucket_lava", 1, 1 }, E1 },
|
||||
{ { "mcl_core:diamond", 1, 1 }, E1 },
|
||||
{ { "mcl_core:emerald", 1, 1 }, { "mcl_armor:helmet_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 4, 4 }, { "mcl_armor:chestplate_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_shields:shield", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:diamond", 3, 4 }, E1 },
|
||||
{ { "mcl_core:emerald", 16, 19 }, { "mcl_armor:chestplate_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 19, 33 }, { "mcl_armor:leggings_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 13, 27 }, { "mcl_armor:boots_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:emerald", 5, 7 }, { "mcl_armor:boots_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 9, 11 }, { "mcl_armor:leggings_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 5, 7 }, { "mcl_armor:helmet_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 11, 15 }, { "mcl_armor:chestplate_chain", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 13, 27 }, { "mcl_armor:helmet_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 21, 35 }, { "mcl_armor:chestplate_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
leatherworker = {
|
||||
name = N("Leatherworker"),
|
||||
texture = "mobs_mc_villager_butcher.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_butcher.png",
|
||||
"mobs_mc_villager_butcher.png",
|
||||
},
|
||||
jobsite = "mcl_cauldrons:cauldron",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_mobitems:leather", 9, 12 }, E1 },
|
||||
{ { "mcl_core:emerald", 2, 4 }, { "mcl_armor:leggings_leather", 2, 4 } },
|
||||
{ { "mcl_core:emerald", 3, 3 }, { "mcl_armor:leggings_leather", 2, 4 } },
|
||||
{ { "mcl_core:emerald", 7, 7 }, { "mcl_armor:chestplate_leather", 2, 4 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:emerald", 7, 12 }, { "mcl_armor:chestplate_leather_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:flint", 26, 26 }, E1 },
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_armor:helmet_leather", 2, 4 } },
|
||||
{ { "mcl_core:emerald", 4, 4 }, { "mcl_armor:boots_leather", 2, 4 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_mobitems:rabbit_hide", 9, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 7, 7 }, { "mcl_armor:chestplate_leather", 1, 1 } },
|
||||
},
|
||||
{
|
||||
--{ { "FIXME: scute", 4, 4 }, E1 },
|
||||
{ { "mcl_core:emerald", 8, 10 }, { "mcl_mobitems:saddle", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:emerald", 6, 6 }, { "mcl_mobitems:saddle", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_armor:helmet_leather", 2, 4 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
butcher = {
|
||||
name = N("Butcher"),
|
||||
texture = "mobs_mc_villager_butcher.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_butcher.png",
|
||||
"mobs_mc_villager_butcher.png",
|
||||
},
|
||||
jobsite = "mcl_smoker:smoker",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_mobitems:beef", 14, 18 }, E1 },
|
||||
{ { "mcl_mobitems:chicken", 14, 18 }, E1 },
|
||||
{ { "mcl_mobitems:beef", 14, 14 }, E1 },
|
||||
{ { "mcl_mobitems:chicken", 7, 7 }, E1 },
|
||||
{ { "mcl_mobitems:rabbit", 4, 4 }, E1 },
|
||||
{ E1, { "mcl_mobitems:rabbit_stew", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:coal_lump", 16, 24 }, E1 },
|
||||
{ E1, { "mcl_mobitems:cooked_beef", 5, 7 } },
|
||||
{ E1, { "mcl_mobitems:cooked_chicken", 6, 8 } },
|
||||
{ { "mcl_core:coal_lump", 15, 15 }, E1 },
|
||||
{ E1, { "mcl_mobitems:cooked_porkchop", 5, 5 } },
|
||||
{ E1, { "mcl_mobitems:cooked_chicken", 8, 8 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_mobitems:mutton", 7, 7 }, E1 },
|
||||
{ { "mcl_mobitems:beef", 10, 10 }, E1 },
|
||||
},
|
||||
{
|
||||
{ { "mcl_mobitems:mutton", 7, 7 }, E1 },
|
||||
{ { "mcl_mobitems:beef", 10, 10 }, E1 },
|
||||
},
|
||||
{
|
||||
--{ { "FIXME: Sweet Berries", 10, 10 }, E1 },
|
||||
},
|
||||
},
|
||||
},
|
||||
weapon_smith = {
|
||||
name = N("Weapon Smith"),
|
||||
texture = "mobs_mc_villager_smith.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_smith.png",
|
||||
"mobs_mc_villager_smith.png",
|
||||
},
|
||||
jobsite = "mcl_villages:stonebrickcarved", --FIXME: grindstone
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_core:coal_lump", 16, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 6, 8 }, { "mcl_tools:axe_iron", 1, 1 } },
|
||||
{ { "mcl_core:coal_lump", 15, 15 }, E1 },
|
||||
{ { "mcl_core:emerald", 3, 3 }, { "mcl_tools:axe_iron", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 7, 21 }, { "mcl_tools:sword_iron_enchanted", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:iron_ingot", 7, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 9, 10 }, { "mcl_tools:sword_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:iron_ingot", 4, 4 }, E1 },
|
||||
--{ { "mcl_core:emerald", 36, 36 }, { "FIXME: Bell", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:flint", 7, 9 }, E1 },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:diamond", 7, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 17, 31 }, { "mcl_tools:axe_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:diamond", 3, 4 }, E1 },
|
||||
{ { "mcl_core:emerald", 12, 15 }, { "mcl_tools:sword_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 9, 12 }, { "mcl_tools:axe_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 13, 27 }, { "mcl_tools:sword_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
tool_smith = {
|
||||
name = N("Tool Smith"),
|
||||
texture = "mobs_mc_villager_smith.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_smith.png",
|
||||
"mobs_mc_villager_smith.png",
|
||||
},
|
||||
jobsite = "mcl_anvils:anvil", --FIXME: smithing table
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_core:coal_lump", 16, 24 }, E1 },
|
||||
{ { "mcl_core:emerald", 5, 7 }, { "mcl_tools:shovel_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:coal_lump", 15, 15 }, E1 },
|
||||
{ E1, { "mcl_tools:axe_stone", 1, 1 } },
|
||||
{ E1, { "mcl_tools:shovel_stone", 1, 1 } },
|
||||
{ E1, { "mcl_tools:pick_stone", 1, 1 } },
|
||||
{ E1, { "mcl_farming:hoe_stone", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:iron_ingot", 7, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 9, 11 }, { "mcl_tools:pick_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:iron_ingot", 4, 4 }, E1 },
|
||||
--{ { "mcl_core:emerald", 36, 36 }, { "FIXME: Bell", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_core:diamond", 3, 4 }, E1 },
|
||||
{ { "mcl_core:emerald", 12, 15 }, { "mcl_tools:pick_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:flint", 30, 30 }, E1 },
|
||||
{ { "mcl_core:emerald", 6, 20 }, { "mcl_tools:axe_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 7, 21 }, { "mcl_tools:shovel_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 8, 22 }, { "mcl_tools:pick_iron_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 4, 4 }, { "mcl_farming:hoe_diamond", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:diamond", 1, 1 }, E1 },
|
||||
{ { "mcl_core:emerald", 17, 31 }, { "mcl_tools:axe_diamond_enchanted", 1, 1 } },
|
||||
{ { "mcl_core:emerald", 10, 24 }, { "mcl_tools:shovel_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
{
|
||||
{ { "mcl_core:emerald", 18, 32 }, { "mcl_tools:pick_diamond_enchanted", 1, 1 } },
|
||||
},
|
||||
},
|
||||
},
|
||||
cleric = {
|
||||
name = N("Cleric"),
|
||||
texture = "mobs_mc_villager_priest.png",
|
||||
textures = {
|
||||
"mobs_mc_villager_priest.png",
|
||||
"mobs_mc_villager_priest.png",
|
||||
},
|
||||
jobsite = "mcl_brewing:stand_000",
|
||||
trades = {
|
||||
{
|
||||
{ { "mcl_mobitems:rotten_flesh", 36, 40 }, E1 },
|
||||
{ { "mcl_core:gold_ingot", 8, 10 }, E1 },
|
||||
{ { "mcl_mobitems:rotten_flesh", 32, 32 }, E1 },
|
||||
{ E1, { "mesecons:redstone", 2, 2 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ E1, { "mesecons:redstone", 1, 4 } },
|
||||
{ E1, { "mcl_dye:blue", 1, 2 } },
|
||||
{ { "mcl_core:gold_ingot", 3, 3 }, E1 },
|
||||
{ E1, { "mcl_dye:blue", 1, 1 } },
|
||||
},
|
||||
|
||||
{
|
||||
{ E1, { "mcl_nether:glowstone", 1, 3 } },
|
||||
{ { "mcl_core:emerald", 4, 7 }, { "mcl_throwing:ender_pearl", 1, 1 } },
|
||||
{ { "mcl_mobitems:rabbit_foot", 2, 2 }, E1 },
|
||||
{ E1, { "mcl_nether:glowstone", 4, 4 } },
|
||||
},
|
||||
{
|
||||
--{ { "FIXME: scute", 4, 4 }, E1 },
|
||||
{ { "mcl_potions:glass_bottle", 9, 9 }, E1 },
|
||||
{ { "mcl_core:emerald", 5, 5 }, { "mcl_throwing:ender_pearl", 1, 1 } },
|
||||
TRADE_V6_RED_SANDSTONE,
|
||||
},
|
||||
|
||||
{
|
||||
{ { "mcl_nether:nether_wart_item", 22, 22 }, E1 },
|
||||
{ { "mcl_core:emerald", 3, 3 }, { "mcl_experience:bottle", 1, 1 } },
|
||||
|
@ -331,7 +527,10 @@ local professions = {
|
|||
},
|
||||
nitwit = {
|
||||
name = N("Nitwit"),
|
||||
texture = "mobs_mc_villager.png",
|
||||
textures = {
|
||||
"mobs_mc_villager.png",
|
||||
"mobs_mc_villager.png",
|
||||
},
|
||||
-- No trades for nitwit
|
||||
trades = nil,
|
||||
}
|
||||
|
@ -342,11 +541,110 @@ for id, _ in pairs(professions) do
|
|||
table.insert(profession_names, id)
|
||||
end
|
||||
|
||||
local jobsites={}
|
||||
for _,n in pairs(profession_names) do
|
||||
table.insert(jobsites,professions[n].jobsite)
|
||||
end
|
||||
|
||||
local stand_still = function(self)
|
||||
self.walk_chance = 0
|
||||
self.jump = false
|
||||
end
|
||||
|
||||
local function init_trader_vars(self)
|
||||
if not self._max_trade_tier then
|
||||
self._max_trade_tier = 1
|
||||
end
|
||||
if not self._locked_trades then
|
||||
self._locked_trades = 0
|
||||
end
|
||||
if not self._trading_players then
|
||||
self._trading_players = {}
|
||||
end
|
||||
end
|
||||
|
||||
----- JOBSITE LOGIC
|
||||
|
||||
local function set_velocity(self, v)
|
||||
local yaw = (self.object:get_yaw() or 0) + self.rotate
|
||||
self.object:set_velocity({
|
||||
x = (math.sin(yaw) * -v),
|
||||
y = self.object:get_velocity().y,
|
||||
z = (math.cos(yaw) * v),
|
||||
})
|
||||
end
|
||||
|
||||
local function go_to_pos(entity,b)
|
||||
local s=entity.object:get_pos()
|
||||
if vector.distance(b,s) < 1 then
|
||||
--set_velocity(entity,0)
|
||||
return true
|
||||
end
|
||||
local v = { x = b.x - s.x, z = b.z - s.z }
|
||||
local yaw = (math.atan(v.z / v.x) + math.pi / 2) - entity.rotate
|
||||
if b.x > s.x then yaw = yaw + math.pi end
|
||||
entity.object:set_yaw(yaw)
|
||||
set_velocity(entity,entity.follow_velocity)
|
||||
end
|
||||
|
||||
local function go_home(entity)
|
||||
entity.state = "go_home"
|
||||
local b=entity.bed
|
||||
if not b then return end
|
||||
if go_to_pos(entity,b) then
|
||||
entity.state = "stand"
|
||||
set_velocity(entity,0)
|
||||
entity.object:set_pos(b)
|
||||
local n=minetest.get_node(b)
|
||||
if n and n.name ~= "mcl_beds:bed_red_bottom" then
|
||||
entity.bed=nil --the stormtroopers have killed uncle owen
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_profession_by_jobsite(js)
|
||||
for k,v in pairs(professions) do
|
||||
if v.jobsite == js then return k end
|
||||
end
|
||||
end
|
||||
|
||||
local function employ(self,jobsite_pos)
|
||||
local n = minetest.get_node(jobsite_pos)
|
||||
local m = minetest.get_meta(jobsite_pos)
|
||||
local p = get_profession_by_jobsite(n.name)
|
||||
if p and m:get_string("villager") == "" then
|
||||
self._profession=p
|
||||
m:set_string("villager",self._id)
|
||||
self._jobsite = jobsite_pos
|
||||
self.object:set_properties({textures=professions[self._profession].textures})
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function unemploy(self)
|
||||
self._profession="unemployed"
|
||||
self._jobsite = nil
|
||||
self.object:set_properties({textures=professions[self._profession].textures})
|
||||
end
|
||||
|
||||
local function get_a_job(self)
|
||||
local p = self.object:get_pos()
|
||||
local nn = minetest.find_nodes_in_area(vector.offset(p,-8,-8,-8),vector.offset(p,8,8,8),jobsites)
|
||||
for _,n in pairs(nn) do
|
||||
if n and employ(self,n) then return end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_jobsite(self)
|
||||
local n = minetest.get_node(self._jobsite)
|
||||
local m = minetest.get_meta(self._jobsite)
|
||||
if n.name ~= professions[self._profession].jobsite or m:get_string("villager") ~= self._id then
|
||||
unemploy(self)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local update_max_tradenum = function(self)
|
||||
if not self._trades then
|
||||
return
|
||||
|
@ -362,30 +660,6 @@ local update_max_tradenum = function(self)
|
|||
self._max_tradenum = #trades
|
||||
end
|
||||
|
||||
local init_trader_vars = function(self)
|
||||
if not self._profession then
|
||||
-- Select random profession from all professions with matching clothing
|
||||
local texture = self.base_texture[1]
|
||||
local matches = {}
|
||||
for prof_id, prof in pairs(professions) do
|
||||
if texture == prof.texture then
|
||||
table.insert(matches, prof_id)
|
||||
end
|
||||
end
|
||||
local p = math.random(1, #matches)
|
||||
self._profession = matches[p]
|
||||
end
|
||||
if not self._max_trade_tier then
|
||||
self._max_trade_tier = 1
|
||||
end
|
||||
if not self._locked_trades then
|
||||
self._locked_trades = 0
|
||||
end
|
||||
if not self._trading_players then
|
||||
self._trading_players = {}
|
||||
end
|
||||
end
|
||||
|
||||
local init_trades = function(self, inv)
|
||||
local profession = professions[self._profession]
|
||||
local trade_tiers = profession and profession.trades
|
||||
|
@ -516,7 +790,7 @@ local function show_trade_formspec(playername, trader, tradenum)
|
|||
"size[9,8.75]"
|
||||
.."background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]"
|
||||
..disabled_img
|
||||
.."label[4,0;"..F(minetest.colorize("#313131", S(profession))).."]"
|
||||
.."label[3,0;"..F(minetest.colorize("#313131", S(profession).." - "..S(tiernames[trader._max_trade_tier]))) .."]"
|
||||
.."list[current_player;main;0,4.5;9,3;9]"
|
||||
.."list[current_player;main;0,7.74;9,1;]"
|
||||
..b_prev..b_next
|
||||
|
@ -941,31 +1215,9 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
visual = "mesh",
|
||||
mesh = "mobs_mc_villager.b3d",
|
||||
textures = {
|
||||
{
|
||||
"mobs_mc_villager.png",
|
||||
"mobs_mc_villager.png", --hat
|
||||
},
|
||||
{
|
||||
"mobs_mc_villager_farmer.png",
|
||||
"mobs_mc_villager_farmer.png", --hat
|
||||
},
|
||||
{
|
||||
"mobs_mc_villager_priest.png",
|
||||
"mobs_mc_villager_priest.png", --hat
|
||||
},
|
||||
{
|
||||
"mobs_mc_villager_librarian.png",
|
||||
"mobs_mc_villager_librarian.png", --hat
|
||||
},
|
||||
{
|
||||
"mobs_mc_villager_butcher.png",
|
||||
"mobs_mc_villager_butcher.png", --hat
|
||||
},
|
||||
{
|
||||
"mobs_mc_villager_smith.png",
|
||||
"mobs_mc_villager_smith.png", --hat
|
||||
},
|
||||
},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
rotate = 270,
|
||||
skittish = true,
|
||||
|
@ -1000,12 +1252,35 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
fear_height = 4,
|
||||
jump = true,
|
||||
walk_chance = DEFAULT_WALK_CHANCE,
|
||||
bed = nil,
|
||||
_id = nil,
|
||||
_profession = "unemployed",
|
||||
look_at_player = true,
|
||||
pick_up = {"mcl_farming:bread"},
|
||||
on_pick_up = function(self,itementity)
|
||||
local clicker
|
||||
for _,p in pairs(minetest.get_connected_players()) do
|
||||
if vector.distance(p:get_pos(),self.object:get_pos()) < 10 then
|
||||
clicker = p
|
||||
end
|
||||
end
|
||||
if not clicker then minetest.log("no clicker") end
|
||||
if clicker then
|
||||
mobs:feed_tame(self, clicker, 1, true, true)
|
||||
return
|
||||
end
|
||||
return true --do not pick up
|
||||
end,
|
||||
on_rightclick = function(self, clicker)
|
||||
end
|
||||
if self.child or self._profession == "unemployed" then
|
||||
return
|
||||
end
|
||||
-- Initiate trading
|
||||
--init_trader_vars(self)
|
||||
local name = clicker:get_player_name()
|
||||
self._trading_players[name] = true
|
||||
|
||||
init_trader_vars(self)
|
||||
if self._trades == nil then
|
||||
init_trades(self)
|
||||
end
|
||||
|
@ -1042,6 +1317,7 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
if not self._player_scan_timer then
|
||||
self._player_scan_timer = 0
|
||||
end
|
||||
|
||||
self._player_scan_timer = self._player_scan_timer + dtime
|
||||
-- Check infrequently to keep CPU load low
|
||||
if self._player_scan_timer > PLAYER_SCAN_INTERVAL then
|
||||
|
@ -1063,20 +1339,36 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
self.walk_chance = DEFAULT_WALK_CHANCE
|
||||
self.jump = true
|
||||
end
|
||||
if self.bed and ( self.state == "go_home" or vector.distance(self.object:get_pos(),self.bed) > 50 ) then
|
||||
go_home(self)
|
||||
end
|
||||
if self._profession == "unemployed" then
|
||||
get_a_job(self)
|
||||
else
|
||||
check_jobsite(self)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_spawn = function(self)
|
||||
init_trader_vars(self)
|
||||
if self._id then
|
||||
self.object:set_properties({textures=professions[self._profession].textures})
|
||||
return
|
||||
end
|
||||
self._id=minetest.sha1(minetest.get_gametime()..minetest.pos_to_string(self.object:get_pos())..tostring(math.random()))
|
||||
self._profession = "unemployed"
|
||||
self.object:set_properties({textures=professions[self._profession].textures})
|
||||
end,
|
||||
on_die = function(self, pos)
|
||||
-- Close open trade formspecs and give input back to players
|
||||
local trading_players = self._trading_players
|
||||
for name, _ in pairs(trading_players) do
|
||||
minetest.close_formspec(name, "mobs_mc:trade_"..name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
return_fields(player)
|
||||
if trading_players then
|
||||
for name, _ in pairs(trading_players) do
|
||||
minetest.close_formspec(name, "mobs_mc:trade_"..name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
return_fields(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue