2 mobs.create_data_handling_functions = function(def,mob_register)
3 mob_register.get_staticdata = function(self)
4 if self.deactivating == false then
5 global_mob_amount = global_mob_amount + 1
6 --print("Mob Spawned. Current Mobs: "..global_mob_amount)
7 elseif self.deactivating == true then
8 minetest.after(0, function()
9 if not self.object:get_luaentity() then
10 global_mob_amount = global_mob_amount - 1
11 --print("Mob Deactivated. Current Mobs: "..global_mob_amount)
16 return minetest.serialize({
20 hostile = self.hostile,
21 hostile_timer = self.hostile_timer,
22 death_animation_timer = self.death_animation_timer,
24 tnt_timer = self.tnt_timer,
25 tnt_tick_timer = self.tnt_tick_timer,
26 tnt_mod_state = self.tnt_mod_state,
27 punch_timer = self.punch_timer,
28 projectile_timer = self.projectile_timer,
30 scared_timer = self.scared_timer,
31 c_mob_data = self.c_mob_data,
36 mob_register.on_activate = function(self, staticdata, dtime_s)
37 self.object:set_armor_groups({immortal = 1})
38 --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
39 self.object:set_acceleration(def.gravity)
40 if string.sub(staticdata, 1, string.len("return")) == "return" then
41 local data = minetest.deserialize(staticdata)
42 if data and type(data) == "table" then
43 --self.range = data.range
45 self.hunger = data.hunger
46 self.hostile = data.hostile
47 self.hostile_timer = data.hostile_timer
48 self.death_animation_timer = data.death_animation_timer
50 self.tnt_timer = data.tnt_timer
51 self.tnt_tick_timer = data.tnt_tick_timer
52 self.tnt_mod_state = data.tnt_mod_state
53 self.punch_timer = data.punch_timer
54 self.projectile_timer = data.projectile_timer
55 self.scared = data.scared
56 self.scared_timer = data.scared_timer
57 self.c_mob_data = data.c_mob_data
62 self.object:set_animation(def.standing_frame, 0, 0, true)
63 self.current_animation = 0
64 self.object:set_hp(self.hp)
65 self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
69 if self.head_bone then
70 self.object:set_bone_position(self.head_bone, self.head_position_correction, vector.new(0,0,0))
73 self.object:set_armor_groups({immortal = 1})
75 if self.custom_on_activate then
76 self.custom_on_activate(self)
78 --self.object:set_yaw(math.pi*math.random(-1,1)*math.random())
80 --use this to handle the global mob table
81 minetest.after(0,function()
82 self.deactivating = true
86 --this is the info on the mob
87 mob_register.debug_nametag = function(self,dtime)
88 --we're doing this to the child because the nametage breaks the
89 --animation on the mob's body
91 --we add in items we want to see in this list
92 local debug_items = {"hostile","hostile_timer"}
94 for _,item in pairs(debug_items) do
95 if self[item] ~= nil then
96 text = text..item..": "..tostring(self[item]).."\n"
99 self.object:set_nametag_attributes({