Cars and texture improvements
>texture improvements(masda, jet, lambogoni) >car driving function instead of drive_simple >nitro added to cars(forward+sneak)
50
api.lua
@ -158,6 +158,9 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, moving_anim,
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function object_drive_simple(entity, dtime, speed, decell)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local velo = entity.object:getvelocity()
|
||||
@ -176,6 +179,53 @@ function object_drive_simple(entity, dtime, speed, decell)
|
||||
end
|
||||
end
|
||||
|
||||
function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local velo = entity.object:getvelocity()
|
||||
local nitro_remaining = entity.nitro
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local vec_forward = {x=dir.x*speed,y=velo.y-0.5,z=dir.z*speed}
|
||||
local vec_nitro = {x=dir.x*(speed*1.5),y=velo.y-0.5,z=dir.z*(speed*1.5)}
|
||||
local vec_backward = {x=-dir.x*speed,y=velo.y-0.5,z=-dir.z*speed}
|
||||
local vec_stop = {x=velo.x*decell,y=velo.y-1,z=velo.z*decell}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
if not entity.nitro then
|
||||
minetest.after(4, function()
|
||||
entity.nitro = true
|
||||
end)
|
||||
end
|
||||
if ctrl.up and ctrl.sneak and entity.nitro then
|
||||
entity.object:setvelocity(vec_nitro)
|
||||
local pos = entity.object:getpos()
|
||||
minetest.add_particlespawner(
|
||||
15, --amount
|
||||
1, --time
|
||||
{x=pos.x-0.5, y=pos.y, z=pos.z-0.5}, --minpos
|
||||
{x=pos.x+0.5, y=pos.y, z=pos.z+0.5}, --maxpos
|
||||
{x=0, y=0, z=0}, --minvel
|
||||
{x=-velo.x, y=-velo.y, z=-velo.z}, --maxvel
|
||||
{x=-0,y=-0,z=-0}, --minacc
|
||||
{x=0,y=0,z=0}, --maxacc
|
||||
0.1, --minexptime
|
||||
0.2, --maxexptime
|
||||
10, --minsize
|
||||
15, --maxsize
|
||||
false, --collisiondetection
|
||||
"vehicles_nitro.png" --texture
|
||||
)
|
||||
minetest.after(nitro_duration, function()
|
||||
entity.nitro = false
|
||||
end)
|
||||
elseif ctrl.up then
|
||||
entity.object:setvelocity(vec_forward)
|
||||
elseif ctrl.down then
|
||||
entity.object:setvelocity(vec_backward)
|
||||
elseif not ctrl.down or ctrl.up then
|
||||
entity.object:setvelocity(vec_stop)
|
||||
end
|
||||
end
|
||||
|
||||
function object_turret(entity, dtime, arrow, attack_anim, stand_anim)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local pos = entity.driver:getpos();
|
||||
|
162
init.lua
@ -141,13 +141,25 @@ minetest.register_entity("vehicles:tank", {
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive(self, dtime, 6, 0.5, true, "vehicles:missile_2", nil, nil, true)
|
||||
object_drive(self, dtime, 6, 0.5, true, "vehicles:missile_2", nil, nil, false)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity("vehicles:turret", {
|
||||
visual = "mesh",
|
||||
mesh = "turret.b3d",
|
||||
textures = {"vehicles_tank.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = 1.5,
|
||||
hp_max = 200,
|
||||
physical = true,
|
||||
collisionbox = {-1, -0.6, -0.9, 1, 0.9, 0.9},
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:tank", "Tank", "vehicles_tank_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:nizzan", {
|
||||
@ -167,9 +179,12 @@ minetest.register_entity("vehicles:nizzan", {
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_simple(self, dtime, 9, 0.8)
|
||||
object_drive_car(self, dtime, 14, 0.8, 5)
|
||||
local pos = self.object:getpos()
|
||||
minetest.add_particlespawner(
|
||||
15, --amount
|
||||
@ -212,9 +227,12 @@ minetest.register_entity("vehicles:nizzan2", {
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_simple(self, dtime, 9, 0.8)
|
||||
object_drive_car(self, dtime, 14, 0.8, 5)
|
||||
local pos = self.object:getpos()
|
||||
minetest.add_particlespawner(
|
||||
15, --amount
|
||||
@ -240,6 +258,36 @@ minetest.register_entity("vehicles:nizzan2", {
|
||||
|
||||
register_vehicle_spawner("vehicles:nizzan2", "Nizzan (green)", "vehicles_nizzan_inv2.png")
|
||||
|
||||
minetest.register_entity("vehicles:lambogoni", {
|
||||
visual = "mesh",
|
||||
mesh = "lambogoni.b3d",
|
||||
textures = {"vehicles_lambogoni.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = 1,
|
||||
hp_max = 200,
|
||||
physical = true,
|
||||
collisionbox = {-1, 0, -1, 1.3, 1, 1},
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.driver and clicker == self.driver then
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 15, 0.8, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:lambogoni", "Lambogoni (grey)", "vehicles_lambogoni_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:masda", {
|
||||
visual = "mesh",
|
||||
@ -258,9 +306,12 @@ minetest.register_entity("vehicles:masda", {
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_simple(self, dtime, 10, 0.95)
|
||||
object_drive_car(self, dtime, 15, 0.95, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
@ -269,6 +320,68 @@ minetest.register_entity("vehicles:masda", {
|
||||
|
||||
register_vehicle_spawner("vehicles:masda", "Masda (pink)", "vehicles_masda_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:musting", {
|
||||
visual = "mesh",
|
||||
mesh = "musting.b3d",
|
||||
textures = {"vehicles_musting.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = 1,
|
||||
hp_max = 200,
|
||||
physical = true,
|
||||
collisionbox = {-1, 0, -1, 1.3, 1, 1},
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.driver and clicker == self.driver then
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 15, 0.95, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:musting", "Musting (purple)", "vehicles_musting_inv2.png")
|
||||
|
||||
minetest.register_entity("vehicles:musting2", {
|
||||
visual = "mesh",
|
||||
mesh = "musting.b3d",
|
||||
textures = {"vehicles_musting2.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = 1,
|
||||
hp_max = 200,
|
||||
physical = true,
|
||||
collisionbox = {-1, 0, -1, 1.3, 1, 1},
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.driver and clicker == self.driver then
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 15, 0.85, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:musting2", "Musting (white)", "vehicles_musting_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:pooshe", {
|
||||
visual = "mesh",
|
||||
mesh = "pooshe.b3d",
|
||||
@ -286,9 +399,12 @@ minetest.register_entity("vehicles:pooshe", {
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_simple(self, dtime, 10, 0.95)
|
||||
object_drive_car(self, dtime, 15, 0.95, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
@ -297,6 +413,37 @@ minetest.register_entity("vehicles:pooshe", {
|
||||
|
||||
register_vehicle_spawner("vehicles:pooshe", "Pooshe (red)", "vehicles_pooshe_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:pooshe2", {
|
||||
visual = "mesh",
|
||||
mesh = "pooshe.b3d",
|
||||
textures = {"vehicles_pooshe2.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = 1,
|
||||
hp_max = 200,
|
||||
physical = true,
|
||||
collisionbox = {-1, 0, -1, 1.3, 1, 1},
|
||||
on_rightclick = function(self, clicker)
|
||||
if self.driver and clicker == self.driver then
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 15, 0.95, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:pooshe2", "Pooshe (yellow)", "vehicles_pooshe_inv2.png")
|
||||
|
||||
minetest.register_entity("vehicles:masda2", {
|
||||
visual = "mesh",
|
||||
mesh = "masda.b3d",
|
||||
@ -314,9 +461,12 @@ minetest.register_entity("vehicles:masda2", {
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, {x=0, y=2, z=4}, {x=0, y=3, z=-72})
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_simple(self, dtime, 10, 0.95)
|
||||
object_drive_car(self, dtime, 15, 0.95, 4)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
|
BIN
models/jet.b3d
BIN
models/lambogoni.b3d
Normal file
BIN
models/musting.b3d
Normal file
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 25 KiB |
BIN
textures/vehicles_lambogoni.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
textures/vehicles_lambogoni_inv.png
Normal file
After Width: | Height: | Size: 486 B |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 68 KiB |
BIN
textures/vehicles_musting.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
textures/vehicles_musting2.png
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
textures/vehicles_musting_inv.png
Normal file
After Width: | Height: | Size: 495 B |
BIN
textures/vehicles_musting_inv2.png
Normal file
After Width: | Height: | Size: 434 B |
BIN
textures/vehicles_nitro.png
Normal file
After Width: | Height: | Size: 688 B |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 59 KiB |
BIN
textures/vehicles_pooshe2.png
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
textures/vehicles_pooshe_inv2.png
Normal file
After Width: | Height: | Size: 512 B |