BlueHeavenHero, I understand... Then, let's rewrite the function like this:
function TownCaptured( oldowner, newowner )
if ( newowner == PLAYER_1 ) and ( GetObjectiveState("prim6") ~= OBJECTIVE_ACTIVE ) then
DeployReserveHero("Christian", 98, 108, 0)
SetObjectiveState("prim5", OBJECTIVE_COMPLETED, 1)
SetObjectiveState("prim6", OBJECTIVE_ACTIVE, 1)
sleep(3)
MoveHero("Christian", 126, 139, -1)
end
if newowner == PLAYER_2 then
SetObjectiveState("prim5", OBJECTIVE_FAILED, 1)
sleep(10)
Loose()
end
end
Trigger( OBJECT_CAPTURE_TRIGGER, "castle", "TownCaptured" );Using the same logic, we can attach a trigger to the loss of heroes for the player who owns your hero. When a hero is lost, a function will be triggered that checks if the player lost the correct hero, and then a cutscene or something else will be launched if needed.
By the way, a similar problem arose with another function - a cutscene is launched, then a battle begins, and AFTER the battle, a text message appears. But - the cutscene is launched, and the text message appears BEFORE the battle. How can this be fixed?
If the battle is launched through StartCombat, there is an argument that allows you to launch a function after the battle is over. Write a function with the text that will be launched after the battle and display the text.
