1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2024-12-22 17:00:26 +01:00
mobs_monster/dungeon_master.lua

182 lines
4.2 KiB
Lua
Raw Normal View History

2024-08-10 15:39:51 +02:00
2023-08-13 12:02:47 +02:00
local S = minetest.get_translator("mobs_monster")
2016-06-11 12:03:00 +02:00
2024-08-10 15:39:51 +02:00
-- custom dungeon master types
2021-09-01 09:05:13 +02:00
local master_types = {
{ nodes = {"nether:rack"},
skins = {"mobs_dungeon_master_nether.png"},
},
{ nodes = {"nether:rack_deep"},
skins = {"mobs_dungeon_master_netherdeep.png"},
}
}
2016-04-15 16:00:45 +02:00
-- Dungeon Master by PilzAdam
mobs:register_mob("mobs_monster:dungeon_master", {
type = "monster",
passive = false,
damage = 6,
2016-04-15 16:00:45 +02:00
attack_type = "dogshoot",
dogshoot_switch = 1,
dogshoot_count_max = 12, -- shoot for 10 seconds
dogshoot_count2_max = 3, -- dogfight for 3 seconds
2016-04-15 16:00:45 +02:00
reach = 3,
shoot_interval = 2.2,
2016-04-15 16:00:45 +02:00
arrow = "mobs_monster:fireball",
friendly_fire = false,
2016-04-15 16:00:45 +02:00
shoot_offset = 1,
2021-03-02 14:35:17 +01:00
hp_min = 42,
hp_max = 75,
2016-04-15 16:00:45 +02:00
armor = 60,
collisionbox = {-0.7, -1, -0.7, 0.7, 1.6, 0.7},
visual = "mesh",
mesh = "mobs_dungeon_master.b3d",
textures = {
{"mobs_dungeon_master.png"},
{"mobs_dungeon_master2.png"},
2022-09-27 12:27:47 +02:00
{"mobs_dungeon_master3.png"}
2016-04-15 16:00:45 +02:00
},
makes_footstep_sound = true,
sounds = {
random = "mobs_dungeonmaster",
2022-09-27 12:27:47 +02:00
shoot_attack = "mobs_fireball"
2016-04-15 16:00:45 +02:00
},
walk_velocity = 1,
run_velocity = 3,
jump = true,
view_range = 15,
drops = {
2018-07-13 20:11:40 +02:00
{name = "default:mese_crystal_fragment", chance = 1, min = 0, max = 2},
2018-07-18 16:41:48 +02:00
{name = "mobs:leather", chance = 2, min = 0, max = 2},
{name = "default:mese_crystal", chance = 3, min = 0, max = 2},
2018-07-13 20:11:40 +02:00
{name = "default:diamond", chance = 4, min = 0, max = 1},
2022-09-27 12:27:47 +02:00
{name = "default:diamondblock", chance = 30, min = 0, max = 1}
2016-04-15 16:00:45 +02:00
},
water_damage = 1,
lava_damage = 1,
light_damage = 0,
fear_height = 3,
animation = {
2024-08-10 15:39:51 +02:00
stand_start = 0, stand_end = 19,
walk_start = 20, walk_end = 35,
punch_start = 36, punch_end = 48,
shoot_start = 36, shoot_end = 48,
speed_normal = 15, speed_run = 15
2016-04-15 16:00:45 +02:00
},
2021-09-01 09:05:13 +02:00
-- check surrounding nodes and spawn a specific monster
on_spawn = function(self)
local pos = self.object:get_pos() ; pos.y = pos.y - 1
local tmp
for n = 1, #master_types do
tmp = master_types[n]
if minetest.find_node_near(pos, 1, tmp.nodes) then
self.base_texture = tmp.skins
self.object:set_properties({textures = tmp.skins})
2024-08-10 15:39:51 +02:00
if tmp.drops then self.drops = tmp.drops end
2021-09-01 09:05:13 +02:00
return true
end
end
return true -- run only once, false/nil runs every activation
end
2016-04-15 16:00:45 +02:00
})
2024-08-10 15:39:51 +02:00
-- where to spawn
if not mobs.custom_spawn_monster then
2022-09-27 12:27:47 +02:00
mobs:spawn({
name = "mobs_monster:dungeon_master",
nodes = {"default:stone", "nether:rack", "nether:rack_deep"},
max_light = 5,
chance = 9000,
active_object_count = 1,
max_height = -70
})
end
2016-04-15 16:00:45 +02:00
2024-08-10 15:39:51 +02:00
-- spawn egg
2024-08-10 15:39:51 +02:00
mobs:register_egg("mobs_monster:dungeon_master", S("Dungeon Master"),
"fire_basic_flame.png", 1, true)
2016-04-15 16:00:45 +02:00
2024-08-10 15:39:51 +02:00
-- old mobs mod compatibility
2024-08-10 15:39:51 +02:00
mobs:alias_mob("mobs:dungeon_master", "mobs_monster:dungeon_master")
2024-08-10 15:39:51 +02:00
-- fireball arrow
2016-04-15 16:00:45 +02:00
mobs:register_arrow("mobs_monster:fireball", {
visual = "sprite",
visual_size = {x = 1, y = 1},
textures = {"mobs_fireball.png"},
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
velocity = 7,
2017-01-20 10:29:41 +01:00
tail = 1,
tail_texture = "mobs_fireball.png",
tail_size = 10,
glow = 5,
expire = 0.1,
2016-04-15 16:00:45 +02:00
on_activate = function(self, staticdata, dtime_s)
-- make fireball indestructable
self.object:set_armor_groups({immortal = 1, fleshy = 100})
end,
-- if player has a good weapon with 7+ damage it can deflect fireball
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
if hitter and hitter:is_player() and tool_capabilities and dir then
local damage = tool_capabilities.damage_groups and
tool_capabilities.damage_groups.fleshy or 1
local tmp = tflp / (tool_capabilities.full_punch_interval or 1.4)
if damage > 6 and tmp < 4 then
self.object:set_velocity({
x = dir.x * self.velocity,
y = dir.y * self.velocity,
2022-09-27 12:27:47 +02:00
z = dir.z * self.velocity
})
end
end
end,
2016-04-15 16:00:45 +02:00
-- direct hit, no fire... just plenty of pain
hit_player = function(self, player)
2024-08-10 15:39:51 +02:00
2016-04-15 16:00:45 +02:00
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
2022-09-27 12:27:47 +02:00
damage_groups = {fleshy = 8}
2016-04-15 16:00:45 +02:00
}, nil)
end,
hit_mob = function(self, player)
2024-08-10 15:39:51 +02:00
2016-04-15 16:00:45 +02:00
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
2022-09-27 12:27:47 +02:00
damage_groups = {fleshy = 8}
2016-04-15 16:00:45 +02:00
}, nil)
end,
-- node hit
2016-04-15 16:00:45 +02:00
hit_node = function(self, pos, node)
mobs:boom(self, pos, 1)
2016-04-15 16:00:45 +02:00
end
})
--minetest.override_item("default:obsidian", {on_blast = function() end})