mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-11-14 06:20:18 +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
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20230925",
|
||||
version = "20230926",
|
||||
translate = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||
|
@ -126,17 +126,17 @@ local creatura = minetest.get_modpath("creatura") and
|
|||
|
||||
|
||||
mobs.mob_class = {
|
||||
-- stepheight = 1.1,
|
||||
stepheight = 1.1,
|
||||
fly_in = "air",
|
||||
owner = "",
|
||||
order = "",
|
||||
jump_height = 4,
|
||||
lifetimer = 180, -- 3 minutes
|
||||
-- physical = true,
|
||||
-- collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
||||
-- visual_size = {x = 1, y = 1},
|
||||
physical = true,
|
||||
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
||||
visual_size = {x = 1, y = 1},
|
||||
texture_mods = "",
|
||||
-- makes_footstep_sound = false,
|
||||
makes_footstep_sound = false,
|
||||
view_range = 5,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 2,
|
||||
|
@ -733,20 +733,20 @@ local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
|
|||
function mob_class:update_tag()
|
||||
|
||||
local col
|
||||
local qua = self.initial_properties.hp_max / 6
|
||||
local qua = self.hp_max / 6
|
||||
|
||||
if self.health <= qua then
|
||||
col = "#FF0000" -- (255,0,0)
|
||||
col = "#FF0000"
|
||||
elseif self.health <= (qua * 2) then
|
||||
col = "#FF7A00" -- (255,122,0)
|
||||
col = "#FF7A00"
|
||||
elseif self.health <= (qua * 3) then
|
||||
col = "#FFB500" -- (255,181,0)
|
||||
col = "#FFB500"
|
||||
elseif self.health <= (qua * 4) then
|
||||
col = "#FFFF00" -- (255,255,0)
|
||||
col = "#FFFF00"
|
||||
elseif self.health <= (qua * 5) then
|
||||
col = "#B4FF00" -- (180,255,0)
|
||||
col = "#B4FF00"
|
||||
elseif self.health > (qua * 5) then
|
||||
col = "#00FF00" -- (0,255,0)
|
||||
col = "#00FF00"
|
||||
end
|
||||
|
||||
local text = ""
|
||||
|
@ -767,16 +767,13 @@ function mob_class:update_tag()
|
|||
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)
|
||||
.. text
|
||||
|
||||
-- set changes
|
||||
self.object:set_properties({
|
||||
nametag = self.nametag,
|
||||
nametag_color = col,
|
||||
infotext = self.infotext
|
||||
})
|
||||
nametag = self.nametag, nametag_color = col, infotext = self.infotext})
|
||||
end
|
||||
|
||||
|
||||
|
@ -906,8 +903,8 @@ function mob_class:check_for_death(cmi_cause)
|
|||
end
|
||||
|
||||
-- make sure health isn't higher than max
|
||||
if self.health > self.initial_properties.hp_max then
|
||||
self.health = self.initial_properties.hp_max
|
||||
if self.health > self.hp_max then
|
||||
self.health = self.hp_max
|
||||
end
|
||||
|
||||
self:update_tag()
|
||||
|
@ -1746,7 +1743,7 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||
end, self)
|
||||
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
|
||||
use_pathfind = true
|
||||
|
@ -1792,7 +1789,7 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||
jumpheight = min(ceil(
|
||||
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
|
||||
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)
|
||||
if mob_hit_effect then
|
||||
|
||||
local _dtm = self.initial_properties.damage_texture_modifier
|
||||
|
||||
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()
|
||||
|
||||
|
@ -3214,12 +3209,11 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
def.textures = {def.textures}
|
||||
end
|
||||
|
||||
self.base_texture = def.textures
|
||||
and def.textures[random(#def.textures)]
|
||||
self.base_texture = def.textures and def.textures[random(#def.textures)]
|
||||
self.base_mesh = def.mesh
|
||||
self.base_size = self.initial_properties.visual_size
|
||||
self.base_colbox = self.initial_properties.collisionbox
|
||||
self.base_selbox = self.initial_properties.selectionbox
|
||||
self.base_size = self.visual_size
|
||||
self.base_colbox = self.collisionbox
|
||||
self.base_selbox = self.selectionbox
|
||||
end
|
||||
|
||||
-- for current mobs that dont have this set
|
||||
|
@ -3265,7 +3259,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
-- pathfinding init
|
||||
|
@ -3298,7 +3292,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
self.standing_on = "air"
|
||||
|
||||
-- check for existing nametag
|
||||
self.nametag = self.initial_properties.nametag or def.nametag
|
||||
self.nametag = self.nametag or def.nametag
|
||||
|
||||
-- set anything changed above
|
||||
self.object:set_properties(self)
|
||||
|
@ -3599,44 +3593,7 @@ function mobs:register_mob(name, def)
|
|||
|
||||
minetest.register_entity(":" .. name, setmetatable({
|
||||
|
||||
initial_properties = {
|
||||
|
||||
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,
|
||||
stepheight = def.stepheight,
|
||||
name = name,
|
||||
type = def.type,
|
||||
attack_type = def.attack_type,
|
||||
|
@ -3645,29 +3602,26 @@ minetest.register_entity(":" .. name, setmetatable({
|
|||
keep_flying = def.keep_flying,
|
||||
owner = def.owner,
|
||||
order = def.order,
|
||||
on_die = def.on_die,
|
||||
on_flop = def.on_flop,
|
||||
do_custom = def.do_custom,
|
||||
jump_height = def.jump_height,
|
||||
can_leap = def.can_leap,
|
||||
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
|
||||
rotate = rad(def.rotate or 0), -- 0=front 90=side 180=back 270=side2
|
||||
-- glow = def.glow,
|
||||
glow = def.glow,
|
||||
lifetimer = def.lifetimer,
|
||||
hp_min = max(1, (def.hp_min or 5) * difficulty),
|
||||
-- hp_max = max(1, (def.hp_max or 10) * difficulty),
|
||||
-- collisionbox = collisionbox,
|
||||
-- selectionbox = def.selectionbox or collisionbox,
|
||||
-- visual = def.visual,
|
||||
-- visual_size = def.visual_size,
|
||||
-- mesh = def.mesh,
|
||||
-- makes_footstep_sound = def.makes_footstep_sound,
|
||||
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
||||
collisionbox = collisionbox, --def.collisionbox,
|
||||
selectionbox = def.selectionbox or collisionbox, --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,
|
||||
view_range = def.view_range,
|
||||
walk_velocity = def.walk_velocity,
|
||||
run_velocity = def.run_velocity,
|
||||
damage = max(0, (def.damage or 0) * difficulty),
|
||||
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_min = def.light_damage_min,
|
||||
light_damage_max = def.light_damage_max,
|
||||
|
@ -3734,9 +3688,13 @@ minetest.register_entity(":" .. name, setmetatable({
|
|||
ignore_invisibility = def.ignore_invisibility,
|
||||
messages = def.messages,
|
||||
|
||||
custom_attack = def.custom_attack,
|
||||
on_replace = def.on_replace,
|
||||
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_blast = def.on_blast, -- class redifinition
|
||||
do_punch = def.do_punch,
|
||||
|
@ -3902,7 +3860,6 @@ function mobs:add_mob(pos, def)
|
|||
end
|
||||
|
||||
-- and resize to half height (multiplication is faster than division)
|
||||
|
||||
mob:set_properties({
|
||||
textures = textures,
|
||||
visual_size = {
|
||||
|
@ -4097,13 +4054,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||
end
|
||||
|
||||
local ent = minetest.registered_entities[name]
|
||||
local cbox = ent.initial_properties.collisionbox
|
||||
|
||||
-- should we check mob area for obstructions ?
|
||||
if mob_area_spawn ~= true then
|
||||
|
||||
-- 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
|
||||
|
||||
|
@ -4122,7 +4078,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||
if pos then
|
||||
|
||||
-- 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)
|
||||
|
||||
|
@ -4727,9 +4683,9 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
-- increase health
|
||||
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
|
||||
|
||||
self.object:set_hp(self.health)
|
||||
|
@ -4888,7 +4844,7 @@ function mobs:alias_mob(old_name, new_name)
|
|||
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
static_save = false
|
||||
static_save = false,
|
||||
},
|
||||
|
||||
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