Compare commits
2 Commits
6def6b85f8
...
ca2912a0cb
Author | SHA1 | Date |
---|---|---|
kno10 | ca2912a0cb | |
kno10 | 173e17e37c |
|
@ -2,8 +2,8 @@ local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
|||
local mob_class = mcl_mobs.mob_class
|
||||
--local validate_vector = mcl_util.validate_vector
|
||||
|
||||
local MAX_DTIME = 0.25 -- todo: make user configurable?
|
||||
local ACCELERATION_MIX = 1.0 -- how much of acceleration to handle in Lua instead of MTE todo: make user configurable
|
||||
local MAX_DTIME = 0.5 -- todo: make user configurable?
|
||||
local ACCELERATION_MIX = 0.2 -- how much of acceleration to handle in Lua instead of MTE todo: make user configurable
|
||||
local ENTITY_CRAMMING_MAX = 24
|
||||
local CRAMMING_DAMAGE = 3
|
||||
local DEATH_DELAY = 0.5
|
||||
|
@ -49,9 +49,7 @@ function mob_class:update_standing(pos, moveresult)
|
|||
local temp_pos = vector.offset(pos, 0, self.collisionbox[2] + 0.5, 0) -- foot level
|
||||
self.collides = moveresult and moveresult.collides
|
||||
self.standing_in = minetest.registered_nodes[minetest.get_node(temp_pos).name] or NODE_IGNORE
|
||||
temp_pos.y = temp_pos.y - 1.5 -- below
|
||||
self.standing_on_node = minetest.get_node(temp_pos) -- to allow access to param2 in, e.g., stalker
|
||||
self.standing_on = self.standing_on_node and minetest.registered_nodes[self.standing_on_node.name] or NODE_IGNORE
|
||||
temp_pos.y = temp_pos.y - 1 -- below
|
||||
-- sometimes, we may be colliding with a node *not* below us, effectively standing on it instead (e.g., a corner)
|
||||
if not self.standing_on.walkable and moveresult and moveresult.collisions then
|
||||
-- to inspect: minetest.log("action", dump(moveresult):gsub(" *\n\\s*",""))
|
||||
|
@ -59,10 +57,14 @@ function mob_class:update_standing(pos, moveresult)
|
|||
if c.axis == "y" and c.type == "node" and c.old_velocity.y < 0 then
|
||||
self.standing_on_node = minetest.get_node(c.node_pos)
|
||||
self.standing_on = minetest.registered_nodes[self.standing_on_node.name]
|
||||
break
|
||||
goto standing_on_updated
|
||||
end
|
||||
end
|
||||
end
|
||||
-- fallback
|
||||
self.standing_on_node = minetest.get_node(temp_pos) -- to allow access to param2 in, e.g., stalker
|
||||
self.standing_on = self.standing_on_node and minetest.registered_nodes[self.standing_on_node.name] or NODE_IGNORE
|
||||
::standing_on_updated::
|
||||
-- approximate height of head over ground:
|
||||
self.standing_height = pos.y - math.floor(temp_pos.y + 0.5) - 0.5 + self.head_eye_height * 0.9
|
||||
temp_pos.y = temp_pos.y + 2 -- at +1 = above
|
||||
|
|
|
@ -35,7 +35,7 @@ local fox = {
|
|||
makes_footstep_sound = true,
|
||||
head_swivel = "Bone.001",
|
||||
head_yaw = "z",
|
||||
head_eye_height = 0.5,
|
||||
head_eye_height = 0.3,
|
||||
head_bone_position = vector.new( 0, 0.5, 0 ), -- for minetest <5.8
|
||||
curiosity = 5,
|
||||
sounds = {
|
||||
|
@ -84,7 +84,7 @@ local fox = {
|
|||
--die_start = 0, die_end = 0, die_speed = 0,--die_loop = 0,
|
||||
},
|
||||
jump = true,
|
||||
jump_height = 4, -- TODO: when attacking, allow to jump higher
|
||||
jump_height = 1.3, -- TODO: when attacking, allow to jump higher
|
||||
attacks_monsters = true,
|
||||
attack_animals = true,
|
||||
specific_attack = {
|
||||
|
|
|
@ -3,33 +3,23 @@
|
|||
local S = minetest.get_translator("mobs_mc")
|
||||
|
||||
-- foliage and grass palettes, loaded from mcl_maps
|
||||
local palettes = {}
|
||||
local colors = {}
|
||||
|
||||
local function load_json_file(name)
|
||||
local file = assert(io.open(name, "r"))
|
||||
local data = minetest.parse_json(file:read("*all"))
|
||||
file:close()
|
||||
return data
|
||||
end
|
||||
local mapmodpath = minetest.get_modpath("mcl_maps")
|
||||
if mapmodpath then
|
||||
for k,v in pairs(load_json_file(mapmodpath .. "/palettes_grass.json")) do
|
||||
palettes[k] = v
|
||||
end
|
||||
for k,v in pairs(load_json_file(mapmodpath .. "/palettes_foliage.json")) do
|
||||
palettes[k] = v
|
||||
end
|
||||
for k,v in pairs(load_json_file(mapmodpath .. "/palettes_water.json")) do
|
||||
palettes[k] = v
|
||||
local file = assert(io.open(mapmodpath .. "/colors.json", "r"))
|
||||
local data = minetest.parse_json(file:read("*all"))
|
||||
file:close()
|
||||
for k,v in pairs(data) do
|
||||
colors[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function get_texture(self, prev)
|
||||
local standing_on = minetest.registered_nodes[self.standing_on]
|
||||
-- TODO: we do not have access to param2 here (color palette index) yet
|
||||
local standing_on = self.standing_on
|
||||
local texture
|
||||
local texture_suff = ""
|
||||
local tex_mod = ""
|
||||
if standing_on and (standing_on.walkable or standing_on.groups.liquid) then
|
||||
local tiles = standing_on.tiles
|
||||
if tiles then
|
||||
|
@ -37,17 +27,14 @@ local function get_texture(self, prev)
|
|||
local color
|
||||
if type(tile) == "table" then
|
||||
texture = tile.name or tile.image
|
||||
if tile.color then
|
||||
color = minetest.colorspec_to_colorstring(tile.color)
|
||||
end
|
||||
color = tile.color and minetest.colorspec_to_colorstring(tile.color)
|
||||
elseif type(tile) == "string" then
|
||||
texture = tile
|
||||
end
|
||||
if not color then
|
||||
color = minetest.colorspec_to_colorstring(standing_on.color)
|
||||
end
|
||||
-- handle param2
|
||||
if standing_on.palette and self.standing_on_node then
|
||||
color = color or minetest.colorspec_to_colorstring(standing_on.color)
|
||||
-- get colors from mcl_maps data where possible, including param2
|
||||
local cols = colors[standing_on.name]
|
||||
if cols and type(cols[1]) == "table" and self.standing_on_node then
|
||||
local param2
|
||||
if standing_on.paramtype2 == "color" then
|
||||
param2 = self.standing_on_node.param2
|
||||
|
@ -60,16 +47,13 @@ local function get_texture(self, prev)
|
|||
elseif standing_on.paramtype2 == "colordegrotate" then
|
||||
param2 = math.floor(self.standing_on_node.param2 / 8)
|
||||
end
|
||||
local palette = palettes[standing_on.palette]
|
||||
local oldcol = color
|
||||
if param2 and palette then
|
||||
local c = palette[param2 + 1]
|
||||
if c then color = minetest.rgba(c[1], c[2], c[3], c[4]) end
|
||||
end
|
||||
color = cols[param2 + 1] or color
|
||||
end
|
||||
if color then
|
||||
texture_suff = "^[multiply:" .. color .. "^[contrast:20:10" --"^[hsl:0:0:20"
|
||||
if type(color) == "table" then color = minetest.rgba(color[1], color[2], color[3], color[4]) end
|
||||
tex_mod = "^[multiply:" .. color
|
||||
end
|
||||
tex_mod = tex_mod .. "^[hsl:0:20:20"
|
||||
end
|
||||
end
|
||||
if not texture or texture == "" then
|
||||
|
@ -78,10 +62,10 @@ local function get_texture(self, prev)
|
|||
return prev
|
||||
end
|
||||
texture = "vl_stalker_default.png"
|
||||
if texture_suff then texture = texture .. texture_suff end
|
||||
if tex_mod then texture = texture .. tex_mod end
|
||||
else
|
||||
texture = texture:gsub("([\\^:\\[])", "\\%1") -- escape texture modifiers
|
||||
texture = "(vl_stalker_default.png^[combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture .. ")" .. texture_suff .. ")"
|
||||
texture = "(vl_stalker_default.png^[combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture .. ")" .. tex_mod .. ")"
|
||||
end
|
||||
if self.attack then
|
||||
texture = texture .. "^vl_mobs_stalker_overlay_angry.png"
|
||||
|
|
Loading…
Reference in New Issue