mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-30 23:03:45 +01:00
Improve stalker textures (#4674)
- don't change back to default texture when falling, but rather keep the previous texture - use a colorized default texture for gaps in the texture Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4674 Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land> Co-authored-by: kno10 <erich.schubert@gmail.com> Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
parent
f6f5481f30
commit
fb3c85e289
@ -7,12 +7,13 @@ local S = minetest.get_translator("mobs_mc")
|
|||||||
--###################
|
--###################
|
||||||
|
|
||||||
|
|
||||||
local function get_texture(self)
|
local function get_texture(self, prev)
|
||||||
local on_name = self.standing_on
|
local standing_on = minetest.registered_nodes[self.standing_on]
|
||||||
|
-- TODO: we do not have access to param2 here (color palette index) yet
|
||||||
local texture
|
local texture
|
||||||
local texture_suff = ""
|
local texture_suff = ""
|
||||||
if on_name and on_name ~= "air" then
|
if standing_on and (standing_on.walkable or standing_on.groups.liquid) then
|
||||||
local tiles = minetest.registered_nodes[on_name].tiles
|
local tiles = standing_on.tiles
|
||||||
if tiles then
|
if tiles then
|
||||||
local tile = tiles[1]
|
local tile = tiles[1]
|
||||||
local color
|
local color
|
||||||
@ -25,7 +26,7 @@ local function get_texture(self)
|
|||||||
texture = tile
|
texture = tile
|
||||||
end
|
end
|
||||||
if not color then
|
if not color then
|
||||||
color = minetest.colorspec_to_colorstring(minetest.registered_nodes[on_name].color)
|
color = minetest.colorspec_to_colorstring(standing_on.color)
|
||||||
end
|
end
|
||||||
if color then
|
if color then
|
||||||
texture_suff = "^[multiply:" .. color .. "^[hsl:0:0:20"
|
texture_suff = "^[multiply:" .. color .. "^[hsl:0:0:20"
|
||||||
@ -33,14 +34,19 @@ local function get_texture(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not texture or texture == "" then
|
if not texture or texture == "" then
|
||||||
texture = "vl_stalker_default.png"
|
-- try to keep last texture when, e.g., falling
|
||||||
|
if prev and (not (not self.attack)) == (string.find(prev, "vl_mobs_stalker_overlay_angry.png") ~= nil) then
|
||||||
|
return prev
|
||||||
end
|
end
|
||||||
texture = texture:gsub("([\\^:\\[])","\\%1") -- escape texture modifiers
|
texture = "vl_stalker_default.png"
|
||||||
texture = "([combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture ..")".. texture_suff
|
|
||||||
if self.attack then
|
|
||||||
texture = texture .. ")^vl_mobs_stalker_overlay_angry.png"
|
|
||||||
else
|
else
|
||||||
texture = texture .. ")^vl_mobs_stalker_overlay.png"
|
texture = texture:gsub("([\\^:\\[])", "\\%1") -- escape texture modifiers
|
||||||
|
texture = "(vl_stalker_default.png^[combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture .. ")" .. texture_suff .. ")"
|
||||||
|
end
|
||||||
|
if self.attack then
|
||||||
|
texture = texture .. "^vl_mobs_stalker_overlay_angry.png"
|
||||||
|
else
|
||||||
|
texture = texture .. "^vl_mobs_stalker_overlay.png"
|
||||||
end
|
end
|
||||||
return texture
|
return texture
|
||||||
end
|
end
|
||||||
@ -132,7 +138,7 @@ mcl_mobs.register_mob("mobs_mc:stalker", {
|
|||||||
self:boom(mcl_util.get_object_center(self.object), self.explosion_strength)
|
self:boom(mcl_util.get_object_center(self.object), self.explosion_strength)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local new_texture = get_texture(self)
|
local new_texture = get_texture(self, self._stalker_texture)
|
||||||
if self._stalker_texture ~= new_texture then
|
if self._stalker_texture ~= new_texture then
|
||||||
self.object:set_properties({textures={new_texture, "mobs_mc_empty.png"}})
|
self.object:set_properties({textures={new_texture, "mobs_mc_empty.png"}})
|
||||||
self._stalker_texture = new_texture
|
self._stalker_texture = new_texture
|
||||||
|
Loading…
Reference in New Issue
Block a user