Compare commits
5 Commits
a8f447a346
...
0dc95615e5
Author | SHA1 | Date |
---|---|---|
general | 0dc95615e5 | |
general | b4a943690c | |
tenplus1 | a0e0719dfe | |
tenplus1 | 5a479b3b83 | |
general | 11ff8c34be |
78
api.lua
78
api.lua
|
@ -1,4 +1,4 @@
|
|||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local MP = minetest.get_modpath("mobs")
|
||||
-- Check for translation method
|
||||
local S
|
||||
|
||||
|
@ -21,22 +21,31 @@ else
|
|||
end
|
||||
end
|
||||
end
|
||||
local FS = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
|
||||
-- CMI support check
|
||||
local use_cmi = minetest.global_exists("cmi")
|
||||
|
||||
-- MineClone2 check
|
||||
local use_mc2 = minetest.get_modpath("mcl_core")
|
||||
|
||||
-- Visual Harm 1ndicator check
|
||||
local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
||||
|
||||
-- Global
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20230805",
|
||||
intllib = S,
|
||||
version = "20230927",
|
||||
translate = S, intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
node_ice = "default:ice",
|
||||
node_snow = minetest.registered_aliases["mapgen_snow"] or "default:snow" or "mcl_core:snow",
|
||||
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "default:dirt" or "mcl_core:dirt"
|
||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||
or (use_mc2 and "mcl_core:snow") or "default:snow",
|
||||
node_dirt = minetest.registered_aliases["mapgen_dirt"]
|
||||
or (use_mc2 and "mcl_core:dirt") or "default:dirt"
|
||||
}
|
||||
mobs.fallback_node = mobs.node_dirt
|
||||
|
||||
|
||||
-- localize common functions
|
||||
local pi = math.pi
|
||||
local square = math.sqrt
|
||||
|
@ -1580,6 +1589,8 @@ function mob_class:breed()
|
|||
-- make sure baby is actually there
|
||||
if ent2 then
|
||||
|
||||
textures = self.base_texture
|
||||
|
||||
-- using specific child texture (if found)
|
||||
if self.child_texture then
|
||||
textures = self.child_texture[1]
|
||||
|
@ -1668,8 +1679,7 @@ function mob_class:replace(pos)
|
|||
local newnode = with
|
||||
|
||||
-- pass actual node name when using table or groups
|
||||
if type(oldnode) == "table"
|
||||
or oldnode:find("group:") then
|
||||
if type(oldnode) == "table" or oldnode:find("group:") then
|
||||
oldnode = minetest.get_node(pos).name
|
||||
end
|
||||
|
||||
|
@ -2478,6 +2488,11 @@ function mob_class:do_states(dtime)
|
|||
self:set_velocity(0)
|
||||
self.state = "stand"
|
||||
self:set_animation("stand")
|
||||
|
||||
-- try to turn so we are not stuck
|
||||
yaw = yaw + random(-1, 1) * 1.5
|
||||
yaw = self:set_yaw(yaw, 4)
|
||||
|
||||
else
|
||||
self:set_velocity(self.run_velocity)
|
||||
self:set_animation("walk")
|
||||
|
@ -3117,15 +3132,16 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||
self.following = nil
|
||||
end
|
||||
|
||||
local name = hitter:get_player_name() or ""
|
||||
local hitter_name = ""
|
||||
if hitter then if is_player(hitter) then hitter_name = hitter:get_player_name() end end
|
||||
|
||||
-- attack puncher and call other mobs for help
|
||||
if self.passive == false
|
||||
and self.state ~= "flop"
|
||||
and self.child == false
|
||||
and self.attack_players == true
|
||||
and hitter:get_player_name() ~= self.owner
|
||||
and not is_invisible(self, name)
|
||||
and not (is_player(hitter) and hitter_name == self.owner)
|
||||
and not is_invisible(self, hitter_name)
|
||||
and self.object ~= hitter then
|
||||
|
||||
-- attack whoever punched mob
|
||||
|
@ -3134,25 +3150,25 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||
|
||||
-- alert others to the attack
|
||||
local objs = minetest.get_objects_inside_radius(hitter:get_pos(), self.view_range)
|
||||
local obj
|
||||
local ent
|
||||
|
||||
for n = 1, #objs do
|
||||
|
||||
obj = objs[n]:get_luaentity()
|
||||
ent = objs[n] and objs[n]:get_luaentity()
|
||||
|
||||
if obj and obj._cmi_is_mob then
|
||||
if ent and ent._cmi_is_mob then
|
||||
|
||||
-- only alert members of same mob and assigned helper
|
||||
if obj.group_attack == true
|
||||
and obj.state ~= "attack"
|
||||
and obj.owner ~= name
|
||||
and (obj.name == self.name or obj.name == self.group_helper) then
|
||||
obj:do_attack(hitter)
|
||||
if ent.group_attack == true
|
||||
and ent.state ~= "attack"
|
||||
and not (is_player(hitter) and ent.owner == hitter_name)
|
||||
and (ent.name == self.name or ent.name == self.group_helper) then
|
||||
ent:do_attack(hitter)
|
||||
end
|
||||
|
||||
-- have owned mobs attack player threat
|
||||
if obj.owner == name and obj.owner_loyal then
|
||||
obj:do_attack(self.object)
|
||||
if is_player(hitter) and ent.owner == hitter_name and ent.owner_loyal then
|
||||
ent:do_attack(self.object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3426,7 +3442,7 @@ function mob_class:mob_expire(pos, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
-- minetest.log("action", S("lifetimer expired, removed @1", self.name))
|
||||
-- minetest.log("action", "lifetimer expired, removed " .. self.name)
|
||||
|
||||
effect(pos, 15, "tnt_smoke.png", 2, 4, 2, 0)
|
||||
|
||||
|
@ -3921,6 +3937,8 @@ function mobs:add_mob(pos, def)
|
|||
if not ent then
|
||||
--print("[mobs] entity not found " .. def.name)
|
||||
return false
|
||||
else
|
||||
effect(pos, 15, "tnt_smoke.png", 1, 2, 2, 15, 5)
|
||||
end
|
||||
|
||||
if def.child then
|
||||
|
@ -4754,7 +4772,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
self.health = self.health + 4
|
||||
|
||||
if self.health >= self.hp_max then
|
||||
|
||||
self.health = self.hp_max
|
||||
end
|
||||
|
||||
|
@ -4813,8 +4830,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
|
||||
-- if mob has been tamed you can name it with a nametag
|
||||
if item:get_name() == "mobs:nametag"
|
||||
and (name == self.owner
|
||||
or minetest.check_player_privs(name, "protection_bypass")) then
|
||||
and (name == self.owner or minetest.check_player_privs(name, "protection_bypass")) then
|
||||
|
||||
-- store mob and nametag stack in external variables
|
||||
mob_obj[name] = self
|
||||
|
@ -4823,13 +4839,9 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
local tag = self.nametag or ""
|
||||
local esc = minetest.formspec_escape
|
||||
|
||||
minetest.show_formspec(name, "mobs_nametag",
|
||||
"size[8,4]" ..
|
||||
"field[0.5,1;7.5,0;name;" ..
|
||||
esc(S("Enter name:")) ..
|
||||
";" .. tag .. "]" ..
|
||||
"button_exit[2.5,3.5;3,1;mob_rename;" ..
|
||||
esc(S("Rename")) .. "]")
|
||||
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
||||
.. "field[0.5,1;7.5,0;name;" .. esc(FS("Enter name:")) .. ";" .. esc(tag) .. "]"
|
||||
.. "button_exit[2.5,3.5;3,1;mob_rename;" .. esc(FS("Rename")) .. "]")
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
5
init.lua
5
init.lua
|
@ -21,6 +21,9 @@ dofile(path .. "/crafts.lua")
|
|||
dofile(path .. "/spawner.lua")
|
||||
|
||||
-- Lucky Blocks
|
||||
dofile(path .. "/lucky_block.lua")
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
dofile(path .. "/lucky_block.lua")
|
||||
end
|
||||
|
||||
|
||||
print("[MOD] Mobs Redo loaded")
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"mobs:meat_raw"}, 5},
|
||||
{"dro", {"mobs:meat"}, 5},
|
||||
{"dro", {"mobs:nametag"}, 1},
|
||||
{"dro", {"mobs:leather"}, 5},
|
||||
{"dro", {"default:stick"}, 10},
|
||||
{"dro", {"mobs:net"}, 1},
|
||||
{"dro", {"mobs:lasso"}, 1},
|
||||
{"dro", {"mobs:shears"}, 1},
|
||||
{"dro", {"mobs:protector"}, 1},
|
||||
{"dro", {"mobs:fence_wood"}, 10},
|
||||
{"dro", {"mobs:fence_top"}, 12},
|
||||
{"lig"}
|
||||
})
|
||||
end
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"mobs:meat_raw"}, 5},
|
||||
{"dro", {"mobs:meat"}, 5},
|
||||
{"dro", {"mobs:nametag"}, 1},
|
||||
{"dro", {"mobs:leather"}, 5},
|
||||
{"dro", {"default:stick"}, 10},
|
||||
{"dro", {"mobs:net"}, 1},
|
||||
{"dro", {"mobs:lasso"}, 1},
|
||||
{"dro", {"mobs:shears"}, 1},
|
||||
{"dro", {"mobs:protector"}, 1},
|
||||
{"dro", {"mobs:fence_wood"}, 10},
|
||||
{"dro", {"mobs:fence_top"}, 12},
|
||||
{"lig"}
|
||||
})
|
||||
|
|
3
mod.conf
3
mod.conf
|
@ -1,4 +1,5 @@
|
|||
name = mobs
|
||||
depends =default
|
||||
optional_depends = tnt, player_api, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder, mtobjid
|
||||
description = MOBS api for mobs to add animals or monsters etc
|
||||
optional_depends = tnt, player_api, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder, mtobjid
|
||||
min_minetest_version = 5.0
|
||||
|
|
43
mount.lua
43
mount.lua
|
@ -1,8 +1,10 @@
|
|||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||
|
||||
--[[ one of these is needed (for now) to ride mobs, otherwise no riding for you
|
||||
if not minetest.get_modpath("default")
|
||||
or not minetest.get_modpath("player_api") then
|
||||
local is_pa = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check
|
||||
|
||||
-- one of these is needed to ride mobs, otherwise no riding for you
|
||||
if not minetest.get_modpath("default") and not is_pa and not is_mc2 then
|
||||
|
||||
function mobs.attach() end
|
||||
function mobs.detach() end
|
||||
|
@ -11,10 +13,6 @@ or not minetest.get_modpath("player_api") then
|
|||
|
||||
return
|
||||
end
|
||||
]]
|
||||
|
||||
local is_pa = minetest.get_modpath("player_api") -- 5.x compatibility
|
||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 compatibility
|
||||
|
||||
-- are we a real player ?
|
||||
local function is_player(player)
|
||||
|
@ -25,7 +23,7 @@ local function is_player(player)
|
|||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Localise some functions
|
||||
local abs, cos, floor, sin, sqrt, pi =
|
||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||
|
||||
|
@ -117,15 +115,17 @@ local function force_detach(player)
|
|||
|
||||
local name = player:get_player_name()
|
||||
|
||||
if is_pa then
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_attached[player:get_player_name()] = false
|
||||
mcl_player.player_set_animation(player, "stand", 30)
|
||||
else
|
||||
if is_pa then
|
||||
player_api.player_attached[name] = false
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
else
|
||||
default.player_attached[name] = false
|
||||
default.player_set_animation(player, "stand", 30)
|
||||
end
|
||||
end
|
||||
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
|
@ -209,12 +209,14 @@ function mobs.attach(entity, player)
|
|||
|
||||
force_detach(player)
|
||||
|
||||
if is_pa then
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_attached[player:get_player_name()] = true
|
||||
else
|
||||
if is_pa then
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
else
|
||||
default.player_attached[player:get_player_name()] = true
|
||||
end
|
||||
end
|
||||
|
||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||
|
@ -231,13 +233,14 @@ function mobs.attach(entity, player)
|
|||
|
||||
if is_player(player) then
|
||||
|
||||
if is_pa then
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
elseif is_mc2 then
|
||||
if is_mc2 then
|
||||
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
||||
else
|
||||
if is_pa then
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
else
|
||||
default.player_set_animation(player, "sit", 30)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -342,7 +345,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||
if velo.y > 0 then velo.y = 0 end
|
||||
end
|
||||
else
|
||||
if ctrl.jump then -- jump
|
||||
if ctrl.jump then -- jump (only when standing on solid surface)
|
||||
|
||||
if velo.y == 0 then
|
||||
velo.y = velo.y + entity.jump_height
|
||||
|
|
Loading…
Reference in New Issue