109 Commits

Author SHA1 Message Date
Aaron Suen
85b50092eb Work around stack placement double sounds
Regression introduced when placement
prediction was added for non-node items.
2020-05-31 20:24:41 -04:00
Aaron Suen
8d2a8c0890 Predict item stack placement client-side
This still suffers from some issues with sounds
doubling, but for now we'll have to see how it
behaves under high latency.
2020-05-31 17:45:32 -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
b1c1ffb86a Fix item ents settling on map lower bound. 2020-03-22 11:10:47 -04:00
Aaron Suen
24c8984dbe Remove itemstack drop shadow.
- Further simplifies their appearance and
  registration code
- Makes stacks on ground consistent with stacks
  on shelves.
- Makes stacks-on-stacks look a litlte less silly.
- Eliminates spurious implication that stack
  nodes might block light, which they don't
  necessarily do.
2020-01-26 16:06:27 -05:00
Aaron Suen
7bc1a4ddad Standardize node placement sounds.
Add node placement sounds to processes
missing them, like tree growth.
2020-01-16 22:02:59 -05:00
Aaron Suen
5d7f033c81 Rudimentary (inefficient) item merge. 2020-01-05 14:21:54 -05:00
Aaron Suen
c2e014a776 Attenuate scans for dropped items. 2020-01-05 13:48:53 -05:00
Aaron Suen
4d47ab2e75 NC API dependency simplification.
Treat all API mods as a "layer", and use the new
nc_api_all registration to indicate that a mod depends
on the NC API (which ALL NC mods assume they do).
This means that each non-API mod does not need to
worry about which API mods it really needs and which
it does not, nor will they need to be updated for any
internal API restructures.

This is a game, not a modpack, so all mods will be
loaded anyway, and we only care about order.  That
means that we don't really need to worry about
having excess dependencies because any mod we
don't actually need will be needed by something that's
loaded anyway.  If somebody wants to reuse a
component elsewhere, they're likely to need to do
some work to untangle it anyway, because of the
amount that NodeCore mechanics interact and
interdepend.
2020-01-05 12:59:12 -05:00
Aaron Suen
dcfc80b367 Remove explicit names in mod.confs. 2020-01-05 12:38: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
Aaron Suen
b1fab67491 Start work on unifying/simplifying builtins.
falling_node rebuilt from scratch so far.
2020-01-04 10:51:10 -05:00
Aaron Suen
511455fff9 Player/ent freefall physics cleanup.
- Thrown objects inherit initial velocity.
- Player and objects have matched terminal
  velocity and can free-fall in tandem.
- Thrown objects experience horizontal air
  friction too.
2020-01-02 23:03:23 -05:00
Aaron Suen
15134ad90c Fix pulverize priv not covering clearinv cmd. 2019-12-31 08:49:37 -05:00
Aaron Suen
fa24151782 Fix the jumping eggcorn bug. 2019-12-15 08:43:33 -05:00
Aaron Suen
54c2695e23 Use simpler signlike render for stack ent shadow. 2019-12-09 07:51:28 -05:00
Aaron Suen
d514f8f56d More dynamic item settling random management.
Instead of shuffling all the shells once for each tick used,
shuffle only those shells actually used once per tick.  This
should save us more time in common cases where we need
to only check a few shells to find a place to settle.
2019-12-07 11:26:10 -05:00
Aaron Suen
e0f2cb5b6d Item settling overhaul.
- Always prefer closest place first, then lowest height.
- Simplify search order; use a pre-built order instead of scan.
- Randomize search order only once per tick, if used.
2019-12-07 11:12:55 -05:00
Aaron Suen
9beebc3498 Conservation of mass for burning stacks. 2019-11-28 11:18:03 -05:00
Aaron Suen
d016885364 Attempt to settle items stuck inside nodes. 2019-11-28 08:40:28 -05:00
Aaron Suen
0904c78987 Retire unnecessary "blank" images. 2019-11-10 10:44:41 -05:00
Aaron Suen
bc11435786 Drop more pre-raycast MT support. 2019-10-14 05:56:18 -04:00
Aaron Suen
c147da4dde Convert from depends.txt to mod.conf 2019-10-05 11:24:16 -04:00
Aaron Suen
77de117ea1 Place certain stacks as nodes.
If a node is specially tagges with the stack_as_node group, and
the stack size is exactly 1, place as a real node instead of a
stack node.

This reinstates logic from WAY back in the super-early pre-alpha
days, except only for nodes explicitly tagged this way.

This should be applied only to nodes that aren't transformed in
any non-desirable way when placed as nodes instead of stacks, and
can be dug the same ways as stacks (i.e. snappy = 1 or
crumbly = 1).

Currently applied to sticks, staves, leaves, ladders/frames,
and torches.  Ladder/frame placement offers some interesting
possibilities in terms of throwing ladders to rappel down holes.
2019-10-01 18:59:53 -04:00
Aaron Suen
88cf7be08c Don't trigger a craft upon dropping a stack.
This was causing dropping a stack of sticks against the side of a
staff to craft a ladder, and destroy any excess sticks.
2019-09-21 09:06:53 -04:00
Aaron Suen
3b16be70d4 Fix mattock crafting issue. 2019-09-21 08:33:59 -04:00
Aaron Suen
6e345816ad Stack overflow that builds up over time... 2019-09-14 17:09:13 -04:00
Aaron Suen
0ae0172edd Fix crash on to many falling leaves. 2019-09-14 10:16:42 -04:00
Aaron Suen
8a0f073592 Simplify item settling, make instant.
The old method was designed for 0.4 compatibility.  Since 5.0
there appears to be a flag we can just check to see if the item
is still moving according to physics or settled.
2019-09-12 21:56:06 -04:00
Aaron Suen
a9b049db2c Fix delayed visual updates. 2019-09-12 21:12:14 -04:00
Aaron Suen
0d82595a80 Support MagikEh's Pez Dispensers.
When removing a stack, if there is a stack above, move it
immediately into place of the removed stack.  This works
recursively, so stack nodes never have a chance to break out
into item entities, fall to the bottom and make a huge mess.

Unfortunately there isn't a very good visual for the stack
shifting down yet, but at least the gameplay is there.
2019-09-12 21:07:57 -04:00
Aaron Suen
72e35ce9ab Rudimentary cleanup of falling leaf node issues.
When a leaf node is displaced by crushing by a falling node,
instead of ejecting an item, try to place the node itself within
a reasonable distance.

This shoudl reduce the number of stack nodes generated from tree
canopy decay, and should alleviate the inconsistency of leaves
falling sometimes as nodes and sometimes as stacks.
2019-09-12 20:56:51 -04:00
Aaron Suen
52de19a28c Unified falling check, check after craft. 2019-09-09 07:05:01 -04:00
Aaron Suen
1c52be1b0d Require priv for the /pulverize command. 2019-09-09 06:52:32 -04:00
Aaron Suen
247bebe417 Finally break up the nc_items monstrosity. 2019-09-07 09:44:30 -04:00
Aaron Suen
310ce1bc6c Treat NodeCore as a unified thing.
- Collapse all nodecore "core" mods in the /mods listing, so it's
  easier to find the actual add-on mods.
- Parameterize in-game branding to make renaming derivatives just
  a little easier.
2019-09-07 09:08:57 -04:00
Aaron Suen
39dea8a2ae MAJOR: Code quality audit using luacheck.
- Removed lots of unused variables, a few shadowed identifiers.
- Removed a few sections of dead code.
2019-08-31 09:26:53 -04:00
Aaron Suen
3c5d7e200b "Family" stacking API
If items have a common "stackfamily" property in definition, then
they combine stacks; name and metadata are effectively ignored and
any name is considered acceptable for the combined stack name.

This is used by Lux to allow it to stack naturally instead of the
player having to lay them out spaced on the ground to "cool" them
all to the same level, since all Lux changes dynamically anyway.
2019-08-30 22:36:44 -04:00
Aaron Suen
fe2c153f9e Clean up all lua code style.
Formatting rules based on Paul Kulchenko's perl-based formatter...
http://notebook.kulchenko.com/programming/lua-beautifier-in-55-lines-of-perl
...using a single tab for indent.

Mostly pure whitespace changes.
2019-08-27 19:14:51 -04:00
Aaron Suen
a064f52557 Fix unknown item crash. 2019-04-14 01:33:50 -04:00
Aaron Suen
a674184df0 Fix deprecated getpos -> get_pos. 2019-04-06 20:34:13 -04:00
Aaron Suen
47ac931f34 Easy targeted stack placement via drop key + raycast.
Attempt to place stack node directly when player is pointing at
a node space, instead of tossing out an item ent.

This makes item organization less tedious in the early game, as
players are manipulating node positions instead of calculating
ent ballistics in their heads when trying to lay out inventories
on the ground, or using naive shelving.

(Note that wooden shelves still have an advantage in how quickly
items can be taken from them).

Items are still tossed as ents if a player is not looking at a
valid place in nodespace, so inventories can still be e.g. thrown
over a cliff or jettisoned in the ocean...
2019-04-05 07:42:48 -04:00
Aaron Suen
3614068263 Bug fixes, tidier craft excess handling. 2019-04-03 08:10:03 -04:00
Aaron Suen
fbff15e2fe MAJOR fire api/logic rework.
- Expanded fire api, added "check" varieties of things that also
  perform relevant checks for eligibility.  Standardized testing
  for ventilation.
- Snuff embers to coals as fuel.
- Fuel is consumed randomly by flames.  This means that fuel that
  are surrounded by flame burn out quicker, while flames
  surrounded by fuel consume fuel from each node slower.  This
  adds subtlety to furnace design for efficiency.
2019-03-31 20:54:38 -04:00
Aaron Suen
359c625df8 Larger, bolder, easier to see item and stack ents.
This restores an old visual scale from the extremely early days
of NodeCore.  That style was removed to syncrhonize the scale of
stack nodes with item ents.  The syncrhonization can work the
other way, too, though.

This was triggered by wanting to make loose item ents more
visually distinct at a glance from settled stack nodes, by making
loose item ent rotation faster.  Since we were going to change the
properties either way, given that, then we might as well use the
better visual.

Since making stack nodes have a full-size collision hull, it was
distracting having the items inside be so mismatched in scale.
Also, the "pointing around stacks" thing becomes less important
in long-run gameplay with shelves in play, which do not allow
pointing around/through anyway.
2019-03-30 22:07:23 -04:00
Aaron Suen
367013941c Resimplify eggcorn planting.
- Allow applying dirt to eggcorns w/o sneak again.
- Allow dirting any face; basically just do the custom check
  directly.
- Back out the "shove eggcorns into placed dirt" recipe.
2019-03-23 16:56:02 -04:00
Aaron Suen
a8dbfb221f EggCorn Overhaul!
- Place EggCorns as items, not as nodes.
- Tweak visual scales, thicken them up a bit.
- Allow planting eggcorns into dirt, as well as throwing dirt
  over eggcorns, to make planting easier.
2019-03-23 13:01:31 -04:00
Aaron Suen
8a8533a8fc Convert lode to new cooking recipe system. 2019-03-22 22:55:30 -04:00
Aaron Suen
a9c89eac4c Fix collision boxes for shelf/stack to be full cubes. 2019-03-22 18:41:33 -04:00
Aaron Suen
27770dfdb7 Try to fix stack node sounds.
Use same node_sound hook as punch hook, to limit sound rate.
2019-03-16 17:10:20 -04:00