2 mobs.create_data_handling_functions = function(def,mob_register)
3 mob_register.get_staticdata = function(self)
4 return minetest.serialize({
8 hostile = self.hostile,
9 hostile_timer = self.hostile_timer,
10 death_animation_timer = self.death_animation_timer,
12 tnt_timer = self.tnt_timer,
13 tnt_tick_timer = self.tnt_tick_timer,
14 tnt_mod_state = self.tnt_mod_state,
15 punch_timer = self.punch_timer,
16 projectile_timer = self.projectile_timer
21 mob_register.on_activate = function(self, staticdata, dtime_s)
22 global_mob_amount = global_mob_amount + 1
23 print("Mobs Spawned. Current Mobs: "..global_mob_amount)
24 self.object:set_armor_groups({immortal = 1})
25 --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
26 self.object:set_acceleration(def.gravity)
27 if string.sub(staticdata, 1, string.len("return")) == "return" then
28 local data = minetest.deserialize(staticdata)
29 if data and type(data) == "table" then
30 --self.range = data.range
32 self.hunger = data.hunger
33 self.hostile = data.hostile
34 self.hostile_timer = data.hostile_timer
35 self.death_animation_timer = data.death_animation_timer
37 self.tnt_timer = data.tnt_timer
38 self.tnt_tick_timer = data.tnt_tick_timer
39 self.tnt_mod_state = data.tnt_mod_state
40 self.punch_timer = data.punch_timer
41 self.projectile_timer = data.projectile_timer
46 self.object:set_animation(def.standing_frame, 0, 0, true)
47 self.current_animation = 0
48 self.object:set_hp(self.hp)
49 self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
53 if self.head_bone then
54 self.object:set_bone_position(self.head_bone, self.head_position_correction, vector.new(0,0,0))
57 self.object:set_armor_groups({immortal = 1})
58 --self.object:set_yaw(math.pi*math.random(-1,1)*math.random())
61 --this is the info on the mob
62 mob_register.debug_nametag = function(self,dtime)
63 --we're doing this to the child because the nametage breaks the
64 --animation on the mob's body
66 --we add in items we want to see in this list
67 local debug_items = {"hostile","hostile_timer"}
69 for _,item in pairs(debug_items) do
70 if self[item] ~= nil then
71 text = text..item..": "..tostring(self[item]).."\n"
74 self.object:set_nametag_attributes({