2017-07-05 03:15:46 +02:00
|
|
|
--###################
|
|
|
|
--################### ENDERDRAGON
|
|
|
|
--###################
|
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
local S = minetest.get_translator("mobs_mc")
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2022-09-12 23:03:08 +02:00
|
|
|
local BEAM_CHECK_FREQUENCY = 2
|
|
|
|
local POS_CHECK_FREQUENCY = 15
|
|
|
|
local HEAL_AMMOUNT = 37
|
|
|
|
|
|
|
|
local function heal(self)
|
|
|
|
local o = self.object
|
|
|
|
self.health = math.min(self.hp_max,self.health + HEAL_AMMOUNT)
|
|
|
|
end
|
|
|
|
local function check_beam(self)
|
|
|
|
for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do
|
|
|
|
local luaentity = obj:get_luaentity()
|
|
|
|
if luaentity and luaentity.name == "mcl_end:crystal" then
|
|
|
|
if luaentity.beam then
|
|
|
|
if luaentity.beam == self.beam then
|
|
|
|
heal(self)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if self.beam then
|
|
|
|
self.beam:remove()
|
|
|
|
end
|
|
|
|
minetest.add_entity(self.object:get_pos(), "mcl_end:crystal_beam"):get_luaentity():init(self.object, obj)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function check_pos(self)
|
|
|
|
if self._portal_pos then
|
|
|
|
-- migrate old format
|
|
|
|
if type(self._portal_pos) == "string" then
|
|
|
|
self._portal_pos = minetest.string_to_pos(self._portal_pos)
|
|
|
|
end
|
|
|
|
local portal_center = vector.add(self._portal_pos, vector.new(0, 11, 0))
|
|
|
|
local pos = self.object:get_pos()
|
|
|
|
if vector.distance(pos, portal_center) > 50 then
|
|
|
|
self.object:set_pos(self._last_good_pos or portal_center)
|
|
|
|
else
|
|
|
|
self._last_good_pos = pos
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_mob("mobs_mc:enderdragon", {
|
2021-04-25 17:30:15 +02:00
|
|
|
description = S("Ender Dragon"),
|
2017-07-05 03:15:46 +02:00
|
|
|
type = "monster",
|
2020-04-11 02:46:03 +02:00
|
|
|
spawn_class = "hostile",
|
2022-02-13 21:40:12 +01:00
|
|
|
pathfinding = 1,
|
2017-07-05 03:15:46 +02:00
|
|
|
attacks_animals = true,
|
|
|
|
walk_chance = 100,
|
|
|
|
hp_max = 200,
|
|
|
|
hp_min = 200,
|
2020-12-06 15:46:42 +01:00
|
|
|
xp_min = 500,
|
|
|
|
xp_max = 500,
|
2022-02-13 21:40:12 +01:00
|
|
|
collisionbox = {-2, 3, -2, 2, 5, 2},
|
|
|
|
physical = false,
|
2017-07-05 03:15:46 +02:00
|
|
|
visual = "mesh",
|
|
|
|
mesh = "mobs_mc_dragon.b3d",
|
|
|
|
textures = {
|
|
|
|
{"mobs_mc_dragon.png"},
|
|
|
|
},
|
|
|
|
visual_size = {x=3, y=3},
|
2022-09-12 01:43:59 +02:00
|
|
|
view_range = 64,
|
2017-07-05 03:15:46 +02:00
|
|
|
walk_velocity = 6,
|
|
|
|
run_velocity = 6,
|
2021-02-25 12:48:17 +01:00
|
|
|
can_despawn = false,
|
2017-07-05 03:15:46 +02:00
|
|
|
sounds = {
|
2018-09-14 16:27:58 +02:00
|
|
|
-- TODO: more sounds
|
2017-07-05 03:15:46 +02:00
|
|
|
shoot_attack = "mobs_mc_ender_dragon_shoot",
|
|
|
|
attack = "mobs_mc_ender_dragon_attack",
|
|
|
|
distance = 60,
|
|
|
|
},
|
|
|
|
physical = true,
|
|
|
|
damage = 10,
|
2022-06-07 09:55:19 +02:00
|
|
|
knock_back = false,
|
2017-07-05 03:15:46 +02:00
|
|
|
jump = true,
|
|
|
|
jump_height = 14,
|
|
|
|
fly = true,
|
2020-12-05 14:48:58 +01:00
|
|
|
makes_footstep_sound = false,
|
2017-07-05 03:15:46 +02:00
|
|
|
dogshoot_switch = 1,
|
|
|
|
dogshoot_count_max =5,
|
|
|
|
dogshoot_count2_max = 5,
|
|
|
|
passive = false,
|
|
|
|
attack_animals = true,
|
|
|
|
lava_damage = 0,
|
2019-10-02 18:43:48 +02:00
|
|
|
fire_damage = 0,
|
2017-07-05 03:15:46 +02:00
|
|
|
on_rightclick = nil,
|
2022-02-13 21:40:12 +01:00
|
|
|
attack_type = "dogshoot",
|
2019-12-10 01:01:04 +01:00
|
|
|
arrow = "mobs_mc:dragon_fireball",
|
2017-07-05 03:15:46 +02:00
|
|
|
shoot_interval = 0.5,
|
2019-12-10 01:01:04 +01:00
|
|
|
shoot_offset = -1.0,
|
2022-02-13 21:40:12 +01:00
|
|
|
xp_min = 500,
|
|
|
|
xp_max = 500,
|
2017-07-05 03:15:46 +02:00
|
|
|
animation = {
|
|
|
|
fly_speed = 8, stand_speed = 8,
|
|
|
|
stand_start = 0, stand_end = 20,
|
|
|
|
walk_start = 0, walk_end = 20,
|
|
|
|
run_start = 0, run_end = 20,
|
|
|
|
},
|
2018-05-30 11:34:17 +02:00
|
|
|
ignores_nametag = true,
|
2022-09-12 23:03:08 +02:00
|
|
|
do_custom = function(self,dtime)
|
2021-04-11 17:30:32 +02:00
|
|
|
mcl_bossbars.update_boss(self.object, "Ender Dragon", "light_purple")
|
2022-09-12 23:03:08 +02:00
|
|
|
if self._pos_timer == nil or self._pos_timer > POS_CHECK_FREQUENCY then
|
|
|
|
self._pos_timer = 0
|
|
|
|
check_pos(self)
|
2021-04-10 20:58:34 +02:00
|
|
|
end
|
2022-09-12 23:03:08 +02:00
|
|
|
if self._beam_timer == nil or self._beam_timer > BEAM_CHECK_FREQUENCY then
|
|
|
|
self._beam_timer = 0
|
|
|
|
check_beam(self)
|
2021-04-06 16:38:23 +02:00
|
|
|
end
|
2022-09-12 23:03:08 +02:00
|
|
|
self._beam_timer = self._beam_timer + dtime
|
|
|
|
self._pos_timer = self._pos_timer + dtime
|
2021-04-06 14:50:34 +02:00
|
|
|
end,
|
2022-09-12 05:18:04 +02:00
|
|
|
on_die = function(self, pos, cmi_cause)
|
2021-04-06 14:57:29 +02:00
|
|
|
if self._portal_pos then
|
2021-04-06 20:08:20 +02:00
|
|
|
mcl_portals.spawn_gateway_portal()
|
2022-09-12 05:18:04 +02:00
|
|
|
mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1)
|
2021-04-06 15:48:17 +02:00
|
|
|
if self._initial then
|
2022-02-24 21:22:50 +01:00
|
|
|
mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000
|
2022-09-12 01:27:10 +02:00
|
|
|
minetest.set_node(vector.add(self._portal_pos, vector.new(0, 5, 0)), {name = "mcl_end:dragon_egg"})
|
2021-04-06 15:48:17 +02:00
|
|
|
end
|
2022-09-14 00:03:07 +02:00
|
|
|
end
|
2023-08-08 02:53:01 +02:00
|
|
|
|
2022-09-14 00:03:07 +02:00
|
|
|
-- Free The End Advancement
|
|
|
|
for _,players in pairs(minetest.get_objects_inside_radius(pos,64)) do
|
|
|
|
if players:is_player() then
|
2022-09-14 00:09:27 +02:00
|
|
|
awards.unlock(players:get_player_name(), "mcl:freeTheEnd")
|
2022-09-14 00:03:07 +02:00
|
|
|
end
|
2020-07-25 13:32:35 +02:00
|
|
|
end
|
2020-12-24 17:48:40 +01:00
|
|
|
end,
|
|
|
|
fire_resistant = true,
|
2023-08-08 02:53:01 +02:00
|
|
|
is_boss = true,
|
2017-07-05 03:15:46 +02:00
|
|
|
})
|
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
|
|
|
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2019-12-10 01:01:04 +01:00
|
|
|
-- dragon fireball (projectile)
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_arrow("mobs_mc:dragon_fireball", {
|
2017-07-05 03:15:46 +02:00
|
|
|
visual = "sprite",
|
2019-12-10 01:01:04 +01:00
|
|
|
visual_size = {x = 1.25, y = 1.25},
|
2017-07-12 22:09:37 +02:00
|
|
|
textures = {"mobs_mc_dragon_fireball.png"},
|
2017-07-05 03:15:46 +02:00
|
|
|
velocity = 6,
|
|
|
|
|
|
|
|
-- direct hit, no fire... just plenty of pain
|
|
|
|
hit_player = function(self, player)
|
|
|
|
player:punch(self.object, 1.0, {
|
|
|
|
full_punch_interval = 0.5,
|
2019-12-10 01:01:04 +01:00
|
|
|
damage_groups = {fleshy = 12},
|
2017-07-05 03:15:46 +02:00
|
|
|
}, nil)
|
|
|
|
end,
|
|
|
|
|
2017-08-06 14:09:25 +02:00
|
|
|
hit_mob = function(self, mob)
|
2020-04-07 00:55:45 +02:00
|
|
|
minetest.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5, max_hear_distance = 2*64}, true)
|
2017-08-06 14:09:25 +02:00
|
|
|
mob:punch(self.object, 1.0, {
|
2017-07-05 03:15:46 +02:00
|
|
|
full_punch_interval = 0.5,
|
|
|
|
damage_groups = {fleshy = 12},
|
|
|
|
}, nil)
|
|
|
|
end,
|
|
|
|
|
2019-12-10 01:01:04 +01:00
|
|
|
-- node hit, explode
|
2017-07-05 03:15:46 +02:00
|
|
|
hit_node = function(self, pos, node)
|
2022-11-10 15:28:51 +01:00
|
|
|
mcl_mobs.mob_class.boom(self,pos, 2)
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2022-11-09 04:09:58 +01:00
|
|
|
mcl_mobs.register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "#252525", "#b313c9", 0, true)
|
2022-10-02 17:50:43 +02:00
|
|
|
|
2021-03-07 00:42:34 +01:00
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
mcl_wip.register_wip_item("mobs_mc:enderdragon")
|
2023-02-10 03:46:23 +01:00
|
|
|
mcl_mobs:non_spawn_specific("mobs_mc:enderdragon","overworld",0,minetest.LIGHT_MAX+1)
|