What can you do with Mob API's

Post Reply
TheFourthPlace
Member
Posts: 13
Joined: Mon Jan 23, 2017 03:45

What can you do with Mob API's

by TheFourthPlace » Post

(First post on this board)

I've played minecraft on xbox for years and as a competent c++ coder I built my own minecraft like engine from scratch to scratch an itch MC just never helped me with. However there is a lot to it, so I was looking at perhaps just using minetest as the base.

So, as part of a kind of recon of the minetest world I was curious as to where the lines of demark are between lua and c++ code.

I downloaded simple_mobs to have a look and found that lua in init is data definition and in api.lua does in fact look like what appears to be reasonably capable code for npc character independence.

But, what I'm searching for is how I can add better mob behavior. For example, if I wanted some kobolds to travel in a pack, or for them to perhaps perform an ambush or for them to found a kobold encampment I had always assumed I would just have to write the code in c++. Given however that pathfinding is likely already sorted, the 'ai' type code I'm looking to add is not processor intensive then I guess there is no reason to.

Which leads me to the question... where is the demark point? What things can I just not do with lua in relation to mobs? For example if I wanted a raiding party, they would have to share information about their location and group behavior. That state needs to be store somewhere globally available to each mob instance.

Idea's?

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: What can you do with Mob API's

by taikedz » Post

There are no "formal" mob api's in Minetest - that's left to the modding community rather than an engine or core-game part.

There are currently (as far as I am aware) 3 popular mob engines:
I think the current popularity of mobs_redo is in part because if you want to just focus on modelling and texturing, but no coding, it's the easiest choice; a lot of the basic AI for movement and hunting down the player is dealt with. I tried having a quick look at MOBF and the documentation is quite complex; I have not looked at CME in a while.

That said, it doesn't necessarily have the features you describe. Hunting in packs and establishing settlements is outside of its scope.

If you were to define custom routines of your own, you could feed them to mobs_redo in the do_custom, or append them to mobs_redo in a forked version of the code.

For the other engines, I cannot say I am sufficiently familiar with them to tell what you could or could not do with them.

Arguably, there is little you could not-do if you coded the AI yourself, but that would then be a separate engine of your own.

User avatar
TenPlus1
Member
Posts: 3728
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: What can you do with Mob API's

by TenPlus1 » Post

Pack hunting could be achieved by using the do_custom function in mobs redo, a quick search surrounding the mob (say a wolf) to find other wolves and set the self.following to that entity so it will be followed around.

twoelk
Member
Posts: 1482
Joined: Fri Apr 19, 2013 16:19
GitHub: twoelk
IRC: twoelk
In-game: twoelk
Location: northern Germany

Re: What can you do with Mob API's

by twoelk » Post

uuuuuh
herd movements, swarms, flocks, packs, units of soldiers or warriors ...
yeah many have been dreaming of these for quite a while
some mods of interest may be:
Goblins
Alive AI
Smart PVP Mobs (esmobs)
Open AI

none of these does exactly what you may have in mind but each could contain parts that might be usefull in creating such features as mobs moving in organized groups.

This list on the wiki contains links to most mods that contain mobs.

It allready is rather irritating when mobs pile up to climb over fences or reach up to the 1x1 pillar you thought was safe for the night but imagening them moving intelligently in organized groups would probably be freaking awesome not to say pretty scary. Now if someone would get them to hammer some eirie drums and lay an ambush that others chase you into - goblins or esmobs are pretty creepy allready, now if the worked in groups ------------

er nope,
I think I will think of nice harmless herds of
sheep
or deer
or
or
or wolves ---- eeek - run, run for your life
Last edited by twoelk on Tue Feb 21, 2017 16:09, edited 1 time in total.

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: What can you do with Mob API's

by TumeniNodes » Post

But, if one can set mobs to "follow" (meaning they follow the player), does that not imply that they might also be able to be set to follow another entity? as in another mob? So ideally, one mob could be set as the one which the others follow?
Probably just talking out my butt, but... just a quick thought I had. Alive AI and Open AI s seem to be the best examples of "follow"?
A Wonderful World

User avatar
TenPlus1
Member
Posts: 3728
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: What can you do with Mob API's

by TenPlus1 » Post

That's exctly what I said above, the do_custom in mobs redo can make mobs follow one another in packs.

TheFourthPlace
Member
Posts: 13
Joined: Mon Jan 23, 2017 03:45

Re: What can you do with Mob API's

by TheFourthPlace » Post

Kind thanks TenPlus1, I'll look in to this.

Just curious so I know how to start with scripting for mobs. The mobs_redo package seems to do lots of things like registration, which I presume is called out of of a c++ luaL_dofile call. Due to this each call will have a variable context limited to that scripts execution. Since I don't know minetest that well yet (but I do have my own 60k+ line game using lua) I'm curious as to how scripts running in lua can maintain state. Is there a mechanism for minimally storing persistent global variable so when I associate a mob with a group I can do a lookup to see which group it's a part of?

Kind thanks....

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: What can you do with Mob API's

by rubenwardy » Post

The global state of Lua is maintained whilst the game is running [1], and mods can serialise and write data to files in the world (saved game) directory.

Entities are only loaded when the MapBlock ("chunks" in MC, 16x16 nodes) they are in is loaded. When the mapblock is unloaded, a function on the entity is called which allows them to save their data.

[1] - a common thing is to make a global variable which shares its name with the mod. For example, the carts mod has a global variable called "carts". This carts variable is a table which has API functions in it. If the cart mod needed to store data, it may store it in this variable. It's also worth noting the the scope for a file is maintained providing the file has visible functions - ie: if it's possible for a function in the file to be called again, the local scope of that file won't be destroyed. This means that you can store private data as local.

I suggest reading my online modding book to get started on modding: http://rubenwardy.com/minetest_modding_book/
Also see the developer's wiki for mod and engine help: http://dev.minetest.net/
Although please note that the wiki may be out of date, the canonical source of information is the Lua API Reference: https://github.com/minetest/minetest/bl ... ua_api.txt

I also suggest running a latest-dev build, for all those call extra features :D
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

TheFourthPlace
Member
Posts: 13
Joined: Mon Jan 23, 2017 03:45

Re: What can you do with Mob API's

by TheFourthPlace » Post

Kind thanks Ruben. When I used Lua on my own game is was mostly for startup scripts and to define the GUI so I never had to really worry about the lifespan of the script during the game.

Your information on mapblocks is useful. I was wondering how a Kobold village would save it's current state if I walked too far away. I have noticed on MC Xbox that crops don't grow if you are too far away from them so expected that the same kind of destructor like code would be called. It's good to know for sure.

I'll go over your book now... kind thanks.

User avatar
domtron vox
Member
Posts: 111
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

Re: What can you do with Mob API's

by domtron vox » Post

I always wonder why people forget about MirceaKitsune's Creatures mod. Here is a link: viewtopic.php?f=11&t=9240 Last updated about a year ago so maybe that is why people forget about it?

Has some interesting features like compositing images for fur patterns and clothing and differentiating genders. You can code if you want/need to add special actions, but it is mostly just configuration.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests