Added rotate to mob definition
This commit is contained in:
parent
ef89de6c2e
commit
ace1582821
34
api.lua
34
api.lua
@ -19,6 +19,7 @@ on_die = def.on_die,
|
|||||||
jump_height = def.jump_height or 6,
|
jump_height = def.jump_height or 6,
|
||||||
jump_chance = def.jump_chance or 0,
|
jump_chance = def.jump_chance or 0,
|
||||||
footstep = def.footstep,
|
footstep = def.footstep,
|
||||||
|
rotate = def.rotate or 0,
|
||||||
hp_min = def.hp_min or 5,
|
hp_min = def.hp_min or 5,
|
||||||
hp_max = def.hp_max or 10,
|
hp_max = def.hp_max or 10,
|
||||||
physical = true,
|
physical = true,
|
||||||
@ -38,7 +39,7 @@ footstep = def.footstep,
|
|||||||
fall_speed = def.fall_speed or -10, -- must be lower than -2
|
fall_speed = def.fall_speed or -10, -- must be lower than -2
|
||||||
drops = def.drops or {},
|
drops = def.drops or {},
|
||||||
armor = def.armor,
|
armor = def.armor,
|
||||||
drawtype = def.drawtype,
|
--drawtype = def.drawtype,
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
type = def.type,
|
type = def.type,
|
||||||
attack_type = def.attack_type,
|
attack_type = def.attack_type,
|
||||||
@ -89,10 +90,8 @@ footstep = def.footstep,
|
|||||||
|
|
||||||
set_velocity = function(self, v)
|
set_velocity = function(self, v)
|
||||||
if not v then v = 0 end -- added
|
if not v then v = 0 end -- added
|
||||||
local yaw = self.object:getyaw()
|
if def.drawtype and def.drawtype == "side" then self.rotate = 1.5 end
|
||||||
if self.drawtype == "side" then
|
local yaw = self.object:getyaw() + self.rotate
|
||||||
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})
|
||||||
@ -105,10 +104,7 @@ footstep = def.footstep,
|
|||||||
--[[
|
--[[
|
||||||
in_fov = function(self,pos)
|
in_fov = function(self,pos)
|
||||||
-- checks if POS is in self's FOV
|
-- checks if POS is in self's FOV
|
||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw() + self.rotate
|
||||||
if self.drawtype == "side" then
|
|
||||||
yaw = yaw+(math.pi/2)
|
|
||||||
end
|
|
||||||
local vx = math.sin(yaw)
|
local vx = math.sin(yaw)
|
||||||
local vz = math.cos(yaw)
|
local vz = math.cos(yaw)
|
||||||
local ds = math.sqrt(vx^2 + vz^2)
|
local ds = math.sqrt(vx^2 + vz^2)
|
||||||
@ -458,10 +454,7 @@ footstep = def.footstep,
|
|||||||
self.following = nil
|
self.following = nil
|
||||||
else
|
else
|
||||||
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) + self.rotate
|
||||||
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
|
||||||
@ -507,10 +500,7 @@ footstep = def.footstep,
|
|||||||
|
|
||||||
if lp ~= nil then
|
if lp ~= nil then
|
||||||
local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z}
|
local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z}
|
||||||
yaw = math.atan(vec.z/vec.x)+math.pi/2
|
yaw = (math.atan(vec.z/vec.x)+math.pi/2) + self.rotate
|
||||||
if self.drawtype == "side" then
|
|
||||||
yaw = yaw+(math.pi/2)
|
|
||||||
end
|
|
||||||
if lp.x > s.x then
|
if lp.x > s.x then
|
||||||
yaw = yaw+math.pi
|
yaw = yaw+math.pi
|
||||||
end
|
end
|
||||||
@ -581,10 +571,7 @@ footstep = def.footstep,
|
|||||||
end
|
end
|
||||||
|
|
||||||
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) + self.rotate
|
||||||
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
|
||||||
@ -647,10 +634,7 @@ footstep = def.footstep,
|
|||||||
end
|
end
|
||||||
|
|
||||||
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) + self.rotate
|
||||||
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
|
||||||
|
1036
api.lua_bak
1036
api.lua_bak
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,6 @@ mobs:register_mob("mobs:chicken", {
|
|||||||
collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3},
|
collisionbox = {-0.3, -0.75, -0.3, 0.3, 0.1, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_chicken.x",
|
mesh = "mobs_chicken.x",
|
||||||
drawtype = "front",
|
|
||||||
textures = {
|
textures = {
|
||||||
{"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png",
|
{"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png",
|
||||||
"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
|
"mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png", "mobs_chicken.png"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user