Inital commit

This commit is contained in:
CBugDCoder 2020-03-09 14:45:57 -05:00
commit a6d8b30b74
13 changed files with 363 additions and 0 deletions

11
Readme.md Normal file
View File

@ -0,0 +1,11 @@
# Glider: A Realistic Hang Glider Mod
![Screenshot](screenshot.png)
Have you ever wanted to glide through the mountains and feel the wind rushing by you?
Well now, you can!
The glider mod adds two items: the glider itself, and a handheld rocket used to boost your speed.
Punch while holding the glider to take off and soar.
The glider will close when you hit something or when you punch with the glider again.

197
init.lua Normal file
View File

@ -0,0 +1,197 @@
local function rot_to_dir(rot)
local x = -math.cos(rot.x) * math.sin(rot.y)
local y = math.sin(rot.x)
local z = math.cos(rot.x) * math.cos(rot.y)
return {x = x, y = y, z = z}
end
local mouse_controls = minetest.settings:get_bool("glider_mouse_controls", true)
local on_step = function(self, dtime)
local vel = self.object:get_velocity()
local speed = self.speed
local actual_speed = math.sqrt(vel.x^2+vel.y^2+vel.z^2)
local rot = self.object:get_rotation()
local driver = minetest.get_player_by_name(self.driver)
local pos = self.object:get_pos()
--Check Surroundings
local land = false
crash_speed = 0
local under = minetest.get_node(vector.new(pos.x,pos.y-1,pos.z))
local above = minetest.get_node(vector.new(pos.x,pos.y+1,pos.z))
local north = minetest.get_node(vector.new(pos.x,pos.y,pos.z+1))
local south = minetest.get_node(vector.new(pos.x,pos.y,pos.z-1))
local east = minetest.get_node(vector.new(pos.x+1,pos.y,pos.z))
local west = minetest.get_node(vector.new(pos.x-1,pos.y,pos.z))
if minetest.registered_nodes[under.name].walkable then
land = true
crash_speed = math.abs(math.min(0, vel.y))
elseif minetest.registered_nodes[above.name].walkable then
land = true
crash_speed = math.abs(math.max(0, vel.y))
elseif minetest.registered_nodes[north.name].walkable then
land = true
crash_speed = math.abs(math.max(0, vel.z))
elseif minetest.registered_nodes[south.name].walkable then
land = true
crash_speed = math.abs(math.min(0, vel.z))
elseif minetest.registered_nodes[east.name].walkable then
land = true
crash_speed = math.abs(math.max(0, vel.x))
elseif minetest.registered_nodes[west.name].walkable then
land = true
crash_speed = math.abs(math.min(0, vel.x))
end
if land then
driver:set_detach()
driver:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
driver:add_player_velocity(vel)
local crash_dammage = math.floor(math.max(crash_speed-5, 0))
if crash_dammage > 0 then
local node = minetest.get_node(pos)
if minetest.registered_nodes[node.name].liquidtype ~= "none" then
local hp = driver:get_hp()
driver:set_hp(hp-crash_dammage, {type = "fall"})
end
end
self.object:remove()
end
if mouse_controls then
rot.x = rot.x + (-driver:get_look_vertical()-rot.x)*(dtime*2)
local hor = driver:get_look_horizontal()
local angle = hor-rot.y
if angle < -math.pi then angle = angle + math.pi*2 end
if angle > math.pi then angle = angle - math.pi*2 end
rot.y = rot.y + angle*(dtime*2)
speed = speed - math.abs(angle*dtime)
rot.z = -angle
else
local control = driver:get_player_control()
if control.up then
rot.x = rot.x + dtime
end
if control.down then
rot.x = rot.x - dtime
end
if control.left then
rot.z = rot.z - 2*dtime
end
if control.right then
rot.z = rot.z + 2*dtime
end
if rot.z ~= 0 then
speed = speed - math.abs(rot.z*dtime)
if math.abs(rot.z) < 0.01 then
rot.z = 0
end
rot.y = rot.y - (rot.z*dtime)
rot.z = rot.z - rot.z*dtime
end
end
speed = math.max(speed - (rot.x^3)*4 * dtime, 2)
self.object:set_rotation(rot)
local dir = rot_to_dir(rot)
local gravity = -20 * (((speed)/4)^-1)/2
dir = {x = dir.x*speed, y = dir.y*speed+gravity, z = dir.z*speed}
self.speed = speed
self.object:set_velocity(dir)
end
minetest.register_entity("glider:hangglider", {
physical = true,
pointable = false,
visual = "mesh",
mesh = "glider_hangglider.obj",
textures = {"glider_hangglider.png"},
static_save = false,
--Functions
on_step = on_step,
driver = "",
free_fall = false,
speed = 0,
})
minetest.register_tool("glider:glider", {
description = "Glider",
inventory_image = "glider_glider.png",
on_use = function(itemstack, user, pt)
local name = user:get_player_name()
local pos = user:get_pos()
local attach = user:get_attach()
local luaent = nil
if attach then
luaent = attach:get_luaentity()
if luaent.name == "glider:hangglider" then
local vel = attach:get_velocity()
attach:remove()
user:set_detach()
user:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
user:add_player_velocity(vel)
end
else
pos.y = pos.y + 1.5
local ent = minetest.add_entity(pos, "glider:hangglider")
luaent = ent:get_luaentity()
luaent.driver = name
local rot = {y = user:get_look_horizontal(), x = -user:get_look_vertical(), z = 0}
ent:set_rotation(rot)
local vel = vector.multiply(user:get_player_velocity(),2)
ent:set_velocity(vel)
luaent.speed = math.sqrt(vel.x^2+(vel.y/4)^2+vel.z^2)
user:set_attach(ent, "", {x=0,y=0,z=-10}, {x=90,y=0,z=0})
user:set_eye_offset({x=0,y=-16.25,z=0},{x=0,y=-15,z=0})
end
end,
})
minetest.register_craftitem("glider:rocket", {
description = "Rocket (Use while gliding to boost glider speed)",
inventory_image = "glider_rocket.png",
on_use = function(itemstack, user, pt)
local attach = user:get_attach()
if attach then
local luaent = attach:get_luaentity()
if luaent.name == "glider:hangglider" then
luaent.speed = luaent.speed + 10
itemstack:take_item()
minetest.add_particlespawner({
amount = 1000,
time = 2,
minpos = {x = -0.125, y = -0.125, z = -0.125},
maxpos = {x = 0.125, y = 0.125, z = 0.125},
minexptime = 0.5,
maxexptime = 1.5,
attached = attach,
texture = "glider_rocket_particle.png",
})
return itemstack
end
end
end
})
minetest.register_craft({
output = "glider:glider",
recipie = {
{"group:wool", "group:wool", "group:wool" },
{"group:stick","", "group:stick"},
{"", "group:stick","" },
}
})
minetest.register_craft({
output = "glider:rocket 33",
recipie = {
{"group:wood","tnt:gunpowder","group:wood"},
{"group:wood","tnt:gunpowder","group:wood"},
{"group:wood","tnt:gunpowder","group:wood"},
}
})

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = glider
description = Adds fully functional hang gliders to Minetest
optional_depends = tnt

View File

@ -0,0 +1,149 @@
# Blender v2.79 (sub 0) OBJ File: 'hangglider.blend'
# www.blender.org
o Cube_Cube.002
v 5.446254 3.427511 -3.007425
v 5.446254 3.427511 -2.076187
v 4.790705 3.427511 -2.076187
v 4.790705 3.427511 -3.007425
v 4.790705 -2.009049 -3.007425
v 4.790705 -1.379851 -3.007425
v 4.790705 -2.009049 -2.076187
v 4.790705 -1.379851 -2.076187
v 5.446254 -1.379851 -2.076187
v 5.446254 -2.009049 -2.076187
v 5.446254 -1.379851 -3.007425
v 5.446254 -2.009049 -3.007425
v 14.948369 3.427511 -25.382772
v 14.948369 4.119295 -25.382772
v 0.571554 3.427511 26.494781
v 0.571554 4.119295 26.494781
v -5.446254 3.427511 -3.007425
v -5.446254 3.427511 -2.076187
v -4.790705 3.427511 -2.076187
v -4.790705 3.427511 -3.007425
v -4.790705 -2.009049 -3.007425
v -4.790705 -1.379851 -3.007425
v -4.790705 -2.009049 -2.076187
v -4.790705 -1.379851 -2.076187
v -5.446254 -1.379851 -2.076187
v -5.446254 -2.009049 -2.076187
v 0.000000 -2.009049 -3.007425
v 0.000000 -1.379851 -3.007425
v 0.000000 -1.379851 -2.076187
v -5.446254 -1.379851 -3.007425
v 0.000000 -2.009049 -2.076187
v -5.446254 -2.009049 -3.007425
v -14.948369 3.427511 -25.382772
v -14.948369 4.119295 -25.382772
v -0.571554 3.427511 26.494781
v -0.571554 4.119295 26.494781
v 0.000000 3.427511 -18.551571
v 0.000000 4.119295 -18.551571
v 0.000000 4.119295 26.494781
v 0.000000 3.427511 26.494781
vt 0.500000 0.125000
vt 0.500000 0.156250
vt 0.468750 0.156250
vt 0.468750 0.125000
vt 0.500000 0.062500
vt 0.750000 0.062500
vt 0.750000 0.031250
vt 0.500000 0.031250
vt 0.562500 0.125000
vt 0.562500 0.156250
vt 0.531250 0.156250
vt 0.531250 0.125000
vt 0.750000 0.062500
vt 1.000000 0.062500
vt 1.000000 0.031250
vt 0.500000 0.093750
vt 0.750000 0.093750
vt 0.750000 -0.000000
vt 0.500000 -0.000000
vt 0.500000 0.125000
vt 0.750000 0.125000
vt 0.531250 0.187500
vt 0.562500 0.187500
vt 0.750000 0.093750
vt 1.000000 0.093750
vt 1.000000 -0.000000
vt 1.000000 0.125000
vt 0.500000 0.968750
vt 0.531250 0.968750
vt 0.531250 0.968750
vt 0.500000 0.968750
vt 0.875000 0.125000
vt 0.875000 0.125000
vt 0.500000 0.218750
vt 0.500000 0.218750
vt 0.500000 0.125000
vt 0.468750 0.125000
vt 0.468750 0.156250
vt 0.500000 0.156250
vt 0.250000 0.031250
vt 0.250000 0.062500
vt 0.562500 0.125000
vt 0.531250 0.125000
vt 0.531250 0.156250
vt 0.562500 0.156250
vt 0.250000 0.062500
vt 0.000000 0.031250
vt 0.000000 0.062500
vt 0.250000 0.093750
vt 0.250000 -0.000000
vt 0.250000 0.125000
vt 0.531250 0.187500
vt 0.562500 0.187500
vt 0.250000 0.093750
vt 0.000000 0.093750
vt 0.000000 -0.000000
vt 0.000000 0.125000
vt 0.468750 0.968750
vt 0.468750 0.968750
vt 0.125000 0.125000
vt 0.125000 0.125000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.9637 0.0000 0.2671
vn -0.4156 0.0000 -0.9095
vn -0.9637 0.0000 0.2671
vn 0.4156 0.0000 -0.9095
s off
f 7/1/1 10/2/1 9/3/1 8/4/1
f 31/5/1 7/6/1 8/7/1 29/8/1
f 6/9/2 11/10/2 12/11/2 5/12/2
f 9/13/1 2/14/1 3/15/1 8/7/1
f 31/5/3 27/16/3 5/17/3 7/6/3
f 5/12/3 12/11/3 10/2/3 7/1/3
f 8/7/4 6/18/4 28/19/4 29/8/4
f 5/17/2 27/16/2 28/20/2 6/21/2
f 10/22/5 12/11/5 11/10/5 9/23/5
f 11/24/5 1/25/5 2/14/5 9/13/5
f 8/7/6 3/15/6 4/26/6 6/18/6
f 6/21/2 4/27/2 1/25/2 11/24/2
f 40/28/1 15/29/1 16/30/1 39/31/1
f 15/29/7 13/32/7 14/33/7 16/30/7
f 40/28/3 37/34/3 13/32/3 15/29/3
f 16/30/4 14/33/4 38/35/4 39/31/4
f 13/32/8 37/34/8 38/35/8 14/33/8
f 23/36/1 24/37/1 25/38/1 26/39/1
f 31/5/1 29/8/1 24/40/1 23/41/1
f 22/42/2 21/43/2 32/44/2 30/45/2
f 25/46/1 24/40/1 19/47/1 18/48/1
f 31/5/3 23/41/3 21/49/3 27/16/3
f 21/43/3 23/36/3 26/39/3 32/44/3
f 24/40/4 29/8/4 28/19/4 22/50/4
f 21/49/2 22/51/2 28/20/2 27/16/2
f 26/52/6 25/53/6 30/45/6 32/44/6
f 30/54/6 25/46/6 18/48/6 17/55/6
f 24/40/5 22/50/5 20/56/5 19/47/5
f 22/51/2 30/54/2 17/55/2 20/57/2
f 40/28/1 39/31/1 36/58/1 35/59/1
f 35/59/9 36/58/9 34/60/9 33/61/9
f 40/28/3 35/59/3 33/61/3 37/34/3
f 36/58/4 39/31/4 38/35/4 34/60/4
f 33/61/10 34/60/10 38/35/10 37/34/10

BIN
models/hangglider.blend Normal file

Binary file not shown.

BIN
models/screenshot.blend Normal file

Binary file not shown.

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 KiB

BIN
screenshot.xcf Normal file

Binary file not shown.

3
settingtypes.txt Normal file
View File

@ -0,0 +1,3 @@
#When enabled the player will control the glider via looking around.
#When disabled the player will control the glider via the movement keys.
glider_mouse_controls (Mouse Controls) bool true

BIN
textures/glider_glider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
textures/glider_rocket.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B