Skip to content

Commit

Permalink
amazones +light +pro
Browse files Browse the repository at this point in the history
  • Loading branch information
titiger committed Mar 5, 2017
1 parent 422bfcc commit 2d0cfeb
Show file tree
Hide file tree
Showing 28 changed files with 721 additions and 274 deletions.
240 changes: 103 additions & 137 deletions scenarios/amazones/amazones.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="yes" ?>
<scenario>
<difficulty value="4"/>
<difficulty value="3"/>
<players>
<player control="human" faction="tech" team="1"/>
<player control="cpu-ultra" faction="norsemen" team="2"/>
Expand All @@ -14,186 +14,152 @@
<default-units value="false"/>
<default-victory-conditions value="false"/>
<scripts>
<global>
-- global vars
isSent=0
<global>
-- global vars
isSent=0

function addAttackingEnemy(unit, amount, startPosition)
for i=1, amount do
enemyCount=enemyCount+1
if startPosition ~= 'far' then
createUnit(unit, 1, startLocation(1))
else
createUnit(unit, 1, {startLocation(1)[1] - 30, startLocation(1)[2] + 30})
end
enemies[#enemies+1]=lastCreatedUnit()
givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))
function addAttackingEnemy(value)
enemyCount=enemyCount+1
createUnit(value, 1, startLocation(1))
enemies[#enemies+1]=lastCreatedUnit()
givePositionCommand(lastCreatedUnit(), 'attack',startLocation(0))
end

function sendFlyingUnits()
isSent=1
for i=1, 5 do
addAttackingEnemy('flying_valkyrie')
end
end
</global>

</global>
<startup>
--my castle
createUnit('castle', 0, {startLocation(0)[1] - 2, startLocation(0)[2] - 1})

--allied castle
createUnit('castle', 2, {startLocation(0)[1] + 8, startLocation(0)[2] + 5})
alliedCastle=lastCreatedUnit()
disableAi(2)
--disable AI
disableAi(1)
--disableAi(2)
--disableAi(3)

--my units
createUnit('castle', 0, startLocation(0))
createUnit('cow', 0, startLocation(0))
for i=1, 3 do
createUnit('worker', 0, startLocation(0))
createUnit('swordman', 0, startLocation(0))
end
for i=1, 2 do
createUnit('archer', 0, startLocation(0))
end
createUnit('worker', 0, startLocation(0))
createUnit('worker', 0, startLocation(0))
createUnit('worker', 0, startLocation(0))
createUnit('swordman', 0, startLocation(0))
createUnit('swordman', 0, startLocation(0))
createUnit('swordman', 0, startLocation(0))
createUnit('archer', 0, startLocation(0))
createUnit('archer', 0, startLocation(0))
giveResource('gold', 0, 1000);
giveResource('wood', 0, 1200);
giveResource('wood', 0, 1300);
giveResource('stone', 0, 350);
giveResource('food', 0, 150);
giveResource('food', 0, 1000);

--allied units
createUnit('castle', 2, startLocation(0))
alliedCastle=lastCreatedUnit()

-- enemy units
createUnit('castle', 1, startLocation(1))
giveResource('gold', 1, 1000);
giveResource('wood', 1, 1000);
giveResource('food', 1, 1000);

createUnit('castle', 1, startLocation(1))

for i=1, 20 do
createUnit('cow', 1, startLocation(1))
end
for i=1, 30 do
createUnit('valkyrie', 1, startLocation(1))
givePositionCommand(lastCreatedUnit(), 'move', startLocation(1))
end
disableAi(1)
disableConsume(1)
giveResource('food', 1, 150)

enemies={}
enemyCount=0;
addAttackingEnemy('cudgel_lady', 10)
for i=1, 10 do
addAttackingEnemy('cudgel_lady')
end

--objectives
objective='Firstwave'
showMessage('Brief1', 'Amazones')
setDisplayText('Firstwave')

counterMode='Wait'
TimeRatio=50
timer_event1 = startTimerEvent()
timer_event2 = startTimerEvent()
</startup>

<unitCreated>
</unitCreated>

<timerTriggerEvent>
-- displayFormattedText('counterMode=%s, %s/%s, %s/100; enemyCount=%s; objective=%s', counterMode, timerEventSecondsElapsed(timer_event1), TimeRatio, timerEventSecondsElapsed(timer_event2), enemyCount, objective);
if triggeredTimerEventId() == timer_event1 then
if timerEventSecondsElapsed(triggeredTimerEventId()) >= TimeRatio then
TimeRatio=50
counterMode='NextObjective'
end
if counterMode=='KillDetected' then
resetTimerEvent(triggeredTimerEventId())
counterMode='Kill'
<unitDied>
--check for all enemies dead
for i=1, #enemies do
if lastDeadUnit()==enemies[i] then
enemyCount=enemyCount-1
end
if counterMode=='Kill' then
resetTimerEvent(timer_event2)
elseif counterMode=='End' then
stopTimerEvent(triggeredTimerEventId())
end
if objective=="Lastwave" then
if isSent==0 then
sendFlyingUnits()
end
end
if triggeredTimerEventId() == timer_event2 then
if timerEventSecondsElapsed(triggeredTimerEventId()) >= 100 then
counterMode='Kill'
-- print('living enemies=',enemyCount)
if enemyCount==0 then
if(objective=="Lastwave") then
clearDisplayText()
objective="Endgame"
setPlayerAsWinner(0)
setPlayerAsWinner(2)
endGame()
end
if counterMode=='NextObjective' or counterMode=='FinishHim' then
if(objective=="Fourthwave") then
addAttackingEnemy('cudgel_lady', 40)
addAttackingEnemy('valkyrie', 10, 'far')
objective='Lastwave';
elseif(objective=="Thirdwave") then
addAttackingEnemy('cudgel_lady', 30)
addAttackingEnemy('valkyrie', 5, 'far')
objective='Fourthwave';
elseif(objective=="Secondwave") then
addAttackingEnemy('cudgel_lady', 44)
objective='Thirdwave';
elseif(objective=="Firstwave") then
addAttackingEnemy('cudgel_lady', 22)
objective='Secondwave';
end
if counterMode~='End' and counterMode~='FinishHim' then
showMessage(objective, 'Amazones');
setDisplayText(objective);
if(objective=="Fourthwave") then
enemies={}
for i=1, 40 do
addAttackingEnemy('cudgel_lady')
end
if counterMode=='FinishHim' then
-- AI will check the whole map
enableAi(1)
counterMode='End'
else
counterMode='Wait'
for i=1, 10 do
addAttackingEnemy('valkyrie')
end
objective='Lastwave';
giveResource('food', 1, 1000);
end
if counterMode=='Wait' then
resetTimerEvent(timer_event1)
elseif counterMode=='End' then
stopTimerEvent(triggeredTimerEventId())
end
end
if triggeredTimerEventId() == timer_event3 then
if timerEventSecondsElapsed(triggeredTimerEventId()) >= 3 then
endGame()
stopTimerEvent(triggeredTimerEventId())
end
end
</timerTriggerEvent>
<unitDied>
--check for all enemies dead
for i=1, #enemies do
if lastDeadUnit()==enemies[i] then
enemyCount=enemyCount-1

-- only if enemy is killed
if objective=="Lastwave" then
if isSent==0 then
-- delayed attack
addAttackingEnemy('flying_valkyrie', 5, 'far')
isSent=1
end
if(objective=="Thirdwave") then
enemies={}
for i=1, 30 do
addAttackingEnemy('cudgel_lady')
end
if counterMode~='Wait' and counterMode~='End' then
counterMode='KillDetected'
for i=1, 5 do
addAttackingEnemy('valkyrie')
end
if counterMode~='Wait' then
if enemyCount>=25 then
TimeRatio=55
elseif enemyCount>=18 then
TimeRatio=50
elseif enemyCount>=12 then
TimeRatio=45
elseif enemyCount>=7 then
TimeRatio=40
elseif enemyCount>=3 then
TimeRatio=35
else
TimeRatio=30
end
objective='Fourthwave';
giveResource('food', 1, 1000);
end
if(objective=="Secondwave") then
enemies={}
for i=1, 50 do
addAttackingEnemy('cudgel_lady')
end
objective='Thirdwave';
giveResource('food', 1, 1000);
end
if(objective=="Firstwave") then
enemies={}
for i=1, 23 do
addAttackingEnemy('cudgel_lady')
end
objective='Secondwave';
giveResource('food', 1, 1000);
end
if(objective~="Endgame") then
showMessage(objective, 'Amazones');
setDisplayText(objective);
end
end

if lastDeadUnit()==alliedCastle then
counterMode='FinishHim'
setPlayerAsWinner(1)
clearDisplayText()
timer_event3 = startTimerEvent()
elseif enemyCount==0 and counterMode~='End' then
if(objective=="Lastwave") then
counterMode='End'
setPlayerAsWinner(0)
setPlayerAsWinner(2)
clearDisplayText()
timer_event3 = startTimerEvent()
else
-- enemies={}
counterMode='NextObjective'
end
setPlayerAsWinner(1)
endGame()
end
</unitDied>
</scripts>
Expand Down
Loading

0 comments on commit 2d0cfeb

Please sign in to comment.