Refactor mob projectiles

This commit is contained in:
Wuzzy 2019-12-10 01:01:04 +01:00
parent 046f9ab223
commit 2ff5bafd91
6 changed files with 34 additions and 139 deletions

@ -69,7 +69,7 @@ mobs:register_mob("mobs_mc:creeper", {
if self._forced_explosion_countdown_timer ~= nil then
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then
mobs:explosion(self.object:get_pos(), self.explosion_radius, 0, 1, self.sounds.explode)
mobs:boom(self, self.object:get_pos(), self.explosion_radius)
self.object:remove()
end
end

@ -51,9 +51,9 @@ mobs:register_mob("mobs_mc:enderdragon", {
fire_damage = 0,
on_rightclick = nil,
attack_type = "dogshoot",
arrow = "mobs_mc:fireball2",
arrow = "mobs_mc:dragon_fireball",
shoot_interval = 0.5,
shoot_offset = -1,
shoot_offset = -1.0,
animation = {
fly_speed = 8, stand_speed = 8,
stand_start = 0, stand_end = 20,
@ -67,69 +67,19 @@ mobs:register_mob("mobs_mc:enderdragon", {
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
mobs:register_arrow("mobs_mc:roar_of_the_dragon2", {
-- dragon fireball (projectile)
mobs:register_arrow("mobs_mc:dragon_fireball", {
visual = "sprite",
visual_size = {x = 1, y = 1},
--textures = {"transparent.png"},
textures = {"mese_egg.png"},
velocity = 10,
on_step = function(self, dtime)
local pos = self.object:get_pos()
local n = minetest.get_node(pos).name
if self.timer == 0 then
self.timer = os.time()
end
if os.time() - self.timer > 8 or minetest.is_protected(pos, "") then
self.object:remove()
end
local objects = minetest.get_objects_inside_radius(pos, 1)
for _,obj in ipairs(objects) do
local name = self.name
if name~="mobs_mc:roar_of_the_dragon2" and name ~= "mobs_mc:enderdragon" then
obj:set_hp(obj:get_hp()-5)
if (obj:get_hp() <= 0) then
if (not obj:is_player()) and name ~= self.object:get_luaentity().name then
obj:remove()
end
end
end
end
if mobs_griefing then
minetest.set_node(pos, {name="air"})
if math.random(1,2)==1 then
local dx = math.random(-1,1)
local dy = math.random(-1,1)
local dz = math.random(-1,1)
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
minetest.set_node(p, {name="air"})
end
end
end
})
--GOOD LUCK LOL!
-- fireball (weapon)
mobs:register_arrow(":mobs_mc:fireball2", {
visual = "sprite",
visual_size = {x = 1.5, y = 1.5},
visual_size = {x = 1.25, y = 1.25},
textures = {"mobs_mc_dragon_fireball.png"},
--textures = {"mobs_skeleton2_front.png^[makealpha:255,255,255 "},
velocity = 6,
-- direct hit, no fire... just plenty of pain
hit_player = function(self, player)
minetest.sound_play("tnt_explode", {pos = player:get_pos(), gain = 1.5, max_hear_distance = 2*64})
player:punch(self.object, 1.0, {
full_punch_interval = 0.5,
damage_groups = {fleshy = 6},
damage_groups = {fleshy = 12},
}, nil)
end,
hit_mob = function(self, mob)
@ -138,15 +88,11 @@ mobs:register_arrow(":mobs_mc:fireball2", {
full_punch_interval = 0.5,
damage_groups = {fleshy = 12},
}, nil)
end,
-- node hit, bursts into flame
-- node hit, explode
hit_node = function(self, pos, node)
mobs:explosion(pos, 3, 0, 1)
--from tnt
minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 2*64})
mobs:boom(self, pos, 2)
end
})

@ -55,13 +55,10 @@ mobs:register_mob("mobs_mc:ghast", {
},
fall_damage = 0,
view_range = 100,
--attack_type = "dogshoot",
attack_type = "dogshoot",
arrow = "mobs_monster:fireball",
arrow = "mobs_mc:fireball",
shoot_interval = 3.5,
shoot_offset = 1,
--'dogshoot_switch' allows switching between shoot and dogfight modes inside dogshoot using timer (1 = shoot, 2 = dogfight)
--'dogshoot_count_max' number of seconds before switching above modes.
shoot_offset = -5,
dogshoot_switch = 1,
dogshoot_count_max =1,
passive = false,
@ -76,31 +73,33 @@ mobs:register_mob("mobs_mc:ghast", {
mobs:spawn_specific("mobs_mc:ghast", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 18000, 2, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- fireball (weapon)
mobs:register_arrow(":mobs_monster:fireball", {
-- fireball (projectile)
mobs:register_arrow("mobs_mc:fireball", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
visual_size = {x = 1, y = 1},
textures = {"mcl_fire_fire_charge.png"},
velocity = 6,
velocity = 15,
-- direct hit, no fire... just plenty of pain
hit_player = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
damage_groups = {fleshy = 6},
}, nil)
mobs:boom(self, self.object:get_pos(), 3)
end,
hit_mob = function(self, mob)
mob:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
damage_groups = {fleshy = 6},
}, nil)
mobs:boom(self, self.object:get_pos(), 3)
end,
-- node hit, bursts into flame
-- node hit, explode
hit_node = function(self, pos, node)
mobs:explosion(pos, 1, 1, 0)
mobs:boom(self, pos, 3)
end
})

@ -31,7 +31,7 @@ mobs:register_mob("mobs_mc:witch", {
pathfinding = 1,
group_attack = true,
attack_type = "dogshoot",
arrow = "mobs:potion_arrow",
arrow = "mobs_mc:potion_arrow",
shoot_interval = 2.5,
shoot_offset = 1,
dogshoot_switch = 1,
@ -68,8 +68,8 @@ mobs:register_mob("mobs_mc:witch", {
})
-- fireball (weapon)
mobs:register_arrow(":mobs:potion_arrow", {
-- potion projectile (EXPERIMENTAL)
mobs:register_arrow("mobs_mc:potion_arrow", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
--textures = {"vessels_glass_bottle.png"}, --TODO fix to else if default

@ -53,7 +53,7 @@ mobs:register_mob("mobs_mc:wither", {
explosion_radius = 3,
explosion_fire = false,
dogshoot_stop = true,
arrow = "mobs_mc:fireball",
arrow = "mobs_mc:wither_skull",
reach = 5,
shoot_interval = 0.5,
shoot_offset = -1,
@ -67,87 +67,37 @@ mobs:register_mob("mobs_mc:wither", {
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
mobs:register_arrow("mobs_mc:roar_of_the_dragon", {
visual = "sprite",
visual_size = {x = 1, y = 1},
textures = {"blank.png"},
velocity = 10,
on_step = function(self, dtime)
local pos = self.object:get_pos()
local n = minetest.get_node(pos).name
if self.timer == 0 then
self.timer = os.time()
end
if os.time() - self.timer > 8 or minetest.is_protected(pos, "") then
self.object:remove()
end
local objects = minetest.get_objects_inside_radius(pos, 1)
for _,obj in ipairs(objects) do
local name = self.name
if name~="mobs_mc:roar_of_the_dragon" and name ~= "mobs_mc:wither" then
obj:set_hp(obj:get_hp()-5)
if (obj:get_hp() <= 0) then
if (not obj:is_player()) and name ~= self.object:get_luaentity().name then
obj:remove()
end
end
end
end
if mobs_griefing then
minetest.set_node(pos, {name="air"})
if math.random(1,2)==1 then
local dx = math.random(-1,1)
local dy = math.random(-1,1)
local dz = math.random(-1,1)
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
minetest.set_node(p, {name="air"})
end
end
end
})
--GOOD LUCK LOL!
-- fireball (weapon)
mobs:register_arrow(":mobs_mc:fireball", {
mobs:register_arrow("mobs_mc:wither_skull", {
visual = "sprite",
visual_size = {x = 0.75, y = 0.75},
-- TODO: 3D projectile, replace tetxture
textures = {"mobs_mc_TEMP_wither_projectile.png"},
velocity = 6,
-- direct hit, no fire... just plenty of pain
-- direct hit
hit_player = function(self, player)
minetest.sound_play("tnt_explode", {pos = player:get_pos(), gain = 1.5, max_hear_distance = 16})
player:punch(self.object, 1.0, {
full_punch_interval = 0.5,
damage_groups = {fleshy = 8},
}, nil)
mobs:boom(self, self.object:get_pos(), 1)
end,
hit_mob = function(self, mob)
minetest.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5,max_hear_distance = 16})
mob:punch(self.object, 1.0, {
full_punch_interval = 0.5,
damage_groups = {fleshy = 8},
}, nil)
mobs:boom(self, self.object:get_pos(), 1)
end,
-- node hit, bursts into flame
-- node hit, explode
hit_node = function(self, pos, node)
-- FIXME: Deprecated, switch to mobs:boom instead
mobs:explosion(pos, 3, 0, 1)
mobs:boom(self, pos, 1)
end
})
-- TODO: Add blue wither skull
--Spawn egg
mobs:register_egg("mobs_mc:wither", S("Wither"), "mobs_mc_spawn_icon_wither.png", 0)
--Compatibility
mobs:alias_mob("nssm:mese_dragon", "mobs_mc:wither")

@ -68,7 +68,7 @@ local mobkills = {
["mobs_mc:wolf"] = N("@1 was killed by a wolf."),
["mobs_mc:cat"] = N("@1 was killed by a cat."),
["mobs_mc:ocelot"] = N("@1 was killed by an ocelot."),
["mobs_mc:ender_dragon"] = N("@1 was killed by an ender dragon."),
["mobs_mc:enderdragon"] = N("@1 was killed by an ender dragon."),
["mobs_mc:wither"] = N("@1 was killed by a wither."),
["mobs_mc:enderman"] = N("@1 was killed by an enderman."),
["mobs_mc:endermite"] = N("@1 was killed by an endermite."),