Duplicator: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 40: Line 40:
When the duplication timer reaches 5, the timer is reset and the duplicator attempts to duplicate the element in the source direction.
When the duplication timer reaches 5, the timer is reset and the duplicator attempts to duplicate the element in the source direction.


The duplication procedure first checks if a [[player]] (or player clone) is at the destination tile. If so, then the game has the player touch the source tile. This can cause the player to destroy the source tile if it is destructible on contact (e.g. if it's an item like a [[gem]] or an enemy like a [[tiger]]). This can also force other interactions such as the player going through a [[passage]], though that will result in the "[[koopo bug]]" occurring. If a [[boulder]] or [[slider]] is at the source tile, then ZZT will crash (TODO: explain why concisely).
The duplication procedure first checks if a [[player]] (or player clone) is at the destination tile. If so, then the game has the player touch the source tile, with several possible side effects (listed below).


If a player is not at the destination tile, the game instead attempts to push the destination tile away. If the push is unsuccessful, then the duplicator plays its "blocked" sound and then does nothing. If the push is successful, then the contents of the source tile are copied to the destination and the duplication sound is played. If the source tile has stats, then all stats are carried over to the duplicate (including the code).
If a player is not at the destination tile, the game instead attempts to push the destination tile away. If the push is unsuccessful, then the duplicator plays its "blocked" sound and then does nothing. If the push is successful, then the contents of the source tile are copied to the destination and the duplication sound is played. If the source tile has stats, then all stats are carried over to the duplicate (including the code).
Line 47: Line 47:


Duplicators support non-standard x/y-step values, but as always care should be taken to avoid out-of-bounds interactions.
Duplicators support non-standard x/y-step values, but as always care should be taken to avoid out-of-bounds interactions.
== Touching through a Duplicator ==
If a player or player clone is at the destination tile of a duplicator, the player will touch the element on the source tile. Various different side effect can happen depending on the element.
* Collectible items (e.g. [[gem|gems]], [[torch|torches]]: The item is collected and destroyed. However, due to a visual bug the item will appear to stay in place until the board is redrawn.
* Built-in enemies (e.g. [[lion|lions]], [[tiger|tigers]]): The player takes damage, and the enemy is destroyed.
* [[Object]]: The object receives a [[touch]] message.
* [[Passage]] or [[Edge]]: The player is forced through the passage. This will result in the "[[koopo bug]]" occurring (stat parameters on the next board getting corrupted).
* [[Boulder]] or [[Slider]]: ZZT will crash due to a stack overflow.


{{ElementsNavbox}}
{{ElementsNavbox}}

Latest revision as of 22:10, 22 December 2025

Duplicator
ZZT-OOP nameDuplicator
Internal ID12 (0x0C)
Character#char 250 · (0xFA)
Default colorwhite on black (0x0F)
CategoryItem
Stats
X/Y-stepSource Direction
Default cycle(9-P2)*3
P1Duplication Timer
P2Duplication Rate
Other traits
Effect on movementWall
Destructible?no
Uses ZZT-OOP color names?Default only

The duplicator is device that copies an element from its source direction to the tile in its opposite direction. The frequency at which it duplicates can be changed with the "duplication rate" parameter, with higher numbers resulting in faster duplication.

Every tick the duplicator increments its duplication timer by one, and then draws the tile according to the following table:

Duplicator Characters
P1 Character
1 #char 250 · (0xFA)
2 #char 249 (0xF9)
3 #char 248 ° (0xF8)
4 #char 111 o (0x6F)
5 #char 79 O (0x4F)
Default #char 250 · (0xFA)

When the duplication timer reaches 5, the timer is reset and the duplicator attempts to duplicate the element in the source direction.

The duplication procedure first checks if a player (or player clone) is at the destination tile. If so, then the game has the player touch the source tile, with several possible side effects (listed below).

If a player is not at the destination tile, the game instead attempts to push the destination tile away. If the push is unsuccessful, then the duplicator plays its "blocked" sound and then does nothing. If the push is successful, then the contents of the source tile are copied to the destination and the duplication sound is played. If the source tile has stats, then all stats are carried over to the duplicate (including the code).

Note that every tick the duplicator sets its cycle according to the formula Cycle := (9 - P2) * 3, with P2 representing the "Duplication Rate," which limits the granularity and maximum speed of duplicators even when using external editors.

Duplicators support non-standard x/y-step values, but as always care should be taken to avoid out-of-bounds interactions.

Touching through a Duplicator

If a player or player clone is at the destination tile of a duplicator, the player will touch the element on the source tile. Various different side effect can happen depending on the element.

  • Collectible items (e.g. gems, torches: The item is collected and destroyed. However, due to a visual bug the item will appear to stay in place until the board is redrawn.
  • Built-in enemies (e.g. lions, tigers): The player takes damage, and the enemy is destroyed.
  • Object: The object receives a touch message.
  • Passage or Edge: The player is forced through the passage. This will result in the "koopo bug" occurring (stat parameters on the next board getting corrupted).
  • Boulder or Slider: ZZT will crash due to a stack overflow.