]> git.lizzy.rs Git - Crafter.git/commitdiff
Fix mob count handling
authoroilboi <47129783+oilboi@users.noreply.github.com>
Fri, 5 Jun 2020 11:09:27 +0000 (07:09 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Fri, 5 Jun 2020 11:09:27 +0000 (07:09 -0400)
README.md
mc_sound_attributes.txt
mods/mob/api/api_hook.lua
mods/mob/api/data_handling.lua

index 53ea21a595d0c011316ce6a0335a636c3bdb9eff..bf413915ab9426c289c95cc4b6e27a9625ea43e8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -44,6 +44,8 @@ enable_mod_channels = true
 - Tuned a lot of things
 - Made armor work
 - Added in Krock's awesome Colored Names mod for csm chat
+- Added sheep
+- Fixed global mob handling
 ---
 
 
index 32facb2d535f65b62859d03597ea890d4433f8b8..dbf471138e0150625c3ae0080444fb22366ca78f 100644 (file)
@@ -399,4 +399,6 @@ LICENSED UNDER ATTRIBUTION 3.0 UNPORTED (CC BY 3.0)
 "bd.wav" by altemark
 LICENSED UNDER ATTRIBUTION 3.0 UNPORTED (CC BY 3.0)
 "SheepAndLambs.mp3"
-Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)
\ No newline at end of file
+Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)
+"Match Light.wav" - creeper dying
+https://freesound.org/people/Krisboruff/sounds/17748/ Attribution 3.0 Unported (CC BY 3.0)
\ No newline at end of file
index e2763521e53d9fae5e63474ad5c6cfa8ac18ec2a..5f09e6290991c12e4e4cea6b4b9c073d09cbc465 100644 (file)
@@ -136,6 +136,8 @@ mob_register.custom_on_punch = def.custom_on_punch
 
 mob_register.c_mob_data = def.c_mob_data
 
+mob_register.deactivating = false
+
 if def.pathfinds then
        --mob_register.path = {}
        mob_register.pathfinding_timer = 0
index 9afa35b9750d384f856ca028bce74b80905d30a4..ac36fa4531ee75209e533c36a627b0ab6471537f 100644 (file)
@@ -1,6 +1,18 @@
 --
 mobs.create_data_handling_functions = function(def,mob_register)
        mob_register.get_staticdata = function(self)
+               if self.deactivating == false then
+                       global_mob_amount = global_mob_amount + 1
+                       print("Mob Spawned. Current Mobs: "..global_mob_amount)
+               elseif self.deactivating == true then
+                       minetest.after(0, function()
+                               if not self.object:get_luaentity() then
+                                       global_mob_amount = global_mob_amount - 1
+                                       print("Mob Deactivated. Current Mobs: "..global_mob_amount)
+                               end
+                       end)
+               end
+
                return minetest.serialize({
                        --range = self.range,
                        hp = self.hp,
@@ -22,8 +34,6 @@ mobs.create_data_handling_functions = function(def,mob_register)
 
 
        mob_register.on_activate = function(self, staticdata, dtime_s)
-               global_mob_amount = global_mob_amount + 1
-               --print("Mobs Spawned. Current Mobs: "..global_mob_amount)
                self.object:set_armor_groups({immortal = 1})
                --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
                self.object:set_acceleration(def.gravity)
@@ -66,6 +76,11 @@ mobs.create_data_handling_functions = function(def,mob_register)
                        self.custom_on_activate(self)
                end
                --self.object:set_yaw(math.pi*math.random(-1,1)*math.random())
+
+               --use this to handle the global mob table
+               minetest.after(0,function()
+                       self.deactivating = true
+               end)
        end
 
        --this is the info on the mob