apache helicopter, animation speed

master
D00Med 2017-02-04 14:50:34 +10:00
parent 13583cee7d
commit e3fe555406
5 changed files with 56 additions and 13 deletions

24
api.lua
View File

@ -140,6 +140,7 @@ function vehicles.object_drive(entity, dtime, def)
local place_node = def.place_node or nil
local place_chance = def.place_chance or 1
local place_trigger = def.place_trigger or nil
local animation_speed = def.animation_speed or 20
local moving_anim = def.moving_anim
local stand_anim = def.stand_anim
@ -177,6 +178,7 @@ function vehicles.object_drive(entity, dtime, def)
--timer
local absolute_speed = math.sqrt(math.pow(velo.x, 2)+math.pow(velo.z, 2))
local anim_speed = (math.floor(absolute_speed*1.5)/1)+animation_speed
if absolute_speed <= speed and ctrl.up then
timer = timer + 1*dtime
end
@ -285,7 +287,7 @@ function vehicles.object_drive(entity, dtime, def)
end)
--animation
if moving_anim ~= nil and not entity.moving and not hovering then
entity.object:set_animation(move_anim, 20, 0)
entity.object:set_animation(move_anim, anim_speed, 0)
entity.moving = true
end
--rise
@ -293,7 +295,7 @@ function vehicles.object_drive(entity, dtime, def)
entity.object:setvelocity(vec_rise)
--lib_mount animation
if moving_anim ~= nil and not entity.moving then
entity.object:set_animation(moving_anim, 20, 0)
entity.object:set_animation(moving_anim, anim_speed, 0)
entity.moving = true
end
--hover in place
@ -310,7 +312,7 @@ function vehicles.object_drive(entity, dtime, def)
end
--animation
if moving_anim ~= nil and not entity.moving and not hovering then
entity.object:set_animation(moving_anim, 20, 0)
entity.object:set_animation(moving_anim, anim_speed, 0)
entity.moving = true
end
--move backward
@ -322,7 +324,7 @@ function vehicles.object_drive(entity, dtime, def)
end
--animation
if moving_anim ~= nil and not entity.moving and not hovering then
entity.object:set_animation(moving_anim, 20, 0)
entity.object:set_animation(moving_anim, anim_speed, 0)
entity.moving = true
end
--stop
@ -330,7 +332,7 @@ function vehicles.object_drive(entity, dtime, def)
entity.object:setvelocity(vec_stop)
--animation
if moving_anim ~= nil and entity.moving and not hovering then
entity.object:set_animation(stand_anim, 20, 0)
entity.object:set_animation(stand_anim, anim_speed, 0)
entity.moving = false
end
end
@ -347,12 +349,12 @@ function vehicles.object_drive(entity, dtime, def)
object.launcher = entity.driver
--lib_mount animation
if shoot_anim ~= nil and entity.object:get_animation().range ~= shoot_anim then
entity.object:set_animation(shoot_anim, 20, 0)
entity.object:set_animation(shoot_anim, anim_speed, 0)
end
minetest.after(reload_time, function()
entity.loaded = true
if stand_anim ~= nil and shoot_anim ~= nil then
entity.object:set_animation(stand_anim, 20, 0)
entity.object:set_animation(stand_anim, anim_speed, 0)
end
end)
end
@ -370,12 +372,12 @@ function vehicles.object_drive(entity, dtime, def)
object.launcher = entity.driver
--lib_mount animation
if shoot_anim2 ~= nil and entity.object:get_animation().range ~= shoot_anim2 then
entity.object:set_animation(shoot_anim2, 20, 0)
entity.object:set_animation(shoot_anim2, anim_speed, 0)
end
minetest.after(reload_time2, function()
entity.loaded2 = true
if stand_anim ~= nil and shoot_anim2 ~= nil then
entity.object:set_animation(stand_anim, 20, 0)
entity.object:set_animation(stand_anim, anim_speed, 0)
end
end)
end
@ -390,7 +392,7 @@ function vehicles.object_drive(entity, dtime, def)
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)
entity.object:set_animation(jump_anim, anim_speed, 0)
end
minetest.after(5, function()
entity.jumpcharge = true
@ -410,7 +412,7 @@ function vehicles.object_drive(entity, dtime, def)
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)
entity.object:set_animation(jump_anim, anim_speed, 0)
end
minetest.after(0.5, function()
entity.jumpcharge = true

View File

@ -383,7 +383,7 @@ minetest.register_entity("vehicles:assaultsuit", {
reload_time2 = 1,
moving_anim = {x=120, y=140},
stand_anim = {x=1, y=1},
jump = "hover",
jump_type = "hover",
jump_anim = {x=60, y=70},
shoot_anim = {x=40, y=51},
shoot_anim2 = {x=40, y=51},
@ -1469,6 +1469,46 @@ minetest.register_entity("vehicles:jet", {
vehicles.register_spawner("vehicles:jet", S("Jet"), "vehicles_jet_inv.png")
minetest.register_entity("vehicles:apache", {
visual = "mesh",
mesh = "apache.b3d",
textures = {"vehicles_helicopter2.png"},
velocity = 15,
acceleration = -5,
hp_max = 200,
animation_speed = 5,
physical = true,
collisionbox = {-1, 0, -1, 1, 1.9, 1},
on_rightclick = function(self, clicker)
if self.driver and clicker == self.driver then
vehicles.object_detach(self, clicker, {x=1, y=0, z=1})
elseif not self.driver then
vehicles.object_attach(self, clicker, {x=0, y=13, z=14}, true, {x=0, y=4, z=12})
end
end,
on_punch = vehicles.on_punch,
on_step = function(self, dtime)
return vehicles.on_step(self, dtime, {
speed = 14,
decell = 0.95,
shoots = true,
arrow = "vehicles:missile_2",
reload_time = 1,
shoots2 = true,
arrow2 = "vehicles:bullet",
reload_time2 = 0.1,
moving_anim = {x=2, y=18},
stand_anim = {x=25, y=25},
fly = true,
fly_mode = "rise",
gravity = 0.2,
animation_speed = 40,
})
end,
})
vehicles.register_spawner("vehicles:apache", S("Apache Helicopter"), "vehicles_helicopter2_inv.png")
minetest.register_entity("vehicles:helicopter", {
visual = "mesh",
mesh = "helicopter.b3d",
@ -1482,7 +1522,7 @@ minetest.register_entity("vehicles:helicopter", {
gear = {x=1, y=1},
nogear = {x=10, y=10},
},
collisionbox = {-1, 0, -0.9, 1, 2, 0.9},
collisionbox = {-1.1, 0, -1, 1.1, 2, 1},
on_rightclick = function(self, clicker)
if self.driver and clicker == self.driver then
vehicles.object_detach(self, clicker, {x=1, y=0, z=1})
@ -1499,6 +1539,7 @@ minetest.register_entity("vehicles:helicopter", {
stand_anim = {x=1, y=1},
fly = true,
fly_mode = "rise",
animation_speed = 35,
})
end,
})

BIN
models/apache.b3d Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B