]> git.lizzy.rs Git - Crafter.git/commitdiff
Tweak mob magnetic collision detection to work better
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 02:17:31 +0000 (22:17 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 02:17:31 +0000 (22:17 -0400)
README.md
mods/mob/api/interaction.lua
mods/mob/init.lua

index 9da2736735d5df7191d94262e0e2813210e5d1fb..76401d9733cc334c26f151af76d24cd4913ea91f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -139,6 +139,7 @@ enable_mod_channels = true
 - Add in better particles for eating and treecapitator
 - Make player model's head pitch follow the player's look pitch
 - Make music play during certain parts of the day/night
+- Tweaked collision detection for mobs and make slime collision radius fit their size
 ---
 
 
@@ -177,7 +178,7 @@ enable_mod_channels = true
 
 ### snowman
 - you can put a pumpkin on it's head to make it survive when it's not snowing out
-- drops snowballs and coal
+- drops snowballs, coal, or carrot
 
 ### sheep
 - sheep can be punched to drop wool without damage
@@ -206,16 +207,11 @@ enable_mod_channels = true
 - drops all nodes that it's made of when killed
 
 
-### Exploder
-- sneaks up on you and then explodes
-- drops gun powder
-
 
 ---
 
 
 ## Game Mechanics:
-- xp (edit the node drops code to check if node has tag for xp)
 - brewing
 - enchanting/upgrading
 - magic (wands, spells, etc)
@@ -242,8 +238,6 @@ enable_mod_channels = true
 
 
 ### HALLOWEEN!
-- lava acts like water in the nether but lava in the other worlds
-- pumpkins
 - Jack O'Lanterns
 - corn and corn stalks
 - decorations
index a98d8f4f8f522be16626a4d4c048a34c3f0f9f8c..af057c04928fbdcf8ccdbdfe1e1381482a19aead 100644 (file)
@@ -40,28 +40,33 @@ mobs.create_interaction_functions = function(def,mob_register)
                local pos = self.object:get_pos()
                --do collision detection from the base of the mob
                pos.y = pos.y - self.object:get_properties().collisionbox[2]
-               for _,object in ipairs(minetest.get_objects_inside_radius(pos, self.collision_boundary)) do
+               for _,object in ipairs(minetest.get_objects_inside_radius(pos, self.collision_boundary*2)) do
                        if object:is_player() or object:get_luaentity().mob == true then
                                local pos2 = object:get_pos()
                                
-                               local dir = vector.direction(pos,pos2)
-                               dir.y = 0
-                               
-                               --eliminate mob being stuck in corners
-                               if dir.x == 0 and dir.z == 0 then
-                                       dir = vector.new(math.random(-1,1)*math.random(),0,math.random(-1,1)*math.random())
-                               end
-                               
-                               local velocity = vector.multiply(dir,1.1)
-                               
-                               local vel1 = vector.multiply(velocity, -1)
-                               local vel2 = velocity
-                               self.object:add_velocity(vel1)
-                               
-                               if object:is_player() then
-                                       object:add_player_velocity(vel2)
-                               else
-                                       object:add_velocity(vel2)
+                               local distance = vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z))
+
+                               if distance <= self.collision_boundary then
+
+                                       local dir = vector.direction(pos,pos2)
+                                       dir.y = 0
+                                       
+                                       --eliminate mob being stuck in corners
+                                       if dir.x == 0 and dir.z == 0 then
+                                               dir = vector.new(math.random(-1,1)*math.random(),0,math.random(-1,1)*math.random())
+                                       end
+                                       
+                                       local velocity = vector.multiply(dir,1.1)
+                                       
+                                       local vel1 = vector.multiply(velocity, -1)
+                                       local vel2 = velocity
+                                       self.object:add_velocity(vel1)
+                                       
+                                       if object:is_player() then
+                                               object:add_player_velocity(vel2)
+                                       else
+                                               object:add_velocity(vel2)
+                                       end
                                end
                        end
                end
index d5f87ea1c1a4739bc9201aad9c12fdf6e0a59c70..ed66485b60d623b7ed3a0c61a3db7e307326d88a 100644 (file)
@@ -291,6 +291,7 @@ mobs.register_mob(
        textures = {
                "slime.png"
        },
+       collision_boundary = 2.5,
        is_visible = true,
        pointable = true,
        automatic_face_movement_dir = 90,
@@ -329,6 +330,7 @@ mobs.register_mob(
        textures = {
                "slime.png"
        },
+       collision_boundary = 1.25,
        is_visible = true,
        pointable = true,
        automatic_face_movement_dir = 90,
@@ -368,6 +370,7 @@ mobs.register_mob(
        textures = {
                "slime.png"
        },
+       collision_boundary = 0.6,
        is_visible = true,
        pointable = true,
        automatic_face_movement_dir = 90,