forked from mtcontrib/mobs_redo
0.4.16 functions
This commit is contained in:
parent
04ae3502a5
commit
adc4e71a01
28
mount.lua
28
mount.lua
@ -171,7 +171,7 @@ function mobs.detach(player, offset)
|
|||||||
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
|
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
|
||||||
|
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.1, function()
|
||||||
player:setpos(pos)
|
player:set_pos(pos)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local acce_y = 0
|
local acce_y = 0
|
||||||
local velo = entity.object:getvelocity()
|
local velo = entity.object:get_velocity()
|
||||||
|
|
||||||
entity.v = get_v(velo) * get_sign(entity.v)
|
entity.v = get_v(velo) * get_sign(entity.v)
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- fix mob rotation
|
-- fix mob rotation
|
||||||
entity.object:setyaw(entity.driver:get_look_horizontal() - entity.rotate)
|
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
||||||
|
|
||||||
if can_fly then
|
if can_fly then
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
|
|
||||||
if s ~= get_sign(entity.v) then
|
if s ~= get_sign(entity.v) then
|
||||||
|
|
||||||
entity.object:setvelocity({x = 0, y = 0, z = 0})
|
entity.object:set_velocity({x = 0, y = 0, z = 0})
|
||||||
entity.v = 0
|
entity.v = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -345,7 +345,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
if math.abs(velo.y) < 1 then
|
if math.abs(velo.y) < 1 then
|
||||||
local pos = entity.object:get_pos()
|
local pos = entity.object:get_pos()
|
||||||
pos.y = math.floor(pos.y) + 0.5
|
pos.y = math.floor(pos.y) + 0.5
|
||||||
entity.object:setpos(pos)
|
entity.object:set_pos(pos)
|
||||||
velo.y = 0
|
velo.y = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -357,8 +357,8 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
new_velo = get_velocity(v, entity.object:get_yaw() - rot_view, velo.y)
|
new_velo = get_velocity(v, entity.object:get_yaw() - rot_view, velo.y)
|
||||||
new_acce.y = new_acce.y + acce_y
|
new_acce.y = new_acce.y + acce_y
|
||||||
|
|
||||||
entity.object:setvelocity(new_velo)
|
entity.object:set_velocity(new_velo)
|
||||||
entity.object:setacceleration(new_acce)
|
entity.object:set_acceleration(new_acce)
|
||||||
|
|
||||||
-- CRASH!
|
-- CRASH!
|
||||||
if enable_crash then
|
if enable_crash then
|
||||||
@ -386,7 +386,7 @@ end
|
|||||||
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||||
|
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local velo = entity.object:getvelocity()
|
local velo = entity.object:get_velocity()
|
||||||
local dir = entity.driver:get_look_dir()
|
local dir = entity.driver:get_look_dir()
|
||||||
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
|
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
|
||||||
local rot_steer, rot_view = math.pi / 2, 0
|
local rot_steer, rot_view = math.pi / 2, 0
|
||||||
@ -396,24 +396,24 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
entity.object:setvelocity({
|
entity.object:set_velocity({
|
||||||
x = dir.x * speed,
|
x = dir.x * speed,
|
||||||
y = dir.y * speed + 2,
|
y = dir.y * speed + 2,
|
||||||
z = dir.z * speed
|
z = dir.z * speed
|
||||||
})
|
})
|
||||||
|
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
entity.object:setvelocity({
|
entity.object:set_velocity({
|
||||||
x = -dir.x * speed,
|
x = -dir.x * speed,
|
||||||
y = dir.y * speed + 2,
|
y = dir.y * speed + 2,
|
||||||
z = -dir.z * speed
|
z = -dir.z * speed
|
||||||
})
|
})
|
||||||
|
|
||||||
elseif not ctrl.down or ctrl.up or ctrl.jump then
|
elseif not ctrl.down or ctrl.up or ctrl.jump then
|
||||||
entity.object:setvelocity({x = 0, y = -2, z = 0})
|
entity.object:set_velocity({x = 0, y = -2, z = 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
entity.object:setyaw(yaw + math.pi + math.pi / 2 - entity.rotate)
|
entity.object:set_yaw(yaw + math.pi + math.pi / 2 - entity.rotate)
|
||||||
|
|
||||||
-- firing arrows
|
-- firing arrows
|
||||||
if ctrl.LMB and ctrl.sneak and shoots then
|
if ctrl.LMB and ctrl.sneak and shoots then
|
||||||
@ -430,8 +430,8 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
|||||||
ent.owner_id = tostring(entity.object) -- so arrows dont hurt entity you are riding
|
ent.owner_id = tostring(entity.object) -- so arrows dont hurt entity you are riding
|
||||||
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
|
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
|
||||||
local yaw = entity.driver:get_look_horizontal()
|
local yaw = entity.driver:get_look_horizontal()
|
||||||
obj:setyaw(yaw + math.pi / 2)
|
obj:set_yaw(yaw + math.pi / 2)
|
||||||
obj:setvelocity(vec)
|
obj:set_velocity(vec)
|
||||||
else
|
else
|
||||||
obj:remove()
|
obj:remove()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user