Missile rotation
The missiles rotate depending of if they are fired up or down. Currently does not work when moving straight ahead, ie: it will point either up or down
This commit is contained in:
parent
b6af0344ca
commit
6632735116
14
api.lua
14
api.lua
@ -362,6 +362,11 @@ function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, moving_a
|
|||||||
entity.object:setvelocity(vec_stop)
|
entity.object:setvelocity(vec_stop)
|
||||||
entity.object:setacceleration({x=0, y=-4.5, z=0})
|
entity.object:setacceleration({x=0, y=-4.5, z=0})
|
||||||
end
|
end
|
||||||
|
if ctrl.jump and ctrl.up then
|
||||||
|
entity.object:setvelocity({x=dir.x*speed, y=0, z=dir.z*speed})
|
||||||
|
elseif ctrl.jump and not ctrl.up then
|
||||||
|
entity.object:setvelocity({x=velo.x*decell, y=0, z=velo.z*decell})
|
||||||
|
end
|
||||||
if ctrl.sneak and shoots and entity.loaded then
|
if ctrl.sneak and shoots and entity.loaded then
|
||||||
entity.loaded = false
|
entity.loaded = false
|
||||||
local pos = entity.object:getpos()
|
local pos = entity.object:getpos()
|
||||||
@ -679,6 +684,8 @@ minetest.register_tool(vehicle.."_spawner", {
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--out of date, left behind in case it is needed again
|
||||||
function vehicle_drop(ent, player, name)
|
function vehicle_drop(ent, player, name)
|
||||||
if ent.owner == player then
|
if ent.owner == player then
|
||||||
local pos = ent.object:getpos()
|
local pos = ent.object:getpos()
|
||||||
@ -686,3 +693,10 @@ function vehicle_drop(ent, player, name)
|
|||||||
ent.object:remove()
|
ent.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function destroy(ent, player, name)
|
||||||
|
if ent.object:get_hp() == 0 and ent.owner == player then
|
||||||
|
local pos = ent.object:getpos()
|
||||||
|
minetest.env:add_item(pos, "vehicles:tank_spawner")
|
||||||
|
end
|
||||||
|
end
|
14
init.lua
14
init.lua
@ -94,6 +94,14 @@ minetest.register_entity("vehicles:missile_2", {
|
|||||||
minetest.after(10, function()
|
minetest.after(10, function()
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end)
|
end)
|
||||||
|
local velo = self.object:getvelocity()
|
||||||
|
if velo.y <= 1 and velo.y >= -1 then
|
||||||
|
self.object:set_animation({x=1, y=1}, 5, 0)
|
||||||
|
elseif velo.y <= -1 then
|
||||||
|
self.object:set_animation({x=4, y=4}, 5, 0)
|
||||||
|
elseif velo.y >= 1 then
|
||||||
|
self.object:set_animation({x=2, y=2}, 5, 0)
|
||||||
|
end
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
@ -212,6 +220,7 @@ minetest.register_entity("vehicles:tank", {
|
|||||||
textures = {"vehicles_tank.png"},
|
textures = {"vehicles_tank.png"},
|
||||||
velocity = 15,
|
velocity = 15,
|
||||||
acceleration = -5,
|
acceleration = -5,
|
||||||
|
owner = "",
|
||||||
stepheight = 1.5,
|
stepheight = 1.5,
|
||||||
hp_max = 200,
|
hp_max = 200,
|
||||||
physical = true,
|
physical = true,
|
||||||
@ -224,7 +233,7 @@ minetest.register_entity("vehicles:tank", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_punch = function(self, puncher)
|
on_punch = function(self, puncher)
|
||||||
vehicle_drop(self, puncher, "vehicles:tank")
|
destroy(self, puncher, "vehicles:tank")
|
||||||
end,
|
end,
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.driver then
|
if self.driver then
|
||||||
@ -242,7 +251,8 @@ minetest.register_entity("vehicles:turret", {
|
|||||||
velocity = 15,
|
velocity = 15,
|
||||||
acceleration = -5,
|
acceleration = -5,
|
||||||
stepheight = 1.5,
|
stepheight = 1.5,
|
||||||
hp_max = 200,
|
hp_max = 50,
|
||||||
|
groups = {fleshy=3, level=5},
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.6, 0, -0.6, 0.6, 0.9, 0.6},
|
collisionbox = {-0.6, 0, -0.6, 0.6, 0.9, 0.6},
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 4.6 KiB |
Loading…
x
Reference in New Issue
Block a user