Mobkit - Entity API [mobkit][alpha]

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

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

by Termos » Sun Nov 17, 2019 15:29

runs wrote:The code below is when a mob dies. The collisionbox is changed. I do not what it does, it was a suggestion from you.
Code: Select all
    local props = self.object:get_properties()
    props.collisionbox[2] = props.collisionbox[1]
    self.object:set_properties({collisionbox=props.collisionbox})

Somebody must have been on pigeon killing spree.

Yup, that's the culprit.
Pigeon's collisionbox top y is - 0.25, and x is -0.25 as well, so if bottom y is made -0.25 then you get a square instead of a box.
This is a part of builtin dying behavior that makes them rotate and fall on the side, it works fine under assumption the model is alligned properly.

We've been talking through this before, if any rotation is to be done, the model has to be aligned so the pivot point location makes sense, otherwise all weird stuff is going to happen. In this case the pivot point is high above their head.
If a mob is ever going to be rotated, try to align the model so their visual center of mass is around (0,0,0)
 

User avatar
ElCeejo
Member
 
Posts: 49
Joined: Thu Feb 28, 2019 23:29
In-game: ElCeejo

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

by ElCeejo » Mon Nov 18, 2019 01:10

On the topic of collision boxes. How would I go about messing with terrain detection with larger collision boxes?
 

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

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

by Termos » Mon Nov 18, 2019 11:23

ElCeejo wrote:On the topic of collision boxes. How would I go about messing with terrain detection with larger collision boxes?

For now you might experiment with get_nodes_in_area()
there are two modes, default returns a table of unique nodes that intersect with the box as keys, full mode returns all nodes indexed by node position.
These are actual references to node tables, not strings, so tests like .walkable can be performed directly

Better tools are needed though, flying seems good enough for now so I'm moving on to big boxes.
 

User avatar
Extex
Member
 
Posts: 127
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

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

by Extex » Wed Nov 27, 2019 00:15

Eagle is done

Melkor I changed the background (green) to a dark brown because the green was showing up on the edges of the model
Attachments
Eagle.zip
(122.04 KiB) Downloaded 10 times
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

Gundul
Member
 
Posts: 615
Joined: Thu Aug 27, 2015 10:55
Location: Europe/Asia
GitHub: berengma
IRC: Gundul

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

by Gundul » Wed Nov 27, 2019 18:16

Extex wrote:Eagle is done


That looks great. Pretty professionel :)
My servers: Jungle, Lilly in the valley, ZombieTest
 

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

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

by Termos » Wed Nov 27, 2019 18:43

Extex wrote:Eagle is done

Great, hopefully I'll be able to check it out this weekend.

Do you mind if I use it in Wildlife? What license is it?
Would you'd like to rig the other wildlife animals by any chance?
 

User avatar
Melkor
Member
 
Posts: 328
Joined: Sat Sep 24, 2011 01:03
Location: Underground

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

by Melkor » Wed Nov 27, 2019 19:21

Extex wrote:Eagle is done


Good work! :)

Extex wrote:Melkor I changed the background (green) to a dark brown because the green was showing up on the edges of the model


I see, thank you for letting me know this problem, when the mipmaps are active, the green colour "bleeds" and shows in the model. i usually have mipmaps disabled in MT and blender so i didn't notice that.
 

User avatar
Extex
Member
 
Posts: 127
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

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

by Extex » Wed Nov 27, 2019 19:43

Termos: CC BY-NC-SA 3.0, also I rotated the model around 180 degrees so you don't have to rotate it around in lua
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

User avatar
Extex
Member
 
Posts: 127
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

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

by Extex » Thu Nov 28, 2019 21:17

Hey Termos how would I make an entity that instead of jumping up blocks, climbs them?
NOTE: This mob is gonna be pretty small
E.g.
Image
Attachments
temporary_1574975738705.gif
(16.87 KiB) Not downloaded yet
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

User avatar
Lone_Wolf
Member
 
Posts: 2216
Joined: Sun Apr 09, 2017 05:50
Location: Hopefully very far from yours, snoop :P
GitHub: LoneWolfHT
IRC: Lone_Wolf
In-game: Lone_Wolf

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

by Lone_Wolf » Thu Nov 28, 2019 22:57

Extex wrote:Hey Termos how would I make an entity that instead of jumping up blocks, climbs them?

I think you can just set stepheight (Ctrl+F it in the mobkit/minetest api files) to 1

Another jumping-related question: I haven't looked too closely at the API but is it possible to decrease the time an entity spends jumping up onto nodes? It slows them down quite a bit
Content DB -|- Working on Voxel Knights
 

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

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

by Termos » Fri Nov 29, 2019 11:09

Lone_Wolf wrote:I think you can just set stepheight (Ctrl+F it in the mobkit/minetest api files) to 1

Stepheight was extremely glitchy last time I checked, so I don't rely on it. It also works instantly, so not exactly what Extex seems to be going for.

Lone_Wolf wrote:Another jumping-related question: I haven't looked too closely at the API but is it possible to decrease the time an entity spends jumping up onto nodes? It slows them down quite a bit

Probably, better behaviors are needed for that. I'm working on terrain testing for arbitrary collisionbox sizes, that may accomplish it, or maybe someone else is going to try.

Extex wrote:Hey Termos how would I make an entity that instead of jumping up blocks, climbs them?

Custom behaviors are needed, at least a low lever behavior, something like:

Code: Select all
self.object:set_acceleration({x=0,y=0,z=0}) -- turn gravity off if using builtin physics

if mobkit.get_stand_pos(self).y > tgt_terrain_height then   -- finish condition
   mobkit.go_forward_horizontal(self,[some speed])  -- move it onto the new node
   return true  -- exit the behavior
else
   self.object:set_velocity({x=0,y=[some vertical vel],z=0})  -- climb
end
 

User avatar
Andrey01
Member
 
Posts: 2327
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Fri Nov 29, 2019 11:54

I would like to write a function mobkit.lq_lookat() that will allow smoothly mobs` heads to rotate towards to all 3rd dimensions, so it could turn at any direction. I`ve thought out such algorithm: known two rotations tables (in rad), first of a head (in given case it comes as an attached object to the parent entity) and second of the target one. Given a turn velocity (in rad/s) of the head and at each step over 0.3 second it will add each component of the rotation table with the corresponding one of the turn while they all don`t reach the values are in the second table (if one of them exceeds, equalize that to the corresponding component of the target rotation table).

But I don`t know, whether is this true algorithm? If no, may anybody know how to implement that?
 

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

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

by Termos » Fri Nov 29, 2019 12:23

Andrey01 wrote:I would like to write a function mobkit.lq_lookat() that will allow smoothly mobs` heads to rotate towards to all 3rd dimensions

Important: you would use mobkit.lq_lookat if you're going to make a PR for mobkit, if it's for your mod, it has to be something else, like [yourmod].lq_lookat of just lq_lookat if local.

Andrey01 wrote:But I don`t know, whether is this true algorithm? If no, may anybody know how to implement that?

For my take on smooth turning, see mobkit.turn2yaw. No tables needed, just current yaw and target yaw.
3D would be a little bit more complex, but the principle is the same.

Another thing, attachment rotations use degrees instead of rads iirc.

Code: Select all
function mobkit.turn2yaw(self,tyaw,rate)
   tyaw = tyaw or 0
   rate = rate or 6
      local yaw = self.object:get_yaw()
      yaw = yaw+pi
      tyaw=(tyaw+pi)%(pi*2)
      
      local step=min(self.dtime*rate,abs(tyaw-yaw)%(pi*2))
      
      local dir = abs(tyaw-yaw)>pi and -1 or 1
      dir = tyaw>yaw and dir*1 or dir * -1
      
      local nyaw = (yaw+step*dir)%(pi*2)
      self.object:set_yaw(nyaw-pi)
      
      if nyaw==tyaw then return true, nyaw-pi
      else return false, nyaw-pi end
end
 

User avatar
Andrey01
Member
 
Posts: 2327
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Fri Nov 29, 2019 17:00

Termos wrote:
Andrey01 wrote:I would like to write a function mobkit.lq_lookat() that will allow smoothly mobs` heads to rotate towards to all 3rd dimensions

Important: you would use mobkit.lq_lookat if you're going to make a PR for mobkit, if it's for your mod, it has to be something else, like [yourmod].lq_lookat of just lq_lookat if local.

Andrey01 wrote:But I don`t know, whether is this true algorithm? If no, may anybody know how to implement that?

For my take on smooth turning, see mobkit.turn2yaw. No tables needed, just current yaw and target yaw.
3D would be a little bit more complex, but the principle is the same.

Another thing, attachment rotations use degrees instead of rads iirc.

Code: Select all
function mobkit.turn2yaw(self,tyaw,rate)
   tyaw = tyaw or 0
   rate = rate or 6
      local yaw = self.object:get_yaw()
      yaw = yaw+pi
      tyaw=(tyaw+pi)%(pi*2)
      
      local step=min(self.dtime*rate,abs(tyaw-yaw)%(pi*2))
      
      local dir = abs(tyaw-yaw)>pi and -1 or 1
      dir = tyaw>yaw and dir*1 or dir * -1
      
      local nyaw = (yaw+step*dir)%(pi*2)
      self.object:set_yaw(nyaw-pi)
      
      if nyaw==tyaw then return true, nyaw-pi
      else return false, nyaw-pi end
end

Ok, thanks. And also other question: tyaw means what yaw should be as a result or how many rads necessary to turn? And could you please explain me what happens in your code below line with get_yaw()? Pretty complicated calculations as to me!
 

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

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

by Termos » Fri Nov 29, 2019 19:08

Andrey01 wrote:Ok, thanks. And also other question: tyaw means what yaw should be as a result or how many rads necessary to turn?

Tyaw stands for target yaw, this is what you want the yaw to be after everything's done.
The variable holding rads to turn during an engine step is called step (yeah i know sorry).

Andrey01 wrote:And could you please explain me what happens in your code below line with get_yaw()? Pretty complicated calculations as to me!

That's about all of it ;)

First in order to get rid of ambiguity and simplify comparisons I convert the yaws to <0,2pi> range by adding pi and getting a modulo 2pi

Then step is simply rate times dtime, that way it makes approx rate rads per second (cause dtime is expressed in seconds), and then dir is the turn direction, calculated so they always take the shorter turn.
 

User avatar
Extex
Member
 
Posts: 127
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

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

by Extex » Fri Nov 29, 2019 19:19

OK as soon as the behavior is available let me know.
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

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

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

by Termos » Sat Nov 30, 2019 12:42

New Aerotest demo featuring Extex' eagle as an ambient mob.
aerotest003.zip
(77.05 KiB) Downloaded 12 times


This time it's a little bit more server friendly as is, the magic word has been removed, instead they'll try to spawn roughly every 30 mins. Eagles are removed if their velocity goes below 2m/s (i.e. they crash), their time to live is 24 hours RL.
The licenses are MIT/CCBYSA3 should anyone care.

The model, i had to rotate it around X for the body to be level, because pitch angle is controlled by entity rotation, and translate so 0,0,0 is inside the body, because rotations around a point outside the model look all kinds of wrong.
 

Gundul
Member
 
Posts: 615
Joined: Thu Aug 27, 2015 10:55
Location: Europe/Asia
GitHub: berengma
IRC: Gundul

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

by Gundul » Sat Nov 30, 2019 15:57

would it be possible that "self.isinliquid" could hold the name of the liquid source node or nil
instead of just true or false ?
My servers: Jungle, Lilly in the valley, ZombieTest
 

Gundul
Member
 
Posts: 615
Joined: Thu Aug 27, 2015 10:55
Location: Europe/Asia
GitHub: berengma
IRC: Gundul

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

by Gundul » Sun Dec 01, 2019 16:11

Termos wrote:New Aerotest demo featuring Extex' eagle as an ambient mob.



The eagle already flies very nicely. Best results I had so far in singleplayer.
What it would need in the future is a kind of radar to not crash into mountans or
trees, which will be kind of difficult as lower the eagle will come to sea level.
My servers: Jungle, Lilly in the valley, ZombieTest
 

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

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

by Termos » Sun Dec 01, 2019 17:17

Gundul wrote:would it be possible that "self.isinliquid" could hold the name of the liquid source node or nil
instead of just true or false ?

Should be no problem I guess, I'll consider.
Just tell me what you need it for.

Gundul wrote:The eagle already flies very nicely. Best results I had so far in singleplayer.
What it would need in the future is a kind of radar to not crash into mountans or
trees, which will be kind of difficult as lower the eagle will come to sea level.

Yes the high level behaviors are just quick few liners.
They only scan terrain below, not what lies ahead, but that could be done easily using raycast.
 

Gundul
Member
 
Posts: 615
Joined: Thu Aug 27, 2015 10:55
Location: Europe/Asia
GitHub: berengma
IRC: Gundul

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

by Gundul » Mon Dec 02, 2019 05:34

Termos wrote:
Gundul wrote:would it be possible that "self.isinliquid" could hold the name of the liquid source node or nil
instead of just true or false ?

Should be no problem I guess, I'll consider.
Just tell me what you need it for.

Like in my water_life not every animal likes every kind of fluid. Riverfish can be caught now and be released somewhere. I use isinliquid actually to do damage if released on land. If released in lava, the lava would do the damage itself I guess ? There are even more liquids in Lilly where fish should not be able to live in.
Would make it easier too to keep sharks in seawater where rivers flow into the sea, too.
self.isinliquid could be used as before. true if a source node is given, false if nil. No mod would have to be changed if someone is not interested in the kind of the liquid source node.


Termos wrote:
Gundul wrote:The eagle already flies very nicely. Best results I had so far in singleplayer.
What it would need in the future is a kind of radar to not crash into mountans or
trees, which will be kind of difficult as lower the eagle will come to sea level.

Yes the high level behaviors are just quick few liners.
They only scan terrain below, not what lies ahead, but that could be done easily using raycast.

raycast is a good idea. Never used that before. I should consider that for my whales too, I guess.
My servers: Jungle, Lilly in the valley, ZombieTest
 

User avatar
Andrey01
Member
 
Posts: 2327
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Mon Dec 02, 2019 09:31

Termos, I`m trying to define a field with 'head' key for saving an entity string in the entity def table of minetest.register_entity(), but actually this own field is not entered (I viewed it via minetest.registered_entities, also called get_properties() method and both don`t have it inside themselves).

I asked the core developers and they answered custom properties can`t be defined. However, I see your own ones can be defined (buoyancy, max_hp, brainfunc and etc) there and everything works fine?
 

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

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

by Termos » Mon Dec 02, 2019 13:01

Gundul wrote:Like in my water_life not every animal likes every kind of fluid. Riverfish can be caught now and be released somewhere. I use isinliquid actually to do damage if released on land. If released in lava, the lava would do the damage itself I guess ?
[...]
Would make it easier too to keep sharks in seawater where rivers flow into the sea, too.

The way i see it, these are two separate things

The first is environment damage.
Isinliquid checks only single node at a single point, while even the smallest colbox can intersect with up to 8 nodes. This his where mobkit.get_nodes_in_area comes in handy. For examples see zombies and wildlife animals, they have lava damage enabled.

The second is avoiding certain nodes
Isinliquid is not very good for this, because by the time you get the info they're already there. The solution would be to modify the aqua radar, my version just checks if nodes are nonsolid, you probably need to change the condition to check if they are specific node names/groups.
General rule of thumb: If you're thinking of specific nodes, probably it requires some coding on the mod's end.
 

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

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

by Termos » Mon Dec 02, 2019 13:06

Andrey01 wrote:Termos, I`m trying to define a field with 'head' key for saving an entity string in the entity def table of minetest.register_entity(), but actually this own field is not entered (I viewed it via minetest.registered_entities, also called get_properties() method and both don`t have it inside themselves).

Initial properties only work for several select parameters, but if you defined your custom field outside initial_properties it should be accessible directly.

Could be an error either in entity definition or the code where the field is being accessed, I can't tell without seeing the code.
 

User avatar
Andrey01
Member
 
Posts: 2327
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

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

by Andrey01 » Mon Dec 02, 2019 14:38

Termos wrote:
Andrey01 wrote:Termos, I`m trying to define a field with 'head' key for saving an entity string in the entity def table of minetest.register_entity(), but actually this own field is not entered (I viewed it via minetest.registered_entities, also called get_properties() method and both don`t have it inside themselves).

Initial properties only work for several select parameters, but if you defined your custom field outside initial_properties it should be accessible directly.

Could be an error either in entity definition or the code where the field is being accessed, I can't tell without seeing the code.

Oh, I`ve just discovered minetest.registered_entities has inside custom properties, before I tried get_properties() and it output only initial ones! In any case, thanks for helping!
 

PreviousNext

Return to WIP Mods



Who is online

Users browsing this forum: MSN [Bot] and 4 guests