Difference between revisions of "Player-World Interaction"
Jump to navigation
Jump to search
Hybrid Dog (talk | contribs) |
ROllerozxa (talk | contribs) (remove randomly interspersed broken wikilinks) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Incomplete}} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Digging a node == | == Digging a node == | ||
− | Preconditions are a | + | Preconditions are a node somewhere in the map.<br/> |
− | This node is | + | This node is pointable, has a selection box and can be dug by the hand or the tool the player is wielding.<br/> |
− | The player has interact | + | The player has interact priv and the tool has a tool range that the node can be pointed.<br/> |
The node is not stuck somewhere the player can't point it. | The node is not stuck somewhere the player can't point it. | ||
− | * First look at the node, it becomes | + | * First look at the node, it becomes pointed_thing. |
− | : Note that on | + | : Note that on android the node is pointed without looking (referring to the cross position) at it. |
− | * Then | + | * Then LMB is pressed down while holding an item which does not have on_use. |
: If LMB wasn't released before, a click happens, which causes a punch event. | : If LMB wasn't released before, a click happens, which causes a punch event. | ||
:: The client send a punch event (client->interact(4, pointed), see game.cpp:3657 (28.02.2017)). | :: The client send a punch event (client->interact(4, pointed), see game.cpp:3657 (28.02.2017)). | ||
− | :: On server side the punch event is passed to mods, see | + | :: On server side the punch event is passed to mods, see on_punch and the deprecated register_on_punchnode. |
: Then the client sends the digging start event to the server (interact(0, pointed), game.cpp:3948). | : Then the client sends the digging start event to the server (interact(0, pointed), game.cpp:3948). | ||
:: The server uses this information for anticheat measurements. | :: The server uses this information for anticheat measurements. | ||
* Now continue looking at the node, i.e. keep pointing it, and hold down LMB. | * Now continue looking at the node, i.e. keep pointing it, and hold down LMB. | ||
− | : Periodically client-side: Crack animation is updated, digging particles are spawned (if not disabled in the settings) and the | + | : Periodically client-side: Crack animation is updated, digging particles are spawned (if not disabled in the settings) and the node dig sound is played. |
− | :: The dig sound is either the "dig" field in the "sounds" | + | :: The dig sound is either the "dig" field in the "sounds" table in the nodedef |
:: or, if it's not present, the client uses the sound "default_dig_${groupname}" (file name extension omitted here), where $groupname is one of the groups the node has, see (game.cpp:4001), and gain is set to 0.5. | :: or, if it's not present, the client uses the sound "default_dig_${groupname}" (file name extension omitted here), where $groupname is one of the groups the node has, see (game.cpp:4001), and gain is set to 0.5. | ||
:: The default_dig_ thing should be banned from source code in my opinion. | :: The default_dig_ thing should be banned from source code in my opinion. | ||
− | * Some time later, when the | + | * Some time later, when the digging time elapsed, |
: the client sends a digging completion event to the server (interact(2, pointed), game.cpp:4018), | : the client sends a digging completion event to the server (interact(2, pointed), game.cpp:4018), | ||
: the node disappears client-side, | : the node disappears client-side, | ||
Line 35: | Line 28: | ||
* Now the server recieves the digging completion event. | * Now the server recieves the digging completion event. | ||
: Anticheat probably, e.g due to lag, thinks the player dug the node too fast. | : Anticheat probably, e.g due to lag, thinks the player dug the node too fast. | ||
− | :: dug_too_fast cheat is passed to mods, see | + | :: dug_too_fast cheat is passed to mods, see register_on_cheat, and digging aborts. |
− | : If the nodedef has a | + | : If the nodedef has a can_dig function, it's executed and probably stops the digging. |
− | : The | + | : The on_dig function in the nodedef is called now. |
− | :: The default function | + | :: The default on_dig function problably removes the node: |
− | : | + | ::: The on_destruct is executed, air is set and after_destruct is executed. |
+ | :: And probably (the same probably as before) it then calls the after_dig_node function in the nodedef if present. | ||
+ | |||
+ | [[Category:Core Engine]] |
Latest revision as of 19:08, 25 January 2023
This article is incomplete. Please help expand this article to include more useful information. |
Digging a node
Preconditions are a node somewhere in the map.
This node is pointable, has a selection box and can be dug by the hand or the tool the player is wielding.
The player has interact priv and the tool has a tool range that the node can be pointed.
The node is not stuck somewhere the player can't point it.
- First look at the node, it becomes pointed_thing.
- Note that on android the node is pointed without looking (referring to the cross position) at it.
- Then LMB is pressed down while holding an item which does not have on_use.
- If LMB wasn't released before, a click happens, which causes a punch event.
- The client send a punch event (client->interact(4, pointed), see game.cpp:3657 (28.02.2017)).
- On server side the punch event is passed to mods, see on_punch and the deprecated register_on_punchnode.
- Then the client sends the digging start event to the server (interact(0, pointed), game.cpp:3948).
- The server uses this information for anticheat measurements.
- Now continue looking at the node, i.e. keep pointing it, and hold down LMB.
- Periodically client-side: Crack animation is updated, digging particles are spawned (if not disabled in the settings) and the node dig sound is played.
- The dig sound is either the "dig" field in the "sounds" table in the nodedef
- or, if it's not present, the client uses the sound "default_dig_${groupname}" (file name extension omitted here), where $groupname is one of the groups the node has, see (game.cpp:4001), and gain is set to 0.5.
- The default_dig_ thing should be banned from source code in my opinion.
- Some time later, when the digging time elapsed,
- the client sends a digging completion event to the server (interact(2, pointed), game.cpp:4018),
- the node disappears client-side,
- more particles are spawned (if enabled) and
- the dug sound is played.
- Now the server recieves the digging completion event.
- Anticheat probably, e.g due to lag, thinks the player dug the node too fast.
- dug_too_fast cheat is passed to mods, see register_on_cheat, and digging aborts.
- If the nodedef has a can_dig function, it's executed and probably stops the digging.
- The on_dig function in the nodedef is called now.
- The default on_dig function problably removes the node:
- The on_destruct is executed, air is set and after_destruct is executed.
- And probably (the same probably as before) it then calls the after_dig_node function in the nodedef if present.
- The default on_dig function problably removes the node: