mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-25 10:52:25 +01:00
Wither melee attack and bug fixes
This commit is contained in:
parent
924a6c1c47
commit
645072507f
@ -11,6 +11,7 @@ local w_strafes = minetest.settings:get_bool("wither_strafes", true)
|
||||
local anti_troll = minetest.settings:get_bool("wither_anti_troll_measures", false)
|
||||
|
||||
local WITHER_INIT_BOOM = 7
|
||||
local WITHER_MELEE_COOLDOWN = 3
|
||||
|
||||
local function atan(x)
|
||||
if not x or x ~= x then
|
||||
@ -48,9 +49,8 @@ local function wither_unstuck(self)
|
||||
end
|
||||
end
|
||||
end end end
|
||||
else -- when mobs_griefing disabled, make a small nondestructive explosion
|
||||
mcl_mobs.mob_class.safe_boom(self, pos, 2)
|
||||
end
|
||||
mcl_mobs.mob_class.safe_boom(self, pos, 2)
|
||||
end
|
||||
|
||||
mobs_mc.wither_count_overworld = 0
|
||||
@ -105,7 +105,7 @@ mcl_mobs.register_mob("mobs_mc:wither", {
|
||||
dogshoot_stop = true,
|
||||
arrow = "mobs_mc:wither_skull",
|
||||
reach = 5,
|
||||
shoot_interval = 0.5,
|
||||
shoot_interval = 1,
|
||||
shoot_offset = -0.5,
|
||||
animation = {
|
||||
walk_speed = 12, run_speed = 12, stand_speed = 12,
|
||||
@ -306,6 +306,42 @@ mcl_mobs.register_mob("mobs_mc:wither", {
|
||||
if rand_pos == 1 then m = sr
|
||||
elseif rand_pos == 2 then m = sl end
|
||||
|
||||
-- melee attack
|
||||
if not self._melee_timer then
|
||||
self._melee_timer = 0
|
||||
end
|
||||
if self._melee_timer < WITHER_MELEE_COOLDOWN then
|
||||
self._melee_timer = self._melee_timer + dtime
|
||||
else
|
||||
self._melee_timer = 0
|
||||
local pos = table.copy(s)
|
||||
pos.y = pos.y + 2
|
||||
local objs = minetest.get_objects_inside_radius(pos, self.reach)
|
||||
local obj_pos, dist
|
||||
local hit_some = false
|
||||
for n = 1, #objs do
|
||||
objs[n]:punch(objs[n], 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 4},
|
||||
}, pos)
|
||||
local ent = objs[n]:get_luaentity()
|
||||
if objs[n]:is_player() or ent then
|
||||
mcl_util.deal_damage(objs[n], 8, {type = "magic"})
|
||||
hit_some = true
|
||||
end
|
||||
mcl_mobs.effect_functions["withering"](objs[n], 0.5, 10)
|
||||
end
|
||||
if hit_some then
|
||||
mcl_mobs.effect(pos, 32, "mcl_particles_soul_fire_flame.png", 5, 10, self.reach, 1, 0)
|
||||
end
|
||||
end
|
||||
|
||||
if dist < self.reach then
|
||||
self.shoot_interval = 3
|
||||
else
|
||||
self.shoot_interval = 1
|
||||
end
|
||||
|
||||
if self.shoot_interval
|
||||
and self.timer > self.shoot_interval
|
||||
and not minetest.raycast(vector.add(m, vector.new(0,self.shoot_offset,0)), vector.add(self.attack:get_pos(), vector.new(0,1.5,0)), false, false):next()
|
||||
|
@ -730,7 +730,7 @@ end
|
||||
|
||||
function mcl_potions.healing_func(player, hp)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local obj = player:get_luaentity()
|
||||
|
||||
@ -760,7 +760,7 @@ end
|
||||
|
||||
function mcl_potions.swiftness_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -793,7 +793,7 @@ end
|
||||
|
||||
function mcl_potions.leaping_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -826,7 +826,7 @@ end
|
||||
|
||||
function mcl_potions.weakness_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -854,7 +854,7 @@ end
|
||||
|
||||
function mcl_potions.strength_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -882,7 +882,7 @@ end
|
||||
|
||||
function mcl_potions.withering_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and (entity.is_boss or string.find(entity.name, "wither")) then return false end
|
||||
@ -910,7 +910,7 @@ end
|
||||
|
||||
function mcl_potions.poison_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and (entity.is_boss or entity.harmed_by_heal or string.find(entity.name, "spider")) then return false end
|
||||
@ -938,7 +938,7 @@ end
|
||||
|
||||
function mcl_potions.regeneration_func(player, factor, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and (entity.is_boss or entity.harmed_by_heal) then return false end
|
||||
@ -966,7 +966,7 @@ end
|
||||
|
||||
function mcl_potions.invisiblility_func(player, null, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -993,7 +993,7 @@ end
|
||||
|
||||
function mcl_potions.water_breathing_func(player, null, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -1020,7 +1020,7 @@ end
|
||||
|
||||
function mcl_potions.fire_resistance_func(player, null, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
@ -1046,7 +1046,7 @@ end
|
||||
|
||||
function mcl_potions.night_vision_func(player, null, duration)
|
||||
|
||||
if player:get_hp() <= 0 then return false end
|
||||
if not player or player:get_hp() <= 0 then return false end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
if entity and entity.is_boss then return false end
|
||||
|
Loading…
Reference in New Issue
Block a user