Page 1 of 1

Breeding Mobs

PostPosted: Mon Feb 09, 2015 15:43
by Rochambeau
Hi,

I would like to have the ability to breed peaceful mobs without changing the orginal mobs source code.

My favourite mobs mod is mobs redo. I suggested to include breeding into this mode but it was rejected due to performance issues, which is ok for me.
I still haven't given up the idea and will try to code an mobs redo add-on.

So what my mod would do:

- when giving "aphrodisiac" (maybe a special kind of fruit) to an animal, the animal would turn to a temporary "lovemode"
- the mod would then search for other horny animals within a certain radius
- if found, a new animal would spawn

Is it generally possible to code these functionalities as an mod add-on?

Re: Breeding Mobs

PostPosted: Wed Feb 11, 2015 14:15
by Rochambeau
Ok, so i created my aphrodisiac (combination of different fruits) and now, well I'm stuck.

My next step would be to target a cow, right-click the aphrodisiac and get the cows ID or something. Then, I'd flag the cow as horny and search for potential mates in sight.

But how do I get the cows I'd?

Re: Breeding Mobs

PostPosted: Wed Feb 11, 2015 18:28
by Krock
You can't get an unique ID of an entity, add a variable in the initial_properties and fill it with a random number/hash.

Re: Breeding Mobs

PostPosted: Wed Feb 11, 2015 19:44
by Rochambeau
Given I added that variable to the mobs mod, how can I read it from my breeding mod? Sorry, but I'm a programming newbie.

Re: Breeding Mobs

PostPosted: Fri Feb 13, 2015 06:51
by Rochambeau
What I've got so far:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craftitem("breed:aphrodisiac", {
   description = "Aphrodisiac",
   inventory_image = "breed_aphrodisiac.png",
   on_use = function(itemstack, user, pointed_thing)
       local pos = minetest.get_pointed_thing_position(pointed_thing, true)
       if pos ~= nil then
          minetest.chat_send_all(minetest.pos_to_string(pos))
          minetest.chat_send_all(pointed_thing.type)
          for _,object in ipairs(minetest.get_objects_inside_radius(pos, 20)) do
             if object ~= nil and object:get_luaentity() then
                   minetest.chat_send_all("test")
--                   minetest.chat_send_all(object:get_luaentity().name)
--                   minetest.chat_send_all(object:get_luaentity().itemstring)
             end
         end
         
--      itemstack:take_item()
      return itemstack
       end
   end,
})


I do find mobs around me but i can't get any information about them. How do I get their name or hitpoints or other any other information?

As you can see, I've tested

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.chat_send_all(object:get_luaentity().name)
minetest.chat_send_all(object:get_luaentity().itemstring)


but both lines are not working.

Re: Breeding Mobs

PostPosted: Sun Feb 15, 2015 18:27
by Rochambeau
Well, after scouting a lot of other mods, I'm almost done. Hooray! (will release when it's ready)

One thing that is bothering me: when two mobs do their "magic" I make some hearts appear, which should disappear after a while.
The problem is, the hearts won't disappear (see screenshot).

The code is taken from 4aimobs, but it doesn't seem to work on mine. Can anybody help me out?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local function spawn_hearts(ppp)
   local sdd = minetest.add_particlespawner({
      amount = 15,
      time = 0,
      minpos = {x=ppp.x-0.3,y=ppp.y+0.3,z=ppp.z-0.3},
      maxpos = {x=ppp.x+0.3,y=ppp.y+2.3,z=ppp.z+0.3},
      minvel = {x=-1, y=1, z=-1},
      maxvel = {x=1, y=2, z=1},
      minacc = {x=-1, y=0.5, z=-1},
      maxacc = {x=1, y=2, z=1},
      minexptime = 1,
      maxexptime = 1,
      minsize = 0.5,
      maxsize = 3,
      colliondetection = false,
      vertical = false,
      texture = "heart.png"
      })
      minetest.chat_send_all("erstellt")

      minetest.after(3,function()
         minetest.delete_particlespawner(sdd)
         minetest.chat_send_all("gelöscht")

      end)
end

Re: Breeding Mobs

PostPosted: Sun Feb 15, 2015 18:32
by ExeterDad
Awwww Sheep Love!
Great going on what you've come up with so far :)

Re: Breeding Mobs

PostPosted: Sun Feb 15, 2015 20:00
by Rochambeau
Edit: Not needed anymore. Mobs redo has breeding already included now.

----------------------------------------

What I've got so far:

https://github.com/Rochambeau/breeding

Warning!! May/will/does contain bugs!

Suggestions welcome.