summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiezo_ <orderofthefourthwall@gmail.com>2018-12-28 17:52:01 -0800
committerPiezo_ <orderofthefourthwall@gmail.com>2018-12-28 17:52:01 -0800
commit954ce034356dbf00088141c8d7462c24f15d8f47 (patch)
tree2e9395ed50ea4583f1579e7acd378278c11f72c3
parentc88921a81d49f5c8e236829056063ee1bf9a029b (diff)
parent43056dfe65b2dba26f82ad0ff7179a9801ac39a1 (diff)
downloadhangglider-954ce034356dbf00088141c8d7462c24f15d8f47.tar.gz
hangglider-954ce034356dbf00088141c8d7462c24f15d8f47.tar.bz2
hangglider-954ce034356dbf00088141c8d7462c24f15d8f47.zip
Merge branch 'master' of https://notabug.org/Piezo_/minetest-hangglider
-rwxr-xr-xLICENSE.txt3
-rwxr-xr-xdepends.txt3
-rw-r--r--init.lua72
-rw-r--r--sounds/hangglider_flak_shot.oggbin0 -> 12808 bytes
4 files changed, 74 insertions, 4 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
index 1dab26d..407255a 100755
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -49,4 +49,5 @@ Textures:
Default wood and wool textures from minetest-game.
Models and sounds:
- CC BY-SA (4.0) by Piezo_. \ No newline at end of file
+ CC BY-SA (4.0) by Piezo_.
+ hangglider_flak_shot: tnt_explode sound from minetest_game (CC BY-SA 3.0)
diff --git a/depends.txt b/depends.txt
index f3e3b6d..bcab691 100755
--- a/depends.txt
+++ b/depends.txt
@@ -1,3 +1,4 @@
default
wool
-minetest_systemd? \ No newline at end of file
+minetest_systemd?
+areas?
diff --git a/init.lua b/init.lua
index 876b4f5..8284a9b 100644
--- a/init.lua
+++ b/init.lua
@@ -40,6 +40,13 @@
-- Removed airbreak until minetest devs are smart enough to implement better serverside players.
-- Simplified liquid check.
+-- Modifications by gpcf
+-- 2018-12-09
+-- get shot down while flying over protected areas marked as no-fly-zones (flak, from German Flugabwehrkanone)
+-- set these areas with the /area_flak command
+
+
+
local HUD_Overlay = true --show glider struts as overlay on HUD
local debug = false --show debug info in top-center of hud
local moveModelUp = false
@@ -88,6 +95,31 @@ minetest.register_entity("hangglider:airstopper", { --A one-instant entity that
end
})]]
+if areas then
+ hangglider.flak = true
+ -- chat command definition essentially copied from areas mod.
+ minetest.register_chatcommand("area_flak",{
+ params = "<ID>",
+ description = "Toggle airspace restrictions for area <ID>",
+ func = function(name, param)
+ local id = tonumber(param)
+ 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
+ local open = not areas.areas[id].flak
+ -- Save false as nil to avoid inflating the DB.
+ areas.areas[id].flak = open or nil
+ areas:save()
+ return true, ("Area's airspace %s."):format(open and "closed" or "opened")
+ end
+ })
+end
+
if minetestd and minetestd.services.gravityctl.enabled then
minetestd.gravityctl.register_gravity_effect("hangglider",
function(player)
@@ -103,6 +135,28 @@ minetestd.gravityctl.register_gravity_effect("hangglider",
)
end
+hangglider.can_fly = function (pname, pos)
+ -- Checks if the player will get shot down at the position
+ if 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
+ end
+ end
+ end
+ return true
+end
+
+hangglider.shot_sound = function (pos)
+ minetest.sound_play("hangglider_flak_shot", {
+ pos = pos,
+ max_hear_distance = 30,
+ gain = 10.0,
+ })
+end
+
local step_v
minetest.register_entity("hangglider:glider", {
visual = "mesh",
@@ -111,7 +165,7 @@ minetest.register_entity("hangglider:glider", {
immortal = true,
static_save = false,
textures = {"wool_white.png","default_wood.png"},
- on_step = function(self, _)
+ on_step = function(self, dtime)
local canExist = false
if self.object:get_attach() then
local player = self.object:get_attach("parent")
@@ -142,6 +196,20 @@ minetest.register_entity("hangglider:glider", {
]]end
end
end
+ if not hangglider.can_fly(pname,pos) then
+ 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
+ player:set_hp(1)
+ player:get_inventory():remove_item("main", ItemStack("hangglider:hangglider"))
+ hangglider.shot_sound(pos)
+ canExist = false
+ end
+ end
if not canExist then
player:set_physics_override({
jump = 1,
@@ -270,4 +338,4 @@ minetest.register_craft({
{"default:stick", "", "default:stick"},
{"", "default:stick", ""},
}
-}) \ No newline at end of file
+})
diff --git a/sounds/hangglider_flak_shot.ogg b/sounds/hangglider_flak_shot.ogg
new file mode 100644
index 0000000..a414ea0
--- /dev/null
+++ b/sounds/hangglider_flak_shot.ogg
Binary files differ