Merge remote-tracking branch 'origin/master'
# Conflicts: # license.txt
243
api.lua
@ -47,18 +47,17 @@ local function force_detach(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function object_attach(entity, player, attach_at, visible, eye_offset)
|
function object_attach(entity, player, attach_at, visible, eye_offset)
|
||||||
eye_offset = eye_offset or {x=0, y=0, z=0}
|
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
entity.driver = player
|
entity.driver = player
|
||||||
entity.loaded = true
|
entity.loaded = true
|
||||||
player:set_attach(entity.object, "", attach_at, {x=0, y=0, z=0})
|
player:set_attach(entity.object, "", attach_at, {x=0, y=0, z=0})
|
||||||
--this is to hide the player when the attaching doesn't work properly
|
-- this is to hide the player when the attaching doesn't work properly
|
||||||
if not visible then
|
if not visible then
|
||||||
player:set_properties({visual_size = {x=0, y=0}})
|
player:set_properties({visual_size = {x=0, y=0}})
|
||||||
else
|
else
|
||||||
player:set_properties({visual_size = {x=1, y=1}})
|
player:set_properties({visual_size = {x=1, y=1}})
|
||||||
end
|
end
|
||||||
player:set_eye_offset(eye_offset, {x=0, y=2, z=-40})
|
player:set_eye_offset(eye_offset, {x=eye_offset.x, y=eye_offset.y+1, z=-40})
|
||||||
default.player_attached[player:get_player_name()] = true
|
default.player_attached[player:get_player_name()] = true
|
||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
default.player_set_animation(player, "sit" , 30)
|
default.player_set_animation(player, "sit" , 30)
|
||||||
@ -109,13 +108,14 @@ end)
|
|||||||
timer = 0
|
timer = 0
|
||||||
|
|
||||||
--basic driving, use for basic vehicles/mounts, with optional weapons
|
--basic driving, use for basic vehicles/mounts, with optional weapons
|
||||||
function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, moving_anim, stand_anim, jumps)
|
function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, moving_anim, stand_anim, jump, jump_anim, shoot_anim, shoot_y)
|
||||||
--variables
|
--variables
|
||||||
|
local shoot_y = shoot_y or 1.5
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local velo = entity.object:getvelocity()
|
local velo = entity.object:getvelocity()
|
||||||
local dir = entity.driver:get_look_dir();
|
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_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 vec_stop = {x=velo.x*decell,y=velo.y+1*-2,z=velo.z*decell}
|
||||||
local yaw = entity.driver:get_look_yaw();
|
local yaw = entity.driver:get_look_yaw();
|
||||||
--timer
|
--timer
|
||||||
@ -128,6 +128,8 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
|||||||
end
|
end
|
||||||
--timer dependant variables
|
--timer dependant variables
|
||||||
local vec_forward = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=velo.y+1*-2,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
local vec_forward = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=velo.y+1*-2,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||||
|
local vec_forward_hover = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=1.5,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||||
|
local vec_forward_jump = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=4,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||||
|
|
||||||
--respond to controls
|
--respond to controls
|
||||||
--water effects
|
--water effects
|
||||||
@ -138,12 +140,27 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
|||||||
elseif ctrl.up then
|
elseif ctrl.up then
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
entity.object:setvelocity(vec_forward)
|
entity.object:setvelocity(vec_forward)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving and not hovering then
|
||||||
|
entity.object:set_animation(moving_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
entity.object:setvelocity(vec_backward)
|
entity.object:setvelocity(vec_backward)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving and not hovering then
|
||||||
|
entity.object:set_animation(moving_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
elseif not ctrl.down or ctrl.up then
|
elseif not ctrl.down or ctrl.up then
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
entity.object:setvelocity(vec_stop)
|
entity.object:setvelocity(vec_stop)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and entity.moving and not hovering then
|
||||||
|
entity.object:set_animation(stand_anim, 20, 0)
|
||||||
|
entity.moving = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if ctrl.sneak and shoots and entity.loaded then
|
if ctrl.sneak and shoots and entity.loaded then
|
||||||
local pname = entity.driver:get_player_name();
|
local pname = entity.driver:get_player_name();
|
||||||
@ -152,44 +169,64 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
|||||||
local remov = inv:remove_item("main", arrow.."_item")
|
local remov = inv:remove_item("main", arrow.."_item")
|
||||||
entity.loaded = false
|
entity.loaded = false
|
||||||
local pos = entity.object:getpos()
|
local pos = entity.object:getpos()
|
||||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
|
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();
|
local yaw = entity.driver:get_look_yaw();
|
||||||
obj:setyaw(yaw+math.pi/2)
|
obj:setyaw(yaw+math.pi/2)
|
||||||
obj:setvelocity(vec)
|
obj:setvelocity(vec)
|
||||||
local object = obj:get_luaentity()
|
local object = obj:get_luaentity()
|
||||||
object.launcher = entity.driver
|
object.launcher = entity.driver
|
||||||
|
if shoot_anim ~= nil and entity.object:get_animation().range ~= shoot_anim then
|
||||||
|
entity.object:set_animation(shoot_anim, 20, 0)
|
||||||
|
end
|
||||||
minetest.after(reload, function()
|
minetest.after(reload, function()
|
||||||
entity.loaded = true
|
entity.loaded = true
|
||||||
|
if stand_anim ~= nil and shoot_anim ~= nil then
|
||||||
|
entity.object:set_animation(stand_anim, 20, 0)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--lib_mount animation
|
|
||||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
if jump == "hover" and ctrl.jump and not entity.jumpcharge then
|
||||||
if stand_anim and stand_anim ~= nil and mobs_redo == true then
|
if not ctrl.up then
|
||||||
self.object:set_animation(entity, stand_anim)
|
local vec_hover = {x=velo.x+0,y=1,z=velo.z+0}
|
||||||
|
entity.object:setvelocity(vec_hover)
|
||||||
|
else
|
||||||
|
entity.object:setvelocity(vec_forward_hover)
|
||||||
end
|
end
|
||||||
return
|
hovering = true
|
||||||
|
if jump_anim ~= nil and entity.object:get_animation().range ~= jump_anim and hovering then
|
||||||
|
entity.object:set_animation(jump_anim, 20, 0)
|
||||||
end
|
end
|
||||||
if moving_anim and moving_anim ~= nil then
|
minetest.after(5, function()
|
||||||
self.object:set_animation(entity, moving_anim)
|
entity.jumpcharge = true
|
||||||
|
end)
|
||||||
|
minetest.after(10, function()
|
||||||
|
entity.jumpcharge = false
|
||||||
|
hovering = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if jump == "jump" and ctrl.jump and not entity.jumpcharge then
|
||||||
|
if not ctrl.up then
|
||||||
|
local vec_jump = {x=velo.x+0,y=4,z=velo.z+0}
|
||||||
|
entity.object:setvelocity(vec_jump)
|
||||||
|
else
|
||||||
|
entity.object:setvelocity(vec_forward_hover)
|
||||||
|
end
|
||||||
|
hovering = true
|
||||||
|
if jump_anim ~= nil and entity.object:get_animation().range ~= jump_anim and hovering then
|
||||||
|
entity.object:set_animation(jump_anim, 20, 0)
|
||||||
|
end
|
||||||
|
minetest.after(0.5, function()
|
||||||
|
entity.jumpcharge = true
|
||||||
|
end)
|
||||||
|
minetest.after(1, function()
|
||||||
|
entity.jumpcharge = false
|
||||||
|
hovering = false
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
--jumping not working
|
|
||||||
-- local jumps = jumps or false
|
|
||||||
-- if jumps == true and ctrl.jump then
|
|
||||||
-- local xvel = entity.object:getvelocity().x
|
|
||||||
-- local zvel = entity.object:getvelocity().z
|
|
||||||
-- local yvel = entity.object:getvelocity().y
|
|
||||||
-- local vel = {x=xvel,y=10,z=zvel}
|
|
||||||
-- entity.object:setvelocity(vel)
|
|
||||||
-- minetest.after(1.5, function()
|
|
||||||
-- local xvel = entity.object:getvelocity().x
|
|
||||||
-- local zvel = entity.object:getvelocity().z
|
|
||||||
-- local yvel = entity.object:getvelocity().y
|
|
||||||
-- local vel = {x=xvel,y=-10,z=zvel}
|
|
||||||
-- entity.object:setvelocity(vel)
|
|
||||||
-- end)
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -215,7 +252,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--same as above but with improvements for cars and nitro/boost
|
--same as above but with improvements for cars and nitro/boost
|
||||||
function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
function object_drive_car(entity, dtime, speed, decell, nitro_duration, move_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:getvelocity()
|
||||||
local dir = entity.driver:get_look_dir()
|
local dir = entity.driver:get_look_dir()
|
||||||
@ -247,7 +284,9 @@ function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
|||||||
|
|
||||||
--face the right way
|
--face the right way
|
||||||
local yaw = entity.driver:get_look_yaw();
|
local yaw = entity.driver:get_look_yaw();
|
||||||
|
--if ctrl.up or ctrl.down then
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
|
--end
|
||||||
if not entity.nitro then
|
if not entity.nitro then
|
||||||
minetest.after(4, function()
|
minetest.after(4, function()
|
||||||
entity.nitro = true
|
entity.nitro = true
|
||||||
@ -281,17 +320,37 @@ function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
|||||||
minetest.after(nitro_duration, function()
|
minetest.after(nitro_duration, function()
|
||||||
entity.nitro = false
|
entity.nitro = false
|
||||||
end)
|
end)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving then
|
||||||
|
entity.object:set_animation(move_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
elseif ctrl.up then
|
elseif ctrl.up then
|
||||||
entity.object:setvelocity(vec_forward)
|
entity.object:setvelocity(vec_forward)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving then
|
||||||
|
entity.object:set_animation(move_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
entity.object:setvelocity(vec_backward)
|
entity.object:setvelocity(vec_backward)
|
||||||
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving then
|
||||||
|
entity.object:set_animation(move_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
elseif not ctrl.down or ctrl.up then
|
elseif not ctrl.down or ctrl.up then
|
||||||
entity.object:setvelocity(vec_stop)
|
entity.object:setvelocity(vec_stop)
|
||||||
|
--lib_mount animation
|
||||||
|
if stand_anim ~= nil and entity.moving then
|
||||||
|
entity.object:set_animation(stand_anim, 20, 0)
|
||||||
|
entity.moving = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
--play engine sound
|
--play engine sound
|
||||||
if entity.sound_ready then
|
if entity.sound_ready then
|
||||||
minetest.sound_play("engine",
|
minetest.sound_play("engine",
|
||||||
{gain = 6, max_hear_distance = 3, loop = false})
|
{gain = 4, max_hear_distance = 3, loop = false})
|
||||||
entity.sound_ready = false
|
entity.sound_ready = false
|
||||||
minetest.after(11, function()
|
minetest.after(11, function()
|
||||||
entity.sound_ready = true
|
entity.sound_ready = true
|
||||||
@ -341,7 +400,7 @@ function object_turret(entity, dtime, height, arrow, shoot_interval)
|
|||||||
local dir = entity.driver:get_look_dir();
|
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 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 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:setyaw(yaw+math.pi/2)
|
||||||
obj:setvelocity(vec)
|
obj:setvelocity(vec)
|
||||||
local object = obj:get_luaentity()
|
local object = obj:get_luaentity()
|
||||||
@ -354,11 +413,13 @@ function object_turret(entity, dtime, height, arrow, shoot_interval)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--basic flying, with optional weapons
|
--basic flying, with optional weapons
|
||||||
function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, reload, moving_anim, stand_anim)
|
function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, reload, moving_anim, stand_anim, mode2)
|
||||||
|
local mode2 = mode2 or "hold"
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local dir = entity.driver:get_look_dir();
|
local dir = entity.driver:get_look_dir();
|
||||||
local velo = entity.object:getvelocity()
|
local velo = entity.object:getvelocity()
|
||||||
local vec_forward = {x=dir.x*speed,y=(dir.y*speed)/4+math.abs(velo.z+velo.x)/10,z=dir.z*speed}
|
local vec_forward = {x=dir.x*speed,y=(dir.y*speed)/4+math.abs(velo.z+velo.x)/10,z=dir.z*speed}
|
||||||
|
local vec_rise = {x=entity.object:getvelocity().x, y=speed*accel, z=entity.object:getvelocity().z}
|
||||||
local acc_forward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
local acc_forward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
||||||
--local vec_backward = {x=-dir.x*speed,y=dir.y*speed+3,z=-dir.z*speed}
|
--local vec_backward = {x=-dir.x*speed,y=dir.y*speed+3,z=-dir.z*speed}
|
||||||
--local acc_backward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
--local acc_backward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
||||||
@ -367,6 +428,16 @@ function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, reload,
|
|||||||
--pitch doesn't work/exist
|
--pitch doesn't work/exist
|
||||||
--local pitch = entity.driver:get_look_pitch();
|
--local pitch = entity.driver:get_look_pitch();
|
||||||
|
|
||||||
|
-- --timer
|
||||||
|
-- local absolute_speed = math.sqrt(math.pow(velo.x, 2)+math.pow(velo.z, 2))
|
||||||
|
-- if absolute_speed <= speed and ctrl.up then
|
||||||
|
-- timer = timer + 1*dtime
|
||||||
|
-- end
|
||||||
|
-- if not ctrl.up then
|
||||||
|
-- timer = 0
|
||||||
|
-- end
|
||||||
|
-- --timer dependant variables
|
||||||
|
-- local vec_forward = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=dir.y*speed/4*math.atan(0.5*timer-2)+8*dir.y,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||||
|
|
||||||
--water effects
|
--water effects
|
||||||
local pos = entity.object:getpos()
|
local pos = entity.object:getpos()
|
||||||
@ -383,84 +454,34 @@ function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, reload,
|
|||||||
--entity.object:setpitch(pitch+math.pi+math.pi/2)
|
--entity.object:setpitch(pitch+math.pi+math.pi/2)
|
||||||
--entity.object:setvelocity(vec_backward)
|
--entity.object:setvelocity(vec_backward)
|
||||||
--entity.object:setacceleration(acc_backward)
|
--entity.object:setacceleration(acc_backward)
|
||||||
elseif not ctrl.down or ctrl.up then
|
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
|
||||||
entity.object:setvelocity(vec_stop)
|
|
||||||
entity.object:setacceleration({x=0, y=-4.5, z=0})
|
|
||||||
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
|
|
||||||
local pname = entity.driver:get_player_name();
|
|
||||||
local inv = minetest.get_inventory({type="player", name=pname});
|
|
||||||
if inv:contains_item("main", arrow.."_item") then
|
|
||||||
local remov = inv:remove_item("main", arrow.."_item")
|
|
||||||
entity.loaded = false
|
|
||||||
local pos = entity.object:getpos()
|
|
||||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+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 yaw = entity.driver:get_look_yaw();
|
|
||||||
obj:setyaw(yaw+math.pi/2)
|
|
||||||
obj:setvelocity(vec)
|
|
||||||
local object = obj:get_luaentity()
|
|
||||||
object.launcher = entity.driver
|
|
||||||
minetest.after(reload, function()
|
|
||||||
entity.loaded = true
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--lib_mount animation
|
--lib_mount animation
|
||||||
if minetest.get_modpath("mobs")then
|
if moving_anim ~= nil and not entity.moving then
|
||||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
entity.object:set_animation(moving_anim, 20, 0)
|
||||||
if stand_anim and stand_anim ~= nil then
|
entity.moving = true
|
||||||
entity.object:set_animation(entity, stand_anim)
|
|
||||||
end
|
end
|
||||||
return
|
elseif ctrl.jump and mode2 == "rise" then
|
||||||
end
|
|
||||||
if moving_anim and moving_anim ~= nil then
|
|
||||||
entity.object:set_animation(entity, moving_anim)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--flying with jump to increase height in addition to looking up/down
|
|
||||||
function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, reload, moving_anim, stand_anim)
|
|
||||||
local ctrl = entity.driver:get_player_control()
|
|
||||||
local dir = entity.driver:get_look_dir();
|
|
||||||
local yvel = entity.object:getvelocity().y
|
|
||||||
local vec_forward = {x=dir.x*speed,y=yvel,z=dir.z*speed}
|
|
||||||
local acc_forward = {x=dir.x*accel/2,y=yvel,z=dir.z*accel/2}
|
|
||||||
--local vec_backward = {x=-dir.x*speed,y=yvel,z=-dir.z*speed}
|
|
||||||
--local acc_backward = {x=dir.x*accel/2,y=yvel,z=dir.z*accel/2}
|
|
||||||
local vec_stop = {x=entity.object:getvelocity().x*decell, y=entity.object:getvelocity().y, z=entity.object:getvelocity().z*decell}
|
|
||||||
local vec_rise = {x=entity.object:getvelocity().x, y=speed*accel, z=entity.object:getvelocity().z}
|
|
||||||
local yaw = entity.driver:get_look_yaw();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--water effects
|
|
||||||
local pos = entity.object:getpos()
|
|
||||||
local node = minetest.get_node(pos).name
|
|
||||||
if node == "default:water_source" or node == "default:river_water_source" or node == "default:river_water_flowing" or node == "default:water_flowing" then
|
|
||||||
entity.object:setvelocity({x=velo.x*0.9, y=-1, z=velo.z*0.9})
|
|
||||||
elseif ctrl.up then
|
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
|
||||||
entity.object:setvelocity(vec_forward)
|
|
||||||
entity.object:setacceleration(acc_forward)
|
|
||||||
--elseif ctrl.down then
|
|
||||||
-- entity.object:setyaw(yaw+math.pi+math.pi/2)
|
|
||||||
-- entity.object:setvelocity(vec_backward)
|
|
||||||
-- entity.object:setacceleration(acc_backward)
|
|
||||||
elseif ctrl.jump then
|
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
entity.object:setvelocity(vec_rise)
|
entity.object:setvelocity(vec_rise)
|
||||||
elseif not ctrl.down or ctrl.up or ctrl.jump then
|
--lib_mount animation
|
||||||
|
if moving_anim ~= nil and not entity.moving then
|
||||||
|
entity.object:set_animation(moving_anim, 20, 0)
|
||||||
|
entity.moving = true
|
||||||
|
end
|
||||||
|
elseif not ctrl.up and not ctrl.jump then
|
||||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||||
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})
|
||||||
|
--lib_mount animation
|
||||||
|
if stand_anim ~= nil and entity.moving then
|
||||||
|
entity.object:set_animation(stand_anim, 20, 0)
|
||||||
|
entity.moving = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ctrl.jump and ctrl.up and mode2 == "hold" then
|
||||||
|
entity.object:setvelocity({x=dir.x*speed, y=0, z=dir.z*speed})
|
||||||
|
elseif not ctrl.jump and not ctrl.up then
|
||||||
|
entity.object:setvelocity({x=velo.x*decell, y=-1, z=velo.z*decell})
|
||||||
end
|
end
|
||||||
if ctrl.sneak and shoots and entity.loaded then
|
if ctrl.sneak and shoots and entity.loaded then
|
||||||
local pname = entity.driver:get_player_name();
|
local pname = entity.driver:get_player_name();
|
||||||
@ -481,18 +502,6 @@ function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, reload
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--lib_mount animation
|
|
||||||
local velo = entity.object:getvelocity()
|
|
||||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
|
||||||
if stand_anim and stand_anim ~= nil then
|
|
||||||
self.object:set_animation(entity, stand_anim)
|
|
||||||
end
|
|
||||||
entity.object:setpos(entity.object:getpos())
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if moving_anim and moving_anim ~= nil then
|
|
||||||
self.object:set_animation(entity, moving_anim)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--gliding
|
--gliding
|
||||||
|
381
init.lua
@ -42,6 +42,23 @@ minetest.register_entity("vehicles:missile", {
|
|||||||
self.object:setvelocity(vec)
|
self.object:setvelocity(vec)
|
||||||
end
|
end
|
||||||
local pos = self.object:getpos()
|
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)
|
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
|
||||||
if obj:get_luaentity() ~= nil then
|
if obj:get_luaentity() ~= nil then
|
||||||
@ -100,14 +117,30 @@ minetest.register_entity("vehicles:missile_2", {
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end)
|
end)
|
||||||
local velo = self.object:getvelocity()
|
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)
|
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)
|
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)
|
self.object:set_animation({x=2, y=2}, 5, 0)
|
||||||
end
|
end
|
||||||
local pos = self.object:getpos()
|
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)
|
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
|
||||||
if obj:get_luaentity() ~= nil then
|
if obj:get_luaentity() ~= nil then
|
||||||
@ -129,6 +162,22 @@ minetest.register_entity("vehicles:missile_2", {
|
|||||||
local n = minetest.env:get_node(p).name
|
local n = minetest.env:get_node(p).name
|
||||||
if n ~= "vehicles:missile_2" and n ~= "vehicles:tank" and n ~= "vehicles:jet" and n ~= "air" then
|
if n ~= "vehicles:missile_2" and n ~= "vehicles:tank" and n ~= "vehicles:jet" and n ~= "air" then
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 30,
|
||||||
|
time = 0.5,
|
||||||
|
minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5},
|
||||||
|
maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5},
|
||||||
|
minvel = {x=-1, y=-1, z=-1},
|
||||||
|
maxvel = {x=1, y=1, z=1},
|
||||||
|
minacc = {x=0, y=0.2, z=0},
|
||||||
|
maxacc = {x=0, y=0.6, z=0},
|
||||||
|
minexptime = 0.5,
|
||||||
|
maxexptime = 1,
|
||||||
|
minsize = 10,
|
||||||
|
maxsize = 20,
|
||||||
|
collisiondetection = false,
|
||||||
|
texture = "vehicles_explosion.png"
|
||||||
|
})
|
||||||
tnt.boom(pos, {damage_radius=5,radius=5,ignore_protection=false})
|
tnt.boom(pos, {damage_radius=5,radius=5,ignore_protection=false})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
@ -179,12 +228,18 @@ minetest.register_entity("vehicles:water", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_entity("vehicles:bullet", {
|
minetest.register_entity("vehicles:bullet", {
|
||||||
visual = "sprite",
|
visual = "mesh",
|
||||||
|
mesh = "bullet.b3d",
|
||||||
textures = {"vehicles_bullet.png"},
|
textures = {"vehicles_bullet.png"},
|
||||||
velocity = 15,
|
velocity = 15,
|
||||||
acceleration = -5,
|
acceleration = -5,
|
||||||
damage = 2,
|
damage = 2,
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
|
on_activate = function(self)
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
minetest.sound_play("shot",
|
||||||
|
{gain = 0.4, max_hear_distance = 3, loop = false})
|
||||||
|
end,
|
||||||
on_step = function(self, obj, pos)
|
on_step = function(self, obj, pos)
|
||||||
minetest.after(10, function()
|
minetest.after(10, function()
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
@ -196,7 +251,7 @@ minetest.register_entity("vehicles:bullet", {
|
|||||||
if obj:get_luaentity().name ~= "vehicles:bullet" and n ~= "vehicles:turret" and obj:get_luaentity().name ~= "__builtin:item" then
|
if obj:get_luaentity().name ~= "vehicles:bullet" and n ~= "vehicles:turret" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||||
obj:punch(self.launcher, 1.0, {
|
obj:punch(self.launcher, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
damage_groups={fleshy=0.5},
|
damage_groups={fleshy=1},
|
||||||
}, nil)
|
}, nil)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
@ -253,7 +308,7 @@ minetest.register_entity("vehicles:tank", {
|
|||||||
end,
|
end,
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.driver then
|
if self.driver then
|
||||||
object_drive(self, dtime, 6, 0.5, true, "vehicles:missile_2", 1, nil, nil, false)
|
object_drive(self, dtime, 6, 0.5, true, "vehicles:missile_2", 1, {x=1, y=1}, {x=1, y=1}, false, nil, {x=1, y=1})
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -305,6 +360,55 @@ minetest.register_entity("vehicles:turret", {
|
|||||||
register_vehicle_spawner("vehicles:tank", "Tank", "vehicles_tank_inv.png")
|
register_vehicle_spawner("vehicles:tank", "Tank", "vehicles_tank_inv.png")
|
||||||
register_vehicle_spawner("vehicles:turret", "Gun turret", "vehicles_turret_inv.png")
|
register_vehicle_spawner("vehicles:turret", "Gun turret", "vehicles_turret_inv.png")
|
||||||
|
|
||||||
|
minetest.register_entity("vehicles:assaultsuit", {
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "assaultsuit.b3d",
|
||||||
|
textures = {"vehicles_assaultsuit.png"},
|
||||||
|
velocity = 15,
|
||||||
|
acceleration = -5,
|
||||||
|
owner = "",
|
||||||
|
stepheight = 1.5,
|
||||||
|
hp_max = 200,
|
||||||
|
physical = true,
|
||||||
|
collisionbox = {-0.8, 0, -0.8, 0.8, 3, 0.8},
|
||||||
|
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=20, z=8})
|
||||||
|
end
|
||||||
|
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(self, dtime, 6, 0.5, true, "vehicles:bullet", 0.2, {x=120, y=140}, {x=1, y=1}, "hover", {x=60, y=70}, {x=40, y=51}, 3.5)
|
||||||
|
self.standing = false
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
if not standing then
|
||||||
|
self.object:set_animation({x=1, y=1}, 20, 0)
|
||||||
|
self.standing = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
register_vehicle_spawner("vehicles:assaultsuit", "Assault Suit", "vehicles_assaultsuit_inv.png")
|
||||||
|
|
||||||
minetest.register_entity("vehicles:firetruck", {
|
minetest.register_entity("vehicles:firetruck", {
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "firetruck.b3d",
|
mesh = "firetruck.b3d",
|
||||||
@ -347,6 +451,146 @@ minetest.register_entity("vehicles:firetruck", {
|
|||||||
|
|
||||||
register_vehicle_spawner("vehicles:firetruck", "Fire truck", "vehicles_firetruck_inv.png")
|
register_vehicle_spawner("vehicles:firetruck", "Fire truck", "vehicles_firetruck_inv.png")
|
||||||
|
|
||||||
|
minetest.register_entity("vehicles:geep", {
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "geep.b3d",
|
||||||
|
textures = {"vehicles_geep.png"},
|
||||||
|
velocity = 15,
|
||||||
|
acceleration = -5,
|
||||||
|
stepheight = 1.5,
|
||||||
|
hp_max = 200,
|
||||||
|
physical = true,
|
||||||
|
collisionbox = {-1.1, 0, -1.1, 1.1, 1, 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 self.driver and clicker ~= self.driver and not self.rider then
|
||||||
|
clicker:set_attach(self.object, "", {x=0, y=5, z=-5}, false, {x=0, y=0, z=-2})
|
||||||
|
self.rider = true
|
||||||
|
elseif self.driver and clicker ~=self.driver and self.rider then
|
||||||
|
clicker:set_detach()
|
||||||
|
self.rider = false
|
||||||
|
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_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_activate = function(self)
|
||||||
|
self.nitro = true
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
if self.driver then
|
||||||
|
object_drive_car(self, dtime, 14, 0.6, 6)
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
minetest.add_particlespawner(
|
||||||
|
15, --amount
|
||||||
|
1, --time
|
||||||
|
{x=pos.x, y=pos.y, z=pos.z}, --minpos
|
||||||
|
{x=pos.x, y=pos.y, z=pos.z}, --maxpos
|
||||||
|
{x=0, y=0, z=0}, --minvel
|
||||||
|
{x=0, y=0, z=0}, --maxvel
|
||||||
|
{x=-0,y=-0,z=-0}, --minacc
|
||||||
|
{x=0,y=0,z=0}, --maxacc
|
||||||
|
0.5, --minexptime
|
||||||
|
1, --maxexptime
|
||||||
|
10, --minsize
|
||||||
|
15, --maxsize
|
||||||
|
false, --collisiondetection
|
||||||
|
"vehicles_dust.png" --texture
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
register_vehicle_spawner("vehicles:geep", "Geep", "vehicles_geep_inv.png")
|
||||||
|
|
||||||
|
minetest.register_entity("vehicles:ambulance", {
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "ambulance.b3d",
|
||||||
|
textures = {"vehicles_ambulance.png"},
|
||||||
|
velocity = 15,
|
||||||
|
acceleration = -5,
|
||||||
|
stepheight = 1.5,
|
||||||
|
hp_max = 200,
|
||||||
|
physical = true,
|
||||||
|
collisionbox = {-1.4, 0, -1.4, 1.4, 2, 1.4},
|
||||||
|
on_rightclick = function(self, clicker)
|
||||||
|
if self.driver and clicker == self.driver then
|
||||||
|
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||||
|
elseif self.driver and clicker ~= self.driver and not self.rider then
|
||||||
|
clicker:set_attach(self.object, clicker, {x=0, y=5, z=4}, false, {x=0, y=7, z=10})
|
||||||
|
self.rider = true
|
||||||
|
clicker:set_hp(20)
|
||||||
|
elseif self.driver and clicker ~= self.driver and self.rider then
|
||||||
|
clicker:set_detach()
|
||||||
|
self.rider = false
|
||||||
|
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 = 4, max_hear_distance = 3, loop = false})
|
||||||
|
self.sound_ready = false
|
||||||
|
minetest.after(14, function()
|
||||||
|
self.sound_ready = true
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
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_activate = function(self)
|
||||||
|
self.nitro = true
|
||||||
|
end,
|
||||||
|
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
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
register_vehicle_spawner("vehicles:ambulance", "Ambulance", "vehicles_ambulance_inv.png")
|
||||||
|
|
||||||
minetest.register_entity("vehicles:ute", {
|
minetest.register_entity("vehicles:ute", {
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "ute.b3d",
|
mesh = "ute.b3d",
|
||||||
@ -361,7 +605,7 @@ minetest.register_entity("vehicles:ute", {
|
|||||||
if self.driver and clicker == self.driver then
|
if self.driver and clicker == self.driver then
|
||||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||||
elseif self.driver and clicker ~= self.driver and not self.rider then
|
elseif self.driver and clicker ~= self.driver and not self.rider then
|
||||||
clicker:set_attach(self.object, "", {x=0, y=5, z=-5}, false, {x=0, y=0, z=-2})
|
clicker:set_attach(self.object, clicker, {x=0, y=5, z=-5}, false, {x=0, y=0, z=-2})
|
||||||
self.rider = true
|
self.rider = true
|
||||||
elseif self.driver and clicker ~=self.driver and self.rider then
|
elseif self.driver and clicker ~=self.driver and self.rider then
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
@ -369,7 +613,7 @@ minetest.register_entity("vehicles:ute", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -435,7 +679,7 @@ minetest.register_entity("vehicles:ute2", {
|
|||||||
if self.driver and clicker == self.driver then
|
if self.driver and clicker == self.driver then
|
||||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||||
elseif self.driver and clicker ~= self.driver and not self.rider then
|
elseif self.driver and clicker ~= self.driver and not self.rider then
|
||||||
clicker:set_attach(self.object, "", {x=0, y=5, z=-5}, {x=0, y=0, z=0})
|
clicker:set_attach(self.object, clicker, {x=0, y=5, z=-5}, {x=0, y=0, z=0})
|
||||||
self.rider = true
|
self.rider = true
|
||||||
elseif self.driver and clicker ~=self.driver and self.rider then
|
elseif self.driver and clicker ~=self.driver and self.rider then
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
@ -443,7 +687,7 @@ minetest.register_entity("vehicles:ute2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -494,7 +738,7 @@ minetest.register_entity("vehicles:astonmaaton", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -545,7 +789,7 @@ minetest.register_entity("vehicles:nizzan", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -613,7 +857,7 @@ minetest.register_entity("vehicles:nizzan2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -681,7 +925,7 @@ minetest.register_entity("vehicles:lambogoni", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -732,7 +976,7 @@ minetest.register_entity("vehicles:lambogoni2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -783,7 +1027,7 @@ minetest.register_entity("vehicles:masda", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -818,6 +1062,57 @@ minetest.register_entity("vehicles:masda", {
|
|||||||
|
|
||||||
register_vehicle_spawner("vehicles:masda", "Masda (pink)", "vehicles_masda_inv.png")
|
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", {
|
minetest.register_entity("vehicles:musting", {
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "musting.b3d",
|
mesh = "musting.b3d",
|
||||||
@ -834,7 +1129,7 @@ minetest.register_entity("vehicles:musting", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -885,7 +1180,7 @@ minetest.register_entity("vehicles:musting2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -946,7 +1241,7 @@ minetest.register_entity("vehicles:fewawi", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -1008,7 +1303,7 @@ minetest.register_entity("vehicles:fewawi2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -1060,7 +1355,7 @@ minetest.register_entity("vehicles:pooshe", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -1111,7 +1406,7 @@ minetest.register_entity("vehicles:pooshe2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -1162,7 +1457,7 @@ minetest.register_entity("vehicles:masda2", {
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||||
minetest.sound_play("engine_start",
|
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
|
self.sound_ready = false
|
||||||
minetest.after(14, function()
|
minetest.after(14, function()
|
||||||
self.sound_ready = true
|
self.sound_ready = true
|
||||||
@ -1258,7 +1553,7 @@ minetest.register_entity("vehicles:jet", {
|
|||||||
if self.driver and clicker == self.driver then
|
if self.driver and clicker == self.driver then
|
||||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
object_attach(self, clicker, {x=0, y=5, z=5}, false, {x=0, y=3, z=4})
|
object_attach(self, clicker, {x=0, y=3, z=3}, false, {x=0, y=3, z=3})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_punch = function(self, puncher)
|
on_punch = function(self, puncher)
|
||||||
@ -1277,7 +1572,7 @@ minetest.register_entity("vehicles:jet", {
|
|||||||
end,
|
end,
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
if self.driver then
|
if self.driver then
|
||||||
object_fly(self, dtime, 14, 0.2, 0.95, true, "vehicles:missile_2", 1, {x=1, y=1}, {x=10, y=10})
|
object_fly(self, dtime, 14, 0.2, 0.95, true, "vehicles:missile_2", 1, {x=10, y=10}, {x=1, y=1}, "rise")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
self.object:setvelocity({x=0, y=-1, z=0})
|
self.object:setvelocity({x=0, y=-1, z=0})
|
||||||
@ -1738,6 +2033,15 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "vehicles:policecar_spawner",
|
||||||
|
recipe = {
|
||||||
|
{"", "dye:blue", "dye:red"},
|
||||||
|
{"", "vehicles:body", ""},
|
||||||
|
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "vehicles:tank_spawner",
|
output = "vehicles:tank_spawner",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -1791,6 +2095,33 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "vehicles:geep_spawner",
|
||||||
|
recipe = {
|
||||||
|
{"", "", ""},
|
||||||
|
{"", "vehicles:engine", ""},
|
||||||
|
{"vehicles:wheel", "vehicles:armor", "vehicles:wheel"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "vehicles:ambulance_spawner",
|
||||||
|
recipe = {
|
||||||
|
{"", "", ""},
|
||||||
|
{"vehicles:body", "vehicles:body", "dye:white"},
|
||||||
|
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "vehicles:assaultsuit_spawner",
|
||||||
|
recipe = {
|
||||||
|
{"vehicles:gun", "default:glass", "vehicles:armor"},
|
||||||
|
{"", "vehicles:engine", ""},
|
||||||
|
{"vehicles:armor", "", "vehicles:armor"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "vehicles:backpack",
|
output = "vehicles:backpack",
|
||||||
|
@ -31,6 +31,10 @@ geep.b3d, vehicles_geep.png - CC BY-SA 3.0 UNPORTED. Created by Kdog14
|
|||||||
License for sounds:
|
License for sounds:
|
||||||
CC BY-NC 3.0 oniwe https://freesound.org/people/oniwe/sounds/32316/
|
CC BY-NC 3.0 oniwe https://freesound.org/people/oniwe/sounds/32316/
|
||||||
|
|
||||||
|
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:
|
--License of lib_mount:
|
||||||
-- Minetest mod: lib_mount
|
-- Minetest mod: lib_mount
|
||||||
-- =======================
|
-- =======================
|
||||||
|
BIN
models/ambulance.b3d
Normal file
BIN
models/assaultsuit.b3d
Normal file
BIN
models/bullet.b3d
Normal file
BIN
models/geep.b3d
Normal file
BIN
models/policecar.b3d
Normal file
BIN
sounds/ambulance.ogg
Normal file
BIN
sounds/shot.ogg
Normal file
BIN
textures/vehicles_ambulance.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
textures/vehicles_ambulance_inv.png
Normal file
After Width: | Height: | Size: 473 B |
BIN
textures/vehicles_assaultsuit.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
textures/vehicles_assaultsuit_inv.png
Normal file
After Width: | Height: | Size: 512 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 120 B |
BIN
textures/vehicles_geep.png
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
textures/vehicles_geep_inv.png
Normal file
After Width: | Height: | Size: 382 B |
BIN
textures/vehicles_policecar.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
textures/vehicles_policecar_inv.png
Normal file
After Width: | Height: | Size: 388 B |
BIN
textures/vehicles_smoke.png
Normal file
After Width: | Height: | Size: 168 B |