1
0
Fork 0

Merge remote-tracking branch 'origin/master' into mineclone5

mineclone5
kay27 2021-06-22 05:16:30 +04:00
commit 7cf49c2cfd
3 changed files with 102 additions and 8 deletions

View File

@ -129,6 +129,7 @@ end
local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/" local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/"
--ignite all parts of the api --ignite all parts of the api
dofile(api_path .. "flow_lib.lua")
dofile(api_path .. "ai.lua") dofile(api_path .. "ai.lua")
dofile(api_path .. "animation.lua") dofile(api_path .. "animation.lua")
dofile(api_path .. "collision.lua") dofile(api_path .. "collision.lua")

View File

@ -9,6 +9,8 @@ local minetest_get_item_group = minetest.get_item_group
local minetest_get_node = minetest.get_node local minetest_get_node = minetest.get_node
local minetest_line_of_sight = minetest.line_of_sight local minetest_line_of_sight = minetest.line_of_sight
local minetest_get_node_light = minetest.get_node_light local minetest_get_node_light = minetest.get_node_light
local minetest_registered_nodes = minetest.registered_nodes
local flow = mobs.get_flowing_dir
local DOUBLE_PI = math.pi * 2 local DOUBLE_PI = math.pi * 2
local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125 local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125
@ -521,8 +523,8 @@ ______ _
| _| | | | | | | _| | | | | |
| | | | |_| | | | | | |_| |
\_| |_|\__, | \_| |_|\__, |
__/ | __/ |
|___/ |___/
]]-- ]]--
-- state switching logic (stand, walk, run, attacks) -- state switching logic (stand, walk, run, attacks)
@ -675,12 +677,12 @@ end
--[[ --[[
___ ___
|_ | |_ |
| |_ _ _ __ ___ _ __ | |_ _ _ __ ___ _ __
| | | | | '_ ` _ \| '_ \ | | | | | '_ ` _ \| '_ \
/\__/ / |_| | | | | | | |_) | /\__/ / |_| | | | | | | |_) |
\____/ \__,_|_| |_| |_| .__/ \____/ \__,_|_| |_| |_| .__/
| | | |
|_| |_|
]]-- ]]--
@ -787,8 +789,8 @@ ___ ___ _ _ _
| |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __| | |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __|
| | | | (_| | | | | | | |___| (_) | (_| | | (__ | | | | (_| | | | | | | |___| (_) | (_| | | (__
\_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___| \_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___|
__/ | __/ |
|___/ |___/
]]-- ]]--
--the main loop --the main loop
@ -1011,6 +1013,19 @@ function mobs.mob_step(self, dtime)
end end
end end
--mobs flow from Crafter
local pos = self.object:get_pos()
if pos then
local flow_dir = flow(pos)
if flow_dir then
flow_dir = vector.multiply(flow_dir,10)
local vel = self.object:get_velocity()
local acceleration = vector.new(flow_dir.x-vel.x,flow_dir.y-vel.y,flow_dir.z-vel.z)
acceleration = vector.multiply(acceleration, 0.01)
self.object:add_velocity(acceleration)
end
end
--mob is stunned after being hit --mob is stunned after being hit
if self.pause_timer > 0 then if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime self.pause_timer = self.pause_timer - dtime

View File

@ -0,0 +1,78 @@
--this is from https://github.com/HybridDog/builtin_item/blob/e6dfd9dce86503b3cbd1474257eca5f6f6ca71c2/init.lua#L50
local
minetest,vector,math,pairs,minetest_get_node,vector_subtract,minetest_registered_nodes
=
minetest,vector,math,pairs,minetest.get_node,vector.subtract,minetest.registered_nodes
local tab
local n
local function get_nodes(pos)
tab,n = {},1
for i = -1,1,2 do
for _,p in pairs({
{x=pos.x+i, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+i}
}) do
tab[n] = {p, minetest_get_node(p)}
n = n+1
end
end
return tab
end
local data
local param2
local nd
local par2
local name
local tmp
local c_node
function mobs.get_flowing_dir(pos)
c_node = minetest_get_node(pos).name
if c_node ~= "mcl_core:water_flowing" and c_node ~= "mcl_core:water" then
return nil
end
data = get_nodes(pos)
param2 = minetest_get_node(pos).param2
if param2 > 7 then
return nil
end
if c_node == "mcl_core:water" then
for _,i in pairs(data) do
nd = i[2]
name = nd.name
par2 = nd.param2
if name == "mcl_core:water_flowing" and par2 == 7 then
return(vector_subtract(i[1],pos))
end
end
end
for _,i in pairs(data) do
nd = i[2]
name = nd.name
par2 = nd.param2
if name == "mcl_core:water_flowing" and par2 < param2 then
return(vector_subtract(i[1],pos))
end
end
for _,i in pairs(data) do
nd = i[2]
name = nd.name
par2 = nd.param2
if name == "mcl_core:water_flowing" and par2 >= 11 then
return(vector_subtract(i[1],pos))
end
end
for _,i in pairs(data) do
nd = i[2]
name = nd.name
par2 = nd.param2
tmp = minetest_registered_nodes[name]
if tmp and not tmp.walkable and name ~= "mcl_core:water_flowing" and name ~= "mcl_core:water" then
return(vector_subtract(i[1],pos))
end
end
return nil
end