I made a scenario, and 3 units attack you when you destroy them 4 more come if you survive that then you win, But it they destroy your main unit (Like a castle) you lose. And it wont work? Help!
Here is the scenario script
---------------------------------------------------
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="3"/>
<players>
<player control="human" faction="pirates" team="1"/>
<player control="cpu" faction="pirates" team="1"/>
<player control="cpu" faction="pirates" team="2"/>
<player control="closed"/>
</players>
<map value="The_sea2"/>
<tileset value="sea"/>
<tech-tree value="magitech"/>
<default-resources value="false"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<startup>
--disable AI
disableAi(1)
disableAi(2)
disableAi(3)
--allied units
createUnit('docks', 0, startLocation(2))
dockUnit= lastCreatedUnit()
giveResource('gold', 0, 500);
giveResource('wood', 0, 500);
giveResource('stone', 0, 500);
giveResource('food', 0, 50);
createUnit('worker', 0, startLocation(2))
createUnit('worker', 0, startLocation(2))
createUnit('worker', 0, startLocation(2))
createUnit('captain', 1, startLocation(2))
summonerUnit= lastCreatedUnit()
<!--setCameraPosition(unitPosition(summonerUnit))-->
<!--givePositionCommand(summonerUnit, 'attack', startLocation(1))-->
--player units
for i=1, 1 do
createUnit('pirate_ship', 0, startLocation(0))
end
<!--enemy units village
createUnit('library', 2, startLocation(1))
libraryUnit= lastCreatedUnit()
createUnit('golem', 2, startLocation(1))-->
--create enemy attackers
for i=1, 1 do
createUnit('cargo_ship', 2, startLocation(1))
ship1Unit= lastCreatedUnit()
givePositionCommand(ship1Unit(), 'attack', startLocation(2))
end
for i=1, 1 do
createUnit('cargo_ship', 2, startLocation(1))
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))
end
for i=1, 1 do
createUnit('cargo_ship', 2, startLocation(1))
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))
end
--objectives
objective='ObjectiveBoat'
showMessage('start', 'captain')
setDisplayText('ObjectiveBoat')
</startup>
<unitDied>
--check for dock dying
if lastDeadUnit()==dockUnit then
clearDisplayText()
setPlayerAsWinner(3)
endGame()
end
--check for first village destroyed
if lastDeadUnit()==ship1Unit then
for i=1, 1 do
createUnit('cargo_ship', 2, startLocation(1))
ship2Unit= lastCreatedUnit()
givePositionCommand(ship2Unit(), 'attack', startLocation(2))
end
for i=1, 3 do
createUnit('cargo_ship', 2, startLocation(1))
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))
end
--check for second village destroyed
if lastDeadUnit()==ship2Unit then
clearDisplayText()
setPlayerAsWinner(0)
setPlayerAsWinner(1)
endGame()
end
</unitDied>
</scripts>
</scenario>