mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +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)
|
function airutils.physics(self)
|
||||||
local friction = 0.99
|
local friction = self._ground_friction or 0.99
|
||||||
local vel=self.object:get_velocity()
|
local vel=self.object:get_velocity()
|
||||||
local new_velocity = vel
|
local new_velocity = vel
|
||||||
|
|
||||||
|
@ -72,6 +72,15 @@ function airutils.physics(self)
|
||||||
end
|
end
|
||||||
new_velocity = vnew
|
new_velocity = vnew
|
||||||
end
|
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)
|
self.object:set_velocity(new_velocity)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -344,14 +344,27 @@ function airutils.testImpact(self, velocity, position)
|
||||||
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point}))
|
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=touch_point}))
|
||||||
if (noded and noded.drawtype ~= 'airlike') and (noded.drawtype ~= 'liquid') then
|
if (noded and noded.drawtype ~= 'airlike') and (noded.drawtype ~= 'liquid') then
|
||||||
self._last_touch = 0
|
self._last_touch = 0
|
||||||
minetest.sound_play("airutils_touch", {
|
if not self._ground_friction then self._ground_friction = 0.99 end
|
||||||
--to_player = self.driver_name,
|
|
||||||
object = self.object,
|
if self._ground_friction > 0.97 then
|
||||||
max_hear_distance = 15,
|
minetest.sound_play("airutils_touch", {
|
||||||
gain = 1.0,
|
--to_player = self.driver_name,
|
||||||
fade = 0.0,
|
object = self.object,
|
||||||
pitch = 1.0,
|
max_hear_distance = 15,
|
||||||
}, true)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue