TheTermos / mobkit

Entity API for Minetest
MIT License
27 stars 12 forks source link

mobkit.isinliquid implies any liquid, not just source #35

Open wsor4035 opened 3 years ago

wsor4035 commented 3 years ago

self.isinliquid -- true if feet submerged in liquid type=source

suggestion that this should be changed to true if in source or flowing, however this might break mods that assume this so as a alternative self.isinflowingliquid could exist for liquid type = source

TheTermos commented 3 years ago

This is intentional, the property is used for physics stuff like buoyancy, and for swimming, things that shouldn't happen in flowing liquid as it is. Maybe the name doesn't reflect that so well, but I like to keep names short.

wsor4035 commented 3 years ago

ah, makes sense, is it possible then that self.isinflowingliquid could be implemented in the api then?

TheTermos commented 3 years ago

Sure it's possible, the question though is if it's worth it performance wise, because such parameters are evaluated every single step.

Can you describe an use case for this parameter?

wsor4035 commented 3 years ago

Can you describe an use case for this parameter?

sure, here are a few, however they mainly fall into aquatic and non aquatic for aquatic you might want to kill the mob if it is out of water and out of flowing water, or in flowing water trigger a behavior to look for the nearest source block (because players or mapgens can make flowing rivers, or waterfalls, etc)

for non aquatic examples a mob might want to avoid flowing water as well as water sources, etc

wsor4035 commented 3 years ago

@TheTermos bump on this if you dont mind

TheTermos commented 3 years ago

Ok, isinliquid is important for basic movement, that's why it's evaluated every step, and that's why it's as simple as a single point check.

For the things you mention, you need info about a volume of nodes, and you don't need to run it every step, it may be on demand or interval. Check function lava_dmg() in zombiestrd, might be what you're looking for.