1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2025-07-05 18:00:20 +02:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
2021-03-12 12:30:34 +01:00
30 changed files with 431 additions and 49 deletions

View File

@ -11,6 +11,47 @@ local get_velocity = function(self)
return (v.x * v.x + v.z * v.z) ^ 0.5
end
local spider_types = {
{ nodes = {"default:snow", "default:snowblock", "default:dirt_with_snow"},
skins = {"mobs_spider_snowy.png"},
docile = true,
drops = nil
},
{ nodes = {"default:dirt_with_rainforest_litter", "default:jungletree"},
skins = {"mobs_spider_orange.png"},
docile = true,
drops = nil,
shoot = true
},
{ nodes = {"default:stone", "default:gravel"},
skins = {"mobs_spider_grey.png"},
docile = nil,
drops = nil,
small = true
},
{ nodes = {"default:mese", "default:stone_with_mese"},
skins = {"mobs_spider_mese.png"},
docile = nil,
drops = {
{name = "farming:string", chance = 1, min = 0, max = 2},
{name = "default:mese_crystal_fragment", chance = 2, min = 1, max = 4}}
},
{ nodes = {"ethereal:crystal_dirt", "ethereal:crystal_spike"},
skins = {"mobs_spider_crystal.png"},
docile = true,
drops = {
{name = "farming:string", chance = 1, min = 0, max = 2},
{name = "ethereal:crystal_spike", chance = 15, min = 1, max = 2}}
}
}
-- Spider by AspireMint (CC-BY-SA 3.0 license)
mobs:register_mob("mobs_monster:spider", {
@ -54,7 +95,7 @@ mobs:register_mob("mobs_monster:spider", {
light_damage = 0,
animation = {
speed_normal = 15,
speed_run = 20,--15,
speed_run = 20,
stand_start = 0,
stand_end = 0,
walk_start = 1,
@ -64,42 +105,46 @@ mobs:register_mob("mobs_monster:spider", {
punch_start = 25,
punch_end = 45,
},
-- what kind of spider are we spawning?
-- check surrounding nodes and spawn a specific spider
on_spawn = function(self)
local pos = self.object:get_pos() ; pos.y = pos.y - 1
local tmp
-- snowy spider
if minetest.find_node_near(pos, 1,
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
self.base_texture = {"mobs_spider_snowy.png"}
self.object:set_properties({textures = self.base_texture})
self.docile_by_day = true
-- tarantula
elseif minetest.find_node_near(pos, 1,
{"default:dirt_with_rainforest_litter", "default:jungletree"}) then
self.base_texture = {"mobs_spider_orange.png"}
self.object:set_properties({textures = self.base_texture})
self.docile_by_day = true
-- grey spider
elseif minetest.find_node_near(pos, 1,
{"default:stone", "default:gravel"}) then
self.base_texture = {"mobs_spider_grey.png"}
self.object:set_properties({textures = self.base_texture})
-- mese spider
elseif minetest.find_node_near(pos, 1,
{"default:mese", "default:stone_with_mese"}) then
self.base_texture = {"mobs_spider_mese.png"}
self.object:set_properties({textures = self.base_texture})
elseif minetest.find_node_near(pos, 1,
{"ethereal:crystal_dirt", "ethereal:crystal_spike"}) then
self.base_texture = {"mobs_spider_crystal.png"}
self.object:set_properties({textures = self.base_texture})
self.docile_by_day = true
self.drops = {
{name = "farming:string", chance = 1, min = 0, max = 2},
{name = "ethereal:crystal_spike", chance = 15, min = 1, max = 2},
}
for n = 1, #spider_types do
tmp = spider_types[n]
if minetest.find_node_near(pos, 1, tmp.nodes) then
self.base_texture = tmp.skins
self.object:set_properties({textures = tmp.skins})
self.docile_by_day = tmp.docile
if tmp.drops then
self.drops = tmp.drops
end
if tmp.shoot then
self.attack_type = "dogshoot"
self.arrow = "mobs_monster:cobweb"
self.dogshoot_switch = 1
self.dogshoot_count_max = 60
self.dogshoot_count2_max = 20
self.shoot_interval = 2
self.shoot_offset = 2
end
if tmp.small then
self.object:set_properties({
collisionbox = {-0.2, -0.2, -0.2, 0.2, 0, 0.2},
visual_size = {x = 0.25, y = 0.25}
})
end
return true
end
end
return true -- run only once, false/nil runs every activation
@ -234,7 +279,7 @@ minetest.register_node(":mobs:cobweb", {
walkable = false,
groups = {snappy = 1, disable_jump = 1},
drop = "farming:string",
sounds = default.node_sound_leaves_defaults(),
sounds = default.node_sound_leaves_defaults()
})
minetest.register_craft({
@ -246,4 +291,48 @@ minetest.register_craft({
}
})
local web_place = function(pos)
local pos2 = minetest.find_node_near(pos, 1, {"air", "group:leaves"}, true)
if pos2 then
minetest.swap_node(pos2, {name = "mobs:cobweb"})
end
end
mobs:register_arrow("mobs_monster:cobweb", {
visual = "sprite",
visual_size = {x = 1, y = 1},
textures = {"mobs_cobweb.png"},
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
velocity = 15,
tail = 1,
tail_texture = "mobs_cobweb.png",
tail_size = 5,
glow = 2,
expire = 0.1,
hit_player = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 2.0,
damage_groups = {fleshy = 3},
}, nil)
web_place(self.object:get_pos())
end,
hit_node = function(self, pos, node)
web_place(pos)
end,
hit_mob = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 2.0,
damage_groups = {fleshy = 3},
}, nil)
end
})
minetest.register_alias("mobs:spider_cobweb", "mobs:cobweb")