Add drawtype to definition of mobs
parent
d7212dc8bc
commit
e4f54d11e6
23
init.lua
23
init.lua
|
@ -16,6 +16,7 @@ function mobs:register_monster(name, def)
|
||||||
drop = def.drop,
|
drop = def.drop,
|
||||||
drop_count = def.drop_count,
|
drop_count = def.drop_count,
|
||||||
armor = def.armor,
|
armor = def.armor,
|
||||||
|
drawtype = def.drawtype,
|
||||||
|
|
||||||
timer = 0,
|
timer = 0,
|
||||||
attack = {player=nil, dist=nil},
|
attack = {player=nil, dist=nil},
|
||||||
|
@ -25,6 +26,9 @@ function mobs:register_monster(name, def)
|
||||||
|
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
|
if self.drawtype == "side" then
|
||||||
|
yaw = yaw+(math.pi/2)
|
||||||
|
end
|
||||||
local x = math.sin(yaw) * -v
|
local x = math.sin(yaw) * -v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||||
|
@ -38,6 +42,9 @@ function mobs:register_monster(name, def)
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.object:getvelocity().y > 0.1 then
|
if self.object:getvelocity().y > 0.1 then
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
|
if self.drawtype == "side" then
|
||||||
|
yaw = yaw+(math.pi/2)
|
||||||
|
end
|
||||||
local x = math.sin(yaw) * -2
|
local x = math.sin(yaw) * -2
|
||||||
local z = math.cos(yaw) * 2
|
local z = math.cos(yaw) * 2
|
||||||
self.object:setacceleration({x=x, y=-10, z=z})
|
self.object:setacceleration({x=x, y=-10, z=z})
|
||||||
|
@ -137,6 +144,9 @@ function mobs:register_monster(name, def)
|
||||||
|
|
||||||
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
|
||||||
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
local yaw = math.atan(vec.z/vec.x)+math.pi/2
|
||||||
|
if self.drawtype == "side" then
|
||||||
|
yaw = yaw+(math.pi/2)
|
||||||
|
end
|
||||||
if p.x > s.x then
|
if p.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
|
@ -231,6 +241,7 @@ function mobs:register_animal(name, def)
|
||||||
drop = def.drop,
|
drop = def.drop,
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
drop_count = def.drop_count,
|
drop_count = def.drop_count,
|
||||||
|
drawtype = def.drawtype,
|
||||||
|
|
||||||
timer = 0,
|
timer = 0,
|
||||||
state = "stand",
|
state = "stand",
|
||||||
|
@ -238,7 +249,9 @@ function mobs:register_animal(name, def)
|
||||||
|
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
yaw = yaw+(math.pi/2)
|
if self.drawtype == "side" then
|
||||||
|
yaw = yaw+(math.pi/2)
|
||||||
|
end
|
||||||
local x = math.sin(yaw) * -v
|
local x = math.sin(yaw) * -v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
self.object:setvelocity({x=x, y=self.object:getvelocity().y, z=z})
|
||||||
|
@ -252,7 +265,9 @@ function mobs:register_animal(name, def)
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.object:getvelocity().y > 0.1 then
|
if self.object:getvelocity().y > 0.1 then
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
yaw = yaw+(math.pi/2)
|
if self.drawtype == "side" then
|
||||||
|
yaw = yaw+(math.pi/2)
|
||||||
|
end
|
||||||
local x = math.sin(yaw) * -2
|
local x = math.sin(yaw) * -2
|
||||||
local z = math.cos(yaw) * 2
|
local z = math.cos(yaw) * 2
|
||||||
self.object:setacceleration({x=x, y=-10, z=z})
|
self.object:setacceleration({x=x, y=-10, z=z})
|
||||||
|
@ -394,6 +409,7 @@ mobs:register_monster("mobs:dirt_monster", {
|
||||||
drop = "default:dirt",
|
drop = "default:dirt",
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1)
|
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1)
|
||||||
|
|
||||||
|
@ -412,6 +428,7 @@ mobs:register_monster("mobs:stone_monster", {
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 2,
|
armor = 2,
|
||||||
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1)
|
mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1)
|
||||||
|
|
||||||
|
@ -431,6 +448,7 @@ mobs:register_monster("mobs:sand_monster", {
|
||||||
drop_count = 3,
|
drop_count = 3,
|
||||||
light_resistant = true,
|
light_resistant = true,
|
||||||
armor = 3,
|
armor = 3,
|
||||||
|
drawtype = "front",
|
||||||
})
|
})
|
||||||
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1)
|
mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1)
|
||||||
|
|
||||||
|
@ -444,6 +462,7 @@ mobs:register_animal("mobs:sheep", {
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
drop = "mobs:meat_raw",
|
drop = "mobs:meat_raw",
|
||||||
drop_count = 2,
|
drop_count = 2,
|
||||||
|
drawtype = "side",
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if self.naked then
|
if self.naked then
|
||||||
|
|
Loading…
Reference in New Issue