fix acceleration crash and added touch sound

master
Alexsandro Percy 2022-08-04 19:42:04 -03:00
parent 5010f66f1b
commit 04507973a7
6 changed files with 25 additions and 9 deletions

BIN
sounds/trike_touch.ogg Normal file

Binary file not shown.

View File

@ -46,7 +46,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
elseif self._engine_running == false and self._energy > 0 then
self._engine_running = true
-- sound and animation
self.sound_handle = minetest.sound_play({name = "engine"},
self.sound_handle = minetest.sound_play({name = "trike_engine"},
{object = self.object, gain = 2.0,
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
loop = true,})
@ -75,7 +75,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
--sound
if self.sound_handle then
minetest.sound_stop(self.sound_handle)
self.sound_handle = minetest.sound_play({name = "engine"},
self.sound_handle = minetest.sound_play({name = "trike_engine"},
{object = self.object, gain = 2.0,
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
loop = true,})
@ -104,7 +104,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
else
--sound
minetest.sound_stop(self.sound_handle)
self.sound_handle = minetest.sound_play({name = "engine"},
self.sound_handle = minetest.sound_play({name = "trike_engine"},
{object = self.object, gain = 2.0,
pitch = 0.5 + ((self._power_lever/100)/2),
max_hear_distance = 32, loop = true,})

View File

@ -334,7 +334,7 @@ minetest.register_entity("trike:trike", {
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
--airutils.make_sound(self,'hit')
self.hp_max = self.hp_max - 10
minetest.sound_play("collision", {
minetest.sound_play("trike_collision", {
object = self.object,
max_hear_distance = 5,
gain = 1.0,

View File

@ -216,13 +216,27 @@ function trike.testImpact(self, velocity)
end
end
if impact > 0.5 and self._longit_speed > 2 then
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=-0.1}))
if (noded and noded.drawtype ~= 'airlike') then
minetest.sound_play("trike_touch", {
--to_player = self.driver_name,
object = self.object,
max_hear_distance = 15,
gain = 1.0,
fade = 0.0,
pitch = 1.0,
}, true)
end
end
if collision then
--self.object:set_velocity({x=0,y=0,z=0})
local damage = impact / 2
self.hp_max = self.hp_max - damage --subtract the impact value directly to hp meter
if self.driver_name then
minetest.sound_play("collision", {
minetest.sound_play("trike_collision", {
to_player = self.driver_name,
--pos = curr_pos,
--max_hear_distance = 5,
@ -399,10 +413,12 @@ function trike.flightstep(self)
if self.isinliquid then self._engine_running = false end
--[[if player then
trike.attach(self, player)
end]]--
self.object:set_acceleration(new_accel)
--added accell check to avoid mercurio server problem
if new_accel then
if new_accel.x ~= nil and new_accel.y ~= nil and new_accel.z ~= nil then
self.object:set_acceleration(new_accel)
end
end
-- end lift
--adjust wing pitch (3d model)