Commit b0a5edea authored by D00Med's avatar D00Med Committed by GitHub

Merge pull request #11 from taikedz/cleanup

Cleanup
parents 8cb1216b 37a3dc0d
# D00Med's Mobs
local base_arrow = {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
velocity = 8,
tail = 1, -- enable tail
tail_texture = "dmobs_ice.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)
self.object:remove()
end,
}
for _,arrowtype in pairs( {"ice","lightning","poison"} ) do
base_arrow.textures = {"dmobs_"..arrowtype..".png"},
mobs:register_arrow("dmobs:"..arrowtype, dmobs.deepclone(base_arrow) )
end
--function to register tamed dragon attacks
function dmobs.register_fire(fname, texture, dmg, replace_node, explode, ice, variance, size)
minetest.register_entity(fname, {
textures = {texture},
velocity = 0.1,
damage = dmg,
collisionbox = {0, 0, 0, 0, 0, 0},
on_step = function(self, obj, pos)
local remove = minetest.after(2, function()
self.object:remove()
end)
local pos = self.object:getpos()
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= fname and obj:get_luaentity().name ~= "dmobs:dragon_red" and obj:get_luaentity().name ~= "dmobs:dragon_blue" and obj:get_luaentity().name ~= "dmobs:dragon_black" and obj:get_luaentity().name ~= "dmobs:dragon_green" and obj:get_luaentity().name ~= "dmobs:dragon_great_tame" and obj:get_luaentity().name ~= "__builtin:item" then
obj:punch(self.launcher, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=3},
}, nil)
self.object:remove()
end
end
end
for dx=0,1 do
for dy=0,1 do
for dz=0,1 do
local p = {x=pos.x+dx, y=pos.y, z=pos.z+dz}
local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
local n = minetest.env:get_node(p).name
if n ~= fname and n ~="default:dirt_with_grass" and n ~="default:dirt_with_dry_grass" and n ~="default:stone" then
if minetest.registered_nodes[n].groups.flammable --[[or math.random(1, 100) <= 1]] then
minetest.env:set_node(t, {name=replace_node})
self.object:remove()
return
end
if ice and n == "default:water_source" then
minetest.env:set_node(t, {name="default:ice"})
self.object:remove()
end
end
end
end
end
local apos = self.object:getpos()
local part = minetest.add_particlespawner(
6, --amount
0.3, --time
{x=apos.x-variance, y=apos.y-variance, z=apos.z-variance}, --minpos
{x=apos.x+variance, y=apos.y+variance, z=apos.z+variance}, --maxpos
{x=-0, y=-0, z=-0}, --minvel
{x=0, y=0, z=0}, --maxvel
{x=variance,y=-0.5-variance,z=variance}, --minacc
{x=0.5+variance,y=0.5+variance,z=0.5+variance}, --maxacc
0.1, --minexptime
0.3, --maxexptime
size, --minsize
size+2, --maxsize
false, --collisiondetection
texture --texture
)
end,
})
end
dmobs.register_fire("dmobs:fire_plyr", "dmobs_fire.png", 2, "fire:basic_flame", true, false, 0.3, 1)
dmobs.register_fire("dmobs:ice_plyr", "dmobs_ice.png", 2, "default:ice", false, true, 0.5, 10)
dmobs.register_fire("dmobs:poison_plyr", "dmobs_poison.png", 2, "air", false, false, 0.3, 1)
dmobs.register_fire("dmobs:lightning_plyr", "dmobs_lightning.png", 2, "air", true, false, 0, 0.5)
--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)
self.object:remove()
end,
})
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:register_arrow("dmobs:sting", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"dmobs_sting.png"},
velocity = 8,
tail = 0, -- 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 = 1},
}, nil)
end,
hit_mob = function(self, player)
end,
hit_node = function(self, pos, node)
self.object:remove()
end,
})
This diff is collapsed.
This diff is collapsed.
D00Med's Mobs
How to Dragon
By defeating dragons you will get eggs. Place them in their ideal environment and feed them a gem to create an elemental egg.
By defeating special dragons, you can obtain elemental gems.
Feed the right elemental gem to the elemental egg to hatch a dragon.
Use the Use key to shoot fireballs when riding your new pet dragon.
ENjoy
local dragondef = {
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"},
},
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,
follow = {"dmobs:dragon_gem"},
pathfinding = true,
fall_damage = 0,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "dmobs:egg", chance = 1, min = 1, max = 1},
{name = "dmobs:dragon_gem", 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,
do_custom = dmobs.dragon.step_custom,
on_rightclick = dmobs.dragon.on_rc
}
mobs:register_mob("dmobs:dragon", dmobs.deepclone(dragondef) )
dragondef.type = "npc"
dragondef.attacks_monsters = true
dragondef.on_rightclick = dmobs.dragon.ride
dragondef.do_custom = dmobs.dragon.do_custom
mobs:register_mob("dmobs:dragon_red", dmobs.deepclone(dragondef) )
local dragondef = {
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:lightning",
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_dragon2.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,
follow = {"dmobs:dragon_gem"},
pathfinding = true,
fall_damage = 0,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "dmobs:egg", chance = 1, min = 1, max = 1},
{name = "dmobs:dragon_gem", 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,
do_custom = dmobs.dragon.step_custom,
on_rightclick = dmobs.dragon.on_rc
}
mobs:register_mob("dmobs:dragon2", dmobs.deepclone(dragondef) )
dragondef.type = "npc"
dragondef.attacks_monsters = true
dragondef.on_rightclick = dmobs.dragon.ride
dragondef.do_custom = dmobs.dragon.do_custom
mobs:register_mob("dmobs:dragon_black", dmobs.deepclone(dragondef) )
local dragondef = {
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:poison",
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_dragon3.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,
follow = {"dmobs:dragon_gem"},
pathfinding = true,
fall_damage = 0,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "dmobs:egg", chance = 1, min = 1, max = 1},
{name = "dmobs:dragon_gem", 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,
do_custom = dmobs.dragon.step_custom,
on_rightclick = dmobs.dragon.on_rc
}
mobs:register_mob("dmobs:dragon3", dmobs.deepclone(dragondef) )
dragondef.type = "npc"
dragondef.attacks_monsters = true
dragondef.on_rightclick = dmobs.dragon.ride
dragondef.do_custom = dmobs.dragon.do_custom
mobs:register_mob("dmobs:dragon_green", dmobs.deepclone(dragondef) )
local dragondef = {
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:ice",
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_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,
follow = {"dmobs:dragon_gem"},
pathfinding = true,
fall_damage = 0,
sounds = {
shoot_attack = "mobs_fireball",
},
walk_velocity = 3,
run_velocity = 5,
jump = true,
fly = true,
drops = {
{name = "dmobs:egg", chance = 1, min = 1, max = 1},
{name = "dmobs:dragon_gem", 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,
do_custom = dmobs.dragon.step_custom,
on_rightclick = dmobs.dragon.on_rc
}
mobs:register_mob("dmobs:dragon4", dmobs.deepclone(dragondef) )
dragondef.type = "npc"
dragondef.attacks_monsters = true
dragondef.on_rightclick = dmobs.dragon.ride
dragondef.do_custom = dmobs.dragon.do_custom
mobs:register_mob("dmobs:dragon_blue", dmobs.deepclone(dragondef) )
--dragon
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,
})
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)
-- eggs from mobs_dragon --------------------------------------------------------------------------
local dragonpairs = {
fire = {colour="red",nest="default:lava_source"},
lightning = {colour="black",nest="default:obsidian"},
poison = {colour="green",nest="default:cactus"},
ice = {colour="black",nest="default:ice"},
great = {colour="great",nest=""},
}
local function egg_transform(pos, node, clicker, item, _)
local wield_item = clicker:get_wielded_item():get_name()
if wield_item == "dmobs:dragon_gem" then
local p = {x = pos.x, y = pos.y - 1, z = pos.z}
local corner_name
for x1 = -1,1 do
for z1 = -1,1 do
p.x = pos.x + x1
p.z = pos.z + z1
local nestfloor_name = minetest.get_node(p).name
if x1 == -1 and z1 == -1 then
corner_name = minetest.get_node(p).name
elseif x1 == 0 and z1 == 0 then -- special case in centre
-- must be obsidian
if nestfloor_name ~= "default:obsidian" then return end
else
-- else ring must all be of the same type
if nestfloor_name ~= corner_name then return end
end
end
end
local dragon_type
for element,details in pairs(dragonpairs) do
if corner_name == details.nest then
dragon_type = element
break
end
end
minetest.chat_send_player(clicker:get_player_name()," ... something seems to be happening .... come back later?")
minetest.after(dmobs.eggtimer,
function(pos, dragon, pname)
minetest.set_node(pos, {name="dmobs:dragon_egg_"..dragon_type})
end,
pos
)
item:take_item()
end
end
local function egghatch(pos, node, clicker, item, _)
local wield_item = clicker:get_wielded_item():get_name()
local eggnode = minetest.get_node(pos).name
for nature,details in pairs(dragonpairs) do
if ( wield_item == "dmobs:dragon_gem_"..nature and eggnode:find(nature) ) or
( wield_item == "dmobs:dragon_gem" and eggnode == "dmobs:dragon_egg_great" ) then -- special case... because inconsiderate/inconsistent naming
minetest.chat_send_player(clicker:get_player_name(), " ... it ... swallowed the gem...")
minetest.after(dmobs.eggtimer,
function(pos, dragon, pname)
local neweggnode = minetest.get_node(pos).name
if eggnode ~= neweggnode then return end -- prevent infinite hatchings
minetest.remove_node(pos)
local thedragon = "dmobs:dragon_"..details.colour
if eggnode == "dmobs:dragon_egg_great" then
thedragon = "dmobs:dragon_great"
end
local ent = minetest.add_entity(pos, thedragon)
minetest.sound_play("dmobs_chirrup",{pos=pos,max_hear_distance=20})
local obj = ent:get_luaentity()
if eggnode ~= "dmobs:dragon_egg_great" then
ent:set_properties({
textures = {"dmobs_dragon_young.png"},
visual_size = {x=1, y=1},
})
end
obj.tamed = true
obj.owner = clicker:get_player_name()
end,
pos, clicker:get_player_name()
)
item:take_item()
break
end
end -- for loop
end
-- Egg form dfinitions -----------------------------------------
local base_egg = { -- base template for all dragon eggs
description = "Dragon Egg",
drawtype = "mesh",
mesh = "egg.b3d",
tiles = {"dmobs_egg.png"},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {fleshy=3, dig_immediate=3},
sounds = default.node_sound_leaves_defaults(),
on_rightclick = egg_transform,
}
minetest.register_node("dmobs:egg", dmobs.deepclone(base_egg) ) -- clone, to not affect the base template
base_egg.groups.not_in_creative_inventory=1
base_egg.on_rightclick = egghatch
base_egg.tiles = {"dmobs_egg1.png"}
minetest.register_node("dmobs:dragon_egg_fire", dmobs.deepclone(base_egg) )