1
0
Fork 0
MineClone2/mods/ENTITIES/mobs_mc/creeper.lua

127 lines
3.3 KiB
Lua
Raw Normal View History

2017-07-05 01:15:46 +00:00
--License for code WTFPL and otherwise stated in readmes
local S = minetest.get_translator("mobs_mc")
2017-07-05 01:15:46 +00:00
--###################
--################### CREEPER
--###################
mobs:register_mob("mobs_mc:creeper", {
type = "monster",
2020-04-11 00:46:03 +00:00
spawn_class = "hostile",
2017-07-05 01:15:46 +00:00
hp_min = 20,
hp_max = 20,
2020-12-06 14:46:42 +00:00
xp_min = 5,
xp_max = 5,
2017-07-05 01:15:46 +00:00
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"},
},
visual_size = {x=3, y=3},
sounds = {
attack = "tnt_ignite",
2018-09-18 14:14:55 +00:00
death = "mobs_mc_creeper_death",
damage = "mobs_mc_creeper_hurt",
fuse = "tnt_ignite",
2017-07-05 01:15:46 +00:00
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" },
2017-07-05 01:15:46 +00:00
attack_type = "explode",
2020-05-02 16:50:25 +00:00
explosion_strength = 3,
reach = 4,
explosion_timer = 1.5,
allow_fuse_reset = true,
stop_to_explode = true,
2017-07-05 01:15:46 +00:00
-- 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
2020-07-10 14:08:40 +00:00
if not minetest.is_creative_enabled(clicker:get_player_name()) then
2017-07-05 01:15:46 +00:00
-- Wear tool
local wdef = item:get_definition()
item:add_wear(1000)
-- Tool break sound
2017-08-06 12:09:25 +00:00
if item:get_count() == 0 and wdef.sound and wdef.sound.breaks then
2020-04-06 22:55:45 +00:00
minetest.sound_play(wdef.sound.breaks, {pos = clicker:get_pos(), gain = 0.5}, true)
2017-07-05 01:15:46 +00:00
end
clicker:set_wielded_item(item)
end
self._forced_explosion_countdown_timer = self.explosion_timer
2020-04-06 22:55:45 +00:00
minetest.sound_play(self.sounds.attack, {pos = self.object:get_pos(), gain = 1, max_hear_distance = 16}, true)
2017-07-05 01:15:46 +00:00
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
2020-05-10 12:54:43 +00:00
mobs:boom(self, self.object:get_pos(), self.explosion_strength)
2017-07-05 01:15:46 +00:00
self.object:remove()
end
end
end,
on_die = function(self, pos)
-- Drop a random music disc
-- TODO: Only do this if killed by skeleton
if math.random(1, 200) == 1 then
local r = math.random(1, #mobs_mc.items.music_discs)
minetest.add_item({x=pos.x, y=pos.y+1, z=pos.z}, mobs_mc.items.music_discs[r])
end
end,
maxdrops = 2,
drops = {
{name = mobs_mc.items.gunpowder,
chance = 1,
min = 0,
max = 2,},
2017-07-05 22:43:34 +00:00
-- Head
-- TODO: Only drop if killed by charged creeper
{name = mobs_mc.items.head_creeper,
chance = 200, -- 0.5%
2017-07-05 01:15:46 +00:00
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,
})
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)
2017-07-05 01:15:46 +00:00
-- spawn eggs
mobs:register_egg("mobs_mc:creeper", S("Creeper"), "mobs_mc_spawn_icon_creeper.png", 0)