-- Reduced airbreak penalty severity
-- gave glider limited durability.
-- Improved gravity adjustment function.
--- Changed airbreaking process
+-- Changed airbreaking process
-- Removed airbreak penalty, as any 'advantage' seems minimal after new adjustments
-- Removed airbreak until minetest devs are smart enough to implement better serverside players.
-- Simplified liquid check.
if player:is_player() then
local pname = player:get_player_name()
canExist = true
- if player:get_player_velocity().y < 0.5 and player:get_player_velocity().y > -0.5 then
+ if player:get_player_velocity().y < 0.5 and player:get_player_velocity().y > -0.5 then
--Let go when the player actually stops, as that's the whole point.
if hangglider.use[pname] then
if moveModelUp then
end
})]]
-if areas then
+if core.global_exists("areas") then
hangglider.flak = true
-- chat command definition essentially copied from areas mod.
minetest.register_chatcommand("area_flak",{
if not id then
return false, "Invalid usage, see /help area_flak."
end
-
+
if not areas:isAreaOwner(id, name) then
return false, "Area "..id.." does not exist"
.." or is not owned by you."
})
end
-if minetestd and minetestd.services.physicsctl.enabled then
-minetestd.physicsctl.register_physics_effect("hangglider",
+if core.global_exists("minetestd") and minetestd.services.physicsctl.enabled then
+minetestd.physicsctl.register_physics_effect("hangglider",
function(player) -- check
- return hangglider.use[player:get_player_name()]
+ return hangglider.use[player:get_player_name()]
end,
function(phys, player) -- blend
local vel_y = player:get_player_velocity().y
if vel_y < 0 and vel_y > -3 then
phys.speed = (math.abs(vel_y/2) + 0.75)
elseif vel_y <= -3 then --Cap our gliding movement speed.
- phys.speed = phys.speed*2.25
+ phys.speed = 2.25
end
phys.jump = 0
end,
return (minetest.check_player_privs(pname, {protection_bypass=true}) or wardzones.checkPlayerZoneAccess(pname, zone) or not zone["data"]["no_fly"])
end
end
- if areas and minetest.is_protected(vector.round(pos), pname) then
- if hangglider.flak then
+ if areas and minetest.is_protected(vector.round(pos), pname) then
+ if hangglider.flak then
for id, area in pairs(areas:getAreasAtPos(pos)) do
if area.flak then
return false
})
end
+local function set_fast(name, value)
+ local privs = minetest.get_player_privs(name)
+ privs.fast = value
+ minetest.set_player_privs(name, privs)
+end
+
local physics_attrs = {"jump", "speed", "gravity"}
local function apply_physics_override(player, overrides)
- if player_monoids then
- for _, attr in pairs(physics_attrs) do
- if overrides[attr] then
- player_monoids[attr]:add_change(player, overrides[attr], "hangglider:glider")
- end
- end
- else
- player:set_physics_override(overrides)
- end
+ if player_monoids then
+ for _, attr in pairs(physics_attrs) do
+ if overrides[attr] then
+ player_monoids[attr]:add_change(player, overrides[attr], "hangglider:glider")
+ end
+ end
+ else
+ player:set_physics_override(overrides)
+ end
+ if minetest.settings:get_bool("hangglider_no_fast") then
+ set_fast(player:get_player_name(), nil)
+ end
end
local function remove_physics_override(player, overrides)
- for _, attr in pairs(physics_attrs) do
- if overrides[attr] then
- if player_monoids then
- player_monoids[attr]:del_change(player, "hangglider:glider")
- else
- player:set_physics_override({[attr] = 1})
- end
- end
- end
+ for _, attr in pairs(physics_attrs) do
+ if overrides[attr] then
+ if core.global_exists("player_monoids") then
+ player_monoids[attr]:del_change(player, "hangglider:glider")
+ else
+ player:set_physics_override({[attr] = 1})
+ end
+ end
+ end
+ set_fast(player:get_player_name(), true)
end
local step_v
if mrn_name then
if not (mrn_name.walkable or mrn_name.liquidtype ~= "none") then
canExist = true
-
+
if not minetestd then
step_v = player:get_player_velocity().y
if step_v < 0 and step_v > -3 then
end
--[[local vel = player:get_player_velocity()
if debug then player:hud_change(hangglider.debug[pname].id, "text", vel.y..', '..grav..', '..tostring(hangglider.airbreak[pname])) end
-
+
player:set_physics_override({gravity = (vel.y + 2.0)/20})
]]end
end
end
if not hangglider.can_fly(pname,pos) then
- if not self.warned then -- warning shot
+ if not self.warned then -- warning shot
self.warned = 0
hangglider.shot_sound(pos)
minetest.chat_send_player(pname, "Protected area! You will be shot down in two seconds by anti-aircraft guns!")
- end
- self.warned = self.warned + dtime
- if self.warned > 2 then -- shoot down
+ end
+ self.warned = self.warned + dtime
+ if self.warned > 2 then -- shoot down
player:set_hp(1)
player:get_inventory():remove_item("main", ItemStack("hangglider:hangglider"))
hangglider.shot_sound(pos)
canExist = false
- end
+ end
end
if not canExist then
-
+
if not minetestd then
remove_physics_override(player, {
gravity=1,
end
end
end
- if not canExist then
+ if not canExist then
self.object:set_detach()
- self.object:remove()
+ self.object:remove()
end
end
})
alignment = {x=1, y=1},
offset = {x=0, y=0}
}) end
- if debug then
+ if debug then
hangglider.debug[pname] = {id = player:hud_add({hud_elem_type = "text",
position = {x=0.5, y=0.1},
text = "-",
player:set_attach( stopper, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
end, stopper, player)
end]]
- if not airbreak then
+ if not airbreak then
if moveModelUp then
minetest.add_entity(pos, "hangglider:glider"):set_attach(player, "", {x=0,y=10,z=0}, {x=0,y=0,z=0})
else
hangglider.use[pname] = true
apply_physics_override(player, {jump = 0})
-- if minetest 0.4.x use this:
-
+
-- if minetest 5.x use this:
-- minetest.add_entity(player:get_pos(), "hangglider:glider"):set_attach(player, "", {x=0,y=10,z=0}, {x=0,y=0,z=0})
itemstack:set_wear(itemstack:get_wear() + 255)