diff --git a/api.lua b/api.lua index b289844..ae69e4b 100644 --- a/api.lua +++ b/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(); diff --git a/init.lua b/init.lua index 2ddd17a..314e3e9 100644 --- a/init.lua +++ b/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 diff --git a/models/jet.b3d b/models/jet.b3d index 5d32c89..f3fa874 100644 Binary files a/models/jet.b3d and b/models/jet.b3d differ diff --git a/models/lambogoni.b3d b/models/lambogoni.b3d new file mode 100644 index 0000000..345d276 Binary files /dev/null and b/models/lambogoni.b3d differ diff --git a/models/musting.b3d b/models/musting.b3d new file mode 100644 index 0000000..fe7cca5 Binary files /dev/null and b/models/musting.b3d differ diff --git a/textures/vehicles_jet.png b/textures/vehicles_jet.png index c671c3b..aa23a8f 100644 Binary files a/textures/vehicles_jet.png and b/textures/vehicles_jet.png differ diff --git a/textures/vehicles_lambogoni.png b/textures/vehicles_lambogoni.png new file mode 100644 index 0000000..ff0ccd3 Binary files /dev/null and b/textures/vehicles_lambogoni.png differ diff --git a/textures/vehicles_lambogoni_inv.png b/textures/vehicles_lambogoni_inv.png new file mode 100644 index 0000000..5c7965a Binary files /dev/null and b/textures/vehicles_lambogoni_inv.png differ diff --git a/textures/vehicles_masda.png b/textures/vehicles_masda.png index cc8ffd9..93c2166 100644 Binary files a/textures/vehicles_masda.png and b/textures/vehicles_masda.png differ diff --git a/textures/vehicles_musting.png b/textures/vehicles_musting.png new file mode 100644 index 0000000..f4d3f44 Binary files /dev/null and b/textures/vehicles_musting.png differ diff --git a/textures/vehicles_musting2.png b/textures/vehicles_musting2.png new file mode 100644 index 0000000..a366fc3 Binary files /dev/null and b/textures/vehicles_musting2.png differ diff --git a/textures/vehicles_musting_inv.png b/textures/vehicles_musting_inv.png new file mode 100644 index 0000000..34ec417 Binary files /dev/null and b/textures/vehicles_musting_inv.png differ diff --git a/textures/vehicles_musting_inv2.png b/textures/vehicles_musting_inv2.png new file mode 100644 index 0000000..c9e9a2e Binary files /dev/null and b/textures/vehicles_musting_inv2.png differ diff --git a/textures/vehicles_nitro.png b/textures/vehicles_nitro.png new file mode 100644 index 0000000..23fb232 Binary files /dev/null and b/textures/vehicles_nitro.png differ diff --git a/textures/vehicles_pooshe.png b/textures/vehicles_pooshe.png index eb51685..897b875 100644 Binary files a/textures/vehicles_pooshe.png and b/textures/vehicles_pooshe.png differ diff --git a/textures/vehicles_pooshe2.png b/textures/vehicles_pooshe2.png new file mode 100644 index 0000000..7dd6a2a Binary files /dev/null and b/textures/vehicles_pooshe2.png differ diff --git a/textures/vehicles_pooshe_inv2.png b/textures/vehicles_pooshe_inv2.png new file mode 100644 index 0000000..d4d5567 Binary files /dev/null and b/textures/vehicles_pooshe_inv2.png differ