mirror of
https://github.com/APercy/airutils.git
synced 2025-03-23 03:12:20 +00:00
added destruction effects
This commit is contained in:
parent
a77131dc82
commit
a12b583c43
6 changed files with 96 additions and 5 deletions
7
LICENSE
7
LICENSE
|
@ -20,3 +20,10 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
|
Media Licence:
|
||||||
|
|
||||||
|
CC0-1.0 for all media
|
||||||
|
the "airutils_explode.ogg" comes from minetest game tnt mod
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -214,9 +214,12 @@ function airutils.logic(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
--is an stall, force a recover
|
--is an stall, force a recover
|
||||||
if longit_speed < self._min_speed and climb_rate < -4 and is_flying then
|
if longit_speed < (self._min_speed+0.5) and climb_rate < -1.5 and is_flying then
|
||||||
|
if player and self.driver_name then
|
||||||
|
minetest.chat_send_player(self.driver_name,core.colorize('#ff0000', " >>> STALL"))
|
||||||
|
end
|
||||||
self._elevator_angle = 0
|
self._elevator_angle = 0
|
||||||
self._angle_of_attack = -2
|
self._angle_of_attack = -1
|
||||||
newpitch = math.rad(self._angle_of_attack)
|
newpitch = math.rad(self._angle_of_attack)
|
||||||
else
|
else
|
||||||
--ajustar angulo de ataque
|
--ajustar angulo de ataque
|
||||||
|
@ -455,7 +458,7 @@ end
|
||||||
|
|
||||||
function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
||||||
if self.hp_max <= 0 then
|
if self.hp_max <= 0 then
|
||||||
airutils.destroy(self)
|
airutils.destroy(self, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not puncher or not puncher:is_player() then
|
if not puncher or not puncher:is_player() then
|
||||||
|
|
|
@ -147,7 +147,8 @@ function airutils.checkAttach(self, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- destroy the boat
|
-- destroy the boat
|
||||||
function airutils.destroy(self)
|
function airutils.destroy(self, effects)
|
||||||
|
effects = effects or false
|
||||||
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 = nil
|
self.sound_handle = nil
|
||||||
|
@ -168,6 +169,7 @@ function airutils.destroy(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
if effects then airutils.add_destruction_effects(pos, 5) end
|
||||||
|
|
||||||
if self._destroy_parts_method then
|
if self._destroy_parts_method then
|
||||||
self._destroy_parts_method(self)
|
self._destroy_parts_method(self)
|
||||||
|
@ -196,6 +198,9 @@ function airutils.destroy(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function airutils.testImpact(self, velocity, position)
|
function airutils.testImpact(self, velocity, position)
|
||||||
|
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
|
||||||
|
airutils.destroy(self, true)
|
||||||
|
end
|
||||||
local p = position --self.object:get_pos()
|
local p = position --self.object:get_pos()
|
||||||
local collision = false
|
local collision = false
|
||||||
if self._last_vel == nil then return end
|
if self._last_vel == nil then return end
|
||||||
|
@ -233,6 +238,32 @@ function airutils.testImpact(self, velocity, position)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--damage by speed
|
||||||
|
if self._speed_not_exceed then
|
||||||
|
if self._last_speed_damage_time == nil then self._last_speed_damage_time = 0 end
|
||||||
|
self._last_speed_damage_time = self._last_speed_damage_time + self.dtime
|
||||||
|
if self._last_speed_damage_time > 2 then self._last_speed_damage_time = 2 end
|
||||||
|
if self._longit_speed > self._speed_not_exceed and self._last_speed_damage_time >= 2 then
|
||||||
|
self._last_speed_damage_time = 0
|
||||||
|
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)
|
||||||
|
self.hp_max = self.hp_max - 5
|
||||||
|
if self.driver_name then
|
||||||
|
local player_name = self.driver_name
|
||||||
|
airutils.setText(self, self.infotext)
|
||||||
|
end
|
||||||
|
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
|
||||||
|
airutils.destroy(self, true)
|
||||||
|
end
|
||||||
|
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
|
||||||
|
@ -252,7 +283,7 @@ function airutils.testImpact(self, velocity, position)
|
||||||
|
|
||||||
--minetest.chat_send_all('damage: '.. damage .. ' - hp: ' .. self.hp_max)
|
--minetest.chat_send_all('damage: '.. damage .. ' - hp: ' .. self.hp_max)
|
||||||
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
|
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
|
||||||
airutils.destroy(self)
|
airutils.destroy(self, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(player_name)
|
local player = minetest.get_player_by_name(player_name)
|
||||||
|
@ -419,3 +450,53 @@ function airutils.paint_with_mask(self, colstr, target_texture, mask_texture)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function airutils.add_destruction_effects(pos, radius)
|
||||||
|
minetest.sound_play("airutils_explode", {
|
||||||
|
pos = pos,
|
||||||
|
max_hear_distance = 100,
|
||||||
|
gain = 2.0,
|
||||||
|
fade = 0.0,
|
||||||
|
pitch = 1.0,
|
||||||
|
}, true)
|
||||||
|
minetest.add_particle({
|
||||||
|
pos = pos,
|
||||||
|
velocity = vector.new(),
|
||||||
|
acceleration = vector.new(),
|
||||||
|
expirationtime = 0.4,
|
||||||
|
size = radius * 10,
|
||||||
|
collisiondetection = false,
|
||||||
|
vertical = false,
|
||||||
|
texture = "airutils_boom.png",
|
||||||
|
glow = 15,
|
||||||
|
})
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 32,
|
||||||
|
time = 0.5,
|
||||||
|
minpos = vector.subtract(pos, radius / 2),
|
||||||
|
maxpos = vector.add(pos, radius / 2),
|
||||||
|
minvel = {x = -10, y = -10, z = -10},
|
||||||
|
maxvel = {x = 10, y = 10, z = 10},
|
||||||
|
minacc = vector.new(),
|
||||||
|
maxacc = vector.new(),
|
||||||
|
minexptime = 1,
|
||||||
|
maxexptime = 2.5,
|
||||||
|
minsize = radius * 3,
|
||||||
|
maxsize = radius * 5,
|
||||||
|
texture = "airutils_boom.png",
|
||||||
|
})
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 64,
|
||||||
|
time = 1.0,
|
||||||
|
minpos = vector.subtract(pos, radius / 2),
|
||||||
|
maxpos = vector.add(pos, radius / 2),
|
||||||
|
minvel = {x = -10, y = -10, z = -10},
|
||||||
|
maxvel = {x = 10, y = 10, z = 10},
|
||||||
|
minacc = vector.new(),
|
||||||
|
maxacc = vector.new(),
|
||||||
|
minexptime = 1,
|
||||||
|
maxexptime = 2.5,
|
||||||
|
minsize = radius * 3,
|
||||||
|
maxsize = radius * 5,
|
||||||
|
texture = "airutils_smoke.png",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
BIN
sounds/airutils_explode.ogg
Normal file
BIN
sounds/airutils_explode.ogg
Normal file
Binary file not shown.
BIN
textures/airutils_boom.png
Normal file
BIN
textures/airutils_boom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
textures/airutils_smoke.png
Normal file
BIN
textures/airutils_smoke.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Loading…
Add table
Reference in a new issue