MegaGlest Forum
Modding and game content creation => Maps, tilesets and scenarios => Topic started by: ElimiNator on 13 May 2009, 05:46:43
-
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>
-
Well, its hard without the files, but here's POSSIBILITIES (just from looking at it quickly, no in depth reading):
-You tried to comment out a line withg <!-- --> This is HTML/XML only, and lau comments with --. That's all you need, and may be the problem. Not sure how lau likes seeing <! (the rest will end up commented out though).
-The map name may be wrong
-Ditto for the tileset, though this is most likely NOT the problem
-You disabled ai number 3 (player 4), who does not exist.
-Its possible you forgot to make the .lng file or didn't name it right
-possible case problems (map, scenario name, not in folder, folder titled wrong, lng titled wrong, etc;)
-You tried to set player 3 (this is actually 4 in normal terms) as the winner, player 3 does not exist.
-A unit may not exist.
Not sure though, since I don't have time to look more carefully, and don't know the files you are using.
Do you get an error message??? What does it say? Are you using glest 3.2.x?
-
Yes I am using glest 3.2.x
It is the right map and tileset.
Here is the error, Couldn't process event: Error loading lua code: Syntax error: [string "unitDied"]:32: 'end' expected (to close 'function' at line 1) near '<eof>'
Segmentation fault
and here is the script again with the stuff you said fixed.
-----------------------------------------------
<?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)
--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))
--player units
for i=1, 1 do
createUnit('pirate_ship', 0, startLocation(0))
end
--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>
-
I'm not an expert on Lua but from what I can see you aren't 'end'ing
--check for first village destroyed
if lastDeadUnit()==ship1Unit then
-
Yes, the whole if statement is blank!
The message tells you exactly where to look (in the unit died section).
if lastDeadUnit()==ship1Unit then
<perform script here>
end
-
To be picky it's not really blank it just doesn't end, whether the intention was to encapsulate the rest of the script or not. Hence the error " 'end' expected ".
-
--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
It ends
-
each control block needs its own end, therefore it would be something like.
--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
end
-
Ok thanks :)