Robin Hood

In 1199 A.D., Robin Longstride (Russell Crowe) is a common archer in the army of King Richard the Lionheart (Danny Huston). A veteran of Richard's crusade, he now takes part in the siege of Chalus Castle. Disillusioned and war-weary, he gives a frank but unflattering appraisal of the King's conduct after the King asks him to answer him honestly. Though the King commends him for his honesty Robin and his comrades â archers Allan A'Dayle (Alan Doyle) and Will Scarlett (Scott Grimes) and soldier Little John (Kevin Durand) â find themselves in the stocks.
When the King is slain during an attack on the castle, Robin and his men decide to free themselves and desert. They come across an ambush of the English royal guard by Godfrey (Mark Strong), an English knight who has conspired with King Philip of France to assassinate the King. As Godfrey flees Robin attempts to shoot him but only succeeds in wounding Godfrey's face with an arrow. Robin decides to take advantage of the situation by having his men impersonate the dead English knights to return to England. As they depart, Robin promises one of the dying knights, Sir Robert Loxley (Douglas Hodge), to return a sword to his father in Nottingham.
As Robin and his men become drunk on the voyage, they awake too late to flee unnoticed and Robin is forced to assume the identity of the slain Loxley and publicly inform the royal family of the King's death. He witnesses the coronation of King John (Oscar Isaac), who orders harsh new taxes to be collected, dispatching Sir Godfrey to the North to do so â unaware that Godfrey will instead use French troops to stir up unrest and create an opening for Philip to invade England.
Robin and his companions head to Nottingham, where Loxley's elderly and blind father, Sir Walter (Max von Sydow), asks him to continue impersonating his son, to prevent the family lands being taken by the Crown. However, Loxley's widow, Lady Marion (Cate Blanchett), is initially cold toward Robin, but warms to him, when he and his men merrily recover tithed grain for the townsfolk to plant.
Godfrey's actions incite the northern barons, who march to meet King John. Speaking now for Sir Walter, Robin proposes the King agree to a charter of rights to ensure the rights of every Englishman and unite his country. Having realized Godfrey's deception, and knowing he must meet the French invasion with an army, the King agrees. Meanwhile, the French marauders plunder Nottingham and Godfrey murders Sir Walter. Robin and the northern barons arrive and stop Godfrey's men.
As the French begin their invasion on the beach below the Cliffs of Dover, Robin leads the now united English army against them. In the midst of the battle, Robin duels with Godfrey, who attempted to kill Marion and flees until Robin finally succeeds in shooting him with an arrow from afar. Philip realizes that his plan to divide England has failed and calls off his invasion. When King John sees the French surrendering to Robin instead of himself, he senses a threat to his power. In London, John reneges on his promise to sign the charter, instead declaring Robin an outlaw to be hunted throughout the kingdom. The Sheriff of Nottingham (Matthew Macfadyen) announces the decree as Robin and his men flee to Sherwood Forest with the orphans of Nottingham. Marion narrates their new life in the greenwood, noting that they live in equality as they right the many wrongs in the Kingdom of King John.

Question: When if the King killed?
Answer: during an attack on the castle