[mobs_mc] rename creeper to stalker and update to upstream version #49

Merged
fusselkater merged 1 commit from update-mobs_mc-stalker into main 2024-06-02 13:45:48 +02:00

View file

@ -3,14 +3,60 @@
local S = minetest.get_translator("mobs_mc")
--###################
--################### CREEPER
--################### STALKER
--###################
local function get_texture(self)
local on_name = self.standing_on
local texture
local texture_suff = ""
if on_name and on_name ~= "air" then
local tiles = minetest.registered_nodes[on_name].tiles
if tiles then
local tile = tiles[1]
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
elseif type(tile) == "string" then
texture = tile
end
if not color then
color = minetest.colorspec_to_colorstring(minetest.registered_nodes[on_name].color)
end
if color then
texture_suff = "^[multiply:" .. color .. "^[hsl:0:0:20"
end
end
end
if not texture or texture == "" then
texture = "vl_stalker_default.png"
end
texture = texture:gsub("([\\^:\\[])","\\%1") -- escape texture modifiers
texture = "([combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture ..")".. texture_suff
if self.attack then
texture = texture .. ")^vl_mobs_stalker_overlay_angry.png"
else
texture = texture .. ")^vl_mobs_stalker_overlay.png"
end
return texture
end
local AURA = "vl_stalker_overloaded_aura.png"
local function get_overloaded_aura(timer)
local frame = math.floor(timer*16)
local f = tostring(frame)
local nf = tostring(16-f)
return "[combine:16x24:-" .. nf ..",0=" .. AURA .. ":" .. f .. ",0=" .. AURA
end
mcl_mobs.register_mob("mobs_mc:creeper", {
description = S("Creeper"),
mcl_mobs.register_mob("mobs_mc:stalker", {
description = S("Stalker"),
type = "monster",
spawn_class = "hostile",
spawn_in_group = 1,
@ -21,16 +67,16 @@ mcl_mobs.register_mob("mobs_mc:creeper", {
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.69, 0.3},
pathfinding = 1,
visual = "mesh",
mesh = "mobs_mc_creeper.b3d",
head_swivel = "Head_Control",
mesh = "vl_stalker.b3d",
-- head_swivel = "Head_Control",
bone_eye_height = 2.35,
head_eye_height = 1.8;
curiosity = 2,
textures = {
{"mobs_mc_creeper.png",
{get_texture({}),
"mobs_mc_empty.png"},
},
visual_size = {x=3, y=3},
visual_size = {x=2, y=2},
sounds = {
attack = "tnt_ignite",
death = "mobs_mc_creeper_death",
@ -56,8 +102,8 @@ mcl_mobs.register_mob("mobs_mc:creeper", {
allow_fuse_reset = true,
stop_to_explode = true,
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
-- TODO: Make creeper flash after doing this as well.
-- Force-ignite stalker with flint and steel and explode after 1.5 seconds.
-- TODO: Make stalker flash after doing this as well.
-- TODO: Test and debug this code.
on_rightclick = function(self, clicker)
if self._forced_explosion_countdown_timer ~= nil then
@ -86,6 +132,11 @@ mcl_mobs.register_mob("mobs_mc:creeper", {
self:boom(mcl_util.get_object_center(self.object), self.explosion_strength)
end
end
local new_texture = get_texture(self)
if self._stalker_texture ~= new_texture then
self.object:set_properties({textures={new_texture, "mobs_mc_empty.png"}})
self._stalker_texture = new_texture
end
end,
on_die = function(self, pos, cmi_cause)
-- Drop a random music disc when killed by skeleton or stray
@ -108,35 +159,42 @@ mcl_mobs.register_mob("mobs_mc:creeper", {
looting = "common",},
-- Head
-- TODO: Only drop if killed by charged creeper
{name = "mcl_heads:creeper",
-- TODO: Only drop if killed by charged stalker
{name = "mcl_heads:stalker",
chance = 200, -- 0.5%
min = 1,
max = 1,},
},
animation = {
speed_normal = 24,
speed_run = 48,
speed_normal = 30,
speed_run = 60,
stand_start = 0,
stand_end = 23,
walk_start = 24,
walk_end = 49,
run_start = 24,
run_end = 49,
hurt_start = 110,
hurt_end = 139,
death_start = 140,
death_end = 189,
look_start = 50,
look_end = 108,
fuse_start = 49,
fuse_end = 80,
},
floats = 1,
fear_height = 4,
view_range = 16,
})
mcl_mobs.register_mob("mobs_mc:creeper_charged", {
description = S("Creeper"),
_on_after_convert = function(obj)
obj:set_properties({
visual_size = {x=2, y=2},
mesh = "vl_stalker.b3d",
textures = {
{get_texture({}),
"mobs_mc_empty.png"},
},
})
end,
}) -- END mcl_mobs.register_mob("mobs_mc:stalker", {
mcl_mobs.register_mob("mobs_mc:stalker_overloaded", {
description = S("Overloaded Stalker"),
type = "monster",
spawn_class = "hostile",
hp_min = 20,
@ -146,15 +204,16 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.69, 0.3},
pathfinding = 1,
visual = "mesh",
mesh = "mobs_mc_creeper.b3d",
mesh = "vl_stalker.b3d",
--BOOM
textures = {
{"mobs_mc_creeper.png",
"mobs_mc_creeper_charge.png"},
{get_texture({}),
AURA},
},
visual_size = {x=3, y=3},
use_texture_alpha = true,
visual_size = {x=2, y=2},
sounds = {
attack = "tnt_ignite",
death = "mobs_mc_creeper_death",
@ -178,8 +237,8 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
allow_fuse_reset = true,
stop_to_explode = true,
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
-- TODO: Make creeper flash after doing this as well.
-- Force-ignite stalker with flint and steel and explode after 1.5 seconds.
-- TODO: Make stalker flash after doing this as well.
-- TODO: Test and debug this code.
on_rightclick = function(self, clicker)
if self._forced_explosion_countdown_timer ~= nil then
@ -208,6 +267,9 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
self:boom(mcl_util.get_object_center(self.object), self.explosion_strength)
end
end
if not self._aura_timer or self._aura_timer > 1 then self._aura_timer = 0 end
self._aura_timer = self._aura_timer + dtime
self.object:set_properties({textures={get_texture(self), get_overloaded_aura(self._aura_timer)}})
end,
on_die = function(self, pos, cmi_cause)
-- Drop a random music disc when killed by skeleton or stray
@ -222,7 +284,7 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
end
end,
on_lightning_strike = function(self, pos, pos2, objects)
mcl_util.replace_mob(self.object, "mobs_mc:creeper_charged")
mcl_util.replace_mob(self.object, "mobs_mc:stalker_overloaded")
return true
end,
maxdrops = 2,
@ -234,27 +296,23 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
looting = "common",},
-- Head
-- TODO: Only drop if killed by charged creeper
{name = "mcl_heads:creeper",
-- TODO: Only drop if killed by overloaded stalker
{name = "mcl_heads:stalker",
chance = 200, -- 0.5%
min = 1,
max = 1,},
},
animation = {
speed_normal = 24,
speed_run = 48,
speed_normal = 30,
speed_run = 60,
stand_start = 0,
stand_end = 23,
walk_start = 24,
walk_end = 49,
run_start = 24,
run_end = 49,
hurt_start = 110,
hurt_end = 139,
death_start = 140,
death_end = 189,
look_start = 50,
look_end = 108,
fuse_start = 49,
fuse_end = 80,
},
floats = 1,
fear_height = 4,
@ -262,10 +320,25 @@ mcl_mobs.register_mob("mobs_mc:creeper_charged", {
--Having trouble when fire is placed with lightning
fire_resistant = true,
glow = 3,
_on_after_convert = function(obj)
obj:set_properties({
visual_size = {x=2, y=2},
mesh = "vl_stalker.b3d",
textures = {
{get_texture({}),
AURA},
},
})
end,
}) -- END mcl_mobs.register_mob("mobs_mc:stalker_overloaded", {
-- compat
mcl_mobs.register_conversion("mobs_mc:creeper", "mobs_mc:stalker")
mcl_mobs.register_conversion("mobs_mc:creeper_charged", "mobs_mc:stalker_overloaded")
mcl_mobs:spawn_specific(
"mobs_mc:creeper",
"mobs_mc:stalker",
"overworld",
"ground",
{
@ -413,4 +486,6 @@ mcl_vars.mg_overworld_min,
mcl_vars.mg_overworld_max)
-- spawn eggs
mcl_mobs.register_egg("mobs_mc:creeper", S("Creeper"), "#0da70a", "#000000", 0)
mcl_mobs.register_egg("mobs_mc:stalker", S("Stalker"), "#0da70a", "#000000", 0)
minetest.register_alias("mobs_mc:creeper", "mobs_mc:stalker")
mcl_mobs.register_egg("mobs_mc:stalker_overloaded", S("Overloaded Stalker"), "#00a77a", "#000000", 0)