Because, according to the condition (else), if the object (city?) "castle" does not belong to player 2, then the video is played.
If you need it to play after capturing the city, you need to add a script for capturing the city with the activation of a function through OBJECT_CAPTURE_TRIGGER, where we check that the city has been captured and who the new owner is, and then we will play the video if the city was taken by the player who owns the hero you need. Something like this:function TownCaptured( oldowner, newowner )
if IsHeroAlive("Hafad") then
if IsHeroAlive("Christian") then
if ( newowner == GetObjectOwner("Christian") ) then
StartDialogScene("/DialogScenes/FallenKnight/S3/DialogScene.xdb#xpointer(/DialogScene)")
sleep(1)
SetObjectiveState("prim5", OBJECTIVE_COMPLETED, 1)
SetObjectiveState("prim6", OBJECTIVE_ACTIVE, 1)
elseif newowner == PLAYER_2 then
SetObjectiveState("prim5", OBJECTIVE_FAILED, 1)
sleep(10)
loose()
end
end
end
end
Trigger( OBJECT_CAPTURE_TRIGGER, "castle", "TownCaptured" );Thus, after MoveHero from the function with the hero's respawn, the conditions and actions can be removed)
By the way, a similar problem arose with another function - a cutscene is played, then a battle begins, and AFTER the battle, a text message appears. But - the cutscene is played, and the text message appears BEFORE the battle. How can this be fixed?