diff --git a/lib_planes/custom_physics.lua b/lib_planes/custom_physics.lua index 999c329..8e4a5f6 100755 --- a/lib_planes/custom_physics.lua +++ b/lib_planes/custom_physics.lua @@ -1,5 +1,5 @@ function airutils.physics(self) - local friction = 0.99 + local friction = self._ground_friction or 0.99 local vel=self.object:get_velocity() local new_velocity = vel @@ -72,6 +72,15 @@ function airutils.physics(self) end new_velocity = vnew end + + --damage if the friction is below .97 + if self._last_longit_speed then + if friction <= 0.97 and self._last_longit_speed > 0 then + self.hp_max = self.hp_max - 0.001 + airutils.setText(self, self._vehicle_name) + end --damage the plane if it have hard friction + end + self.object:set_velocity(new_velocity) end diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index 232551e..851c927 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -344,14 +344,27 @@ function airutils.testImpact(self, velocity, position) local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point})) if (noded and noded.drawtype ~= 'airlike') and (noded.drawtype ~= 'liquid') then self._last_touch = 0 - minetest.sound_play("airutils_touch", { - --to_player = self.driver_name, - object = self.object, - max_hear_distance = 15, - gain = 1.0, - fade = 0.0, - pitch = 1.0, - }, true) + if not self._ground_friction then self._ground_friction = 0.99 end + + if self._ground_friction > 0.97 then + minetest.sound_play("airutils_touch", { + --to_player = self.driver_name, + object = self.object, + max_hear_distance = 15, + gain = 1.0, + fade = 0.0, + pitch = 1.0, + }, true) + else + minetest.sound_play("airutils_collision", { + --to_player = self.driver_name, + object = self.object, + max_hear_distance = 15, + gain = 1.0, + fade = 0.0, + pitch = 1.0, + }, true) + end end end