Author Topic: Scenario - Egypt has fallen  (Read 2043 times)

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Scenario - Egypt has fallen
« on: 4 May 2016, 04:52:56 »
My first scenario. I'm sure it will need some adjustments. It's a network scenario. What does anyone think of it?

Code: [Select]
<?xml version="1.0" standalone="yes" ?>
<scenario>
--Grandezza Peril 1a
--Stay alive long enough for your Egyptian ally to reinforce your armies!
--By Andy Alt
--CC-BY-SA
<difficulty value="4"/>
<players>
<player control="network" faction="tech" team="1"/>
<player control="human" faction="indian" team="1"/>
<player control="network" faction="persian" team="1"/>
<player control="cpu-ultra" faction="egypt" team="1"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
</players>
<map value="grandezza"/>
<tileset value="autumn"/>
<tech-tree value="megapack"/>
<default-resources value="true"/>
<default-units value="false"/>
<default-victory-conditions value="true"/>
<fog-of-war value="true"/>

<scripts>
<startup>


--Team 1 units
--create workers
for j=0, 2 do
for i=1, 4 do
createUnit('worker', j, startLocation(j))
end
end

--Main buildings for Team 1
createUnit('castle', 0, startLocation(0))
createUnit('main_teepee', 1, startLocation(1))
createUnit('palace', 2, startLocation(2))

--create defense towers for Team 1
for i=0, 3 do
createUnit('defense_tower', 0, startLocation(i))
end


--Egypt (player 4, Team 1) units

--4 slaves or just one? for loop disabled
--for i=1, 4 do
createUnit('slave', 3, startLocation(3))
--end

--The pyramid is located far away, forcing the Egyptians to build a new one closer to home
createUnit('pyramid', 3, startLocation(0))

--build a farm for them otherwise they will try to build one before starting
--construction on a pyramid
createUnit('farm', 3, startLocation(3))

--create AI units (Team 2, Magic)
for i=4, 7 do
createUnit('mage_tower', i, startLocation(i))
createUnit('energy_source', i, startLocation(i))
createUnit('battlemage', i, startLocation(i))
createUnit('daemon', i, startLocation(i))
createUnit('golem', i, startLocation(i))

--give them an extra energy source
createUnit('energy_source', i, startLocation(i))

for j=1, 4 do
createUnit('initiate', i, startLocation(i))
end

end

--displayFormattedText ('%s', 'Stay alive long enough for your Egyptian ally to reinforce your armies!')


</startup>



</scripts>
</scenario>

« Last Edit: 16 June 2016, 00:54:13 by andy_5995 »

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: Scenario - Grandezza Peril
« Reply #1 on: 4 May 2016, 10:43:04 »
Hi,

I do not see  much difference to normal game (just different amount of units?)

Regarding your coding:

I am pretty sure that the following is not valid XML syntax (does this even work in megaglest?):

<scenario>
--Grandezza Peril 1a
--Stay alive long enough for your Egyptian ally to reinforce your armies!
--By Andy Alt
--CC-BY-SA


you should use:

<scenario>
<!--Grandezza Peril 1a
--Stay alive long enough for your Egyptian ally to reinforce your armies!
--By Andy Alt
--CC-BY-SA-->


Your using many for - loops which are not very self-explanatory.
maybe it would help to use some variables for the factions

team_1_player_1 = 0
team_1_player_2 = 1
...
team_2_player_1 = 4
...


and then just write:
createUnit('defense_tower', 0, startLocation(team_1_player_1))
createUnit('defense_tower', 0, startLocation(team_1_player_2))
createUnit('defense_tower', 0, startLocation(team_1_player_3))


instead of:
for i=0, 3 do
    createUnit('defense_tower', 0, startLocation(i))
end   


this would increase readibility

« Last Edit: 4 May 2016, 11:21:29 by MuwuM »

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Grandezza Peril
« Reply #2 on: 4 May 2016, 22:01:32 »
Thanks for your feedback MuwuM.

I see the other scenarios use -- for the comments; that's why I chose to use that format. I changed some of the variables as you suggested.

There really is not much difference between this scenario and that of a normal game. The main difference is that the Egypt faction has to build a pyramid, so can't assist until a little later in the game.

I haven't had any really good ideas yet for a scenario and not yet familiar with all the commands available, so this first one isn't very complex.

Here is the update for it:
Code: [Select]
<?xml version="1.0" standalone="yes" ?>
<scenario>
--Grandezza Peril 1c
--This text file should go into ~/.megaglest/scenarios/grandezza_peril/grandezza_peril.xml
--Stay alive long enough for your Egyptian ally to reinforce your armies!
--By Andy Alt
--CC-BY-SA
<difficulty value="4"/>
<players>
<player control="network" faction="tech" team="1"/>
<player control="human" faction="indian" team="1"/>
<player control="network" faction="romans" team="1"/>
<player control="cpu-mega" faction="egypt" team="1"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
</players>
<map value="grandezza"/>
<tileset value="autumn"/>
<tech-tree value="megapack"/>
<default-resources value="true"/>
<default-units value="false"/>
<default-victory-conditions value="true"/>
--<fog-of-war value="true"/>

<scripts>
<startup>


--Team 1 units

--Main buildings for Team 1
createUnit('castle', 0, startLocation(0))
createUnit('main_teepee', 1, startLocation(1))
createUnit('forum', 2, startLocation(2))

--create workers
for playerNum=0, 1 do
for i=1, 4 do
createUnit('worker', playerNum, startLocation(playerNum))
end
end

for i=1, 4 do
createUnit('slave', 2, startLocation(2))
end



--create defense towers for Team 1
createUnit('defense_tower', 0, startLocation(0))
createUnit('beehive', 1, startLocation(1))
createUnit('guard_tower', 2, startLocation(2))




--create AI units (Team 2, Magic)
for playerNum=4, 7 do
createUnit('mage_tower', playerNum, startLocation(playerNum))
createUnit('energy_source',playerNum , startLocation(playerNum))
createUnit('battlemage', playerNum, startLocation(playerNum))
createUnit('daemon', playerNum, startLocation(playerNum))
createUnit('golem', playerNum, startLocation(playerNum))


for j=1, 4 do
createUnit('initiate', playerNum, startLocation(playerNum))
end

end


--Egypt (player 4, Team 1) units

--4 slaves or just one? for loop disabled
for i=1, 4 do
createUnit('slave', 3, startLocation(3))
end



--build a farm for them otherwise they will try to build one before starting
--construction on a pyramid
createUnit('farm', 3, startLocation(3))

--The pyramid is located to the far right on player 0's base
--forcing the Egyptians (far left) to build a new one closer to home.
createUnit('pyramid', 3, startLocation(7))

--displayFormattedText ('%s', 'Stay alive long enough for your Egyptian ally to reinforce your armies!')


</startup>



</scripts>
</scenario>

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Scenario - Grandezza Peril
« Reply #3 on: 8 May 2016, 05:17:07 »
@MuwuM, the Lua code sections should indeed be using Lua comments. There's actually kinda some weirdness about having a scripting language inside XML. JS has similar issues when embedded in HTML. But at any rate, the correct thing to do is use the commenting format of the scripting language. It'll typically never have any issues. At any rate, all the other scenarios do it this way.

While avoiding magic numbers is a good idea, it's not really a problem for the team numbers in most cases. Anyone with experience in Lua scripting for MG (or who has the documentation on hand) will obviously know what these numbers mean. Nothing new there. Certainly MG scenarios aren't the pinnacle of software engineering, though. Plenty of times when it's unavoidable, anyway (eg, to give some units to every player).
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Grandezza Peril
« Reply #4 on: 8 May 2016, 17:26:43 »
Thank you for the explanation, Omega

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Grandezza Peril
« Reply #5 on: 8 June 2016, 21:34:57 »
I thought I could make this scenario more interesting this way:

The 3 human players each get a second faction.
Player 1 is Roman but also starts with a Persian palace.
the 2nd player is Indian and gets a Norse castle
the third player is Tech, and gets an Egypt pyramid
So they can build units for two factions instead of one, if they choose. If they want to strategize a little differently than a regular game, they have the option. If not, they can build workers from both main buildings. If that were the case, the 4 Mega 2.5 cpus would probably have to be increased.

Thoughts, opinions?

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Egypt has fallen
« Reply #6 on: 15 June 2016, 20:03:55 »
I've renamed this scenario, made many changes to it, and updated the description

Egypt has fallen!
A MegaGlest ( https://megaglest.org/ ) network scenario
An evil faction, known only as "Magic" has invaded and destroyed most of Egypt's kingdom.
In a futile attempt to fight off Magic's army, Egypt has sent her last remaining soldiers to stop them.
If they are not successful, you will be Egypt's only chance at survival. You must protect her until she's strong enough to fight back and to assist you in vanquishing the Magic faction.
If you are successful, Queen Cleopatra will figure out some way to repay her debt to you...

Factions:

Team 1 - Tech (Human), Norsemen (Human), Indian (Human), Egypt (CPU Mega 2.5)
Team 2 - Magic 4 CPU (Mega 2.5)

Download at https://github.com/andy5995/MegaGlest_scenarios_AA
« Last Edit: 16 June 2016, 00:37:41 by andy_5995 »

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Egypt has fallen
« Reply #7 on: 16 June 2016, 00:46:50 »
I believe I've fixed the github confusion that titi_son and Jammy experienced.

We played this and won it the first time.



Different ways to make it harder? titi_son said I could change the resource multiplier in the xml file

Code: [Select]
<titi_son> the resource multiplier thing is not in the wiki...
somehow... well but what you need to do is "<player control="cpu"
resource_multiplier="1.0" faction="faction_name" team="1"/>"

Another thing that made this easy was I had coded some enemies on Magic's base at game start. By the time they were done, the mage towers were left burning and most of the initiates were dead.

So to make it more difficult? Suggestions? Should I keep it simple and increase the res multiplier? Should I give each enemy Magic faction a summoner's guild? Any other ideas?

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Egypt has fallen
« Reply #8 on: 21 March 2017, 22:50:54 »
This is the last incarnation of the Egypt Has Fallen scenario. Maybe it would be better if it were modified and turned into a single-player scenario.

egypt_has_fallen.xml
Code: [Select]
<?xml version="1.0" standalone="yes" ?>
<scenario>
--Egypt has fallen
--Rev 2016.06.22-01
--A MegaGlest ( https://megaglest.org/ ) network scenario
--Stay alive long enough for your Egyptian ally to reinforce your armies!
--By Andy Alt
--CC-BY-SA
<difficulty value="5"/>
<players>
<player control="network" faction="tech" team="1"/>
<player control="human" faction="indian" team="1"/>
<player control="cpu-mega" faction="egypt" team="1"/>
<player control="network" faction="norsemen" team="1"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
<player control="cpu-mega" faction="magic" team="2"/>
</players>
<map value="grandezza"/>
<tileset value="autumn"/>
<tech-tree value="megapack"/>
<default-resources value="true"/>
<default-units value="false"/>
<default-victory-conditions value="false"/>
<fog-of-war value="true"/>

<scripts>
<global>

--game constants. Only change them if you change the order or factions above
tech = 0
indian = 1
egypt = 2
norsemen = 3

--other variables. Best to leave them unchanged as well ;)
--These are used in unitCreated and unitDied sections below
slaveCount = 0
pyramidCount = 0
mageTowerCount = 0

battlemage_loop = 0
daemon_loop = 0
timesLooped = 0

rndAttackUnits = { "power_golem", "ghost_armor", "behemoth", "draco_rider", "daemon" }
</global>
<startup>


math.randomseed (os.time())


--Team 1 units

--Main buildings for Team 1
createUnit('castle', tech, startLocation(tech))
createUnit('main_teepee', indian, startLocation(indian))
createUnit('castle', norsemen, startLocation(norsemen))

--create workers
for playerNum=tech, indian do
for i=1, 4 do
createUnit('worker', playerNum, startLocation(playerNum))
end
end

for i=1, 4 do
createUnit('thrall', norsemen, startLocation(norsemen))
end

createUnit ( 'cow', tech, {26,210} )
createUnit ( 'cow', norsemen, {26,210} )

createUnit ( 'stickfighter', indian, startLocation (indian) )
createUnit ( 'stickfighter', indian, startLocation (indian) )
createUnit ( 'axe_thrower', indian, startLocation (indian) )
createUnit ( 'axe_thrower', indian, startLocation (indian) )
createUnit ( 'axe_thrower', indian, startLocation (indian) )

createUnit ( 'swordman', tech, startLocation (tech) )
createUnit ( 'swordman', tech, startLocation (tech) )
createUnit ( 'archer', tech, startLocation (tech) )
createUnit ( 'archer', tech, startLocation (tech) )
createUnit ( 'archer', tech, startLocation (tech) )

createUnit ( 'spearman', norsemen, startLocation (norsemen) )
createUnit ( 'spearman', norsemen, startLocation (norsemen) )
createUnit ( 'archer', norsemen, startLocation (norsemen) )
createUnit ( 'archer', norsemen, startLocation (norsemen) )
createUnit ( 'archer', norsemen, startLocation (norsemen) )



--create AI units (Team 2, Magic)
for playerNum=4, 7 do
createUnit('mage_tower', playerNum, startLocation(playerNum))
createUnit('energy_source',playerNum , startLocation(playerNum))
createUnit('energy_source',playerNum , startLocation(playerNum))
createUnit('battlemage', playerNum, startLocation(playerNum))
createUnit('battlemage', playerNum, startLocation(playerNum))
createUnit('daemon', playerNum, startLocation(playerNum))
createUnit('daemon', playerNum, startLocation(playerNum))
createUnit('daemon', playerNum, startLocation(playerNum))
createUnit('golem', playerNum, startLocation(playerNum))
createUnit('library', playerNum, startLocation(playerNum))

for j=1, 5 do
createUnit('initiate', playerNum, startLocation(playerNum))
end
--create nearby Egypt enemies
createUnit ( 'spearthrower', egypt, startLocation(playerNum) )
createUnit ( 'scarab', egypt, startLocation(playerNum) )
createUnit ( 'mummy', egypt, startLocation(playerNum) )
createUnit ( 'mummy', egypt, startLocation(playerNum) )


end



--Egypt units

createUnit( 'farm', egypt, {26,222} )
createUnit( 'farm', egypt, {26,222} )
createUnit( 'chicken', egypt, {26,210} )
createUnit( 'chicken', egypt, {26,210} )
createUnit('slave', egypt, startLocation(egypt))


--The starting pyramid is located near the enemy's  base
--It's needed to store resources long enough for Egypt to start
--building a new base
createUnit('pyramid', egypt, startLocation(5))


giveResource('gold', egypt, 500)
giveResource('stone', egypt, 500)
giveResource('wood', egypt, 500)

togglePauseGame(1)
showMessage ( 'Intro1', 'Introduction' )
showMessage ( 'Intro2', 'Introduction' );
showMessage ( 'Intro3', 'Introduction' );
showMessage ( 'Intro4', 'Introduction' );
showMessage ( 'Intro5', 'Introduction' );


</startup>


<unitCreated>
if lastCreatedUnitName() == 'slave' then
slaveCount = slaveCount + 1
end

if lastCreatedUnitName() == 'pyramid' then
pyramidCount = pyramidCount + 1
end

if lastCreatedUnitName() == 'mage_tower' then
mageTowerCount = mageTowerCount + 1
end

if lastCreatedUnitName() == 'daemon' then
daemon_loop = daemon_loop + 1
if daemon_loop == 5 then
--givePositionCommand( lastCreatedUnit(), 'attack', startLocation(egypt) )
daemon_loop = 0
end
end

if lastCreatedUnitName() == 'battlemage' then
battlemage_loop = battlemage_loop + 1
if battlemage_loop == 5 then
--givePositionCommand( lastCreatedUnit(), 'attack', startLocation(egypt) )

if timesLooped > 1 then
for AIplayer = 4, 7 do
createUnit ('tower_of_souls', AIplayer, startLocation(AIplayer) )
createUnit ('golem', AIplayer, startLocation (AIplayer) )
end


AttackFrom = math.random(4, 7)
AttackTo = math.random (0, 3)

for i = 1, 4 do
whichUnit = math.random (1, #rndAttackUnits)
createUnit (rndAttackUnits[whichUnit], AttackFrom, startLocation (AttackFrom) )
givePositionCommand ( lastCreatedUnit(), 'attack', startLocation (AttackTo) )
end
end

battlemage_loop = 0
timesLooped = timesLooped + 1
end
end



</unitCreated>

<unitDied>
if lastDeadUnitName() == 'slave' then
slaveCount = slaveCount - 1
end

if lastDeadUnitName() == 'pyramid' then
pyramidCount = pyramidCount - 1

end

if ( slaveCount == 0 and pyramidCount == 0 ) then


showMessage ('failure1', 'Failure')
showMessage ('failure2', 'Failure')
showMessage ('failure3', 'Failure')
--wait (15)
for i = 4, 7 do
setPlayerAsWinner(i)
end
endGame()
end

if lastDeadUnitName() == 'mage_tower' then
--print (lastDeadUnitName())
mageTowerCount = mageTowerCount - 1
if mageTowerCount == 0 then

showMessage ('victory1', 'Victory')
showMessage ('victory2', 'Victory')
showMessage ('victory3', 'Victory')
showMessage ('victory4', 'Victory')
showMessage ('victory5', 'Victory')
--wait (15)


for i = 0, 3 do
setPlayerAsWinner(i)
end
endGame()
end
end



</unitDied>



</scripts>
</scenario>

egypt_has_fallen_english.lng
Code: [Select]
SCENARIO_NAME=egypt has fallen

;message headers
Introduction=Introduction
Victory=Victory
Failure=Failure

;message strings
Intro1=Egypt has fallen!
Intro2=An evil faction, known only as "Magic" has invaded and destroyed most of Egypt's kingdom.
Intro3=In a futile attempt to fight off Magic's army, Egypt has sent her last remaining soldiers to stop them.
Intro4=If they are not successful, you will be Egypt's only chance at survival. You must protect her until she's strong enough to fight back and to assist you in vanquishing the Magic faction.
Intro5=If you are successful, Queen Cleopatra will figure out some way to repay her debt to you...

victory1=You are victorious!
victory2=Egypt is once again a thriving civilization.
victory3=Queen Cleopatra walks across the battlefield to find you.
victory4=She puts her hands on your face, leans in, and kisses you passionately.
victory5=Then she takes your hand and leads you to her bed-chamber and turns out the light.

failure1=Though you tried your best, and lost many good men, you have failed.
failure2=Egypt will never again be restored to her former glory.
failure3=On the other side of the battlefield, you see Queen Cleopatra crying, her tears covering the bodies of many fallen warriors.


wciow

  • Behemoth
  • *******
  • Posts: 968
    • View Profile
Re: Scenario - Egypt has fallen
« Reply #9 on: 22 March 2017, 03:33:56 »
Good job Andy  :thumbup:

Would like to test this with you at some point.
Check out my new Goblin faction - https://forum.megaglest.org/index.php?topic=9658.0

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Egypt has fallen
« Reply #10 on: 22 March 2017, 21:42:58 »
Thanks @wciow.

jammyjamjamman

  • Horseman
  • ****
  • Posts: 188
    • View Profile
Re: Scenario - Egypt has fallen
« Reply #11 on: 22 July 2017, 01:26:25 »
Nice Scenario! Very fun to play :)
"All right, I've been thinking. When life gives you lemons? Don't make lemonade. Make life take the lemons back! Get mad! 'I don't want your damn lemons! What am I supposed to do with these?'" ~Cave Johnson, Portal 2

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Egypt has fallen
« Reply #12 on: 22 July 2017, 23:08:40 »
Thanks, Jammy; glad you enjoyed it. Have you played it recently? I think it would be more interesting if Egypt were moved to player slot 3 or 4, because aren't those the slots the AI generally attacks first? imo, it would be more interesting if the allied Egypt AI had to be protected early in the game, when it has no units. What do you think?

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 445
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: Scenario - Egypt has fallen
« Reply #13 on: 26 December 2017, 01:43:32 »

 

anything