To me, the two words of importance here are "ritual" and "script". The on-line Oxford Dictionary defines "ritual" as:
a religious or solemn ceremony consisting of a series of actions performed according to a prescribed order
Likewise, a "script" can be understood to be:
a series of actions performed according to a prescribed order,
It seems that the author is suggesting that Cook's death was the result of some sort of ceremony and, once that ceremony began, it would play out step by step to the finish. There would be no need for individual thinking or volition (i.e. the exercise of personal agency), as every participant simply went through the steps required by the ritual. By participants, I mean the Hawaiian Islanders; no doubt the British sailors would have preferred not to take part in this ceremony.
From my reading of the events (e.g. see link below) this appears to have been a simple act of retribution, and not any form of ritual. In which case, the participants were in possession of their agency, and Cook and his sailors got what they deserved.