diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index f1648525a..ab0bca9d6 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -21,7 +21,8 @@ mobs:register_mob("mobs_mc:creeper", { visual = "mesh", mesh = "mobs_mc_creeper.b3d", textures = { - {"mobs_mc_creeper.png"}, + {"mobs_mc_creeper.png", + "mobs_mc_empty.png"}, }, visual_size = {x=3, y=3}, sounds = { @@ -39,7 +40,10 @@ mobs:register_mob("mobs_mc:creeper", { attack_type = "explode", explosion_strength = 3, - reach = 4, + explosion_radius = 3.5, + explosion_damage_radius = 3.5, + explosiontimer_reset_radius = 6, + reach = 3, explosion_timer = 1.5, allow_fuse_reset = true, stop_to_explode = true, @@ -124,6 +128,127 @@ mobs:register_mob("mobs_mc:creeper", { view_range = 16, }) +mobs:register_mob("mobs_mc:creeper_charged", { + type = "monster", + spawn_class = "hostile", + hp_min = 20, + hp_max = 20, + xp_min = 5, + xp_max = 5, + collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.69, 0.3}, + pathfinding = 1, + visual = "mesh", + mesh = "mobs_mc_creeper.b3d", + textures = { + {"mobs_mc_creeper.png", + "mobs_mc_creeper_charge.png"}, + }, + visual_size = {x=3, y=3}, + sounds = { + attack = "tnt_ignite", + death = "mobs_mc_creeper_death", + damage = "mobs_mc_creeper_hurt", + fuse = "tnt_ignite", + explode = "tnt_explode", + distance = 16, + }, + makes_footstep_sound = true, + walk_velocity = 1.05, + run_velocity = 2.1, + runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, + attack_type = "explode", + + explosion_strength = 5, + explosion_radius = 8, + explosion_damage_radius = 8, + explosiontimer_reset_radius = 6, + reach = 3, + explosion_timer = 1.5, + allow_fuse_reset = true, + stop_to_explode = true, + + -- Force-ignite creeper with flint and steel and explode after 1.5 seconds. + -- TODO: Make creeper flash after doing this as well. + -- TODO: Test and debug this code. + on_rightclick = function(self, clicker) + if self._forced_explosion_countdown_timer ~= nil then + return + end + local item = clicker:get_wielded_item() + if item:get_name() == mobs_mc.items.flint_and_steel then + if not minetest.is_creative_enabled(clicker:get_player_name()) then + -- Wear tool + local wdef = item:get_definition() + item:add_wear(1000) + -- Tool break sound + if item:get_count() == 0 and wdef.sound and wdef.sound.breaks then + minetest.sound_play(wdef.sound.breaks, {pos = clicker:get_pos(), gain = 0.5}, true) + end + clicker:set_wielded_item(item) + end + self._forced_explosion_countdown_timer = self.explosion_timer + minetest.sound_play(self.sounds.attack, {pos = self.object:get_pos(), gain = 1, max_hear_distance = 16}, true) + end + end, + do_custom = function(self, dtime) + 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:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) + self.object:remove() + end + end + end, + on_die = function(self, pos, cmi_cause) + -- Drop a random music disc when killed by skeleton or stray + if cmi_cause and cmi_cause.type == "punch" then + local luaentity = cmi_cause.puncher and cmi_cause.puncher:get_luaentity() + if luaentity and luaentity.name:find("arrow") then + local shooter_luaentity = luaentity._shooter and luaentity._shooter:get_luaentity() + if shooter_luaentity and (shooter_luaentity.name == "mobs_mc:skeleton" or shooter_luaentity.name == "mobs_mc:stray") then + minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, mobs_mc.items.music_discs[math.random(1, #mobs_mc.items.music_discs)]) + end + end + end + end, + maxdrops = 2, + drops = { + {name = mobs_mc.items.gunpowder, + chance = 1, + min = 0, + max = 2, + looting = "common",}, + + -- Head + -- TODO: Only drop if killed by charged creeper + {name = mobs_mc.items.head_creeper, + chance = 200, -- 0.5% + min = 1, + max = 1,}, + }, + animation = { + speed_normal = 24, + speed_run = 48, + stand_start = 0, + stand_end = 23, + walk_start = 24, + walk_end = 49, + run_start = 24, + run_end = 49, + hurt_start = 110, + hurt_end = 139, + death_start = 140, + death_end = 189, + look_start = 50, + look_end = 108, + }, + floats = 1, + fear_height = 4, + view_range = 16, + --Having trouble when fire is placed with lightning + fire_resistant = true, + glow = 3, +}) mobs:spawn_specific("mobs_mc:creeper", mobs_mc.spawn.solid, {"air"}, 0, 7, 20, 16500, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d index bfeb5a6b6..54341579c 100644 Binary files a/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d and b/mods/ENTITIES/mobs_mc/models/mobs_mc_creeper.b3d differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_creeper_charge.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_creeper_charge.png new file mode 100644 index 000000000..a5e8ab443 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_creeper_charge.png differ diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_empty.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_empty.png new file mode 100644 index 000000000..809f22b69 Binary files /dev/null and b/mods/ENTITIES/mobs_mc/textures/mobs_mc_empty.png differ diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 3d6a85e51..5c9fe7e61 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -159,10 +159,13 @@ lightning.strike = function(pos) obj = minetest.add_entity(pos2, "mobs_mc:witch") obj:set_yaw(rot) ]] - -- TODO: creeper → charged creeper (no damage) + -- charged creeper elseif lua.name == "mobs_mc:creeper" then - - -- Other mobs: Just damage + local rot = obj:get_yaw() + obj:remove() + obj = minetest.add_entity(pos2, "mobs_mc:creeper_charged") + obj:set_yaw(rot) + -- Other mobs: Just damage else obj:set_hp(obj:get_hp()-5, { type = "punch", from = "mod" }) end @@ -256,4 +259,3 @@ minetest.register_chatcommand("lightning", { return true end, }) -