[mod] Mob Core [alpha] [mob_core]

Post Reply
User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

[mod] Mob Core [alpha] [mob_core]

by ElCeejo » Post

This mod is meant as an expansion of mobkit with new hq/lq functions and other functions similar to those used in mobs_redo that should allow for more consisent behaviors but won't force the user into using them.

Some things to note:
- This mod is in alpha, expect issues
- Because my coding skills improved a lot throughout development, a lot of the code is inconsistent
- A few things were taken from mobs_redo, so big thanks to that mod and it's contributors

To-do:
- Document HQ/LQ functions
- Re-code older function
- Optimize laggy functions
- Create a wider range of aquatic and aerial roam functions

License: GPL 3.0
Depends: mobkit
Optional Depends: default (for the mount system)
Download
Last edited by ElCeejo on Wed Jan 13, 2021 01:30, edited 1 time in total.

MisterE
Member
Posts: 239
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: [mod] Mob Core [alpha] [mob_core]

by MisterE » Post

I hope this works out. Will we be able to easily port redo mobs to this?

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Re: [mod] Mob Core [alpha] [mob_core]

by ElCeejo » Post

The original goal for this mod was to be able to easily convert mobs redo mobs to mobkit but the goal changed when I realized that it was kinda redundant. Although, in it's current form simple mobs like the cow can be very quickly converted. I was able to convert the cow and chicken in under 5 minutes each.

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Update 0.0.2

by ElCeejo » Post

Small update for Aquatic and Aerial mobs:

- Improved obstacle avoidance
- Reduced lag

MisterE
Member
Posts: 239
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: [mod] Mob Core [alpha] [mob_core]

by MisterE » Post

so does it improve the mob to convert it? If I understand correctly, mobkit has superior mob control functions. Is it worth it to convert? Or, is the purpose of this mod to make it easier for those coming from mobs_redo to start using mobkit?

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Re: [mod] Mob Core [alpha] [mob_core]

by ElCeejo » Post

so does it improve the mob to convert it?
Definitely. If it's converted correctly then you would see a lot less lag and much better behavior. Mobs_redo is good for very basic mobs but things fall apart when you try to implement your own movement behaviors or pathfinding. Mobkit can be used for basic mobs or advanced mobs, you just have to know what you're doing to use it.
is the purpose of this mod to make it easier for those coming from mobs_redo to start using mobkit?
I'd say that making it easier to go from mobs_redo to mobkit is one the goals, but not the central one. There functions that are more or less duplicates of mobs_redo functions such as feed_tame() and protect() that could be used to convert mobs_redo mobs. But the main goal is to have functions that can be used by many different mobkit mobs without having to repeat code, so if someone needed to have a mobs_redo-like feed/tame function for their mobkit mob they could use this mods instead of making their own and wasting space in their mod.

Adnunano
Member
Posts: 42
Joined: Thu Feb 13, 2020 09:28

Re: [mod] Mob Core [alpha] [mob_core]

by Adnunano » Post

ElCeejo wrote:
Thu Oct 29, 2020 18:30
I was able to convert the cow and chicken in under 5 minutes each.
Can you share it to us please?I want a better functioning cow and chicken.
NfAPhpmGaVphBjK8NIr9Mit5xNW2emD2

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Re: [mod] Mob Core [alpha] [mob_core]

by ElCeejo » Post

I will share it somewhat soon.

MisterE
Member
Posts: 239
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: [mod] Mob Core [alpha] [mob_core]

by MisterE » Post

Please give some examples of this mod being used, so I can copy to other mobs
Edit: I found this: https://content.minetest.net/packages/E ... ter_fauna/

Thanks!

However, We still need better docs:

mob_core.register_spawn()
mob_core.growth()
mob_core.vitals()

And others. What do they do, how/when should they be used?

I got the above from the pig in better_fauna

I would really appreciate a simple example mob that has notes of what can go where to have different behaviors.

E.G.

What do I do to get the mob to be captured
what do I do to tame the mob
what mob properties are *required* and what others are not required, but useful
how to make baby animals
how to make an animal brain, a predator brain, how to replace nodes (eating), how to make a monster
how to call various sounds at proper times, etc...

basically, An api description like that in api.txt of mobs_redo. It doesn't cover everything, but definitely enough to get basic behaviors and no bugs in the 1st or 2nd try.

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Re: [mod] Mob Core [alpha] [mob_core]

by ElCeejo » Post

Documentation is in the works. There's a lot of stuff that may be left out when I update it (hopefully soon) but there'll be more than what's there now.

MisterE
Member
Posts: 239
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: [mod] Mob Core [alpha] [mob_core]

by MisterE » Post

BTW, I got this error:

2021-01-09 12:57:32: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback luaentity_Step(): ...netest/games/mesecraft/mods/mobkit/example_behaviors.lua:379: attempt to index local 'rot' (a nil value)
2021-01-09 12:57:32: ERROR[Main]: stack traceback:
2021-01-09 12:57:32: ERROR[Main]: ...netest/games/mesecraft/mods/mobkit/example_behaviors.lua:379: in function 'func'
2021-01-09 12:57:32: ERROR[Main]: /app/share/minetest/games/mesecraft/mods/mobkit/init.lua:627: in function 'execute_queues'
2021-01-09 12:57:32: ERROR[Main]: /app/share/minetest/games/mesecraft/mods/mobkit/init.lua:844: in function 'stepfunc'
2021-01-09 12:57:32: ERROR[Main]: /app/share/minetest/games/mesecraft/mods/mob_core/api.lua:976: in function 'on_step'
2021-01-09 12:57:32: ERROR[Main]: ...e/minetest/games/mesecraft/mods/better_fauna/api/api.lua:511: in function <...e/minetest/games/mesecraft/mods/better_fauna/api/api.lua:510>


This happended after I punched a walrus which I ported over to mobkit. I expect
better_fauna.hq_sporadic_flee(self, 20, puncher)
was called in the walrus's on_punch callback. (walrus depends on mob_core and better_fauna)

regardless, the debug points to this code:

function better_fauna.on_step(self, dtime, moveresult)
mob_core.on_step(self, dtime, moveresult)
if mobkit.timer(self, 1) then
if self.breeding_cooldown > 0 then
self.breeding_cooldown = self.breeding_cooldown - 1
end
mobkit.remember(self, "breeding_cooldown", self.breeding_cooldown)
end
end


specifically,
mob_core.on_step(self, dtime, moveresult)

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Patch 5

by ElCeejo » Post

Alpha Patch 5 is here!

Changes:

- Added mob_core.walkable_nodes table
- Added mob_core.find_val function
- Added pathfinding functions
- Re-Added mob_core.swim_to_next_waypoint
- Improved mob_core.fly_to_next_waypoint
- Improved spawn egg coloration
- Fixed crash when mobs die
- Fixed mob_core.is_mobkit_mob always returning false
- Fixed sound related crash
- Fixed mobs taking fall/fire damage when set to false
- Fixed mobs not defending owners when defend_owner is set to true

MisterE
Member
Posts: 239
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: [mod] Mob Core [alpha] [mob_core]

by MisterE » Post

Suggestion: add optional paramaters to call another spawn function when 1 spawn function is called
This would require optional 'spawn_def_name', 'call_spawn_by_name = {name = 'spawn_def_name',chance = int} and an optional 'disable_natural_spawn' paramaters.
then, you could disable natural spawns for a registered spawn function , but, for example, whenever you spawn a herd of deer, you have a chance of calling the spawn function with spawn_def_name = 'wolf_pack_5' which would spawn a pack of wolves hunting the deer

User avatar
ElCeejo
Member
Posts: 120
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: In a Dragons Lair

Patch 6

by ElCeejo » Post

Alpha Patch 6 is here!

Changes

- Fixed group spawning crashes
- Fixed issues with wildlife mod
- Improved group spawning
- Improved pathfinding
- Renamed old pathfinding to mob_core.find_path_lite()
- Added new mob_core.register_on_spawn() function
- Added optional reliability param to register_spawn()

Note: The reliability param defaults to 3. The higher it is the more likely mobs are to successfully spawn at the minor cost of performance.

Post Reply

Who is online

Users browsing this forum: dpbqRman, ElCeejo and 4 guests