123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- local search_replace2 = function(
- self,
- search_rate,
- search_rate_above,
- search_rate_below,
- search_offset,
- search_offset_above,
- search_offset_below,
- replace_rate,
- replace_what,
- replace_with)
- if math.random(1, search_rate) == 1 then
- local pos = self.object:get_pos() --
- local pos1 = self.object:get_pos()
- local pos2 = self.object:get_pos()
- -- if we are looking, will we look below and by how much?
- if math.random(1, search_rate_below) == 1 then
- pos1.y = pos1.y - search_offset_below
- end
- -- if we are looking, will we look above and by how much?
- if math.random(1, search_rate_above) == 1 then
- pos2.y = pos2.y + search_offset_above
- end
- pos1.x = pos1.x - search_offset
- pos1.z = pos1.z - search_offset
- pos2.x = pos2.x + search_offset
- pos2.z = pos2.z + search_offset
- local nodelist = minetest.find_nodes_in_area(pos1, pos2, replace_what)
- if #nodelist > 0 then
- for key,value in pairs(nodelist) do
- -- ok we see some nodes around us, are we going to replace them?
- if math.random(1, replace_rate) == 1 then
- minetest.set_node(value, {name = replace_with})
- end
- minetest.sound_play(self.sounds.replace, {
- object = self.object,
- max_hear_distance = self.sounds.distance
- })
- end
- end
- end
- end
- local goblin_sounds = {
- random = "goblins_goblin_ambient",
- warcry = "goblins_goblin_attack",
- attack = "goblins_goblin_attack",
- damage = "goblins_goblin_damage",
- death = "goblins_goblin_death",
- distance = 7,
- }
- mobs:register_mob('fantasy_mobs:goblin', {
- description = 'Goblin',
- type = 'monster',
- passive = false,
- damage = 8,
- damage_max = 12,
- damage_chance = 95,
- attack_type = 'dogfight',
- hp_min = 20,
- hp_max = 50,
- armor = 100,
- collisionbox = {-0.35,-1,-0.35, 0.35,-.1,0.35},
- visual = 'mesh',
- mesh = 'fantasy_goblin.b3d',
- textures = {
- {'fantasy_goblin_1.png'},
- {'fantasy_goblin_2.png'},
- {'fantasy_goblin_3.png'},
- {'fantasy_goblin_4.png'},
- {'fantasy_goblin_5.png'},
- {'fantasy_goblin_6.png'},
- {'fantasy_goblin_7.png'},
- {'fantasy_goblin_8.png'},
- {'fantasy_goblin_9.png'},
- {'fantasy_goblin_10.png'},
- {'fantasy_goblin_11.png'},
- {'fantasy_goblin_12.png'},
- },
- makes_footstep_sound = true,
- sounds = goblin_sounds,
- walk_velocity = 2,
- run_velocity = 3,
- jump = true,
- drops = {
- {name = 'default:mossycobble', chance = 1, min = 1, max = 3},
- {name = 'default:apple', chance = 2, min = 1, max = 2},
- {name = 'default:torch', chance = 3, min = 1, max = 10},
- {name = 'default:coal_lump', chance = 10, min = 1, max = 15},
- {name = 'stations:scroll_anti_fire', chance = 30, min = 1, max = 1},
- {name = 'stations:scroll_sulfur_dust', chance = 30, min = 1, max = 1},
- {name = 'stations:scroll_gunpowder', chance = 30, min = 1, max = 1},
- {name = 'default:diamond', chance = 500, min = 0, max = 20},
- {name = 'farming:coffee_beans', chance = 300, min = 0, max = 5},
- {name = 'stations:scroll_ash', chance = 1, min = 0, max = 1},
- {name = 'epic:reaver', chance = 150, min = 0, max = 1},
- {name = 'illuminati:cone_off', chance = 150, min = 0, max = 1},
- {name = 'illuminati:core_off', chance = 150, min = 0, max = 1},
- {name = 'fantasy_mobs:goblin_sketch', chance = 10, min = 1, max = 1},
- },
- water_damage = 0,
- lava_damage = 2,
- light_damage = 0,
- follow = {'default:diamond', 'default:apple', 'farming:bread'},
- view_range = 10,
- animation = {
- speed_normal = 30,
- speed_run = 30,
- stand_start = 0,
- stand_end = 79,
- walk_start = 168,
- walk_end = 187,
- run_start = 168,
- run_end = 187,
- punch_start = 200,
- punch_end = 219,
- },
- replace_what = {'default:torch', 'default:torch_wall', 'default:torch_ceiling'},
- do_custom = function(self)
- search_replace2(
- self,
- 10, --search_rate
- 1, --search_rate_above
- 1, --search_rate_below
- 1, --search_offset
- 2, --search_offset_above
- 1, --search_offset_below
- 5, --replace_rate
- {'default:torch', 'default:torch_wall', 'default:torch_ceiling'}, --replace_what
- 'air') --replace_with
- end,
- })
- mobs:spawn({
- name = 'fantasy_mobs:goblin',
- nodes = {'default:mossycobble'},
- max_light = 13,
- min_height = -31000,
- max_height = -10,
- interval = 30,
- chance = 250,
- active_object_count = 10,
- })
|