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,
32 on_fire = self.on_fire,
37 mob_register.on_activate = function(self, staticdata, dtime_s)
38 self.object:set_armor_groups({immortal = 1})
39 --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
40 self.object:set_acceleration(def.gravity)
41 if string.sub(staticdata, 1, string.len("return")) == "return" then
42 local data = minetest.deserialize(staticdata)
43 if data and type(data) == "table" then
44 --self.range = data.range
46 self.hunger = data.hunger
47 self.hostile = data.hostile
48 self.hostile_timer = data.hostile_timer
49 self.death_animation_timer = data.death_animation_timer
51 self.tnt_timer = data.tnt_timer
52 self.tnt_tick_timer = data.tnt_tick_timer
53 self.tnt_mod_state = data.tnt_mod_state
54 self.punch_timer = data.punch_timer
55 self.projectile_timer = data.projectile_timer
56 self.scared = data.scared
57 self.scared_timer = data.scared_timer
58 self.c_mob_data = data.c_mob_data
59 self.on_fire = data.on_fire
64 self.object:set_animation(def.standing_frame, 0, 0, true)
65 self.current_animation = 0
66 self.object:set_hp(self.hp)
67 self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
71 if self.head_bone then
72 self.object:set_bone_position(self.head_bone, self.head_position_correction, vector.new(0,0,0))
75 self.object:set_armor_groups({immortal = 1})
77 if self.custom_on_activate then
78 self.custom_on_activate(self)
81 if self.on_fire == true then
82 start_fire(self.object)
85 --use this to handle the global mob table
86 minetest.after(0,function()
87 self.deactivating = true
91 --this is the info on the mob
92 mob_register.debug_nametag = function(self,dtime)
93 --we're doing this to the child because the nametage breaks the
94 --animation on the mob's body
96 --we add in items we want to see in this list
97 local debug_items = {"hostile","hostile_timer"}
99 for _,item in pairs(debug_items) do
100 if self[item] ~= nil then
101 text = text..item..": "..tostring(self[item]).."\n"
104 self.object:set_nametag_attributes({