I am trying to make scenarios but when I move the horseman the game crash, whats wrong ?
the 'you' variable is the horseman
'indianchief' is the variable that start with 'not_here' value, and change to 'end' if the horseman stay near to the mainteepee.
Here is the function :
cell_event2 = registerCellTriggerEventForUnitToLocation(you,{100,100})
</startup>
<cellTriggerEvent>
if triggeredCellEventId() == cell_event2 and indianchief == 'end' then
setPlayerAsWinner(0)
endGame()
unregisterCellTriggerEvent(cell_event1)
end
</cellTriggerEvent>
</scripts>
</scenario>
And here the full code :
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="1"/>
<players>
<player control="human" faction="tech" team="1"/>
<player control="cpu-easy" faction="indian" team="1"/>
<player control="cpu-easy" faction="indian" team="1"/>
<player control="closed"/>
</players>
<map value="kaloan2-3"/>
<tileset value="forest"/>
<tech-tree value="megapack"/>
<default-resources value="true"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<startup>
showMessage('intro1', 'title')
showMessage('intro2', 'title')
showMessage('messenger1', 'messenger')
showMessage('messenger2', 'messenger')
showMessage('info1', 'info')
createUnit('horseman', 0, startLocation(2))
you = lastCreatedUnit()
createUnit('mainteepee', 1, startLocation(1))
main = lastCreatedUnit()
createUnit('worker', 1, startLocation(1))
worker1 = lastCreatedUnit()
createUnit('worker', 1, startLocation(1))
worker2 = lastCreatedUnit()
createUnit('worker', 1, startLocation(1))
worker3 = lastCreatedUnit()
createUnit('shaman', 1, startLocation(1))
shaman = lastCreatedUnit()
createUnit('archer', 1, startLocation(1))
archer1 = lastCreatedUnit()
createUnit('archer', 1, startLocation(1))
archer2 = lastCreatedUnit()
createUnit('archer', 1, startLocation(1))
archer3 = lastCreatedUnit()
createUnit('roundtent', 1, startLocation(1))
roundtent = lastCreatedUnit()
createUnit('horsefarm', 1, startLocation(1))
cell_event1 = registerCellTriggerEventForFactionToUnit(0,main)
cell_event2 = registerCellTriggerEventForUnitToLocation(you,{100,100})
cell_event3 = registerCellTriggerEventForFactionToUnit(0,worker1)
cell_event4 = registerCellTriggerEventForFactionToUnit(0,worker2)
cell_event5 = registerCellTriggerEventForFactionToUnit(0,worker3)
cell_event6 = registerCellTriggerEventForFactionToUnit(0,shaman)
cell_event7 = registerCellTriggerEventForFactionToUnit(0,roundtent)
cell_event8 = registerCellTriggerEventForFactionToUnit(0,archer1)
cell_event9 = registerCellTriggerEventForFactionToUnit(0,archer2)
cell_event10 = registerCellTriggerEventForFactionToUnit(0,archer3)
indianchief = 'not_here'
</startup>
<cellTriggerEvent>
if triggeredCellEventId() == cell_event1 and indianchief == 'not_here' then
showMessage('messenger1', 'messenger')
end
if triggeredCellEventId() == cell_event1 and indianchief == 'here' then
showMessage('main1', 'messenger')
indianchief = 'end'
unregisterCellTriggerEvent(cell_event1)
end
if triggeredCellEventId() == cell_event2 and indianchief == 'end' then
setPlayerAsWinner(0)
endGame()
unregisterCellTriggerEvent(cell_event1)
end
if triggeredCellEventId() == cell_event3 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event3)
end
if triggeredCellEventId() == cell_event4 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event4)
end
if triggeredCellEventId() == cell_event5 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event5)
end
if triggeredCellEventId() == cell_event6 and indianchief == 'not_here' then
showMessage('shaman1', 'messenger')
indianchief = 'shaman'
end
if triggeredCellEventId() == cell_event6 and indianchief == 'roundtent' then
showMessage('shaman2', 'messenger')
indianchief = 'here'
unregisterCellTriggerEvent(cell_event6)
end
if triggeredCellEventId() == cell_event7 and indianchief == 'shaman' then
showMessage('roundtent1', 'messenger')
indianchief = 'roundtent'
unregisterCellTriggerEvent(cell_event7)
end
if triggeredCellEventId() == cell_event7 and indianchief == 'not_here' then
showMessage('messenger1', 'messenger')
end
if triggeredCellEventId() == cell_event8 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event8)
end
if triggeredCellEventId() == cell_event9 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event9)
end
if triggeredCellEventId() == cell_event10 then
showMessage('messenger1', 'messenger')
unregisterCellTriggerEvent(cell_event10)
end
</cellTriggerEvent>
</scripts>
</scenario>
Please help me !