22 Commits

Author SHA1 Message Date
Aaron Suen
f3bdf91dc6 More accurate entity settling
Under heavy lag conditions, physical entities may
land on the ground at any point during a time
step, but if they have a lot of horizontal velocity
then they may "slide" along the ground, and if we
only check for settling based on their pos at step
times, they may have already slid some distance
dependent on luck and the actual amount of
server lag.  This means that under heavy lag
conditions, items may spread out inconsistently
from their landing positions and make a messy
pile.

Using the MT 5.3+ moveresult parameter of
entity steps, we can easily find out when the
initial ground contact occured, and use that as
the settling position, which should be more
consistent under lag conditions.

This has the effect of making entities more
consistently "sticky" so they always tend to
stick at the point of initial contact and rarely
slide or glance along the ground, unless they
hit an edge/corner.
2021-12-12 10:01:24 -05:00
Aaron Suen
96ba8342ea Fix items tunneling upward from confined spaces
Items being "bumped up" upon landing due to the new column
preserving falling mechanics will never be lifted to higher than
the local maximum posiiton from which they fell.

This should prevent e.g. planks tunneling up several nodes from
a log chopping machine if there isn't enough room for the planks
to escape and the chopping machine is enclosed from above.  Items
can still tunnel using the normal "settling" mechanics, but will
not have the strong upward bias that the column settling mechanic
gave them.
2021-12-01 07:57:08 -05:00
Aaron Suen
3a6dab2b62 Fix blockage detection w/ forms 2021-11-27 18:30:15 -05:00
Aaron Suen
597ad823ae New smarter stack settling recursion
When an ent settles, start an iterative process
of checking each ent near it for settling, bumping
ents upward as needed (during the process only)
and keeping them ordered by their starting height
so that things that start lower settle earlier (and
thus remain lower) even if ents have fallen and
bunched up together due to physics and large
timesteps.

Seems to work fully for falling_nodes (keeps
them in a column and settles them in order), and
partially for items (keeps them in a column but
does not always settle them in order).
2021-11-27 18:25:10 -05:00
Aaron Suen
90dbadb5bd Fix thrown item stack settling flicker
When a thrown item settles into a node space and
becomes a visinv node, reuse the existing entity instead
of deleting the old one and creating a new one, if
possible.
2021-07-06 07:14:14 -04:00
Aaron Suen
568a5be648 Prevent falling nodes falling into displaced nodes 2021-06-23 21:00:48 -04:00
Aaron Suen
12f7419d84 Guard against crash on invalid ent state
Somehow an ent can get into a state where
it needs to set velocity but doesn't know what
velocity to set; velocities are transient
phenomena anyway, so just ignore this.
2020-10-04 08:20:05 -04:00
Aaron Suen
2cb09e21dd Buff lux tool radioactivity
Lux tools also glow a bit
2020-06-06 07:36:11 -04:00
Aaron Suen
2625f61fd1 Make light_source ents themselves glow 2020-05-26 19:43:09 -04:00
Aaron Suen
7fd4e3dc16 Don't set sprite props on non-sprite visuals 2020-05-25 09:49:06 -04:00
Aaron Suen
9c9eb4b85a Guard against dummy objects in 5.3+
Some time in the 5.3 dev stream (docs updated at
217f3a42), object refs started being invalidated
immediately on calling obj:remove(), such that
obj:get_pos() starts to return nil instead of the object's
last known position.

This can cause some crashes in NodeCore, where we
assume that our object is still valid (or usable as if it
were still valid) even though we're looping through
handlers and any one of them may have remove()d the
object before other handlers get a chance to fire.

Instead, just watch for unexpected nil returns from
functions we expect would never return nil (e.g.
get_pos or get_properties) and return if we hit one.
We can assume all other calls will be non-nil after that
one, as long as we stay in the same function flow.
2020-05-18 18:36:06 -04:00
Aaron Suen
f2455c28f2 Stop entities falling of the bottom of the map. 2020-03-22 14:06:23 -04:00
Aaron Suen
d27c9cbc86 Mapgen limit API cleanup. 2020-03-22 10:59:06 -04:00
Aaron Suen
f140618e45 Partial ent settling on mapgen lower bound
Trying to make it so that the map lower bound
(via mapgen_limit) is solid to all built-in objects.
Before, entities would fall into this space, remain
until unloaded, and then be destroyed.

Falling nodes appear to work correctly.
Item ents still don't settle.
2020-03-22 10:42:01 -04:00
Aaron Suen
0b2f3fce52 Tweak settling check fix to be more cautious. 2020-03-21 08:22:58 -04:00
Aaron Suen
a37ef544ee Destabilize item ents stuck on edges.
Instead of checking only in the center below an entity,
check a random x/z offset below its bounding box, so
an ent that's stuck on an edge will eventually detect
the blocking node below that edge and settle.
2020-03-20 08:43:08 -04:00
Aaron Suen
266de04987 API for getting objects inside one node. 2020-02-09 10:11:13 -05:00
Aaron Suen
0c39f34ebb Fix falling_node rapid column settling. 2020-01-11 00:34:13 -05:00
Aaron Suen
23e7a789cb Try to make stone chipping recipe less boring.
- Items don't down settle when rising.
- Give stone chips some upward kick.
2020-01-09 22:32:33 -05:00
Aaron Suen
726fd63183 Fix some entity behavior bugs.
- Items shooting upward on ladders.
- Suspected crash on hitting unloaded areas.
2020-01-07 21:20:18 -05:00
Aaron Suen
9916922432 Drop float support, displace lava.
BOLO gameplay that feels too "exploity" with ability
to forcibly transport lava upwards.
2020-01-05 13:26:45 -05:00
Aaron Suen
89020e8340 Major rebuild of item_entity.
This created a ton of dependency inversions, which
necessitated moving a number of API functions up into
higher layers, and restructuring dependency lists for
a number of mods.

BOLO: non-deterministic load errors due to missed
dependencies.
2020-01-05 11:42:22 -05:00