Mobkit - Entity API [mobkit][alpha]

Post Reply
Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

runs wrote:I have an issue when a mob dies, lays one node above ground.
This has to do with model alignment, depending where the center is relative to the model they may sink or hover above ground when rotated, because collision boxes aren't affected.

If rotation is to be used extensively models have to be aligned accordingly. However this is a simple case, take a look in zombiestrd/init.lua - the model used is centered 1m above feet level, so collisionbox has to be adjusted

Code: Select all

-- workaround for models bottom y being -1. 
		local props = self.object:get_properties()
		props.collisionbox[2] = props.collisionbox[1]
		self.object:set_properties({collisionbox=props.collisionbox})
Now the distance from the pivot point to the bottom colbox face (#2) becomes the same as the distance to the side face (#1)

u18398

Re: Mobkit - Entity API [mobkit][alpha]

by u18398 » Post

Termos wrote: A behavior as described is possible, but it's probably more tricky than it sounds,
for example, the problem with rivers generated by Valleys mapgen is they are often impassable, so a mob would have to find a viable landing spot on the other side before they decide to jump in.
I do not think a hungry wolf would think that difficult :)
There is food nearby, I have to get it.
If the wolf drawns, that is bad luck, but it would look more realistic
than prey and predator circling along the shore :)

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Could you implement the same random mechanism for textures too? Mobs_redo does it and it is cool.

So the same animals could have diferent skins, tones, etc... randomly selected when spawned.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

Gundul wrote: If the wolf drawns, that is bad luck, but it would look more realistic
than prey and predator circling along the shore :)
This would work for rivers, but there's the same problem with other terrain features, like caves, steep slopes and cliffs.

The real reason is deer start running when a wolf is only short distance away - only for aesthetic reasons, it looks better when it's a close chase ;)
In the next version it will be based on time rather than distance, so deer eventually flee out of range and the circling stops.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

runs wrote:Could you implement the same random mechanism for textures too?.
Sure, makes sense.
Actually it could be done easily even now.

Code: Select all

local obj=minetest.add_entity(...
local textures = obj:get_properties().textures
if #textures > 1 then obj:set_properties({textures={textures[math.random(#textures)]}}) end				
But..
There's a bug in minetest api, set_properties resets hp to some default value.
I will implement it for the next release, but first I must sever all ties to engine damage/hp handling.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Termos wrote:
runs wrote:Could you implement the same random mechanism for textures too?.
Sure, makes sense.
Actually it could be done easily even now.

Code: Select all

local obj=minetest.add_entity(...
local textures = obj:get_properties().textures
if #textures > 1 then obj:set_properties({textures={textures[math.random(#textures)]}}) end				
But..
There's a bug in minetest api, set_properties resets hp to some default value.
I will implement it for the next release, but first I must sever all ties to engine damage/hp handling.
Oh, OK, it is easy to implement.

Yes, I have that bug, it resets to 10, the workaround is getting the hp, set the properties, and then set the hp again.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

runs wrote: Yes, I have that bug, it resets to 10, the workaround is getting the hp, set the properties, and then set the hp again.
Yup, this is the workaround, but that was the last straw.
There are no good reasons to keep using the built in damage system in its current state, it has to go.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

I've created a mobkit version of my Petz mod to download.

Remark:
-Only the following pets available: puppy, kitty, lamb, calf, piggy, chicken and ducky.
-The same features that the mobs_redo version: tame, capture, feed, tamagochi, orders, eggs, etc.
-Exclusive behaviours, items and food for this version.

Red_King_Cyclops
Member
Posts: 324
Joined: Sun Jun 16, 2019 20:17
Location: x=123, y=120, z=534

Re: Mobkit - Entity API [mobkit][alpha]

by Red_King_Cyclops » Post

I've only seen the random clips, but already this mod looks like it could overtake Mobs Redo as dominant mob API.
Currently working on new mods.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

runs wrote:I've created a mobkit version of my Petz mod
Cool!
But I'm getting this: ERROR[Main]: mod "petz" has unsatisfied dependencies: "mobs"
Red_King_Cyclops wrote:I've only seen the random clips, but already this mod looks like it could overtake Mobs Redo as dominant mob API.
Thanks!
You can also quickly check it out in action at gundul.ddnss.de Port 39155

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Code: Select all

Cool!
But I'm getting this: [i]ERROR[Main]: mod "petz" has unsatisfied dependencies:  "mobs"[/i]
Sorry, the link was for the mob_redo version. Now fixed.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

I have an issue with my Petz mobs. In the water they float if there is one block underwater, but with two blocks or more they died inmediately (no 10 seconds of breath).

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

runs wrote:In the water they float if there is one block underwater, but with two blocks or more they died inmediately.
This has to do with the distance from the shore rather than depth, mobs drown immediately if they can't find land within their view_range. This is to prevent searching very far away and mobs bunching up in water.

I've seen some mob mods out there use quite ridiculous view ranges like 5 meters, if this is the case they will often drown close to a shore.

All mobkit mobs can see up to active_block_range (48m by default), and they can do it cheaply, view_range is a limit, only used by some behaviors for mobs to ignore stuff farther away than this value.
So don't worry about performance, if you don't have any specific requirements for view_range, just set it to something larger, like 32.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Termos wrote:
runs wrote:In the water they float if there is one block underwater, but with two blocks or more they died inmediately.
This has to do with the distance from the shore rather than depth, mobs drown immediately if they can't find land within their view_range. This is to prevent searching very far away and mobs bunching up in water.

I've seen some mob mods out there use quite ridiculous view ranges like 5 meters, if this is the case they will often drown close to a shore.

All mobkit mobs can see up to active_block_range (48m by default), and they can do it cheaply, view_range is a limit, only used by some behaviors for mobs to ignore stuff farther away than this value.
So don't worry about performance, if you don't have any specific requirements for view_range, just set it to something larger, like 32.
Oh Ok that gots sense. Mobs should not go far away from shore too much. My issue was when I put a mob directely on water, so no matter.

u18398

Re: Mobkit - Entity API [mobkit][alpha]

by u18398 » Post

runs wrote:I've created a mobkit version of my Petz mod to download.

Remark:
-Only the following pets available: puppy, kitty, lamb, calf, piggy, chicken and ducky.
-The same features that the mobs_redo version: tame, capture, feed, tamagochi, orders, eggs, etc.
-Exclusive behaviours, items and food for this version.
That is cool. :) I just tried it for a few minutes but that looks already very nice.
Do the pets spawn by themselves or do they need spawneggs ?

I am pretty busy in the moment in RL by I hope I will get some time next weekend.
Maybe Zombieworld is strong enough to handle your petz together with zombies and
wildlife.

Defend your petz against the hordes of zombies :D

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Gundul wrote:
runs wrote:I've created a mobkit version of my Petz mod to download.

Remark:
-Only the following pets available: puppy, kitty, lamb, calf, piggy, chicken and ducky.
-The same features that the mobs_redo version: tame, capture, feed, tamagochi, orders, eggs, etc.
-Exclusive behaviours, items and food for this version.
That is cool. :) I just tried it for a few minutes but that looks already very nice.
Do the pets spawn by themselves or do they need spawneggs ?

I am pretty busy in the moment in RL by I hope I will get some time next weekend.
Maybe Zombieworld is strong enough to handle your petz together with zombies and
wildlife.

Defend your petz against the hordes of zombies :D
They spawn by themselves. You can specify the rate in 'petz.conf' for each mob, and the max number of mobs into an abr (area), 30 by default.

u18398

Re: Mobkit - Entity API [mobkit][alpha]

by u18398 » Post

runs wrote: They spawn by themselves. You can specify the rate in 'petz.conf' for each mob, and the max number of mobs into an abr (area), 30 by default.
Added to Zombieworld server. (gundul.ddnss.de:39155)

The Petz show very good what the mobkit is already able to do.
Very good work, the mobkit and the Petz

User avatar
Clyde
Member
Posts: 222
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

Re: Mobkit - Entity API [mobkit][alpha]

by Clyde » Post

Hi, i tried this mod on my private testserver and found this in the logs:

Code: Select all

Undeclared global variable "t" accessed at .../.minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:150
This happens with the local var liquidflag.

Code: Select all

function mobkit.get_node_height(pos)
	local npos = mobkit.get_node_pos(pos)
	local node = mobkit.nodeatpos(npos)
	if node == nil then return nil end
	
	local liquidflag = node.drawtype=='liquid' and t
	
	if node.walkable then
		if node.drawtype == 'nodebox' then
			if node.node_box.type == 'fixed' then
				if type(node.node_box.fixed[1]) == 'number' then
					return npos.y + node.node_box.fixed[5] ,0, false
				elseif type(node.node_box.fixed[1]) == 'table' then
					return npos.y + node.node_box.fixed[1][5] ,0, false
				else
					return npos.y + 0.5,1, false			-- todo handle table of boxes
				end		
			elseif node.node_box.type == 'leveled' then
				return minetest.get_node_level(pos)/64-0.5+mobkit.get_node_pos(pos).y, 0, false
			else
				return npos.y + 0.5,1, false	-- the unforeseen
			end
		else
			return npos.y+0.5,1, false	-- full node
		end
	else
		local liquidflag = false
		if node.drawtype == 'liquid' then liquidflag = true end
		return npos.y-0.5,-1,liquidflag	
	end
end
But the server and the mods is still running.
Greetings, Clyde.
My Server: Welcome to Zeitsprung - deadsoft.org:49152 Jungle The next Gundul - jungle-tng.deadsoft.org:49152

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

Clyde wrote: local liquidflag = node.drawtype=='liquid' and t
This is weird, looks like a typo.
Alas Im gonna be afk for a couple of weeks, Ill look into this as soon as I get back to my place.

Meanwhile you might check if youre using the latest, unmodified version.

User avatar
Clyde
Member
Posts: 222
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

Re: Mobkit - Entity API [mobkit][alpha]

by Clyde » Post

Wildlife has crashed my Server Silicon Village:

Code: Select all

ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'wildlife' in callback luaentity_Step(): /usr/local/share/minetest/builtin/common/vector.lua:59: attempt to index local 'b' (a nil value)
2019-07-07 17:52:39: ERROR[Main]: stack traceback:
2019-07-07 17:52:39: ERROR[Main]: 	/usr/local/share/minetest/builtin/common/vector.lua:59: in function 'distance'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:990: in function 'func'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:624: in function 'execute_queues'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:1265: in function <...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:1157>
It is the version of this thread here.

Greetings, Clyde.
My Server: Welcome to Zeitsprung - deadsoft.org:49152 Jungle The next Gundul - jungle-tng.deadsoft.org:49152

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Clyde wrote:Wildlife has crashed my Server Silicon Village:

Code: Select all

ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'wildlife' in callback luaentity_Step(): /usr/local/share/minetest/builtin/common/vector.lua:59: attempt to index local 'b' (a nil value)
2019-07-07 17:52:39: ERROR[Main]: stack traceback:
2019-07-07 17:52:39: ERROR[Main]: 	/usr/local/share/minetest/builtin/common/vector.lua:59: in function 'distance'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:990: in function 'func'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:624: in function 'execute_queues'
2019-07-07 17:52:39: ERROR[Main]: 	...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:1265: in function <...e/minetest/games/Civ_reload/mods/mp_mobs/mobkit/init.lua:1157>
It is the version of this thread here.

Greetings, Clyde.
The error is in the line 990 (warning function, a mob chase another):

Code: Select all

local dist = vector.distance(pos,opos)
So, pos or opos are nil on a certain time. A workarround is put before that line the following function:

Code: Select all

if pos==nil or opos==nil then
  return
end

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

Clyde wrote:Wildlife has crashed my Server Silicon Village:
Thanks, this was one of these suckers that never occur in a local game.

Updated the download link with fixed version.
runs wrote:

Code: Select all

if pos==nil or opos==nil then
  return
end
It should return true so a behavior ends if its object is no longer there.
Also there's a dedicated function: mobkit.is_alive(thing). I just forgot to make the check in one of the behaviors ;)

Also, if there's a need for mobs to interact with 'dead' entities for some reason, there's another: mobkit.exists(thing)

User avatar
Clyde
Member
Posts: 222
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

Re: Mobkit - Entity API [mobkit][alpha]

by Clyde » Post

Thx, now it seems to work, i will report, if i find something strange.

Impressive Work, it's a very lightweight interface for mobs.
Greetings, Clyde.
My Server: Welcome to Zeitsprung - deadsoft.org:49152 Jungle The next Gundul - jungle-tng.deadsoft.org:49152

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Mobkit - Entity API [mobkit][alpha]

by Termos » Post

Release 0.10.3

mobkit: requested feature - variant textures.
  • just provide more than 1 item in the textures table like so:
    textures={'tex1.png', 'tex2.png', ...}
    texture will be chosen randomly upon the first activation
    this chosen texture persists subsequent reactivations, server restarts etc.
mobkit: severed all ties to default damage system
  • all entities get 'immortal' armor group
    other armor groups can be defined as usual
    this means you loose all audiovisual punch effects,
    everything should be handled by mods in on_punch callbacks.
    hitpoints stored in self.hp, plus two new functions:
    mobkit.hurt(luaent,dmg) and mobkit.heal(luaent,dmg).
    calls to get_hp /set_hp for mobs are now obsolete
    mobs are now considered dead at 0 instead of 100 hp.
wildlife: requested modification - changed hq_runfrom behavior
  • herbivores now start running from predators after a few seconds
    even if they fail to get close, to prevent predators running in circles
    when they can't find a path to their prey.
zombiestrd: added zombie texture variant
  • also original textures have been color edited
    for zombies to look less happy and clean shaven, so to speak.
I was going to make builtin behaviors more configurable, but I couldn't get around to this somehow. If you want behaviors to work differently just copy them over to your mod and make'em your own.
I'd rather work on flying/hovering/aquatic behaviors next.
Last edited by Termos on Mon Jul 15, 2019 18:47, edited 1 time in total.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Mobkit - Entity API [mobkit][alpha]

by runs » Post

Cool version. Awating for flying mobs!

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests