mirror of https://github.com/APercy/airutils
Compare commits
4 Commits
a77131dc82
...
ca979a9490
Author | SHA1 | Date |
---|---|---|
Alexsandro Percy | ca979a9490 | |
Alexsandro Percy | 7fb54cff3b | |
Alexsandro Percy | bcf2732e49 | |
Alexsandro Percy | a12b583c43 |
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,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
Media Licence:
|
||||
|
||||
CC0-1.0 for all media
|
||||
the "airutils_explode.ogg" comes from minetest game tnt mod
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ airutils.modname = minetest.get_current_modname()
|
|||
local function get_formspec_by_size(self, size)
|
||||
local background = default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
||||
local default_inventory_formspecs = {
|
||||
["2"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" ..
|
||||
"list[current_player;main;0,2;8,4;]" ..
|
||||
"listring[]",
|
||||
|
||||
["3"]="size[8,6]".. background ..
|
||||
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" ..
|
||||
"list[current_player;main;0,2;8,4;]" ..
|
||||
|
|
|
@ -11,6 +11,7 @@ function airutils.get_staticdata(self) -- unloaded/unloads ... is now saved
|
|||
stored_owner = self.owner,
|
||||
stored_hp = self.hp_max,
|
||||
stored_color = self._color,
|
||||
stored_color_2 = self._color_2,
|
||||
stored_power_lever = self._power_lever,
|
||||
stored_driver_name = self.driver_name,
|
||||
stored_last_accell = self._last_accell,
|
||||
|
@ -31,6 +32,7 @@ function airutils.on_activate(self, staticdata, dtime_s)
|
|||
self.owner = data.stored_owner
|
||||
self.hp_max = data.stored_hp
|
||||
self._color = data.stored_color
|
||||
self._color_2 = data.stored_color_2
|
||||
self._power_lever = data.stored_power_lever
|
||||
self.driver_name = data.stored_driver_name
|
||||
self._last_accell = data.stored_last_accell
|
||||
|
@ -47,7 +49,7 @@ function airutils.on_activate(self, staticdata, dtime_s)
|
|||
self._register_parts_method(self)
|
||||
end
|
||||
|
||||
airutils.param_paint(self, self._color)
|
||||
airutils.param_paint(self, self._color, self._color_2)
|
||||
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
|
||||
|
@ -214,9 +216,12 @@ function airutils.logic(self)
|
|||
end
|
||||
|
||||
--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._angle_of_attack = -2
|
||||
self._angle_of_attack = -1
|
||||
newpitch = math.rad(self._angle_of_attack)
|
||||
else
|
||||
--ajustar angulo de ataque
|
||||
|
@ -455,7 +460,7 @@ end
|
|||
|
||||
function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
||||
if self.hp_max <= 0 then
|
||||
airutils.destroy(self)
|
||||
airutils.destroy(self, true)
|
||||
end
|
||||
|
||||
if not puncher or not puncher:is_player() then
|
||||
|
@ -521,7 +526,7 @@ function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
|
|||
|
||||
-- deal with painting or destroying
|
||||
if itmstck then
|
||||
if airutils.set_param_paint(self, puncher, itmstck) == false then
|
||||
if airutils.set_param_paint(self, puncher, itmstck, 1) == false then
|
||||
if not self.driver and toolcaps and toolcaps.damage_groups
|
||||
and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then
|
||||
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
|
||||
|
@ -588,29 +593,40 @@ function airutils.on_rightclick(self, clicker)
|
|||
--=========================
|
||||
elseif not self.driver_name then
|
||||
if self.owner == name or minetest.check_player_privs(clicker, {protection_bypass=true}) then
|
||||
if clicker:get_player_control().aux1 == true then --lets see the inventory
|
||||
airutils.show_vehicle_trunk_formspec(self, clicker, airutils.trunk_slots)
|
||||
else
|
||||
if is_under_water then return end
|
||||
--remove pax to prevent bug
|
||||
if self._passenger then
|
||||
local pax_obj = minetest.get_player_by_name(self._passenger)
|
||||
airutils.dettach_pax(self, pax_obj)
|
||||
end
|
||||
|
||||
--attach player
|
||||
if clicker:get_player_control().sneak == true then
|
||||
-- flight instructor mode
|
||||
self._instruction_mode = true
|
||||
airutils.attach(self, clicker, true)
|
||||
else
|
||||
-- no driver => clicker is new driver
|
||||
self._instruction_mode = false
|
||||
airutils.attach(self, clicker)
|
||||
end
|
||||
self._elevator_angle = 0
|
||||
self._rudder_angle = 0
|
||||
self._command_is_given = false
|
||||
local itmstck=clicker:get_wielded_item()
|
||||
local item_name = ""
|
||||
if itmstck then item_name = itmstck:get_name() end
|
||||
|
||||
if itmstck then
|
||||
if airutils.set_param_paint(self, clicker, itmstck, 2) == false then
|
||||
|
||||
if clicker:get_player_control().aux1 == true then --lets see the inventory
|
||||
airutils.show_vehicle_trunk_formspec(self, clicker, self._trunk_slots)
|
||||
else
|
||||
if is_under_water then return end
|
||||
--remove pax to prevent bug
|
||||
if self._passenger then
|
||||
local pax_obj = minetest.get_player_by_name(self._passenger)
|
||||
airutils.dettach_pax(self, pax_obj)
|
||||
end
|
||||
|
||||
--attach player
|
||||
if clicker:get_player_control().sneak == true then
|
||||
-- flight instructor mode
|
||||
self._instruction_mode = true
|
||||
airutils.attach(self, clicker, true)
|
||||
else
|
||||
-- no driver => clicker is new driver
|
||||
self._instruction_mode = false
|
||||
airutils.attach(self, clicker)
|
||||
end
|
||||
self._elevator_angle = 0
|
||||
self._rudder_angle = 0
|
||||
self._command_is_given = false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> You aren't the owner of this machine."))
|
||||
|
|
|
@ -147,7 +147,8 @@ function airutils.checkAttach(self, player)
|
|||
end
|
||||
|
||||
-- destroy the boat
|
||||
function airutils.destroy(self)
|
||||
function airutils.destroy(self, effects)
|
||||
effects = effects or false
|
||||
if self.sound_handle then
|
||||
minetest.sound_stop(self.sound_handle)
|
||||
self.sound_handle = nil
|
||||
|
@ -168,6 +169,7 @@ function airutils.destroy(self)
|
|||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
if effects then airutils.add_destruction_effects(pos, 5) end
|
||||
|
||||
if self._destroy_parts_method then
|
||||
self._destroy_parts_method(self)
|
||||
|
@ -196,6 +198,9 @@ function airutils.destroy(self)
|
|||
end
|
||||
|
||||
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 collision = false
|
||||
if self._last_vel == nil then return end
|
||||
|
@ -233,6 +238,32 @@ function airutils.testImpact(self, velocity, position)
|
|||
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
|
||||
--self.object:set_velocity({x=0,y=0,z=0})
|
||||
local damage = impact / 2
|
||||
|
@ -245,14 +276,15 @@ function airutils.testImpact(self, velocity, position)
|
|||
fade = 0.0,
|
||||
pitch = 1.0,
|
||||
}, true)
|
||||
|
||||
airutils.setText(self, self.infotext)
|
||||
|
||||
if self.driver_name then
|
||||
local player_name = self.driver_name
|
||||
airutils.setText(self, self.infotext)
|
||||
|
||||
--minetest.chat_send_all('damage: '.. damage .. ' - hp: ' .. self.hp_max)
|
||||
if self.hp_max < 0 then --if acumulated damage is greater than 50, adieu
|
||||
airutils.destroy(self)
|
||||
airutils.destroy(self, true)
|
||||
end
|
||||
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
|
@ -329,15 +361,23 @@ function airutils.add_paintable_part(self, entity_ref)
|
|||
table.insert(self._paintable_parts, entity_ref:get_luaentity())
|
||||
end
|
||||
|
||||
function airutils.set_param_paint(self, puncher, itmstck)
|
||||
function airutils.set_param_paint(self, puncher, itmstck, mode)
|
||||
mode = mode or 1
|
||||
local item_name = ""
|
||||
if itmstck then item_name = itmstck:get_name() end
|
||||
|
||||
if item_name == "automobiles_lib:painter" or item_name == "bike:painter" then
|
||||
--painting with bike painter
|
||||
local meta = itmstck:get_meta()
|
||||
local colstr = meta:get_string("paint_color")
|
||||
airutils.param_paint(self, colstr)
|
||||
local colour = meta:get_string("paint_color")
|
||||
|
||||
local colstr = self._color
|
||||
local colstr_2 = self._color_2
|
||||
|
||||
if mode == 1 then colstr = colour end
|
||||
if mode == 2 then colstr_2 = colour end
|
||||
|
||||
airutils.param_paint(self, colstr, colstr_2)
|
||||
return true
|
||||
else
|
||||
--painting with dyes
|
||||
|
@ -351,11 +391,16 @@ function airutils.set_param_paint(self, puncher, itmstck)
|
|||
end]]--
|
||||
--lets paint!!!!
|
||||
local color = (item_name:sub(indx+1)):gsub(":", "")
|
||||
local colstr = airutils.colors[color]
|
||||
|
||||
local colstr = self._color
|
||||
local colstr_2 = self._color_2
|
||||
if mode == 1 then colstr = airutils.colors[color] end
|
||||
if mode == 2 then colstr_2 = airutils.colors[color] end
|
||||
|
||||
--minetest.chat_send_all(color ..' '.. dump(colstr))
|
||||
--minetest.chat_send_all(dump(airutils.colors))
|
||||
if colstr then
|
||||
airutils.param_paint(self, colstr)
|
||||
airutils.param_paint(self, colstr, colstr_2)
|
||||
itmstck:set_count(itmstck:get_count()-1)
|
||||
if puncher ~= nil then puncher:set_wielded_item(itmstck) end
|
||||
return true
|
||||
|
@ -369,12 +414,14 @@ end
|
|||
local function _paint(self, l_textures, colstr, paint_list, mask_associations)
|
||||
paint_list = paint_list or self._painting_texture
|
||||
mask_associations = mask_associations or self._mask_painting_associations
|
||||
|
||||
for _, texture in ipairs(l_textures) do
|
||||
for i, texture_name in ipairs(paint_list) do --textures list
|
||||
local indx = texture:find(texture_name)
|
||||
if indx then
|
||||
l_textures[_] = texture_name.."^[multiply:".. colstr --paint it normally
|
||||
local mask_texture = mask_associations[texture_name] --check if it demands a maks too
|
||||
--minetest.chat_send_all(texture_name .. " -> " .. dump(mask_texture))
|
||||
if mask_texture then --so it then
|
||||
l_textures[_] = "("..l_textures[_]..")^("..texture_name.."^[mask:"..mask_texture..")" --add the mask
|
||||
end
|
||||
|
@ -385,18 +432,22 @@ local function _paint(self, l_textures, colstr, paint_list, mask_associations)
|
|||
end
|
||||
|
||||
--painting
|
||||
function airutils.param_paint(self, colstr)
|
||||
function airutils.param_paint(self, colstr, colstr_2)
|
||||
colstr_2 = colstr_2 or colstr
|
||||
if not self then return end
|
||||
if colstr then
|
||||
self._color = colstr
|
||||
self._color_2 = colstr_2
|
||||
local l_textures = self.initial_properties.textures
|
||||
l_textures = _paint(self, l_textures, colstr) --paint the main plane
|
||||
l_textures = _paint(self, l_textures, colstr_2, self._painting_texture_2) --paint the main plane
|
||||
self.object:set_properties({textures=l_textures})
|
||||
|
||||
if self._paintable_parts then --paint individual parts
|
||||
for i, part_entity in ipairs(self._paintable_parts) do
|
||||
local p_textures = part_entity.initial_properties.textures
|
||||
p_textures = _paint(part_entity, p_textures, colstr, self._painting_texture, self._mask_painting_associations)
|
||||
p_textures = _paint(part_entity, p_textures, colstr_2, self._painting_texture_2, self._mask_painting_associations)
|
||||
part_entity.object:set_properties({textures=p_textures})
|
||||
end
|
||||
end
|
||||
|
@ -419,3 +470,53 @@ function airutils.paint_with_mask(self, colstr, target_texture, mask_texture)
|
|||
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
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Loading…
Reference in New Issue