In the Book of Gates, the gods are depicted as assisting Ra in his battle against Apophis.
The text describes the gods as forming a protective barrier around Ra's boat, which shields him from Apophis' attacks.
The gods then use their magical powers to defeat Apophis, firing magical arrows at the serpent and using spells to banish him from the realm of the gods.
The Book of Gates also describes the role of the deceased in this battle. According to the text, the deceased is seen as an ally of the gods, and is depicted as helping to defend Ra's boat from Apophis' attacks.
Ultimately, the text suggests that the deceased can earn their place among the gods by assisting in the defeat of Apophis.
At the end, the defeat of Apophis in the Book of Gates represents the triumph of order over chaos, and highlights the importance of the gods in protecting the universe from the forces of darkness.
It also emphasizes the role of the deceased in this battle, and the belief that they can assist the gods in maintaining the balance of the universe.
The story of Apophis' defeat is just one example of the many rituals and beliefs that the ancient Egyptians used to protect themselves from the malevolent forces that threatened their world.