mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-10 09:50:19 +01:00
Revert initial_properties change, breaks too many routines
This commit is contained in:
parent
55e07dbdd3
commit
9f9a522ec7
138
api.lua
138
api.lua
@ -11,7 +11,7 @@ local use_mc2 = minetest.get_modpath("mcl_core")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230925",
|
version = "20230926",
|
||||||
translate = S,
|
translate = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
@ -126,17 +126,17 @@ local creatura = minetest.get_modpath("creatura") and
|
|||||||
|
|
||||||
|
|
||||||
mobs.mob_class = {
|
mobs.mob_class = {
|
||||||
-- stepheight = 1.1,
|
stepheight = 1.1,
|
||||||
fly_in = "air",
|
fly_in = "air",
|
||||||
owner = "",
|
owner = "",
|
||||||
order = "",
|
order = "",
|
||||||
jump_height = 4,
|
jump_height = 4,
|
||||||
lifetimer = 180, -- 3 minutes
|
lifetimer = 180, -- 3 minutes
|
||||||
-- physical = true,
|
physical = true,
|
||||||
-- collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
||||||
-- visual_size = {x = 1, y = 1},
|
visual_size = {x = 1, y = 1},
|
||||||
texture_mods = "",
|
texture_mods = "",
|
||||||
-- makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
view_range = 5,
|
view_range = 5,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 2,
|
run_velocity = 2,
|
||||||
@ -733,20 +733,20 @@ local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
|
|||||||
function mob_class:update_tag()
|
function mob_class:update_tag()
|
||||||
|
|
||||||
local col
|
local col
|
||||||
local qua = self.initial_properties.hp_max / 6
|
local qua = self.hp_max / 6
|
||||||
|
|
||||||
if self.health <= qua then
|
if self.health <= qua then
|
||||||
col = "#FF0000" -- (255,0,0)
|
col = "#FF0000"
|
||||||
elseif self.health <= (qua * 2) then
|
elseif self.health <= (qua * 2) then
|
||||||
col = "#FF7A00" -- (255,122,0)
|
col = "#FF7A00"
|
||||||
elseif self.health <= (qua * 3) then
|
elseif self.health <= (qua * 3) then
|
||||||
col = "#FFB500" -- (255,181,0)
|
col = "#FFB500"
|
||||||
elseif self.health <= (qua * 4) then
|
elseif self.health <= (qua * 4) then
|
||||||
col = "#FFFF00" -- (255,255,0)
|
col = "#FFFF00"
|
||||||
elseif self.health <= (qua * 5) then
|
elseif self.health <= (qua * 5) then
|
||||||
col = "#B4FF00" -- (180,255,0)
|
col = "#B4FF00"
|
||||||
elseif self.health > (qua * 5) then
|
elseif self.health > (qua * 5) then
|
||||||
col = "#00FF00" -- (0,255,0)
|
col = "#00FF00"
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = ""
|
local text = ""
|
||||||
@ -767,16 +767,13 @@ function mob_class:update_tag()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.infotext = "Health: " .. self.health .. " / " .. self.initial_properties.hp_max
|
self.infotext = "Health: " .. self.health .. " / " .. self.hp_max
|
||||||
.. (self.owner == "" and "" or "\nOwner: " .. self.owner)
|
.. (self.owner == "" and "" or "\nOwner: " .. self.owner)
|
||||||
.. text
|
.. text
|
||||||
|
|
||||||
-- set changes
|
-- set changes
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
nametag = self.nametag,
|
nametag = self.nametag, nametag_color = col, infotext = self.infotext})
|
||||||
nametag_color = col,
|
|
||||||
infotext = self.infotext
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -906,8 +903,8 @@ function mob_class:check_for_death(cmi_cause)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- make sure health isn't higher than max
|
-- make sure health isn't higher than max
|
||||||
if self.health > self.initial_properties.hp_max then
|
if self.health > self.hp_max then
|
||||||
self.health = self.initial_properties.hp_max
|
self.health = self.hp_max
|
||||||
end
|
end
|
||||||
|
|
||||||
self:update_tag()
|
self:update_tag()
|
||||||
@ -1746,7 +1743,7 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||||||
end, self)
|
end, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if abs(vsubtract(s, target_pos).y) > self.initial_properties.stepheight then
|
if abs(vsubtract(s, target_pos).y) > self.stepheight then
|
||||||
|
|
||||||
if height_switcher then
|
if height_switcher then
|
||||||
use_pathfind = true
|
use_pathfind = true
|
||||||
@ -1792,7 +1789,7 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||||||
jumpheight = min(ceil(
|
jumpheight = min(ceil(
|
||||||
self.jump_height / pathfinding_max_jump), pathfinding_max_jump)
|
self.jump_height / pathfinding_max_jump), pathfinding_max_jump)
|
||||||
|
|
||||||
elseif self.initial_properties.stepheight > 0.5 then
|
elseif self.stepheight > 0.5 then
|
||||||
jumpheight = 1
|
jumpheight = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2962,11 +2959,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
-- add healthy afterglow when hit (can cause lag with larger textures)
|
-- add healthy afterglow when hit (can cause lag with larger textures)
|
||||||
if mob_hit_effect then
|
if mob_hit_effect then
|
||||||
|
|
||||||
local _dtm = self.initial_properties.damage_texture_modifier
|
|
||||||
|
|
||||||
self.old_texture_mods = self.texture_mods
|
self.old_texture_mods = self.texture_mods
|
||||||
|
|
||||||
self.object:set_texture_mod(self.texture_mods .. _dtm)
|
self.object:set_texture_mod(self.texture_mods .. self.damage_texture_modifier)
|
||||||
|
|
||||||
minetest.after(0.3, function()
|
minetest.after(0.3, function()
|
||||||
|
|
||||||
@ -3214,12 +3209,11 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
def.textures = {def.textures}
|
def.textures = {def.textures}
|
||||||
end
|
end
|
||||||
|
|
||||||
self.base_texture = def.textures
|
self.base_texture = def.textures and def.textures[random(#def.textures)]
|
||||||
and def.textures[random(#def.textures)]
|
|
||||||
self.base_mesh = def.mesh
|
self.base_mesh = def.mesh
|
||||||
self.base_size = self.initial_properties.visual_size
|
self.base_size = self.visual_size
|
||||||
self.base_colbox = self.initial_properties.collisionbox
|
self.base_colbox = self.collisionbox
|
||||||
self.base_selbox = self.initial_properties.selectionbox
|
self.base_selbox = self.selectionbox
|
||||||
end
|
end
|
||||||
|
|
||||||
-- for current mobs that dont have this set
|
-- for current mobs that dont have this set
|
||||||
@ -3265,7 +3259,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.health == 0 then
|
if self.health == 0 then
|
||||||
self.health = random(self.hp_min, self.initial_properties.hp_max)
|
self.health = random(self.hp_min, self.hp_max)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pathfinding init
|
-- pathfinding init
|
||||||
@ -3298,7 +3292,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
self.standing_on = "air"
|
self.standing_on = "air"
|
||||||
|
|
||||||
-- check for existing nametag
|
-- check for existing nametag
|
||||||
self.nametag = self.initial_properties.nametag or def.nametag
|
self.nametag = self.nametag or def.nametag
|
||||||
|
|
||||||
-- set anything changed above
|
-- set anything changed above
|
||||||
self.object:set_properties(self)
|
self.object:set_properties(self)
|
||||||
@ -3599,44 +3593,7 @@ function mobs:register_mob(name, def)
|
|||||||
|
|
||||||
minetest.register_entity(":" .. name, setmetatable({
|
minetest.register_entity(":" .. name, setmetatable({
|
||||||
|
|
||||||
initial_properties = {
|
stepheight = def.stepheight,
|
||||||
|
|
||||||
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
|
||||||
-- breath_max
|
|
||||||
-- zoom_fov
|
|
||||||
-- eye_height
|
|
||||||
physical = true,
|
|
||||||
-- collide_with_objects
|
|
||||||
collisionbox = collisionbox,
|
|
||||||
selectionbox = def.selectionbox or collisionbox,
|
|
||||||
-- pointable
|
|
||||||
visual = def.visual,
|
|
||||||
visual_size = def.visual_size or {x = 1, y = 1},
|
|
||||||
mesh = def.mesh,
|
|
||||||
textures = nil,
|
|
||||||
-- colors
|
|
||||||
-- use_texture_alpha
|
|
||||||
-- spritediv
|
|
||||||
-- initial_sprite_basepos
|
|
||||||
-- is_visible
|
|
||||||
make_footstep_sound = def.make_footstep_sound,
|
|
||||||
-- automatic_rotate
|
|
||||||
stepheight = def.stepheight or 1.1,
|
|
||||||
-- automatic_face_movement_dir
|
|
||||||
-- automatic_face_movement_max_rotation_per_sec
|
|
||||||
-- backface_culling
|
|
||||||
glow = def.glow,
|
|
||||||
-- nametag
|
|
||||||
-- nametag_color
|
|
||||||
-- nametag_bgcolor
|
|
||||||
-- infotext
|
|
||||||
-- static_save
|
|
||||||
damage_texture_modifier = def.damage_texture_modifier or "^[colorize:#c9900070",
|
|
||||||
-- shaded
|
|
||||||
-- show_on_minimap
|
|
||||||
},
|
|
||||||
|
|
||||||
-- stepheight = def.stepheight,
|
|
||||||
name = name,
|
name = name,
|
||||||
type = def.type,
|
type = def.type,
|
||||||
attack_type = def.attack_type,
|
attack_type = def.attack_type,
|
||||||
@ -3645,29 +3602,26 @@ minetest.register_entity(":" .. name, setmetatable({
|
|||||||
keep_flying = def.keep_flying,
|
keep_flying = def.keep_flying,
|
||||||
owner = def.owner,
|
owner = def.owner,
|
||||||
order = def.order,
|
order = def.order,
|
||||||
on_die = def.on_die,
|
|
||||||
on_flop = def.on_flop,
|
|
||||||
do_custom = def.do_custom,
|
|
||||||
jump_height = def.jump_height,
|
jump_height = def.jump_height,
|
||||||
can_leap = def.can_leap,
|
can_leap = def.can_leap,
|
||||||
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
|
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
|
||||||
rotate = rad(def.rotate or 0), -- 0=front 90=side 180=back 270=side2
|
rotate = rad(def.rotate or 0), -- 0=front 90=side 180=back 270=side2
|
||||||
-- glow = def.glow,
|
glow = def.glow,
|
||||||
lifetimer = def.lifetimer,
|
lifetimer = def.lifetimer,
|
||||||
hp_min = max(1, (def.hp_min or 5) * difficulty),
|
hp_min = max(1, (def.hp_min or 5) * difficulty),
|
||||||
-- hp_max = max(1, (def.hp_max or 10) * difficulty),
|
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
||||||
-- collisionbox = collisionbox,
|
collisionbox = collisionbox, --def.collisionbox,
|
||||||
-- selectionbox = def.selectionbox or collisionbox,
|
selectionbox = def.selectionbox or collisionbox, --def.collisionbox,
|
||||||
-- visual = def.visual,
|
visual = def.visual,
|
||||||
-- visual_size = def.visual_size,
|
visual_size = def.visual_size or {x = 1, y = 1},
|
||||||
-- mesh = def.mesh,
|
mesh = def.mesh,
|
||||||
-- makes_footstep_sound = def.makes_footstep_sound,
|
makes_footstep_sound = def.makes_footstep_sound,
|
||||||
view_range = def.view_range,
|
view_range = def.view_range,
|
||||||
walk_velocity = def.walk_velocity,
|
walk_velocity = def.walk_velocity,
|
||||||
run_velocity = def.run_velocity,
|
run_velocity = def.run_velocity,
|
||||||
damage = max(0, (def.damage or 0) * difficulty),
|
damage = max(0, (def.damage or 0) * difficulty),
|
||||||
damage_group = def.damage_group,
|
damage_group = def.damage_group,
|
||||||
-- damage_texture_modifier = def.damage_texture_modifier or "^[colorize:#c9900070",
|
damage_texture_modifier = def.damage_texture_modifier or "^[colorize:#c9900070",
|
||||||
light_damage = def.light_damage,
|
light_damage = def.light_damage,
|
||||||
light_damage_min = def.light_damage_min,
|
light_damage_min = def.light_damage_min,
|
||||||
light_damage_max = def.light_damage_max,
|
light_damage_max = def.light_damage_max,
|
||||||
@ -3734,9 +3688,13 @@ minetest.register_entity(":" .. name, setmetatable({
|
|||||||
ignore_invisibility = def.ignore_invisibility,
|
ignore_invisibility = def.ignore_invisibility,
|
||||||
messages = def.messages,
|
messages = def.messages,
|
||||||
|
|
||||||
custom_attack = def.custom_attack,
|
|
||||||
on_replace = def.on_replace,
|
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
|
on_die = def.on_die,
|
||||||
|
on_flop = def.on_flop,
|
||||||
|
do_custom = def.do_custom,
|
||||||
|
on_replace = def.on_replace,
|
||||||
|
custom_attack = def.custom_attack,
|
||||||
|
|
||||||
on_spawn = def.on_spawn,
|
on_spawn = def.on_spawn,
|
||||||
on_blast = def.on_blast, -- class redifinition
|
on_blast = def.on_blast, -- class redifinition
|
||||||
do_punch = def.do_punch,
|
do_punch = def.do_punch,
|
||||||
@ -3902,7 +3860,6 @@ function mobs:add_mob(pos, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- and resize to half height (multiplication is faster than division)
|
-- and resize to half height (multiplication is faster than division)
|
||||||
|
|
||||||
mob:set_properties({
|
mob:set_properties({
|
||||||
textures = textures,
|
textures = textures,
|
||||||
visual_size = {
|
visual_size = {
|
||||||
@ -4097,13 +4054,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ent = minetest.registered_entities[name]
|
local ent = minetest.registered_entities[name]
|
||||||
local cbox = ent.initial_properties.collisionbox
|
|
||||||
|
|
||||||
-- should we check mob area for obstructions ?
|
-- should we check mob area for obstructions ?
|
||||||
if mob_area_spawn ~= true then
|
if mob_area_spawn ~= true then
|
||||||
|
|
||||||
-- do we have enough height clearance to spawn mob?
|
-- do we have enough height clearance to spawn mob?
|
||||||
local height = max(0, cbox[5] - cbox[2])
|
local height = max(0, ent.collisionbox[5] - ent.collisionbox[2])
|
||||||
|
|
||||||
for n = 0, floor(height) do
|
for n = 0, floor(height) do
|
||||||
|
|
||||||
@ -4122,7 +4078,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||||||
if pos then
|
if pos then
|
||||||
|
|
||||||
-- adjust for mob collision box
|
-- adjust for mob collision box
|
||||||
pos.y = pos.y + (cbox[2] * -1) - 0.4
|
pos.y = pos.y + (ent.collisionbox[2] * -1) - 0.4
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, name)
|
local mob = minetest.add_entity(pos, name)
|
||||||
|
|
||||||
@ -4727,9 +4683,9 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
-- increase health
|
-- increase health
|
||||||
self.health = self.health + 4
|
self.health = self.health + 4
|
||||||
|
|
||||||
if self.health >= self.initial_properties.hp_max then
|
if self.health >= self.hp_max then
|
||||||
|
|
||||||
self.health = self.initial_properties.hp_max
|
self.health = self.hp_max
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_hp(self.health)
|
self.object:set_hp(self.health)
|
||||||
@ -4888,7 +4844,7 @@ function mobs:alias_mob(old_name, new_name)
|
|||||||
|
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
physical = false,
|
physical = false,
|
||||||
static_save = false
|
static_save = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
|
4950
api_WIP.lua
Normal file
4950
api_WIP.lua
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user