fix acceleration crash and added touch sound
parent
5010f66f1b
commit
04507973a7
Binary file not shown.
|
@ -46,7 +46,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
|
||||||
elseif self._engine_running == false and self._energy > 0 then
|
elseif self._engine_running == false and self._energy > 0 then
|
||||||
self._engine_running = true
|
self._engine_running = true
|
||||||
-- sound and animation
|
-- 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,
|
{object = self.object, gain = 2.0,
|
||||||
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
|
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
|
||||||
loop = true,})
|
loop = true,})
|
||||||
|
@ -75,7 +75,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
|
||||||
--sound
|
--sound
|
||||||
if self.sound_handle then
|
if self.sound_handle then
|
||||||
minetest.sound_stop(self.sound_handle)
|
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,
|
{object = self.object, gain = 2.0,
|
||||||
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
|
pitch = 0.5 + ((self._power_lever/100)/2),max_hear_distance = 32,
|
||||||
loop = true,})
|
loop = true,})
|
||||||
|
@ -104,7 +104,7 @@ function trike.control(self, dtime, hull_direction, longit_speed,
|
||||||
else
|
else
|
||||||
--sound
|
--sound
|
||||||
minetest.sound_stop(self.sound_handle)
|
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,
|
{object = self.object, gain = 2.0,
|
||||||
pitch = 0.5 + ((self._power_lever/100)/2),
|
pitch = 0.5 + ((self._power_lever/100)/2),
|
||||||
max_hear_distance = 32, loop = true,})
|
max_hear_distance = 32, loop = true,})
|
||||||
|
|
|
@ -334,7 +334,7 @@ minetest.register_entity("trike:trike", {
|
||||||
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
||||||
--airutils.make_sound(self,'hit')
|
--airutils.make_sound(self,'hit')
|
||||||
self.hp_max = self.hp_max - 10
|
self.hp_max = self.hp_max - 10
|
||||||
minetest.sound_play("collision", {
|
minetest.sound_play("trike_collision", {
|
||||||
object = self.object,
|
object = self.object,
|
||||||
max_hear_distance = 5,
|
max_hear_distance = 5,
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
|
|
|
@ -216,13 +216,27 @@ function trike.testImpact(self, velocity)
|
||||||
end
|
end
|
||||||
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
|
if collision then
|
||||||
--self.object:set_velocity({x=0,y=0,z=0})
|
--self.object:set_velocity({x=0,y=0,z=0})
|
||||||
local damage = impact / 2
|
local damage = impact / 2
|
||||||
self.hp_max = self.hp_max - damage --subtract the impact value directly to hp meter
|
self.hp_max = self.hp_max - damage --subtract the impact value directly to hp meter
|
||||||
|
|
||||||
if self.driver_name then
|
if self.driver_name then
|
||||||
minetest.sound_play("collision", {
|
minetest.sound_play("trike_collision", {
|
||||||
to_player = self.driver_name,
|
to_player = self.driver_name,
|
||||||
--pos = curr_pos,
|
--pos = curr_pos,
|
||||||
--max_hear_distance = 5,
|
--max_hear_distance = 5,
|
||||||
|
@ -399,10 +413,12 @@ function trike.flightstep(self)
|
||||||
|
|
||||||
if self.isinliquid then self._engine_running = false end
|
if self.isinliquid then self._engine_running = false end
|
||||||
|
|
||||||
--[[if player then
|
--added accell check to avoid mercurio server problem
|
||||||
trike.attach(self, player)
|
if new_accel then
|
||||||
end]]--
|
if new_accel.x ~= nil and new_accel.y ~= nil and new_accel.z ~= nil then
|
||||||
self.object:set_acceleration(new_accel)
|
self.object:set_acceleration(new_accel)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- end lift
|
-- end lift
|
||||||
|
|
||||||
--adjust wing pitch (3d model)
|
--adjust wing pitch (3d model)
|
||||||
|
|
Loading…
Reference in New Issue