Mobkit - Entity API [mobkit][alpha]
Re: Mobkit - Entity API [mobkit][alpha]
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>
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 u18398 on Sun Sep 29, 2019 13:36, edited 1 time in total.
Re: Mobkit - Entity API [mobkit][alpha]
I think it is related to https://forum.minetest.net/viewtopic.php?f=9&t=22112&start=150#p355442Gundul 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>
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
Re: Mobkit - Entity API [mobkit][alpha]
thanks, looks like that helpsruns 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
Re: Mobkit - Entity API [mobkit][alpha]
Yeah, there must be a mod running that defines a nodebox type node without an actual node_box.Gundul wrote:attempt to index field 'node_box' (a nil value)
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.
Re: Mobkit - Entity API [mobkit][alpha]
Yes, mobs jumping in snow is cool and appropiate. :-DTermos wrote:Yeah, there must be a mod running that defines a nodebox type node without an actual node_box.Gundul wrote:attempt to index field 'node_box' (a nil value)
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.
Re: Mobkit - Entity API [mobkit][alpha]
This is a very good question.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.
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.
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.
Re: Mobkit - Entity API [mobkit][alpha]
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)
- 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)
Re: Mobkit - Entity API [mobkit][alpha]
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.runs wrote:Sharks (my dolphins) do not submerge. Maybe a min and max ocean deep set?
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.
Predator behavior is ready, hq_aqua_attack takes an objectref as an argument, it can be used to attack anything that floats.runs wrote:- Follow, run away and predator behaviours (so my dolphins could be smart enough and pursue fishes)
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 ;)
Re: Mobkit - Entity API [mobkit][alpha]
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.
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.
- ElCeejo
- Member
- Posts: 210
- Joined: Thu Feb 28, 2019 23:29
- GitHub: ElCeejo
- In-game: ElCeejo
- Location: Your Mother's house
Re: Mobkit - Entity API [mobkit][alpha]
I tried doing what you suggested
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
I probably could have described that better but I'm tired. Hopefully I was clear enough that you get what I'm saying :P
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
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
Re: Mobkit - Entity API [mobkit][alpha]
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
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
Re: Mobkit - Entity API [mobkit][alpha]
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: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
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
Re: Mobkit - Entity API [mobkit][alpha]
Works ok on my end, I'd have to take a look at your code.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
- ElCeejo
- Member
- Posts: 210
- Joined: Thu Feb 28, 2019 23:29
- GitHub: ElCeejo
- In-game: ElCeejo
- Location: Your Mother's house
Re: Mobkit - Entity API [mobkit][alpha]
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
Code: Select all
..\mods\mobkit\init.lua:604: attempt to get length of field 'hqueue' (a nil value)
Re: Mobkit - Entity API [mobkit][alpha]
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
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)
- if prty < 12 then
Re: Mobkit - Entity API [mobkit][alpha]
I checked again, but I do not know what I am doing wrong.Termos wrote:Works ok on my end, I'd have to take a look at your code.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
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)
Re: Mobkit - Entity API [mobkit][alpha]
Now that's an important hint, because they aren't missing.Gundul wrote: I think these funstion are still missing in your documentation :)
Their entries were added in the last commit 190927. Also in the same commit, I fixed some hardcoded speed values.
Your mobkit seems outdated.
Re: Mobkit - Entity API [mobkit][alpha]
LOL I can't believe it. You are right ! I mixed up the konsoles of my remote servers (which are up to date) with myTermos 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.
local computer directory (which was not up to date)
All good now, sry for wasting your time.
Re: Mobkit - Entity API [mobkit][alpha]
I did it :-D but I have to tweak the API again cos this line forces fishes to stay in water: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 ;)
self.object:set_acceleration({x=-vel.x,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z})
Re: Mobkit - Entity API [mobkit][alpha]
No, please, don't do that ;)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})
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.
- ElCeejo
- Member
- Posts: 210
- Joined: Thu Feb 28, 2019 23:29
- GitHub: ElCeejo
- In-game: ElCeejo
- Location: Your Mother's house
Re: Mobkit - Entity API [mobkit][alpha]
I'm doing even more complicated stuff, namely trying to make mobs grow in increments, and I've found a puzzling issue.
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.
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
Re: Mobkit - Entity API [mobkit][alpha]
I did it :-DTermos wrote:No, please, don't do that ;)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})
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.
A question:
does mobkit.is_in_deep(target) check the water deep (below) or the deep where the mob is (above)?
Re: Mobkit - Entity API [mobkit][alpha]
Both;) At least one of them has to be liquid source as well.runs wrote: does mobkit.is_in_deep(target) check the water deep (below) or the deep where the mob is (above)?
That's probably on me.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.
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.
Re: Mobkit - Entity API [mobkit][alpha]
Quick update 191005
Changes:
Changes:
- Improved compatibility with set_properties() objectref method
Now it should be safe to alter collisionbox at any time.
Who is online
Users browsing this forum: No registered users and 34 guests