Breeding Mobs

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Breeding Mobs

by Rochambeau » Mon Feb 09, 2015 15:43

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?
 

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Wed Feb 11, 2015 14:15

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?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Breeding Mobs

by Krock » Wed Feb 11, 2015 18:28

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Wed Feb 11, 2015 19:44

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.
 

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Fri Feb 13, 2015 06:51

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.
 

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Sun Feb 15, 2015 18:27

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
Attachments
sparkle.png
sparkle.png (427.17 KiB) Viewed 1811 times
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: Breeding Mobs

by ExeterDad » Sun Feb 15, 2015 18:32

Awwww Sheep Love!
Great going on what you've come up with so far :)
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

Rochambeau
Member
 
Posts: 68
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Sun Feb 15, 2015 20:00

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.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron