How to remove and create unit in scenario without losing scenario in Age of Empires II (HD)?
I'm currently making an Age of Empires 2 (HD) scenario which involves triggers. Now I'm trying to replace a unit by first teleporting a Gaia unit into the player's LOS, and then removing the player's other unit.
But when the Gaia unit is teleported, it converts to the player's color, but nevertheless the scenario is ended with 'You have been defeated'.
How can I make sure that the scenario is not ended prematurely?
You can have the player's only unit change in the manner you describe. The issue is that only certain units will allow them to stay in the game.
Some units don't count towards having a surviving unit. Pictured below, I have lost despite controlling a Fishing Ship, Junk, Sheep, Relic Cart, Trade Cart, Turkey, Cow and Llama. (The right-most unit was a military unit who just died)
Controlling a combat unit, monk or villager averts the problem. Unexpectedly, there are some units that despite not being "useful" (no combat ability), will allow the player to continue playing as their only unit. At least Camel (Gaia), Horse, and Siege Tower also posses this trait.
If you are set on the player only having a specific unit, you can also use buildings to prevent a loss. However many building that don't produce units buildings will not help.