rp_mobs: The new Repixture Mobs API (feedback wanted)

Post Reply
User avatar
Wuzzy
Member
Posts: 5100
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

rp_mobs: The new Repixture Mobs API (feedback wanted)

by Wuzzy » Post

In the last weeks, I've worked my ass off by completely redoing the whole mobs system behind Repixture.
It's still not released but I've made significant progress. It can be seen here.

Repixture used to be based on an ancient Mobs Redo fork but this is now gone in the developer version. I've created a completely new Mobs API from scratch, specifically for Repixture. Mobs Redo has good default features but is extremely unflexible and has a clunky code base, so it needed to go.

You may wonder, why yet another Mobs API while there are so many others? Well, I've looked at the other ones but either they had bad performance, were poorly to extend, or lacked many essential features, or they were not documented at all. I really tried to *not* reinvent the wheel but eventually I caved and did it anyway.

rp_mobs

rp_mobs is the core of the new Repixture mobs system. I want to talk about some of the (probably?) innovative approaches:
  • (almost) everything is optional: Mobs only run the code and features they need;
  • Offer a common baseline: Important features that many mobs need are available by default
  • Flexibility: I make very little assumptions about mobs so the actual mobs aren't contrained in what they can do
  • I reimplemented most key features of Mobs Redo like breeding, capturing
  • Player-like: Mobs need to support features that players have: Drowning, node damage, disable_jump, climbing, fall-damage, etc.
  • Documentation! The lack of documentation was the most frustrating part of the other mob "APIs" so I want to do better than them
I see rp_mobs as kind of a "middle ground" between Mobs Redo and mobkit. Mobs Redo has a good baseline of built-in features and makes it easy to add new mobs but everything is too hardcoded and it's very unflexible. mobkit is extremely flexible but offers so little features that it basically feels more like a small set of helper functions than a complete API. I might as well code the mobs directly as entities without any API (fun fact: this is what I did for Shadow Forest).

The task system

The heart of rp_mobs is the task system. Every mob has a number of task queues which in turn contain tasks which in turn contain microtasks. Microtasks contain the actual code and it can be basically anything.

Tasks are for high-level goals, like "find some food" while microtasks are the sequence of concrete steps to reach that goal, like "walk to coordinate XYZ", "jump", etc. Microtasks and tasks run sequentially, i.e. in the same order you put them in.

Task queues are different. They are completely independent from each other and run in parrallel. It turned out adding this feature allowed me to simplify the code a lot. This allows me to run things like checking/scanning the environment while simultanously walking around, while making random animal noises and potentially more all in parrallel and cleanly separated. This idea is loosely inspired by operating systems.

Templates
If the only thing the mod offers would be the task system, that wouldn't be enough. I think a good Mob API needs to have a readily-availble set of movement primitives ready to use. And features that many mobs will need. Otherwise, mobs need to reinvent the wheel over and over again (the mobkit approach) which is not my goal. That's why I added a number of simple template functions that can be added as microtasks.

Most templates are about movement, but there's also a template that plays a mob sound in random intervals, emulating the "random" sound in Mobs Redo.

Progress so far
rp_mobs works pretty nice, the documentation is written and I have been able to re-implement all the mobs from the current Repixture version. I consider it to be almost feature-complete.

But there are still some small bugs with the movement. Still, I think rp_mobs is now definitely in a state that I could say the hard rework already has paid off. The ancient Mobs Redo fork is finally gone which was the main goal.

In Repixture, I am currently in the process of working on the villager behavior and teaching it to walk, pathfind, etc. but this technically isn't part of rp_mobs anymore.

Weak points
I think the biggest weakness in rp_mobs right now is physics. I am piss-poor in maths so there aren't any truly elaborate movement helpers or functions, but those that exist are good enough to emulate the current Repixture mobs. The mobs will not have a "smooth-looking" movement unless you code such microtasks yourself. But that's an acceptable weakness for now, my primary goal is to replace Mobs Redo (done) and make a release (not done). Maybe I could later copy code from the other mods (attributed, of course). ;-)

I believe another weakness might be the learning curve. The API documentation is long and I wonder how hard the barrier of entry is for others. I wonder where it could be simplified, if at all. But I also believe a lot of the complexity is simply unavoidable.

Check it out!
If you want to check out the current development state of rp_mobs, check out these links:
Please remember this is still WIP and the development version so compability-breakage can happen at any time.



So what's your opinion on that so far?
Did you read the documentation and did you like it?
What do you think about the presented concepts?
Was I right to start a new mob API?
Any other questions?

machoo
New member
Posts: 4
Joined: Fri Mar 24, 2023 13:55

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by machoo » Post

It's exciting to see a new mob API. I feel like all mob APIs developed over the past 10 or so years have fallen short in terms of polish, functionality, documentation, etc. It's a shame that Minetest doesn't supply it's own built-in mob API. If you want to add a variety of mobs to your game, you will invariably get a hodge-podge of mobs based off of multiple different mob APIs (mobkit, mobs redo, Creatura), each with their own jank.

Could you make some showcase videos of how the mobs behave? I'm pretty curious. In terms of physics stuff, perhaps there are some principles you could implement from Jordan4Ibanez' Crafter game? It seems to have the most polished of any of the mob implementations I've seen in terms of how mobs move and behave.

https://youtu.be/5fOS0tq2NOU?si=84o7qahf2SzMUT32
https://github.com/jordan4ibanez/Crafte ... r/mods/mob

User avatar
Wuzzy
Member
Posts: 5100
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Wuzzy » Post

Well, in terms of video footage, not much too see yet. The API currently is focused more on the technical aspects like the whole task system thing. This is very abstract and the physics primitives are … well … primitive. The animals move like in the version before (Mobs Redo style), so it isn't smooth at all. First I just wanted to get the API working to cleanly replace the status quo in Repixture
In later versions (post-release) I might tackle cleaner movement. Villagers are more interesting since I taught them movement using a pathfinder, but it looks somewhat robotic.

Anyway, maybe I'll post a video once I made a release.


I think the biggest issue with Minetest is not so much that it lacks a builtin mob API but more like that there is a huge chasm between built-in player features and built-in entity features. Entities lack many capabilities that players have. Namely, fall damage, gravity, liquid phyiscs, move resistance, node damage, drowning, slippery nodes, disable_jump, inventory. All of that has to be re-implemented in Lua. If there was engine support for that, that would already hugely simplify a lot of code. Also, we lack a bunch of physics helper function. Sorcerykid did some interesting work in a PR for that, however it was rejected because the PR was too chaotic.

Oddly, bouncy node physics ARE respected by non-player entities. That’s weirdly inconsistent.

Anyway, my mob API thus reimplements most of these features, but everything is optional. So mobs CAN obey disable_jump or node damage, but don't have to. Some of this is imperfect; for example, the fall damage is not calculated the same as for players.

For drowning and node damage, mobs have to explicitly define a drowning point and node damage points. If any of these points are within a drowning or node damage points, they drown / take node damage. So you can set the drowning point pixel-perfect to the mob's head. This is different from other mods which just automatically guess when the mob is drowning. There can be multiple node damage points. This was required for the villager because of the 2-node height.

I think a proper game should stick with only one API. Trying to mix multiple mob APIs into the same game is a very bad idea. All mobs definitely should use the same API and missing mobs need to be re-implemented.

I agree that Crafter definitely has the cleanest AND best-performing mob walking I've seen in any mob mod ever. It's very simple, too. Note this was always just a prototype. But I could definitely draw inspiration from that. But oddly, in version 0.0.8, mobs seem to become worse again, as if old code was thrown away. Probably I need to check out an older version but I don't know which one.

User avatar
Wuzzy
Member
Posts: 5100
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Wuzzy » Post

Video demonstration of the WIP villager pathfinder:

https://tube.tchncs.de/w/o58aiuF9cHFwekKVbxUpie

Codiac
Member
Posts: 90
Joined: Sun Apr 23, 2023 03:04

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Codiac » Post

Hi Wuzzy, the path finder in the new mobs system handles different mob heights, but not different mob widths, are you likely to add that?

Imagine an iron golem trying to walk around a tree.

User avatar
Wuzzy
Member
Posts: 5100
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Wuzzy » Post

Unlikely to happen soon, as this game doesn't have wide mobs so far, and I'm not planning wide mobs.

Codiac
Member
Posts: 90
Joined: Sun Apr 23, 2023 03:04

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Codiac » Post

Hi Wuzzy, are you going to make rp_mods a stand alone mod so it can be used by mobs in other games?

User avatar
Wuzzy
Member
Posts: 5100
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Wuzzy » Post

I don't have plans to release it as a standalone mod right now.
This is mostly because it just would be an additional maintenance burden for me.

Besides, I first need to create more and better mobs in Repixture to "prove" this mod's usefulness. Before that, I'm not even considering a standalone release.
The mod so far works fine, but the current mobs are still relatively simplistic and more experimentation is needed IMO.

Codiac
Member
Posts: 90
Joined: Sun Apr 23, 2023 03:04

Re: rp_mobs: The new Repixture Mobs API (feedback wanted)

by Codiac » Post

Wuzzy wrote:
Fri Jan 09, 2026 10:52
I don't have plans to release it as a standalone mod right now.
This is mostly because it just would be an additional maintenance burden for me.

Besides, I first need to create more and better mobs in Repixture to "prove" this mod's usefulness. Before that, I'm not even considering a standalone release.
The mod so far works fine, but the current mobs are still relatively simplistic and more experimentation is needed IMO.
OK, thanks for the reply :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests