Breeding Mobs

Post Reply
Rochambeau
Member
Posts: 119
Joined: Tue Sep 23, 2014 11:37

Breeding Mobs

by Rochambeau » Post

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: 119
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Post

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
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Breeding Mobs

by Krock » Post

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.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

Re: Breeding Mobs

by Rochambeau » Post

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: 119
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Post

What I've got so far:

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

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: 119
Joined: Tue Sep 23, 2014 11:37

Re: Breeding Mobs

by Rochambeau » Post

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?

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 436 times

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: Breeding Mobs

by ExeterDad » Post

Awwww Sheep Love!
Great going on what you've come up with so far :)

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

Re: Breeding Mobs

by Rochambeau » Post

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.

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 11 guests