mobs_dragon and lib_mount merged.

>Merged mobs_dragon and lib_mount.
>Added boss dragons.
>Separate spawn eggs for dragon types.
>Orcs and Ogres spawn more commonly if dragons = true
master
D00Med 2016-07-20 18:11:19 +10:00
parent cc894812c3
commit 8e77cffa05
32 changed files with 2030 additions and 88 deletions

350
api.lua Normal file
View File

@ -0,0 +1,350 @@
--vehicles/mounts api by D00Med, based on lib_mount(see below)
--License of lib_mount:
-- Minetest mod: lib_mount
-- =======================
-- by blert2112
-- Based on the Boats mod by PilzAdam.
-- -----------------------------------------------------------
-- -----------------------------------------------------------
-- Minetest Game mod: boats
-- ========================
-- by PilzAdam
-- License of source code:
-- -----------------------
-- WTFPL
--from lib_mount (required by new functions)
local mobs_redo = false
if mobs.mod and mobs.mod == "redo" then
mobs_redo = true
end
local function is_group(pos, group)
local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, group) ~= 0
end
local function force_detach(player)
local attached_to = player:get_attach()
if attached_to and attached_to:get_luaentity() then
local entity = attached_to:get_luaentity()
if entity.driver then
entity.driver = nil
end
player:set_detach()
end
default.player_attached[player:get_player_name()] = false
player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
end
function object_attach(entity, player, attach_at, eye_offset)
eye_offset = eye_offset or {x=0, y=0, z=0}
force_detach(player)
entity.driver = player
player:set_attach(entity.object, "", attach_at, {x=0, y=0, z=0})
player:set_properties({visual_size = {x=1, y=1}})
player:set_eye_offset(eye_offset, {x=0, y=0, z=0})
default.player_attached[player:get_player_name()] = true
minetest.after(0.2, function()
default.player_set_animation(player, "sit" , 30)
end)
entity.object:setyaw(player:get_look_yaw() - math.pi / 2)
end
function object_detach(entity, player, offset)
entity.driver = nil
player:set_detach()
default.player_attached[player:get_player_name()] = false
default.player_set_animation(player, "stand" , 30)
player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
local pos = player:getpos()
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
minetest.after(0.1, function()
player:setpos(pos)
end)
end
-------------------------------------------------------------------------------
minetest.register_on_leaveplayer(function(player)
force_detach(player)
end)
minetest.register_on_shutdown(function()
local players = minetest.get_connected_players()
for i = 1,#players do
force_detach(players[i])
end
end)
minetest.register_on_dieplayer(function(player)
force_detach(player)
return true
end)
-------------------------------------------------------------------------------
--mixed code(from this mod and lib_mount)
function object_drive(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim, jumps)
local ctrl = entity.driver:get_player_control()
local dir = entity.driver:get_look_dir();
local vec_forward = {x=dir.x*speed,y=-2,z=dir.z*speed}
local vec_backward = {x=-dir.x*speed,y=-2,z=-dir.z*speed}
local vec_stop = {x=0,y=0,z=0}
local yaw = entity.driver:get_look_yaw();
if ctrl.up then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_forward)
elseif ctrl.down then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_backward)
elseif not ctrl.down or ctrl.up then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_stop)
end
if ctrl.sneak and ctrl.LMB and shoots then
local pos = entity.object:getpos()
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
local yaw = entity.driver:get_look_yaw();
obj:setyaw(yaw+math.pi/2)
obj:setvelocity(vec)
end
--lib_mount animation
local velo = entity.object:getvelocity()
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
if stand_anim and stand_anim ~= nil and mobs_redo == true then
set_animation(entity, stand_anim)
end
entity.object:setpos(entity.object:getpos())
return
end
if moving_anim and moving_anim ~= nil and mobs_redo == true then
set_animation(entity, moving_anim)
end
--jumping not working
-- local jumps = jumps or false
-- if jumps == true and ctrl.jump then
-- local xvel = entity.object:getvelocity().x
-- local zvel = entity.object:getvelocity().z
-- local yvel = entity.object:getvelocity().y
-- local vel = {x=xvel,y=10,z=zvel}
-- entity.object:setvelocity(vel)
-- minetest.after(1.5, function()
-- local xvel = entity.object:getvelocity().x
-- local zvel = entity.object:getvelocity().z
-- local yvel = entity.object:getvelocity().y
-- local vel = {x=xvel,y=-10,z=zvel}
-- entity.object:setvelocity(vel)
-- end)
-- end
end
function object_fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
local ctrl = entity.driver:get_player_control()
local velo = entity.object:getvelocity()
local dir = entity.driver:get_look_dir();
local vec_forward = {x=dir.x*speed,y=dir.y*speed+2,z=dir.z*speed}
local vec_backward = {x=-dir.x*speed,y=dir.y*speed+2,z=-dir.z*speed}
local vec_rise = {x=velo.x,y=velo.y+0.2,z=velo.z}
local vec_stop = {x=0,y=-2,z=0}
local yaw = entity.driver:get_look_yaw();
if ctrl.up then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_forward)
elseif ctrl.down then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_backward)
elseif ctrl.jump then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_rise)
elseif not ctrl.down or ctrl.up or ctrl.jump then
entity.object:setyaw(yaw+math.pi+math.pi/2)
entity.object:setvelocity(vec_stop)
end
if ctrl.LMB and ctrl.sneak and shoots then
local pos = entity.object:getpos()
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2.5,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2.5}, arrow)
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
local yaw = entity.driver:get_look_yaw();
obj:setyaw(yaw+math.pi/2)
obj:setvelocity(vec)
end
--lib_mount animation
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
if stand_anim and stand_anim ~= nil and mobs_redo == true then
set_animation(entity, stand_anim)
end
entity.object:setpos(entity.object:getpos())
return
end
if moving_anim and moving_anim ~= nil and mobs_redo == true then
set_animation(entity, moving_anim)
end
end
--lib_mount (not required by new functions)
local function is_group(pos, group)
local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, group) ~= 0
end
local function get_sign(i)
i = i or 0
if i == 0 then
return 0
else
return i / math.abs(i)
end
end
local function get_velocity(v, yaw, y)
local x = -math.sin(yaw) * v
local z = math.cos(yaw) * v
return {x = x, y = y, z = z}
end
local function get_v(v)
return math.sqrt(v.x ^ 2 + v.z ^ 2)
end
lib_mount = {}
function lib_mount.attach(entity, player, attach_at, eye_offset)
eye_offset = eye_offset or {x=0, y=0, z=0}
force_detach(player)
entity.driver = player
player:set_attach(entity.object, "", attach_at, {x=0, y=0, z=0})
player:set_properties({visual_size = {x=1, y=1}})
player:set_eye_offset(eye_offset, {x=0, y=0, z=0})
default.player_attached[player:get_player_name()] = true
minetest.after(0.2, function()
default.player_set_animation(player, "sit" , 30)
end)
entity.object:setyaw(player:get_look_yaw() - math.pi / 2)
end
function lib_mount.detach(entity, player, offset)
entity.driver = nil
player:set_detach()
default.player_attached[player:get_player_name()] = false
default.player_set_animation(player, "stand" , 30)
player:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
local pos = player:getpos()
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
minetest.after(0.1, function()
player:setpos(pos)
end)
end
function lib_mount.drive(entity, dtime, moving_anim, stand_anim, can_fly)
entity.v = get_v(entity.object:getvelocity()) * get_sign(entity.v)
local ctrl = entity.driver:get_player_control()
local yaw = entity.object:getyaw()
if ctrl.up then
entity.v = entity.v + 0.1
elseif ctrl.down then
entity.v = entity.v - 0.1
end
if ctrl.left then
if entity.v < 0 then
entity.object:setyaw(yaw - (1 + dtime) * 0.03)
else
entity.object:setyaw(yaw + (1 + dtime) * 0.03)
end
elseif ctrl.right then
if entity.v < 0 then
entity.object:setyaw(yaw + (1 + dtime) * 0.03)
else
entity.object:setyaw(yaw - (1 + dtime) * 0.03)
end
end
local velo = entity.object:getvelocity()
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
if stand_anim and stand_anim ~= nil and mobs_redo == true then
set_animation(entity, stand_anim)
end
entity.object:setpos(entity.object:getpos())
return
end
if moving_anim and moving_anim ~= nil and mobs_redo == true then
set_animation(entity, moving_anim)
end
local s = get_sign(entity.v)
entity.v = entity.v - 0.02 * s
if s ~= get_sign(entity.v) then
entity.object:setvelocity({x = 0, y = 0, z = 0})
entity.v = 0
return
end
if math.abs(entity.v) > 5 then
entity.v = 5 * get_sign(entity.v)
end
local p = entity.object:getpos()
p.y = p.y - 0.5
local new_velo = {x = 0, y = 0, z = 0}
local new_acce = {x = 0, y = 0, z = 0}
if not is_group(p, "crumbly") then
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
if (not nodedef) or nodedef.walkable then
entity.v = 0
new_acce = {x = 0, y = 1, z = 0}
else
new_acce = {x = 0, y = -9.8, z = 0}
end
new_velo = get_velocity(entity.v, entity.object:getyaw(),
entity.object:getvelocity().y)
entity.object:setpos(entity.object:getpos())
else
p.y = p.y + 1
if is_group(p, "crumbly") then
local y = entity.object:getvelocity().y
if y >= 5 then
y = 5
elseif y < 0 then
new_acce = {x = 0, y = 20, z = 0}
else
new_acce = {x = 0, y = 5, z = 0}
end
new_velo = get_velocity(entity.v, entity.object:getyaw(), y)
entity.object:setpos(entity.object:getpos())
else
new_acce = {x = 0, y = 0, z = 0}
if math.abs(entity.object:getvelocity().y) < 1 then
local pos = entity.object:getpos()
pos.y = math.floor(pos.y) + 0.5
entity.object:setpos(pos)
new_velo = get_velocity(entity.v, entity.object:getyaw(), 0)
else
new_velo = get_velocity(entity.v, entity.object:getyaw(),
entity.object:getvelocity().y)
entity.object:setpos(entity.object:getpos())
end
end
end
if can_fly and can_fly == true and ctrl.jump then
new_velo.y = new_velo.y + 0.75
end
entity.object:setvelocity(new_velo)
entity.object:setacceleration(new_acce)
end

1535
dragons.lua Normal file

File diff suppressed because it is too large Load Diff

206
init.lua
View File

@ -1,6 +1,14 @@
-- dmobs by D00Med
--mounts api
dofile(minetest.get_modpath("dmobs").."/api.lua")
--enable dragons(disable to remove tamed dragons and dragon bosses)
local dragons = true
mobs:register_mob("dmobs:panda", {
type = "animal",
passive = false,
@ -69,6 +77,7 @@ mobs:register_mob("dmobs:fox", {
armor = 130,
collisionbox = {-0.4, -0.6, -0.4, 0.3, 0.3, 0.3},
runaway = true,
pathfinding = true,
visual = "mesh",
mesh = "fox.b3d",
textures = {
@ -102,7 +111,6 @@ mobs:register_mob("dmobs:fox", {
run_end = 16,
punch_start = 36,
punch_end = 51,
},
on_rightclick = function(self, clicker)
@ -315,7 +323,11 @@ mobs:register_mob("dmobs:orc", {
},
})
if not dragons == true then
mobs:register_spawn("dmobs:orc", {"default:snow","default:snow_block", "default:desert_sand"}, 20, 10, 15000, 2, 31000)
else
mobs:register_spawn("dmobs:orc", {"default:snow","default:snow_block", "default:desert_sand"}, 20, 10, 350, 2, 31000)
end
mobs:register_egg("dmobs:orc", "Orc", "default_desert_sand.png", 1)
@ -363,96 +375,15 @@ mobs:register_mob("dmobs:ogre", {
},
})
if not dragons == true then
mobs:register_spawn("dmobs:ogre", {"default:snow","default:dirt_with_dry_grass", "default:desert_sand"}, 20, 10, 15000, 2, 31000)
else
mobs:register_spawn("dmobs:ogre", {"default:snow","default:dirt_with_dry_grass", "default:desert_sand"}, 20, 10, 350, 2, 31000)
end
mobs:register_egg("dmobs:ogre", "Ogre", "default_desert_sand.png", 1)
mobs:register_mob("dmobs:dragon", {
type = "monster",
passive = false,
attacks_monsters = true,
damage = 8,
reach = 2,
attack_type = "shoot",
shoot_interval = 2.5,
arrow = "dmobs:fire",
shoot_offset = 1,
hp_min = 30,
hp_max = 45,
armor = 80,
collisionbox = {-0.6, -0.9, -0.6, 0.6, 0.6, 0.6},
visual = "mesh",
mesh = "dragon_new.b3d",
textures = {
{"dmobs_dragon.png"},
{"dmobs_dragon2.png"},
{"dmobs_dragon3.png"},
{"dmobs_dragon4.png"},
},
blood_texture = "mobs_blood.png",
visual_size = {x=3, y=3},
makes_footstep_sound = true,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "mobs:lava_orb", chance = 1, min = 1, max = 1},
},
fall_speed = 0,
stepheight = 10,
water_damage = 2,
lava_damage = 0,
light_damage = 0,
view_range = 20,
animation = {
speed_normal = 10,
speed_run = 20,
walk_start = 1,
walk_end = 22,
stand_start = 1,
stand_end = 22,
run_start = 1,
run_end = 22,
punch_start = 22,
punch_end = 47,
},
})
mobs:spawn_specific("dmobs:dragon", {"air"}, {"default:stone"}, 20, 10, 300, 15000, 2, -100, 11000)
mobs:register_egg("dmobs:dragon", "Dragon", "default_apple.png", 1)
--Thanks to Tenplus1
mobs:register_arrow("dmobs:fire", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"dmobs_fire.png"},
velocity = 8,
tail = 1, -- enable tail
tail_texture = "dmobs_fire.png",
hit_player = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_mob = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_node = function(self, pos, node)
mobs:explosion(pos, 2, 1, 1)
end,
})
mobs:register_mob("dmobs:badger", {
type = "animal",
@ -510,3 +441,106 @@ mobs:register_spawn("dmobs:badger", {"default:dirt_with_grass","default:dirt"},
mobs:register_egg("dmobs:badger", "Badger", "default_obsidian.png", 1)
--dragon
if dragons == true then
dofile(minetest.get_modpath("dmobs").."/dragons.lua")
else
mobs:register_mob("dmobs:dragon", {
type = "monster",
passive = false,
attacks_monsters = true,
damage = 4,
reach = 3,
attack_type = "dogshoot",
shoot_interval = 2.5,
dogshoot_switch = 2,
dogshoot_count = 0,
dogshoot_count_max =5,
arrow = "dmobs:fire",
shoot_offset = 1,
hp_min = 70,
hp_max = 100,
armor = 100,
collisionbox = {-0.6, -1.2, -0.6, 0.6, 0.6, 0.6},
visual = "mesh",
mesh = "dragon.b3d",
textures = {
{"dmobs_dragon.png"},
{"dmobs_dragon2.png"},
{"dmobs_dragon3.png"},
{"dmobs_dragon4.png"},
},
blood_texture = "mobs_blood.png",
visual_size = {x=2, y=2},
makes_footstep_sound = true,
runaway = false,
jump_chance = 30,
walk_chance = 80,
fall_speed = 0,
pathfinding = true,
fall_damage = 0,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "mobs:lava_orb", chance = 1, min = 1, max = 1},
},
fall_speed = 0,
stepheight = 10,
water_damage = 2,
lava_damage = 0,
light_damage = 0,
view_range = 20,
animation = {
speed_normal = 10,
speed_run = 20,
walk_start = 1,
walk_end = 22,
stand_start = 1,
stand_end = 22,
run_start = 1,
run_end = 22,
punch_start = 22,
punch_end = 47,
},
knock_back = 2,
})
--Thanks to Tenplus1
mobs:register_arrow("dmobs:fire", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"dmobs_fire.png"},
velocity = 8,
tail = 1, -- enable tail
tail_texture = "fire_basic_flame.png",
hit_player = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_mob = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_node = function(self, pos, node)
mobs:explosion(pos, 2, 1, 1)
end,
})
mobs:spawn_specific("dmobs:dragon", {"air"}, {"default:stone"}, 20, 10, 300, 15000, 2, -100, 11000)
mobs:register_egg("dmobs:dragon", "Dragon", "default_apple.png", 1)
end

View File

@ -19,7 +19,30 @@ You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
License for Textures, Models and Sounds
License for Textures, Models
---------------------------------------
CC-BY-SA 3.0 UNPORTED. Created by D00Med
CC BY-SA 3.0 UNPORTED. Created by D00Med
Roar.ogg - CC BY 3.0 Mike Koenig - http://soundbible.com/1165-Dinosaur-Roar.html
Velociraptor.ogg - CC BY 3.0 snottyboi - http://soundbible.com/1373-Velociraptor-Call.html
--License of lib_mount:
-- Minetest mod: lib_mount
-- =======================
-- by blert2112
-- Based on the Boats mod by PilzAdam.
-- -----------------------------------------------------------
-- -----------------------------------------------------------
-- Minetest Game mod: boats
-- ========================
-- by PilzAdam
-- License of source code:
-- -----------------------
-- WTFPL

BIN
models/dragon.b3d Normal file

Binary file not shown.

BIN
models/egg.b3d Normal file

Binary file not shown.

BIN
models/water_dragon.b3d Normal file

Binary file not shown.

BIN
models/wyvern.b3d Normal file

Binary file not shown.

BIN
sounds/roar.ogg Normal file

Binary file not shown.

BIN
sounds/velociraptor.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 KiB

After

Width:  |  Height:  |  Size: 726 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

BIN
textures/dmobs_egg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
textures/dmobs_egg1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/dmobs_egg2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/dmobs_egg3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
textures/dmobs_egg4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/dmobs_gem.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

BIN
textures/dmobs_gem_fire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
textures/dmobs_gem_ice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
textures/dmobs_ice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

BIN
textures/dmobs_poison.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

BIN
textures/dmobs_wyvern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
textures/mobs_saddle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B