123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- defense_mob_api.register_mob("mob_paniki:paniki", {
- hp_max = 7,
- collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
- mesh = "mob_paniki_paniki.b3d",
- textures = {"mob_paniki_paniki.png"},
- makes_footstep_sound = false,
- animation = {
- idle = {a=0, b=29, rate=50},
- attack = {a=60, b=89, rate=50},
- move = {a=30, b=59, rate=75},
- move_attack = {a=60, b=89, rate=75},
- },
- mass = 1,
- movement = "air",
- move_speed = 16,
- attack_damage = 1,
- attack_range = 1.1,
- attack_interval = 1.2,
- last_hp = 3,
- flee_timer = 0,
- flee_timer = 0,
- on_step = function(self, dtime)
- defense_mob_api.default_prototype.on_step(self, dtime)
- if self.flee_timer > 0
- then
- local nearest = self:find_target()
- local pos = self.object:get_pos()
- local delta = vector.subtract(pos, nearest.player:get_pos())
- local x = delta.x
- delta.x = delta.x - delta.z * 0.4
- delta.z = delta.z + x * 0.4
- self.destination = vector.add(pos, delta)
- if self.flee_timer > 0 and self.last_attack_time + 0.25 < self.timer
- then
- self.flee_timer = self.flee_timer - dtime
- end
- else
- self:hunt()
- if self.object:get_hp() < self.last_hp
- then
- self.flee_timer = 0.5 + math.random() / (self.object:get_hp() + 1)
- end
- self.last_hp = self.object:get_hp()
- end
- end,
- attack = function(self, obj, dir)
- defense_mob_api.default_prototype.attack(self, obj)
- self.flee_timer = math.random() * 0.5
- end,
- })
- minetest.register_alias("paniki", "mob_paniki:paniki")
|