Fix indentation in witch.lua
This commit is contained in:
parent
729906866f
commit
3e351a6e10
@ -19,7 +19,7 @@ local potion_props = {
|
||||
|
||||
local witch_potion_entity = {
|
||||
initial_properties = potion_props,
|
||||
on_step = function (self, dtime)
|
||||
on_step = function (self)
|
||||
local parent = self.object:get_attach ()
|
||||
if not parent then
|
||||
self.object:remove ()
|
||||
@ -45,13 +45,10 @@ local function witch_equip_potion (self, potion)
|
||||
self:add_physics_factor ("run_velocity", "mobs_mc:witch_potion_penalty", 0.75)
|
||||
|
||||
self._held_potion = potion
|
||||
local object = minetest.add_entity (self.object:get_pos (),
|
||||
"mobs_mc:witch_potion")
|
||||
local object = minetest.add_entity (self.object:get_pos (), "mobs_mc:witch_potion")
|
||||
if object then
|
||||
object:set_properties ({ wield_item = potion, })
|
||||
object:set_attach (self.object, "body",
|
||||
{ x = 0, y = 1.65, z = 1.2, },
|
||||
vector.zero ())
|
||||
object:set_attach (self.object, "body", { x = 0, y = 1.65, z = 1.2, }, vector.zero ())
|
||||
self._held_potion_object = object
|
||||
end
|
||||
-- Must wait 1.5 seconds before consuming this potion.
|
||||
@ -67,8 +64,7 @@ local function witch_consume_potion (self, potion)
|
||||
self:remove_physics_factor ("walk_velocity", "mobs_mc:witch_potion_penalty")
|
||||
self:remove_physics_factor ("run_velocity", "mobs_mc:witch_potion_penalty")
|
||||
mcl_potions.consume_potion (self.object, potion, 0, 0)
|
||||
if self._held_potion_object then
|
||||
self._held_potion_object:remove ()
|
||||
if self._held_potion_object then self._held_potion_object:remove ()
|
||||
self._held_potion_object = nil
|
||||
end
|
||||
-- Reset the timer.
|
||||
@ -90,9 +86,7 @@ local witch_potion_items = {
|
||||
potion = "mcl_potions:water_breathing",
|
||||
test = function (self)
|
||||
local head_nodedef = minetest.registered_nodes[self.head_in]
|
||||
return (not mcl_potions.has_effect (self.object,
|
||||
"water_breathing")
|
||||
and head_nodedef and head_nodedef.drowning > 0)
|
||||
return (not mcl_potions.has_effect (self.object, "water_breathing") and head_nodedef and head_nodedef.drowning > 0)
|
||||
end,
|
||||
chance = 15,
|
||||
},
|
||||
@ -220,20 +214,15 @@ mcl_mobs.register_mob("mobs_mc:witch", {
|
||||
-- participating in raids to heal them.
|
||||
|
||||
local pos = self.object:get_pos ()
|
||||
local objs
|
||||
= minetest.get_objects_inside_radius (pos, self.view_range)
|
||||
local objs = minetest.get_objects_inside_radius (pos, self.view_range)
|
||||
table.shuffle (objs)
|
||||
for _, obj in pairs (objs) do
|
||||
if self:line_of_sight (pos, obj:get_pos(), 2) then
|
||||
local l = obj:get_luaentity ()
|
||||
if attack_players and obj:is_player ()
|
||||
and (not self._player_cooldown or not self.raidmob) then
|
||||
if attack_players and obj:is_player () and (not self._player_cooldown or not self.raidmob) then
|
||||
self:do_attack (obj)
|
||||
break
|
||||
elseif self.raidmob and l and l.raidmob
|
||||
and (l.name == "mobs_mc:pillager"
|
||||
or l.name == "mobs_mc:vindicator"
|
||||
or l.name == "mobs_mc:evoker") then
|
||||
elseif self.raidmob and l and l.raidmob and (l.name == "mobs_mc:pillager" or l.name == "mobs_mc:vindicator" or l.name == "mobs_mc:evoker") then
|
||||
if not self._illager_cooldown then
|
||||
-- Prohibit selecting illager targets
|
||||
-- again for a period of 5 seconds.
|
||||
@ -307,10 +296,7 @@ mcl_mobs.register_mob("mobs_mc:witch", {
|
||||
-- Ref: https://minecraft.fandom.com/wiki/Witch#Behavior
|
||||
local pos = self.object:get_pos ()
|
||||
local dist = vector.distance (target_pos, pos)
|
||||
if entity
|
||||
and (entity.name == "mobs_mc:pillager"
|
||||
or entity.name == "mobs_mc:vindicator"
|
||||
or entity.name == "mobs_mc:evoker") then
|
||||
if entity and (entity.name == "mobs_mc:pillager" or entity.name == "mobs_mc:vindicator" or entity.name == "mobs_mc:evoker") then
|
||||
-- If it's a raid mob who is being attacked, give it
|
||||
-- either regeneration or instant health subject to
|
||||
-- its remaining health.
|
||||
@ -319,15 +305,11 @@ mcl_mobs.register_mob("mobs_mc:witch", {
|
||||
else
|
||||
effect_potion = "mcl_potions:regeneration_splash"
|
||||
end
|
||||
elseif dist >= 8
|
||||
and not mcl_potions.has_effect (self.attack, "slowness") then
|
||||
elseif dist >= 8 and not mcl_potions.has_effect (self.attack, "slowness") then
|
||||
effect_potion = "mcl_potions:slowness_splash"
|
||||
elseif target_hp >= 8 and not mcl_potions.has_effect (self.attack,
|
||||
"poison") then
|
||||
elseif target_hp >= 8 and not mcl_potions.has_effect (self.attack, "poison") then
|
||||
effect_potion = "mcl_potions:poison_splash"
|
||||
elseif dist <= 3
|
||||
and not mcl_potions.has_effect (self.attack, "weakness")
|
||||
and math.random (1, 4) == 1 then
|
||||
elseif dist <= 3 and not mcl_potions.has_effect (self.attack, "weakness") and math.random (1, 4) == 1 then
|
||||
effect_potion = "mcl_potions:weakness_splash"
|
||||
end
|
||||
|
||||
@ -345,8 +327,7 @@ mcl_mobs.register_mob("mobs_mc:witch", {
|
||||
target_pos.y = target_pos.y + eye_height
|
||||
local d = vector.subtract (target_pos, p)
|
||||
d.y = d.y + vector.length (d) * 0.2
|
||||
mcl_potions.throw_splash (effect_potion, vector.normalize (d), p,
|
||||
self.object, 0, 0)
|
||||
mcl_potions.throw_splash (effect_potion, vector.normalize (d), p, self.object, 0, 0)
|
||||
end,
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user