Mobkit - Entity API [mobkit][alpha]

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 Sep 29, 2019 13:17

crash in wildlife mod

2019-09-29 15:12:34: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'wildlife' in callback environment_Step(): .minetest/mods/mobkit/init.lua:180: attempt to index field 'node_box' (a nil value)
2019-09-29 15:12:34: ERROR[Main]: stack traceback:
2019-09-29 15:12:34: ERROR[Main]: /.minetest/mods/mobkit/init.lua:180: in function 'get_node_height'
2019-09-29 15:12:34: ERROR[Main]: /.minetest/mods/mobkit/init.lua:211: in function </home/mars/.minetest/mods/mobkit/init.lua:207>
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: .minetest/mods/wildlife/init.lua:116: in function '?'
2019-09-29 15:12:34: ERROR[Main]: /usr/local/share/minetest/builtin/game/register.lua:419: in function </usr/local/share/minetest/builtin/game/register.lua:399>
2019-09-29 15:12:34: ERROR[Main]: stack traceback:


and:

2019-09-29 15:22:27: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'wildlife' in callback luaentity_Step(): .minetest/mods/mobkit/init.lua:180: attempt to index field 'node_box' (a nil value)
2019-09-29 15:22:27: ERROR[Main]: stack traceback:
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:180: in function 'get_node_height'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:211: in function </home/mars/.minetest/mods/mobkit/init.lua:207>
2019-09-29 15:22:27: ERROR[Main]: (tail call): ?
2019-09-29 15:22:27: ERROR[Main]: (tail call): ?
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:411: in function 'is_neighbor_node_reachable'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:1110: in function 'func'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:676: in function 'execute_queues'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:894: in function </.minetest/mods/mobkit/init.lua:785>


[Edit] Or maybe it is mobkit itself ?

2019-09-29 15:30:51: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'sharks' in callback luaentity_Step(): .minetest/mods/mobkit/init.lua:180: attempt to index field 'node_box' (a nil value)
2019-09-29 15:30:51: ERROR[Main]: stack traceback:
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:180: in function 'get_node_height'
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:211: in function </home/mars/.minetest/mods/mobkit/init.lua:207>
2019-09-29 15:30:51: ERROR[Main]: (tail call): ?
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:1380: in function 'okpos'
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:1403: in function 'aqua_radar_dumb'
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:1444: in function 'func'
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:676: in function 'execute_queues'
2019-09-29 15:30:51: ERROR[Main]: .minetest/mods/mobkit/init.lua:894: in function </home/mars/.minetest/mods/mobkit/init.lua:785>
Last edited by Gundul on Sun Sep 29, 2019 13:36, edited 1 time in total.
My servers: Jungle, Lilly in the valley, ZombieTest
 

User avatar
runs
Member
 
Posts: 928
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Sun Sep 29, 2019 13:28

Gundul wrote:crash in wildlife mod

2019-09-29 15:12:34: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'wildlife' in callback environment_Step(): .minetest/mods/mobkit/init.lua:180: attempt to index field 'node_box' (a nil value)
2019-09-29 15:12:34: ERROR[Main]: stack traceback:
2019-09-29 15:12:34: ERROR[Main]: /.minetest/mods/mobkit/init.lua:180: in function 'get_node_height'
2019-09-29 15:12:34: ERROR[Main]: /.minetest/mods/mobkit/init.lua:211: in function </home/mars/.minetest/mods/mobkit/init.lua:207>
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: (tail call): ?
2019-09-29 15:12:34: ERROR[Main]: .minetest/mods/wildlife/init.lua:116: in function '?'
2019-09-29 15:12:34: ERROR[Main]: /usr/local/share/minetest/builtin/game/register.lua:419: in function </usr/local/share/minetest/builtin/game/register.lua:399>
2019-09-29 15:12:34: ERROR[Main]: stack traceback:


and:

2019-09-29 15:22:27: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'wildlife' in callback luaentity_Step(): .minetest/mods/mobkit/init.lua:180: attempt to index field 'node_box' (a nil value)
2019-09-29 15:22:27: ERROR[Main]: stack traceback:
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:180: in function 'get_node_height'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:211: in function </home/mars/.minetest/mods/mobkit/init.lua:207>
2019-09-29 15:22:27: ERROR[Main]: (tail call): ?
2019-09-29 15:22:27: ERROR[Main]: (tail call): ?
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:411: in function 'is_neighbor_node_reachable'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:1110: in function 'func'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:676: in function 'execute_queues'
2019-09-29 15:22:27: ERROR[Main]: .minetest/mods/mobkit/init.lua:894: in function </.minetest/mods/mobkit/init.lua:785>


I think it is related to https://forum.minetest.net/viewtopic.php?f=9&t=22112&start=150#p355442

In my mobkit version I've added a line (line 180) to avoid this:

if node.drawtype == 'nodebox' then
if node.node_box == nil then return nil end --added by petz
if node.node_box.type == 'fixed' then
 

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 Sep 29, 2019 13:48

runs wrote:In my mobkit version I've added a line (line 180) to avoid this:

if node.drawtype == 'nodebox' then
if node.node_box == nil then return nil end --added by petz
if node.node_box.type == 'fixed' then


thanks, looks like that helps
My servers: Jungle, Lilly in the valley, ZombieTest
 

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

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

by Termos » Sun Sep 29, 2019 14:08

Gundul wrote:attempt to index field 'node_box' (a nil value)

Yeah, there must be a mod running that defines a nodebox type node without an actual node_box.

This happens in get_node_height() - the function is still very 4.17 and doesn't understand some new 5.0 stuff.
I've been reluctant to fix it because of a fun bug that makes mobs jump in snow - maybe you seen it. But I will eventually.
 

User avatar
runs
Member
 
Posts: 928
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Sun Sep 29, 2019 15:26

Termos wrote:
Gundul wrote:attempt to index field 'node_box' (a nil value)

Yeah, there must be a mod running that defines a nodebox type node without an actual node_box.

This happens in get_node_height() - the function is still very 4.17 and doesn't understand some new 5.0 stuff.
I've been reluctant to fix it because of a fun bug that makes mobs jump in snow - maybe you seen it. But I will eventually.


Yes, mobs jumping in snow is cool and appropiate. :-D
 

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

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

by Termos » Sun Sep 29, 2019 16:11

ElCeejo wrote:Would it be possible to have mobs defend their owners when attacked, or attack anything their owner punches? I've tried accomplishing it using mobkit functions but I've had no luck so far.

This is a very good question.

First, the only reliable place for punch detection is callbacks, so we need a function that will run in every mob's on_punch and on_punchplayer as well.

The function would:
    - determine if a player takes part
    - yes: do get_objects_inside_radius()
    - iterate over all luaentities to see if they have a memory entry indicating the player:get_player_name() is their owner
    - for matching entities: do something to them that would trigger an attack.
    One way would be to add a custom luaentity field that would contain a reference to the culprit's objectref, that would then be interpreted by the brainfunc to kick off an attack behavior.
Please note: I'm storing objectrefs and luaentities in direct violation of RW's guide, but there are no good alternatives.
Just remember to do mobkit.is_alive() first thing in every step if you're going to use a stored reference, and to clear the reference as soon as it's not needed anymore.
Also never place references to objects and luaentities in mobs memory, or it will crash the engine because memory is serialized.

That said, it became clear to me that the api needs some generic event facility to handle such cases and more, so this becomes a priority and the next thing I'm going to try and implement.
 

User avatar
runs
Member
 
Posts: 928
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Tue Oct 01, 2019 15:59

Some request to complete aquatic behaviour:

- Sharks (my dolphins) do not submerge. Maybe a min and max ocean deep set?
- Follow, run away and predator behaviours (so my dolphins could be smart enough and pursue fishes)
 

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

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

by Termos » Tue Oct 01, 2019 16:45

runs wrote:Sharks (my dolphins) do not submerge. Maybe a min and max ocean deep set?

Probably because they have no reason to do so, and maybe their buoyancy is positive. Neutral is 1.0 try setting it to like 1.02, they'll slowly sink.
I don't use specific world coordinates ever, so sharks should work in layered worlds etc, but you can if you're coding for a specific game.

runs wrote:- Follow, run away and predator behaviours (so my dolphins could be smart enough and pursue fishes)

Predator behavior is ready, hq_aqua_attack takes an objectref as an argument, it can be used to attack anything that floats.

As to follow and run away, I might do these at some point, but builtin behaviors are really just examples, the main reason I'm doing them is to figure out what utility functions are needed.
I encourage all to try and write some custom behaviors.

Also if you don't mind my opinion, dolphins just have to jump out of water occasionally, so you need a behavior for that - if it doesn't jump out of water, it's not really a dolphin ;)
 

Robsoie
Member
 
Posts: 98
Joined: Fri Apr 29, 2016 16:22

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

by Robsoie » Wed Oct 02, 2019 01:37

After a quick test, the less i can say is that i am extremely impressed by the sharks, i never thought i would see in minetest a mob moving so naturally, that's brillant.

On my quick test so far i met mostly zombies that were all "mario-jumping" on me, it felt rather hilarious coming from zombies type of enemies (but very damaging juding on much health i was losing).

Oddly i saw some kind of antilopes on the ice/snowy areas, when i approached them they slowly ran away (though very slowly) from me , a behaviour that really felt believable (out of the very slow speed of course).

In some forest i saw what i think was some kind of lion (i think as the sound was rather odd at first i thought i was some more noisy version of a zombie from the sound) that i managed to kill due to being positionned on the high ground (sorry anakin) and striking it everytime the beast was trying to jump on upper nodes.
When it died it waited a few minute to suddenly disappear.

On the fight with the zombies and the "lion" i noticed there wasn't a noticable "feedback" on my sword strikes on them, i had in fact no idea if i was really hitting them or not, as they all jump a lot on their attack i couldn't make a difference between them actually jumping or if it was a "jump" as a sword strike feedback.

Anyways, that shark mob is incredible and its moves feel so natural in the environment.
 

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

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

by Termos » Wed Oct 02, 2019 19:25

Thanks for the review!

Just to clarify things up a bit:
What you've seen is the fruit of accidental collaboration of a few people: Gundul (server), runs (Petz) and me.
This thread is concerned primarily with mobkit which is a humble api and as such doesn't do anything by itself.
 

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

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

by ElCeejo » Thu Oct 03, 2019 11:52

I tried doing what you suggested

Code: Select all
if mobkit.is_alive(self) then
      if puncher:is_player() then -- determine if a player takes part
         local objs = minetest.get_objects_inside_radius(puncher:get_pos(), self.view_range) -- get objects inside radius
         local obj = nil
   
         for n = 1, #objs do

            obj = objs[n]:get_luaentity()
            if obj and obj.owner == puncher:get_player_name() then -- look over all entities to see if the puncher is their owner
                    mobkit.clear_queue_high(obj)
               mobkit.hq_hunt(obj,10,self) -- for all matching entities, do something that would trigger an attack
            end
   


In theory this should work, but the game crashes.

It gives an error message saying it failed to call method "get_pos" which it says is a nil value

Code: Select all
function mobkit.hq_hunt(self,prty,tgtobj)
   local func = function(self)
      if not mobkit.is_alive(tgtobj) then return true end
      if mobkit.is_queue_empty_low(self) and self.isonground then
         local pos = mobkit.get_stand_pos(self)
         local opos = tgtobj:get_pos() <<< Code that's causing the crash
         local dist = vector.distance(pos,opos)
         if dist > self.view_range then
            return true
         elseif dist > 3 then
            mobkit.goto_next_waypoint(self,opos)
         else
            mobkit.hq_attack(self,prty+1,tgtobj)               
         end
      end
   end
   mobkit.queue_high(self,func,prty)
end


I probably could have described that better but I'm tired. Hopefully I was clear enough that you get what I'm saying :P
 

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 » Thu Oct 03, 2019 11:58

How can I slowdown speed on entities.

I copied the sharks and added new b3d and texture for fish
but when I set max_speed = 0.5 and use
mobkit.hq_aqua_roam(self,10,0.1)

the fishes still panicing through the water
My servers: Jungle, Lilly in the valley, ZombieTest
 

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

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

by Termos » Thu Oct 03, 2019 13:03

ElCeejo wrote:In theory this should work, but the game crashes.
It gives an error message saying it failed to call method "get_pos" which it says is a nil value

What you did is more or less it, given the mod is very simple and all affected mobs use same behaviors and priority scheme, there are just some errors, in order of importance:

mobkit.hq_hunt(obj,10,self)
This is the showstopper, the function takes objectref as an argument, try passing self.object

mobkit.clear_queue_high(obj)
Clearing the queue means they abandon whatever they've been doing, even if they're busy dying, they'll get up and come to the rescue. Better is to simply queue the behavior without deleting the queue, it'll get executed when it's time comes.
Better yet, do get_queue_priority and only queue the behavior if prty < 10

if obj and obj.owner == puncher:get_player_name()
There's special memory structure for this kind of thing. Do mobkit.remember(self,'owner',playername) when setting ownership, then here you could do mobkit.recall(obj,'owner').
Added benefit is mobs having memory entries won't timeout.
Calling a luaentity 'obj' is misleading btw.

if mobkit.is_alive(self) then
Ths check is not crucial here. It's not a stored reference, because it's just been retrieved from callback so we know it's active, and behaviors already check if their object is alive. However it might've just been killed by the punch so it's ok I guess, given you call the function after mobkit.hurt() call
 

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

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

by Termos » Thu Oct 03, 2019 13:23

Gundul wrote:How can I slowdown speed on entities.

but when I set max_speed = 0.5 and use
mobkit.hq_aqua_roam(self,10,0.1)
the fishes still panicing through the water

Works ok on my end, I'd have to take a look at your code.
 

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

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

by ElCeejo » Thu Oct 03, 2019 20:00

Code: Select all
   if mobkit.is_alive(self) then
      if puncher:is_player() then
         local objs = minetest.get_objects_inside_radius(puncher:get_pos(), self.view_range)
         local obj = nil


         for n = 1, #objs do
            local prty = mobkit.get_queue_priority(self.object)

            obj = objs[n]:get_luaentity()
            if obj and puncher:get_player_name() == mobkit.recall(self, "owner") then
                if prty < 12 then
                   mobkit.hq_hunt(self.object,12,self)
                   return
               end
            end
         end
        end
    end
end


Now when I punch the mob I get

Code: Select all
..\mods\mobkit\init.lua:604: attempt to get length of field 'hqueue' (a nil value)
 

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

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

by Termos » Thu Oct 03, 2019 20:44

You've changed it the wrong way around
Remember here 'self' is the punched one, its priority and memory are of no importance
The one who's to defend his master I called 'luaent' instead of misleading 'obj'

Something along these lines:

[...]
local pname = puncher:get_player_name()

for n = 1, #objs do
    local luaent = objs[n]:get_luaentity()
    if luaent and pname == mobkit.recall(luaent, "owner") then
    local prty = mobkit.get_queue_priority(luaent)
      if prty < 12 then
      mobkit.hq_hunt(luaent,12,self.object)
[..]
 

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 » Fri Oct 04, 2019 07:08

Termos wrote:
Gundul wrote:How can I slowdown speed on entities.

but when I set max_speed = 0.5 and use
mobkit.hq_aqua_roam(self,10,0.1)
the fishes still panicing through the water

Works ok on my end, I'd have to take a look at your code.


I checked again, but I do not know what I am doing wrong.
This time I took sharks mod and adjusted max_speed and
mobkit.hq_aqua_roam(self,10,X)

But sharks seem to move as usual when I start game again.
https://github.com/berengma/sharks


I think these funstion are still missing in your documentation :)
mobkit.pos_translate2d(pos,yaw,dist)
mobkit.go_forward_horizontal(self,yaw,speed)
mobkit.hq_aqua_roam(self,prty,speed)
mobkit.hq_aqua_turn(self,prty,tyaw,speed)
mobkit.hq_aqua_attack(self,prty,tgtobj,speed)
My servers: Jungle, Lilly in the valley, ZombieTest
 

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

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

by Termos » Fri Oct 04, 2019 09:06

Gundul wrote:I think these funstion are still missing in your documentation :)

Now that's an important hint, because they aren't missing.
Their entries were added in the last commit 190927. Also in the same commit, I fixed some hardcoded speed values.

Your mobkit seems outdated.
 

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 » Fri Oct 04, 2019 10:22

Termos wrote:Now that's an important hint, because they aren't missing.
Their entries were added in the last commit 190927. Also in the same commit, I fixed some hardcoded speed values.

Your mobkit seems outdated.


LOL I can't believe it. You are right ! I mixed up the konsoles of my remote servers (which are up to date) with my
local computer directory (which was not up to date)

All good now, sry for wasting your time.
My servers: Jungle, Lilly in the valley, ZombieTest
 

User avatar
runs
Member
 
Posts: 928
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Fri Oct 04, 2019 21:55

Termos wrote:Also if you don't mind my opinion, dolphins just have to jump out of water occasionally, so you need a behavior for that - if it doesn't jump out of water, it's not really a dolphin ;)


I did it :-D but I have to tweak the API again cos this line forces fishes to stay in water:

self.object:set_acceleration({x=-vel.x,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z})
 

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

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

by Termos » Fri Oct 04, 2019 23:16

runs wrote:
Termos wrote:I did it :-D but I have to tweak the API again cos this line forces fishes to stay in water:
self.object:set_acceleration({x=-vel.x,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z})

No, please, don't do that ;)
Just when they're close to the surface, give em strong enough initial velocity impulse at an angle forward and upwards, and let physics do the rest.
And don't forget to dir_to_rot() them.
 

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

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

by ElCeejo » Sat Oct 05, 2019 05:49

I'm doing even more complicated stuff, namely trying to make mobs grow in increments, and I've found a puzzling issue.

Code: Select all
paleotest.progressive_growth = function(self)

   self.base_size = self.visual_size
   self.base_colbox = self.collisionbox
   self.base_selbox = self.selectionbox

   if self.growth_stage == 1 then
      self.object:set_properties({
         textures = textures,
         visual_size = {
            x = self.base_size.x / 5,
            y = self.base_size.y / 5
         },
         collisionbox = {
            self.base_colbox[1] / 5,
            self.base_colbox[2] / 5,
            self.base_colbox[3] / 5,
            self.base_colbox[4] / 5,
            self.base_colbox[5] / 5,
            self.base_colbox[6] / 5
         },
      })
   end
end


So what's supposed to happen is if the mob is hatched from an egg or a result of breeding 2 adult mobs it starts off at growth stage 1, and grows from there (I probably could find a better way to do it than what I've shown above but I'm lazy :P) . The problem is, if you use set_properties to lower a mobs size it seems to cause some behavior issues, like if it's set it to the size I have in the above code, it won't roam or play animations at all, only moving to attack the player.
 

User avatar
runs
Member
 
Posts: 928
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

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

by runs » Sat Oct 05, 2019 10:31

Termos wrote:
runs wrote:
Termos wrote:I did it :-D but I have to tweak the API again cos this line forces fishes to stay in water:
self.object:set_acceleration({x=-vel.x,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z})

No, please, don't do that ;)
Just when they're close to the surface, give em strong enough initial velocity impulse at an angle forward and upwards, and let physics do the rest.
And don't forget to dir_to_rot() them.


I did it :-D

A question:
does mobkit.is_in_deep(target) check the water deep (below) or the deep where the mob is (above)?
 

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

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

by Termos » Sat Oct 05, 2019 11:05

runs wrote:does mobkit.is_in_deep(target) check the water deep (below) or the deep where the mob is (above)?

Both;) At least one of them has to be liquid source as well.

ElCeejo wrote:I'm doing even more complicated stuff, namely trying to make mobs grow in increments, and I've found a puzzling issue.
[...]
The problem is, if you use set_properties to lower a mobs size it seems to cause some behavior issues, like if it's set it to the size I have in the above code, it won't roam or play animations at all, only moving to attack the player.

That's probably on me.
The core of the api was done in 4.17, where changing colbox on the fly wasn't possible.
I'll try to do a quick fix soon. (edit, here, the new version)

Another issue, I've noticed you do big mobs, however built in land behaviors don't go well with collisionboxes bigger than 1 node. Please make sure x and z collisionbox dimensions never exceed 1. Support for huge collisionboxes is to come later.
Last edited by Termos on Sat Oct 05, 2019 15:58, edited 1 time in total.
 

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

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

by Termos » Sat Oct 05, 2019 15:57

Quick update 191005

Changes:
    Improved compatibility with set_properties() objectref method
    Now it should be safe to alter collisionbox at any time.
 

PreviousNext

Return to WIP Mods



Who is online

Users browsing this forum: luk3yx and 4 guests