mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
added damage when friction is set below 0.97
This commit is contained in:
parent
dd58627099
commit
4efed831b5
2 changed files with 31 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue