Proper turret aiming.

master
Beha 2017-01-07 03:17:03 -05:00
parent a6508974a5
commit 47ef855c45
2 changed files with 4 additions and 4 deletions

View File

@ -184,11 +184,11 @@ function magic.register_missile(name, texture, def, item_def)
end
local function CheckLineNear(line, pos, distance)
local nx = 0.25
local nx = 0.5
if line.finish.x < line.start.x then nx = -nx end
local ny = 0.25
local ny = 0.5
if line.finish.y < line.start.y then ny = -ny end
local nz = 0.25
local nz = 0.5
if line.finish.z < line.start.z then nz = -nz end
for x=line.start.x,line.finish.x,nx do

View File

@ -131,7 +131,7 @@ minetest.register_abm({
end
end
if closest then
local dir = vector.normalize{x=closest:getpos().x - pos.x, y=(closest:getpos().y + 0.5) - pos.y, z=closest:getpos().z - pos.z}
local dir = vector.normalize{x=closest:getpos().x - pos.x, y=(closest:getpos().y + closest:get_properties().collisionbox[5]) - pos.y, z=closest:getpos().z - pos.z}
local mobj = minetest.add_entity(pos, name.."_missile")
mobj:setvelocity({x=dir.x*def.speed, y=dir.y*def.speed, z=dir.z*def.speed})
mobj:setacceleration({x=0, y=-8.5*(def.gravity or 0), z=0})