There are very few rules with respect to hiding in 5e.
- Chapter 7, Using Ability Scores, Dexterity, Stealth, pp 177 PHB
- Chapter 8, Adventuring, Movement, Activity While Traveling, Stealth, pp 182
- Chapter 9, Combat, The Order of Combat, Surprise, pp 189
- Chapter 9, Combat, Actions in Combat, Hide, pp 192
- Chapter 9, Combat, Actions in Combat, Making an Attack, Unseen Attackers and Targets, pp 194-5
The DM determines who might be surprised. If neither side tries to be stealthy, they automatically notice each other. Otherwise, the DM compares the Dexterity (Stealth) checks of anyone hiding with the passive Wisdom (Perception) score of each creature on the opposing side. Any character or monster that doesn't notice a threat is surprised at the start of the encounter.
From Unseen Attackers and Targets:
...you're targeting a creature you can hear but not see... If you are hidden--both unseen and unheard...
You can be unnoticed, both unseen and unheard. Not noticing a threat is required to be surprised.
You can be unseen and and the enemy does not know your location, but the enemy can be aware of your presence. This can happen if your enemy has the Alert feat, or a Weapon of Warning or DM ruling. Not knowing an enemy’s location means you have to guess the location if you want to make an attack.
You can be unseen, but the enemy knows your location. Unseen means the target suffers the penalties of being blinded, but only with respect to attacks or checks against or from the unseen attacker.
Some creatures have other senses (tremorsense, blindsight, truevision or even a wolf's advantage on Perception checks that rely on smell), so "seen" may not always be visual.
Outside of combat, whether you can attempt to hide depends on your Travel Pace.
In your example, the dwarf is in absence of light, and the cultists have normal vision.
A heavily obscured area--such as darkness, opaque fog, or dense foliage--blocks vision entirely. A creature effectively suffers from the blinded condition when trying to see something in that area.
Assuming combat has not started yet, you need to determine surprise and establish positions.
- The fighter's Stealth check had advantage owing to being heavily obscured in the darkness
Heavy obscurity means the cultists are effectively blinded when trying to see something in that area, so you still need to make a check for surprise (to see if they notice the dwarf), but otherwise there is no advantage, except by DM discretion/fiat.
- The fighter's Stealth check had advantage due to her boots of elvenkind
- The fighter's Stealth check had disadvantage due to her armour
If circumstances cause a roll to have both advantage and disadvantage, you are considered to have neither of them
The fighter's Stealth check is normal.
- The cultists' Perception check had advantage because they had already been attacked by the fighter, they knew she was hiding in the darkness up ahead of them, and they expected further attacks to come from that direction.
The fighter is not in dim light, so the cultists do not have disadvantage, however, they are effectively blinded and will not be able to "see" the dwarf, but may notice the dwarf, allowing them not to be surprised. Allowing them advantage because they had been attacked by him before is DM discretion/fiat, otherwise, nothing grants that.
- The advantage to the fighter's Stealth check granted by being heavily obscured would have become a disadvantage to the cultists' Perception check.
No. On opposed checks, a source of advantage or disadvantage is only with respect to the one making the check. If a PC has Advantage and the NPC has Disadvantage, they do not cancel out or affect each others checks.
Both participants in a contest make ability checks appropriate to their efforts. They apply all appropriate bonuses and penalties, but instead of comparing the total to a DC, they compare the totals of their two checks.
- The fighter would still have made a standard Stealth check because she would still have had advantage and disadvantage, which would cancel out
Yes, but because of Disadvantage from armor and Advantage from the boots, and whatever other circumstances the DM warrants. The cultist's circumstance on their Perception check has no effect on the fighter's Stealth check.
- The cultists' Perception check would have had disadvantage because the fighter was heavily obscured from them
No. But they cannot see him in any case. At this point, we're just determining surprise.
You did not say what kind of light the cultists were carrying, but if they were torches, they would be able to see 40' in dim light and the dwarf's darkvision allows him to see 60' as if it was dim light. But since they are in bright light, he can see them without a Perception check within Line of Sight. (He can see them clearly).
After rolling initiative, the question would be are they aware of the dwarf? If not they would not be able to act in the first round. In either case, the dwarf's first attack would most likely be at advantage, as they are effectively blinded, and if they guess correctly the dwarf's location, attacks against him would be at disadvantage. If they do not close with the dwarf, that may remain to be the case, but it all depends on how the combat plays out, whether the dwarf keeps moving, etc.
when you make an attack, you give away your location when the attack hits or misses.
They would no longer have to guess which square.
If they get within 40' of the dwarf, they can attempt a Perception check, at disadvantage. If they come within 20', he'll be in bright light and obviate hiding.
All the Perception checks are passive, unless you use an action.
There are two errata that may impact how this is understood, especially if using an older Player's Handbook.
Hiding (p. 177). The following sentence has been added to the beginning of this section: “The DM decides when circumstances are appropriate for hiding.” The first sentence of the second paragraph now begins, “You can’t hide from a creature that can see you clearly ...”
Vision and Light (p. 183). The second sentence of the third paragraph has been changed to “A creature effectively suffers from the blinded condition (see appendix A) when trying to see something in that area.”
It wasn't clear from the post, but if on his turn, after engaging with the cultists, the dwarf fled down the hall, and the cultists followed on their turn(s), then surprise may not be warranted as combat has already started. In any case, they would not have a chance to "see" the dwarf until they approached within 40'. Given a long enough hallway, the dwarf may be able to keep them in line of sight and continue moving, making successive attacks at advantage. A cultist might throw their torch, dash, or even cast a light spell on a coin and throw it.