Four of the 21 trees have a chance to attract Munchlax; which four can do so are selected when the game begins, based on the player's Trainer ID and Secret ID, meaning that the same trees will always be able to attract Munchlax unless the player starts a new game. Trees which can attract Munchlax are also more likely to attract rarer wild Pokémon.
The species of Pokémon (or whether one will appear at all) is determined at the time a tree is slathered. Therefore, once a tree is slathered, saving the game and resetting will not change the Pokémon that will appear on it. However, its level, gender, Nature, IVs, and other random values are determined when it is encountered.
Which four Honey Trees can contain Munchlax depends on the player's Trainer ID and secret ID (referred to herein as tid and sid). These numbers are 2-byte values, and the game splits each into single bytes. tid1 and sid1 will refer to the lower byte of each ID number (calculable by id % 256), while tid2 and sid2 will refer to the higher byte (calculable by id / 256).
The location of the four Munchlax trees is then determined as follows:
The game checks if any of these are equal. If A is equal to B, B is increased by 1. The game then checks A against C, followed by B against C, adding 1 to C if it is equal after either check. Then the game checks A against D, followed by B against D, and then C against D, and adds 1 to D if it is equal after any of the checks. If at any point any of B, C, or D would equal 21, they are set to 0 instead.
The final values of A, B, C, and D represent the locations of the Munchlax trees. The number can be treated as a 0-based index into the list of Honey Tree locations above. That is, if A = 10, that means the Honey Tree on Route 212 south can contain Munchlax.
When the game generates a species of wild Pokémon to appear on a Honey Tree, it first chooses from one of three possible "groups" of Pokémon before choosing a Pokémon from within that group. These groups are shown in the table below. The 17 non-Munchlax trees have a 70% chance of choosing from Group A, a 20% chance of choosing from Group B, a 0% chance of choosing from Group C, and a 10% chance of choosing no encounter. The four Munchlax trees have a 20% chance of choosing from Group A, a 70% chance of choosing from Group B, a 1% chance of choosing from Group C, and a 9% chance of choosing no encounter.
When Honey is slathered on a tree, if that tree is also the last tree that was slathered, there is a 90% chance that the game will pick the same group as it did the last time. If the tree's last slathering did not produce any Pokémon, it will be treated as if the tree had selected Group A.
Very roughly speaking, the more a tree shakes, the more likely it is for a rare Pokémon to appear. The number of times a tree shakes is randomly decided depending on the group that was selected for the tree.
So, based on the number of times a tree shakes, a Pokémon from the different groups will have the following chance to appear.
For normal trees:
For Munchlax trees:
If the tree being slathered was also the last tree slathered (and the tree is empty), there is a 90% chance that the tree will attract a Pokémon from the same group that was used before. This will render the rates below inaccurate. See above for an explanation of the sets and the exact rarities of Pokémon.
In a flashback in Historical Mystery Tour!, it was revealed that Barry used Honey to attract a Heracross, which he then caught. He repeated this same scenario in an illusionary adventure that a Clown sent him to.
In Honey for Combee, as Diamond, Pearl, and Platinum ventured into Floaroma Meadow, Diamond and his Pokémon smelled Honey and ran off to lick it off a tree, only to be attacked by a swarm of angry Combee, whom the Honey had been meant for. Later, the trio ventured into the Valley Windworks, where they met Mars, who filled the Windworks control room with sand in order to do away with them. Pearl and Platinum ended up outside the building and were able to uncover Diamond's location inside the building and save him thanks to a group of Combee being attracted by the scent of Honey on Diamond and his Pokémon.
Honey may originally have been planned for Generation II, where unused text refers to an item called Sweet Honey (Japanese: あまいミツ Sweet Honey), which could be used to attract Pokémon by slathering it on a tree and waiting about a day, nearly identical to its behavior in Generation IV.