Police car and minor improvements
>Added police car >Added ambulance siren >Added smoke trail to rockets. >Cars are slower in reverse >Vehicles fire faster bullets/missiles
This commit is contained in:
parent
fac85fd257
commit
455263a488
8
api.lua
8
api.lua
@ -115,7 +115,7 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
||||
local velo = entity.object:getvelocity()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
--local vec_forward = {x=dir.x*speed,y=velo.y+1*-2,z=dir.z*speed}
|
||||
local vec_backward = {x=-dir.x*speed,y=velo.y+1*-2,z=-dir.z*speed}
|
||||
local vec_backward = {x=-dir.x*speed/4,y=velo.y+1*-2,z=-dir.z*speed/4}
|
||||
local vec_stop = {x=velo.x*decell,y=velo.y+1*-2,z=velo.z*decell}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
--timer
|
||||
@ -170,7 +170,7 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
||||
entity.loaded = false
|
||||
local pos = entity.object:getpos()
|
||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+shoot_y+dir.y,z=pos.z+0+dir.z*2}, arrow)
|
||||
local vec = {x=dir.x*9,y=dir.y*9,z=dir.z*9}
|
||||
local vec = {x=dir.x*14,y=dir.y*14,z=dir.z*14}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
obj:setyaw(yaw+math.pi/2)
|
||||
obj:setvelocity(vec)
|
||||
@ -350,7 +350,7 @@ function object_drive_car(entity, dtime, speed, decell, nitro_duration, move_ani
|
||||
--play engine sound
|
||||
if entity.sound_ready then
|
||||
minetest.sound_play("engine",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
entity.sound_ready = false
|
||||
minetest.after(11, function()
|
||||
entity.sound_ready = true
|
||||
@ -400,7 +400,7 @@ function object_turret(entity, dtime, height, arrow, shoot_interval)
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local obj = minetest.env:add_entity({x=pos.x+dir.x*1.2,y=pos.y+height,z=pos.z+dir.z*1.2}, arrow)
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
local vec = {x=dir.x*9, y=dir.y*9, z=dir.z*9}
|
||||
local vec = {x=dir.x*12, y=dir.y*12, z=dir.z*12}
|
||||
obj:setyaw(yaw+math.pi/2)
|
||||
obj:setvelocity(vec)
|
||||
local object = obj:get_luaentity()
|
||||
|
132
init.lua
132
init.lua
@ -42,6 +42,23 @@ minetest.register_entity("vehicles:missile", {
|
||||
self.object:setvelocity(vec)
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
local vec = self.object:getvelocity()
|
||||
minetest.add_particlespawner({
|
||||
amount = 1,
|
||||
time = 0.5,
|
||||
minpos = {x=pos.x-0.2, y=pos.y, z=pos.z-0.2},
|
||||
maxpos = {x=pos.x+0.2, y=pos.y, z=pos.z+0.2},
|
||||
minvel = {x=-vec.x/2, y=-vec.y/2, z=-vec.z/2},
|
||||
maxvel = {x=-vec.x, y=-vec.y, z=-vec.z},
|
||||
minacc = {x=0, y=-1, z=0},
|
||||
maxacc = {x=0, y=-1, z=0},
|
||||
minexptime = 0.2,
|
||||
maxexptime = 0.6,
|
||||
minsize = 3,
|
||||
maxsize = 4,
|
||||
collisiondetection = false,
|
||||
texture = "vehicles_smoke.png",
|
||||
})
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
@ -100,14 +117,30 @@ minetest.register_entity("vehicles:missile_2", {
|
||||
self.object:remove()
|
||||
end)
|
||||
local velo = self.object:getvelocity()
|
||||
if velo.y <= 1 and velo.y >= -1 then
|
||||
if velo.y <= 1.2 and velo.y >= -1.2 then
|
||||
self.object:set_animation({x=1, y=1}, 5, 0)
|
||||
elseif velo.y <= -1 then
|
||||
elseif velo.y <= -1.2 then
|
||||
self.object:set_animation({x=4, y=4}, 5, 0)
|
||||
elseif velo.y >= 1 then
|
||||
elseif velo.y >= 1.2 then
|
||||
self.object:set_animation({x=2, y=2}, 5, 0)
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
minetest.add_particlespawner({
|
||||
amount = 2,
|
||||
time = 0.5,
|
||||
minpos = {x=pos.x-0.2, y=pos.y, z=pos.z-0.2},
|
||||
maxpos = {x=pos.x+0.2, y=pos.y, z=pos.z+0.2},
|
||||
minvel = {x=-velo.x/2, y=-velo.y/2, z=-velo.z/2},
|
||||
maxvel = {x=-velo.x, y=-velo.y, z=-velo.z},
|
||||
minacc = {x=0, y=-1, z=0},
|
||||
maxacc = {x=0, y=-1, z=0},
|
||||
minexptime = 0.2,
|
||||
maxexptime = 0.6,
|
||||
minsize = 3,
|
||||
maxsize = 4,
|
||||
collisiondetection = false,
|
||||
texture = "vehicles_smoke.png",
|
||||
})
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
@ -440,7 +473,7 @@ minetest.register_entity("vehicles:geep", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -515,7 +548,7 @@ minetest.register_entity("vehicles:ambulance", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=7, z=14})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -542,6 +575,14 @@ minetest.register_entity("vehicles:ambulance", {
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 13, 0.6, 0, {x=1, y=3}, {x=1, y=1})
|
||||
if not self.siren_ready then
|
||||
minetest.sound_play("ambulance",
|
||||
{gain = 0.1, max_hear_distance = 3, loop = false})
|
||||
self.siren_ready = true
|
||||
minetest.after(4, function()
|
||||
self.siren_ready = false
|
||||
end)
|
||||
end
|
||||
return false
|
||||
end
|
||||
return true
|
||||
@ -572,7 +613,7 @@ minetest.register_entity("vehicles:ute", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -646,7 +687,7 @@ minetest.register_entity("vehicles:ute2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -697,7 +738,7 @@ minetest.register_entity("vehicles:astonmaaton", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -748,7 +789,7 @@ minetest.register_entity("vehicles:nizzan", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -816,7 +857,7 @@ minetest.register_entity("vehicles:nizzan2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -884,7 +925,7 @@ minetest.register_entity("vehicles:lambogoni", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -935,7 +976,7 @@ minetest.register_entity("vehicles:lambogoni2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -986,7 +1027,7 @@ minetest.register_entity("vehicles:masda", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1021,6 +1062,57 @@ minetest.register_entity("vehicles:masda", {
|
||||
|
||||
register_vehicle_spawner("vehicles:masda", "Masda (pink)", "vehicles_masda_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:policecar", {
|
||||
visual = "mesh",
|
||||
mesh = "policecar.b3d",
|
||||
textures = {"vehicles_policecar.png"},
|
||||
velocity = 15,
|
||||
acceleration = -5,
|
||||
stepheight = step,
|
||||
hp_max = 190,
|
||||
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}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_drive_car(self, dtime, 16, 0.95, 8)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
register_vehicle_spawner("vehicles:policecar", "Police Car (US)", "vehicles_policecar_inv.png")
|
||||
|
||||
minetest.register_entity("vehicles:musting", {
|
||||
visual = "mesh",
|
||||
mesh = "musting.b3d",
|
||||
@ -1037,7 +1129,7 @@ minetest.register_entity("vehicles:musting", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1088,7 +1180,7 @@ minetest.register_entity("vehicles:musting2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1149,7 +1241,7 @@ minetest.register_entity("vehicles:fewawi", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1211,7 +1303,7 @@ minetest.register_entity("vehicles:fewawi2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1263,7 +1355,7 @@ minetest.register_entity("vehicles:pooshe", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1314,7 +1406,7 @@ minetest.register_entity("vehicles:pooshe2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
@ -1365,7 +1457,7 @@ minetest.register_entity("vehicles:masda2", {
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
{gain = 4, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
|
@ -29,7 +29,9 @@ geep.b3d, and vehicles_jeep.png - CC BY-SA 3.0 UNPORTED. Created by Kdog14
|
||||
License for sounds:
|
||||
CC BY-NC 3.0 oniwe https://freesound.org/people/oniwe/sounds/32316/
|
||||
|
||||
shot.ogg - by Kibblesbob http://soundbible.com/1804-M4A1-Single.html
|
||||
shot.ogg - CC BY-NC 3.0 by Kibblesbob http://soundbible.com/1804-M4A1-Single.html
|
||||
|
||||
ambulance.ogg - CC BY-SA 4.0 by Demircimehmed https://commons.wikimedia.org/wiki/File:AmbulanceSound1.wav
|
||||
|
||||
--License of lib_mount:
|
||||
-- Minetest mod: lib_mount
|
||||
|
BIN
models/policecar.b3d
Normal file
BIN
models/policecar.b3d
Normal file
Binary file not shown.
BIN
sounds/ambulance.ogg
Normal file
BIN
sounds/ambulance.ogg
Normal file
Binary file not shown.
BIN
textures/vehicles_policecar.png
Normal file
BIN
textures/vehicles_policecar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
textures/vehicles_policecar_inv.png
Normal file
BIN
textures/vehicles_policecar_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 388 B |
BIN
textures/vehicles_smoke.png
Normal file
BIN
textures/vehicles_smoke.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 168 B |
Loading…
x
Reference in New Issue
Block a user