Merge lp:~sirver/widelands/tutorial_mission into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~sirver/widelands/tutorial_mission
Merge into: lp:widelands
Diff against target: 2904 lines (+1455/-235)
41 files modified
campaigns/cconfig (+2/-2)
campaigns/emp01.wmf/scripting/texts.lua (+5/-5)
campaigns/emp02.wmf/scripting/texts.lua (+4/-4)
campaigns/t01.wmf/scripting/initial_messages.lua (+1/-1)
campaigns/t01.wmf/scripting/khantrukhs_talking.lua (+1/-1)
campaigns/t01.wmf/scripting/texts.lua (+5/-5)
campaigns/t02.wmf/scripting/mission_thread.lua (+1/-1)
campaigns/t02.wmf/scripting/mission_thread_texts.lua (+2/-2)
campaigns/t03.wmf/scripting/texts.lua (+14/-14)
campaigns/tutorial01.wmf/elemental (+1/-1)
campaigns/tutorial01.wmf/player_names (+6/-0)
campaigns/tutorial01.wmf/player_position (+2/-0)
campaigns/tutorial01.wmf/scripting/init.lua (+527/-73)
campaigns/tutorial01.wmf/scripting/texts.lua (+425/-104)
src/economy/flag.cc (+11/-0)
src/economy/flag.h (+1/-0)
src/economy/road.cc (+18/-0)
src/economy/road.h (+1/-0)
src/logic/building.cc (+26/-0)
src/logic/building.h (+2/-0)
src/logic/immovable.cc (+9/-0)
src/logic/immovable.h (+10/-0)
src/logic/legacy.cc (+17/-0)
src/save_handler.cc (+3/-0)
src/save_handler.h (+5/-1)
src/scripting/lua_game.cc (+46/-8)
src/scripting/lua_map.cc (+83/-2)
src/scripting/lua_map.h (+31/-2)
src/scripting/lua_ui.cc (+63/-0)
src/scripting/lua_ui.h (+4/-0)
src/scripting/scripting.cc (+5/-0)
src/scripting/test/ts.wmf/scripting/test_baseimmovables.lua (+2/-0)
src/scripting/test/ts.wmf/scripting/test_constructionsite.lua (+46/-0)
src/scripting/test/ts.wmf/scripting/test_flag.lua (+7/-1)
src/scripting/test/ts.wmf/scripting/test_immovables.lua (+1/-0)
src/scripting/test/ts.wmf/scripting/test_road.lua (+11/-4)
src/scripting/test/ts.wmf/scripting/test_ui.lua (+16/-0)
src/ui_basic/panel.cc (+32/-0)
src/ui_basic/panel.h (+4/-0)
src/wlapplication.cc (+0/-2)
src/wui/interactive_base.cc (+5/-2)
To merge this branch: bzr merge lp:~sirver/widelands/tutorial_mission
Reviewer Review Type Date Requested Status
Chuck Wilder playtesting, spellchecking Needs Fixing
Review via email: mp+24444@code.launchpad.net

Description of the change

This is not really a merge request, as an earlier version of this tutorial was already merged together with the ui scripting capabilities, so this will also be merged eventually. I want to try out if making a merge request will help in getting feedback for the mission to further improve on it.

Please, play the mission and give me some feedback (especially positive to keep me motivated :P).

@chuck and other native speakers: I am especially looking forward to english language improvement. Feel free to reformulate whatever you seem unfitting, as long as the sense stays around, I am happy with improvements to the grammar and the words.

Changes:
To tutorial:
* made tutorial more robust against bad user input
  - by allowing user input to be completely suppressed
  - by adding a coroutine that rips everything the user builds when he shouldn't build anything.
* typo and grammatical fixes
* added infos about census & statistics
* added a chapter about resources & mining
* added infos about the mini map
* added a chapter about soldiers, training and warfare
* added mission objectives

To code:
* minimal Lua wrappings for constructionsites
* new functions to suppress user input processing in the UI
* new property fields in base immovables that offers the reverse mapping from Field.immovable

To post a comment you must log in.
Revision history for this message
Chuck Wilder (chuckw20) wrote :

spellchecking

I reviewed the campaigns folder and found a number of instances that require spelling, grammatical and/or wording changes.

These I have applied and can be found in the following branch:
        ~chuckw20/widelands/tutorial_mission_edit

review: Needs Fixing (playtesting, spellchecking)
Revision history for this message
SirVer (sirver) wrote :

I didn't get much feedback for the scenario, so I guess this could count as a failed experiment. I merged this now, so I guess feedback will come from players.

Revision history for this message
Kiscsirke (csirkeee) wrote :

I did try it, and played it through, I just didn't have any problems :)

András

On 3 May 2010 11:39, SirVer <email address hidden> wrote:
> I didn't get much feedback for the scenario, so I guess this could count as a failed experiment. I merged this now, so I guess feedback will come from players.
> --
> https://code.launchpad.net/~sirver/widelands/tutorial_mission/+merge/24444
> You are subscribed to branch lp:widelands.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'campaigns/cconfig' (properties changed: -x to +x)
--- campaigns/cconfig 2010-04-21 17:45:21 +0000
+++ campaigns/cconfig 2010-04-30 14:39:36 +0000
@@ -24,13 +24,13 @@
24campname0=_"(Tutorial) Barbarians - The second Empire"24campname0=_"(Tutorial) Barbarians - The second Empire"
25campsect0=barbariantut25campsect0=barbariantut
26campdiff0=126campdiff0=1
27campdesc0=_"When Chat’Karuth died, he was an old man, father to three strong and ambitious sons and warlord to an army that could match any enemy willing to rise against the ancient forests. Though his glorious reign, Chat’Karuth left his eldest son Thron in the due to succeed him as the tribes warlord – a decision that left his two brothers unsatisfied. The old warlord knew that. As his father told him, Thron left the capital of Al’thunran, the home of the throne among the trees and redrew his forces to the high hills where he buried the corpse of his father and swore to the gods and his spirit, that he’d return to re-established order. While his brothers raged in blind war against Thron and the few forces he left to secure the borders of Al’thunran, the young warlord seeks to reunite his ambitious brothers and force the tribes to march once again under a common banner."27campdesc0=_"When Chat’Karuth died, he was an old man, father to three strong and ambitious sons and warlord to an army that could match any enemy willing to rise against the ancient forests. Though at the end of his glorious reign, Chat’Karuth left his eldest son, Thron, to succeed him as the tribe's warlord – a decision that left his two brothers unsatisfied. The old warlord knew that. As his father instructed him, Thron left the capital of Al’thunran, the home of the Throne Among the Trees and withdrew his forces to the high hills where he buried the corpse of his father. There he swore to the gods and his father's spirit that he’d return to re-established order. While his brothers raged in blind war against Thron and the few forces he left to secure the borders of Al’thunran, the young warlord seeks to reunite his ambitious brothers and force the tribes to march once again under a common banner."
28campvisi0=128campvisi0=1
29# Empire Campaign29# Empire Campaign
30campname1=_"Empire - The months of exile"30campname1=_"Empire - The months of exile"
31campsect1=empiretut31campsect1=empiretut
32campdiff1=232campdiff1=2
33campdesc1=_"Six months ago, Lutius - a young general of the Empire - was send with 150 soldiers to the frontier beyond the northern forests where Barbarian-tribes and official Empire-land are crossing. His task was to defend the Empire-land. At first, everything was calm. He even talked to a few barbarian children and thought about a peaceful life - side by side with this archaic folk. He began to feel safer and his army began to drop their attention off the potential enemy. That was their fault. At one night in march his unprepared army was attacked by 100 barbarian footmen and was completely scattered. Only with his bare life he and a handful of his soldiers survived."33campdesc1=_"Six months ago, Lutius - a young general of the Empire - was sent with 150 soldiers to the frontier beyond the northern forests where Barbarian tribes were crossing onto land held by the Empire. His task was to defend the Empire's land. At first, everything was calm. He even talked to a few barbarian children and thought about a peaceful life - side by side with this archaic folk. He began to feel safer and his army began to drop their attention off the potential enemy. That was their undoing. One night in March his unprepared army was attacked by 100 barbarian footmen and was completely scattered. Only with his bare life he and a handful of his soldiers survived."
34campvisi1=034campvisi1=0
35# Atlantean Campaign35# Atlantean Campaign
36campname2=_"Atlanteans - the new rise"36campname2=_"Atlanteans - the new rise"
3737
=== modified file 'campaigns/emp01.wmf/scripting/texts.lua' (properties changed: -x to +x)
--- campaigns/emp01.wmf/scripting/texts.lua 2010-04-18 06:46:20 +0000
+++ campaigns/emp01.wmf/scripting/texts.lua 2010-04-30 14:39:36 +0000
@@ -35,7 +35,7 @@
35 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..35 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
36 _"Diary of Lutius" ..36 _"Diary of Lutius" ..
37 "</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..37 "</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..
38 _[[ "Finally, the Gods were with us!<br> We landed on an unknown coast and found peaceful rest under the palm trees growing at the strand. But that is about as good as it gets. The truth is:<br> when I woke up this morning, I saw nothing more than sand around us.<br> It really seems as if we landed under the only palm trees existing in this far-away sandy desert. I fear we won't find the help we need to get our ship repaired in good time." ]] ..38 _[[ "Finally, the Gods were with us!<br> We landed on an unknown coast and found peaceful rest under the palm trees growing at the shore. But that is about as good as it gets. The truth is:<br> when I woke up this morning, I saw nothing more than sand around us.<br> It really seems as if we landed under the only palm trees existing in this far-away sandy desert. I fear we won't find the help we need to get our ship repaired in good time." ]] ..
39 "</p></rt>",39 "</p></rt>",
40 width=400,40 width=400,
41 height=350,41 height=350,
@@ -47,7 +47,7 @@
47 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..47 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..
48 _"Saledus looks around nervously..." ..48 _"Saledus looks around nervously..." ..
49 "</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..49 "</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..
50 _[[ "Sire, I fear we are not safe in this foreign land. Who knows what terrible creatures live beyond this forest, in that mighty desert? What if these creatures enter the woods and await the time to attack us?<br> Well, perhaps my fear is misguided, but it can't be wrong to keep watch in the forests - so that we can be sure to see any potential enemies before they can see us.<br> We really should build a barracks in the eastern portion of the forest. Than one of us will keep watch in the darkness and keep us safe from these creatures."<br><br>-- NEW OBJECTIVE --<br> ]] ..50 _[[ "Sire, I fear we are not safe in this foreign land. Who knows what terrible creatures live beyond this forest, in that mighty desert? What if these creatures enter the woods and await the time to attack us?<br> Well, perhaps my fear is misguided, but it can't be wrong to keep watch in the forests - so that we can be sure to see any potential enemies before they can see us.<br> We really should build a barracks in the eastern portion of the forest. Then one of us can keep watch in the darkness and keep us safe from these creatures."<br><br>-- NEW OBJECTIVE --<br> ]] ..
51 _"* Build a barracks at the red point on the east side of the forests, to the right of your headquarters." ..51 _"* Build a barracks at the red point on the east side of the forests, to the right of your headquarters." ..
52 "</p></rt>",52 "</p></rt>",
53 width=400,53 width=400,
@@ -87,7 +87,7 @@
87 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=AF7511>" ..87 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=AF7511>" ..
88 _"Amalea recommends..." ..88 _"Amalea recommends..." ..
89 "</p></rt><rt image=map:Amalea.png><p line-spacing=3 font-size=12><br>" ..89 "</p></rt><rt image=map:Amalea.png><p line-spacing=3 font-size=12><br>" ..
90 _[[ "Hey Lutius, I got the message that our first lumberjack started his work today. Perhaps it would be a good idea to wait until he cleans enough space for building up two further lumberjack's houses, so that we can faster harvest the trunks.<br> But unfortunately the trunks are useless for repairing our ship - we need refined wood, like every ship and every bigger building needs, too. So we should build up a sawmill - as soon as we have enough space for this."<br><br>-- NEW OBJECTIVE --<br> ]] ..90 _[[ "Hey Lutius, I got the message that our first lumberjack started his work today. Perhaps it would be a good idea to wait until he cleans enough space for building up two further lumberjack's houses, so that we can harvest the trunks faster.<br> But unfortunately the trunks are useless for repairing our ship - we need refined lumber, like every ship and every bigger building needs, too. So we should build up a sawmill - as soon as we have enough space for this."<br><br>-- NEW OBJECTIVE --<br> ]] ..
91 _"* Build two more lumberjack's houses and a sawmill as soon as there is enough space for them." ..91 _"* Build two more lumberjack's houses and a sawmill as soon as there is enough space for them." ..
92 "</p></rt>",92 "</p></rt>",
93 width=400,93 width=400,
@@ -99,7 +99,7 @@
99 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=AF7511>" ..99 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=AF7511>" ..
100 _"Amalea comes in..." ..100 _"Amalea comes in..." ..
101 "</p></rt><rt image=map:Amalea.png><p line-spacing=3 font-size=12><br>" ..101 "</p></rt><rt image=map:Amalea.png><p line-spacing=3 font-size=12><br>" ..
102 _[[ "Hi Lutius, I've got two important things to talk about... First the good news:<br> I saw that the construction of the sawmill is complete, so we can begin to refine the trunks the lumberjacks are harvesting to wood.<br> But that's just about the only positive thing I know to talk about. The bad news is that our lumberjacks harvest at an unbelievable speed. There are almost no trees left on this island.<br> Lutius, these trees provide shelter from the sandstorms from the desert, shade on the hot days and they are the home of so many gentle animals. We shouldn't leave this island a complete desert.<br> Lutius, I beg you: find someone who takes care about planting new trees."<br><br>-- NEW OBJECTIVE --<br> ]] ..102 _[[ "Hi Lutius, I've got two important things to talk about... First the good news:<br> I saw that the construction of the sawmill is complete, so we can begin to refine the trunks that the lumberjacks are harvesting into lumber.<br> But that's just about the only positive thing I know to talk about. The bad news is that our lumberjacks harvest at an unbelievable speed. There are almost no trees left on this island.<br> Lutius, these trees provide shelter from the sandstorms from the desert, shade on the hot days and they are the home of so many gentle animals. We shouldn't leave this island a complete desert.<br> Lutius, I beg you: find someone who takes care about planting new trees."<br><br>-- NEW OBJECTIVE --<br> ]] ..
103 _"* Build a forester's house to preserve the wood resources of this island." ..103 _"* Build a forester's house to preserve the wood resources of this island." ..
104 "</p></rt>",104 "</p></rt>",
105 width=400,105 width=400,
@@ -111,7 +111,7 @@
111 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..111 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..
112 _"Saledus notes..." ..112 _"Saledus notes..." ..
113 "</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..113 "</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..
114 _[[ "Hey, my good old friend. I just thought about the rocks standing on the south strand of this land. Perhaps we could cut out some useful hard stones and beautiful marble.<br> The repair of our ship will take a few weeks, anyway, and the resources we harvest now might be the base of strong and big buildings in another land."<br><br>-- NEW OBJECTIVE --<br> ]] ..114 _[[ "Hey, my good old friend. I just thought about the rocks standing on the south shore of this land. Perhaps we could cut out some useful hard stones and beautiful marble.<br> The repair of our ship will take a few weeks, anyway, and the resources we harvest now might be the base of strong and big buildings in another land."<br><br>-- NEW OBJECTIVE --<br> ]] ..
115 _"* Build a quarry in the south to cut some stones and marble out of the rocks.<br> These might be used for future buildings." ..115 _"* Build a quarry in the south to cut some stones and marble out of the rocks.<br> These might be used for future buildings." ..
116 "</p></rt>",116 "</p></rt>",
117 width=400,117 width=400,
118118
=== modified file 'campaigns/emp02.wmf/scripting/texts.lua' (properties changed: -x to +x)
--- campaigns/emp02.wmf/scripting/texts.lua 2010-03-14 11:16:54 +0000
+++ campaigns/emp02.wmf/scripting/texts.lua 2010-04-30 14:39:36 +0000
@@ -66,7 +66,7 @@
66 title =_"Destroy the barbarian tribe",66 title =_"Destroy the barbarian tribe",
67 body ="<rt><p>" ..67 body ="<rt><p>" ..
68_"* As soon as you have enough soldiers, attack and completely destroy the barbarian buildings.<br>" ..68_"* As soon as you have enough soldiers, attack and completely destroy the barbarian buildings.<br>" ..
69_"* Finally, build up a fortress on the peninsula<br> (near where the barbarian headquarters stood befre), to avoid new settlements of other tribes in that region." ..69_"* Finally, build up a fortress on the peninsula<br> (near where the barbarian headquarters stood before), to avoid new settlements of other tribes in that region." ..
70"</p></rt>",70"</p></rt>",
71}71}
7272
@@ -132,7 +132,7 @@
132 body="<rt><p font-size=24 text-align=left font-face=FreeSerif font-weight=bold font-color=2F9131>" ..132 body="<rt><p font-size=24 text-align=left font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
133_"Diary of Lutius" ..133_"Diary of Lutius" ..
134"</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..134"</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..
135_[[ "Great, today the building of the quarry was completed. Now we get enough stone to construct larger buildings." ]] ..135_[[ "Great! Today the building of the quarry was completed. Now we get enough stone to construct larger buildings." ]] ..
136"</p></rt>",136"</p></rt>",
137}137}
138138
@@ -144,7 +144,7 @@
144 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..144 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8F9131>" ..
145_"Saledus looks unhappy" ..145_"Saledus looks unhappy" ..
146"</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..146"</p></rt><rt image=map:Saledus.png><p line-spacing=3 font-size=12><br>" ..
147_[[ "Greetings Lutius, I don't want to start a panic, but I found something which gives me a sinking feeling in my stomach and spreads waves of fear in my heart. As I walked down to the southern strands I found the remains of another ship. I don't know whether these parts are all that is left of that ship. Inn any case: these parts do not seem to be old.<br> Perhaps the people aboard that ship were caught in the same storm which brought us to Malac' Mor - and were brought to this island.<br> I beg you to be cautious and to build some barracks or sentries around our colony."<br><br>-- NEW OBJECTIVE --<br> ]] ..147_[[ "Greetings Lutius, I don't want to start a panic, but I found something which gives me a sinking feeling in my stomach and spreads waves of fear in my heart. As I walked down to the southern shore I found the remains of another ship. I don't know whether these parts are all that is left of that ship. In any case, these parts do not seem to be old.<br> Perhaps the people aboard that ship were caught in the same storm which brought us to Malac' Mor - and were brought to this island.<br> I beg you to be cautious and to build some barracks or sentries around our colony."<br><br>-- NEW OBJECTIVE --<br> ]] ..
148_"* Build some barracks and sentries around the colony." ..148_"* Build some barracks and sentries around the colony." ..
149"</p></rt>",149"</p></rt>",
150}150}
@@ -193,7 +193,7 @@
193 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..193 body="<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
194_"Diary of Lutius" ..194_"Diary of Lutius" ..
195"</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..195"</p></rt><rt image=map:Lutius.png><p line-spacing=3 font-size=12><br>" ..
196_[[ "By the Gods! This is absolutely terrible. It seems as if we stand close to a test - and it seems as if Saledus was right with his fear concerning the shipwreck he found.<br> Today, as I walked down to the eastern strands,<br> I got a shock. I caught sight of one of those hated, evil, barbarian tribes with whom we have had so many problems before.<br> At first, I was naive and hoped that they were peaceful, but as soon as one of them saw me they charged towards me and started attacking me with their throwing-spears. Thanks be to the Gods that<br> I was able to flee and hide myself, before retreating back to our colony under cover of darkness.<br> Anyway, we must build up stronger military buildings as soon as possible."<br><br>-- NEW OBJECTIVE --<br> ]] ..196_[[ "By the Gods! This is absolutely terrible. It seems as if we stand close to a test - and it seems as if Saledus was right with his fear concerning the shipwreck he found.<br> Today, as I walked down to the eastern shore,<br> I got a shock. I caught sight of one of those hated, evil, barbarian tribes with whom we have had so many problems before.<br> At first, I was naive and hoped that they were peaceful, but as soon as one of them saw me they charged towards me and started attacking me with their throwing-spears. Thanks be to the Gods that<br> I was able to flee and hide myself, before retreating back to our colony under cover of darkness.<br> Anyway, we must build up stronger military buildings as soon as possible."<br><br>-- NEW OBJECTIVE --<br> ]] ..
197_"* Build up stronger military buildings, such as an outpost, a barrier or a tower, on the eastern frontier. To watch deep inside the enemy territory, build a tower." ..197_"* Build up stronger military buildings, such as an outpost, a barrier or a tower, on the eastern frontier. To watch deep inside the enemy territory, build a tower." ..
198"</p></rt>",198"</p></rt>",
199}199}
200200
=== modified file 'campaigns/t01.wmf/scripting/initial_messages.lua' (properties changed: -x to +x)
--- campaigns/t01.wmf/scripting/initial_messages.lua 2010-03-19 09:54:23 +0000
+++ campaigns/t01.wmf/scripting/initial_messages.lua 2010-04-30 14:39:36 +0000
@@ -19,7 +19,7 @@
19show_story_box(title, msg, al_thunran)19show_story_box(title, msg, al_thunran)
2020
21msg = "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..21msg = "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
22_[[ "My father's bones rest peacefully in the grounds he cleared from the senseless bloodspilling that has once risen among us.<br> Boldreth, my loyal companion and friend is a source of peace and comfort to me in these dark times. He keeps my spirits high and those of my warriors awake, not to let greed or despair destroy the bonds between us as well." ]] ..22_[[ "My father's bones rest peacefully in the grounds on which he once ended the senseless bloodspilling that has risen among us. It pains me that his peace only endured for one generation.<br> Boldreth, my loyal companion and friend is a source of peace and comfort to me in these dark times. He keeps my spirits high and those of my warriors awake, not to let greed or despair destroy the bonds between us as well." ]] ..
23"</p></rt>"23"</p></rt>"
24show_story_box(title, msg, grave)24show_story_box(title, msg, grave)
2525
2626
=== modified file 'campaigns/t01.wmf/scripting/khantrukhs_talking.lua' (properties changed: -x to +x)
--- campaigns/t01.wmf/scripting/khantrukhs_talking.lua 2010-03-13 20:20:27 +0000
+++ campaigns/t01.wmf/scripting/khantrukhs_talking.lua 2010-04-30 14:39:36 +0000
@@ -22,7 +22,7 @@
22end22end
2323
24function tutorial_thread()24function tutorial_thread()
25 show_story_box(_"Somebody comes upon to you", khantrukh_1)25 show_story_box(_"Somebody comes up to you", khantrukh_1)
26 show_story_box(_"The advisor", khantrukh_2, nil, 80, 80)26 show_story_box(_"The advisor", khantrukh_2, nil, 80, 80)
27 o = start_lumberjack_01(p)27 o = start_lumberjack_01(p)
28 -- Wait till the hut is build.28 -- Wait till the hut is build.
2929
=== modified file 'campaigns/t01.wmf/scripting/texts.lua' (properties changed: -x to +x)
--- campaigns/t01.wmf/scripting/texts.lua 2010-04-18 16:36:26 +0000
+++ campaigns/t01.wmf/scripting/texts.lua 2010-04-30 14:39:36 +0000
@@ -8,7 +8,7 @@
8"<rt><p>" ..8"<rt><p>" ..
9_"* Press SPACE to see where you can build.<br> The red house symbols show you where a small building - like a lumberjack's hut - may be built.<br>" ..9_"* Press SPACE to see where you can build.<br> The red house symbols show you where a small building - like a lumberjack's hut - may be built.<br>" ..
10_"* Build a lumberjack's hut at the red house symbol just right of your headquarters by clicking on it and selecting a lumberjack's hut.<br>" ..10_"* Build a lumberjack's hut at the red house symbol just right of your headquarters by clicking on it and selecting a lumberjack's hut.<br>" ..
11_"* Build a road between your headquarters and the construction site of the lumberjack's hut.<br> When you place the lumberjack's hut, a flag is created for it. You need to connect it to another flag by building a road between them.<br> If you click on a flag and select to build a road, little symbols will appear around it to show you in which directions you can build it.<br> The colour of these symbols indicats how steep this part of the road will be. Green is for flat, yellow means steep and red stands for very steep. The steeper the road is, the harder it will be for your people to walk on it (and your wares will be transported more slowly).<br> You can click on any of the symbols to build the first part of the road there. New symbols will appear to show you where the next part of the road can go, and so on. However, you can also click farer away from the flag to build several steps at once. Click on the flag at the headquarters to finish the road." ..11_"* Build a road between your headquarters and the construction site of the lumberjack's hut.<br> When you place the lumberjack's hut, a flag is created for it. You need to connect it to another flag by building a road between them.<br> If you click on a flag and select to build a road, little symbols will appear around it to show you in which directions you can build it.<br> The colour of these symbols indicates how steep this part of the road will be. Green is for flat, yellow means steep and red stands for very steep. The steeper the road is, the harder it will be for your people to walk on it (and your wares will be transported more slowly).<br> You can click on any of the symbols to build the first part of the road there. New symbols will appear to show you where the next part of the road can go, and so on. However, you can also click farther away from the flag to build several steps at once. Click on the flag at the headquarters to finish the road." ..
12"</p></rt>")12"</p></rt>")
13end13end
1414
@@ -16,7 +16,7 @@
16 return p:add_objective("lumberjack02",16 return p:add_objective("lumberjack02",
17 _ "Build another lumberjack's hut",17 _ "Build another lumberjack's hut",
18 "<rt><p>" ..18 "<rt><p>" ..
19_"* Place a flag in the middle of the road.<br> There is a flag symbol in the middle of the way you just built. You create a flag there by clicking on the symbol and then choosing the flag button in the menu that opens up. This divides the way the wood is transported into two parts with one carrier each.<br> When much wares are being transported between two points, additional flags in between make them arrive at their destination faster, thus improving your infrastructure.<br>" ..19_"* Place a flag in the middle of the road.<br> There is a flag symbol in the middle of the way you just built. You create a flag there by clicking on the symbol and then choosing the flag button in the menu that opens up. This divides the way the wood is transported into two parts with one carrier each.<br> When many wares are being transported between two points, additional flags in between make them arrive at their destination faster, thus improving your infrastructure.<br>" ..
20_"* Place a lumberjack's hut just south of the flag you just placed on the road. Connect the flag you just raised with the flag of the new lumberjack's hut construction site afterwards.<br> Note that instead of building a road step by step, you may also click directly at its destination to build the entire road at once." ..20_"* Place a lumberjack's hut just south of the flag you just placed on the road. Connect the flag you just raised with the flag of the new lumberjack's hut construction site afterwards.<br> Note that instead of building a road step by step, you may also click directly at its destination to build the entire road at once." ..
21"</p></rt>")21"</p></rt>")
22end22end
@@ -48,7 +48,7 @@
48khantrukh_2= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..48khantrukh_2= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..
49_"Khantrukh continues..." ..49_"Khantrukh continues..." ..
50"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..50"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..
51_[[ "None but the gods know how long we have to remain hidden here. The warriors hope we may march back gloriously any day now, but I strongly doubt that will happen soon. And the days are already getting shorter and colder...<br> We should prepare, in case we have to face the winter in these harsh lands. I believe to the east of our campside are a few places where we could raise a lumberjack's hut."<br><br>-- NEW OBJECTIVES --<br> ]] .. 51_[[ "None but the gods know how long we have to remain hidden here. The warriors hope we may march back gloriously any day now, but I strongly doubt that will happen soon. And the days are already getting shorter and colder...<br> We should prepare, in case we have to face the winter in these harsh lands. I believe to the east of our campsite are a few places where we could raise a lumberjack's hut."<br><br>-- NEW OBJECTIVES --<br> ]] ..
52_"* Press SPACE to see where you can build.<br> The red house symbols show you where a small building - like a lumberjack's hut - may be built.<br>" ..52_"* Press SPACE to see where you can build.<br> The red house symbols show you where a small building - like a lumberjack's hut - may be built.<br>" ..
53_"* Build a lumberjack's hut at the red house symbol just right of your headquarters by clicking on it and selecting a lumberjack's hut.<br>" ..53_"* Build a lumberjack's hut at the red house symbol just right of your headquarters by clicking on it and selecting a lumberjack's hut.<br>" ..
54"</p></rt>" 54"</p></rt>"
@@ -58,14 +58,14 @@
58_"The elder remarks..." ..58_"The elder remarks..." ..
59"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..59"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..
60_[[ "Obviously, it would be too exhausting for our people to walk all the way to the lumberjack's hut through the wilderness. We will have to build a road between our hall and the lumberjack's hut. It's not a hard guess that the men would appreciate a way as short and plain as possible - the wood will surely be heavy enough, nevertheless."<br><br>-- NEW OBJECTIVE --<br> ]] ..60_[[ "Obviously, it would be too exhausting for our people to walk all the way to the lumberjack's hut through the wilderness. We will have to build a road between our hall and the lumberjack's hut. It's not a hard guess that the men would appreciate a way as short and plain as possible - the wood will surely be heavy enough, nevertheless."<br><br>-- NEW OBJECTIVE --<br> ]] ..
61_"* Build a road between your headquarters and the construction site of the lumberjack's hut.<br> When you place the lumberjack's hut, a flag is created for it. You need to connect it to another flag by building a road between them.<br> If you click on a flag and select to build a road, little symbols will appear around it to show you in which directions you can build it.<br> The colour of these symbols indicats how steep this part of the road will be. Green is for flat, yellow means steep and red stands for very steep. The steeper the road is, the harder it will be for your people to walk on it (and your wares will be transported more slowly).<br> You can click on any of the symbols to build the first part of the road there. New symbols will appear to show you where the next part of the road can go, and so on. However, you can also click farer away from the flag to build several steps at once. Click on the flag at the headquarters to finish the road." ..61_"* Build a road between your headquarters and the construction site of the lumberjack's hut.<br> When you place the lumberjack's hut, a flag is created for it. You need to connect it to another flag by building a road between them.<br> If you click on a flag and select to build a road, little symbols will appear around it to show you in which directions you can build it.<br> The colour of these symbols indicates how steep this part of the road will be. Green is for flat, yellow means steep and red stands for very steep. The steeper the road is, the harder it will be for your people to walk on it (and your wares will be transported more slowly).<br> You can click on any of the symbols to build the first part of the road there. New symbols will appear to show you where the next part of the road can go, and so on. However, you can also click farer away from the flag to build several steps at once. Click on the flag at the headquarters to finish the road." ..
62"</p></rt>"62"</p></rt>"
6363
64khantrukh_4 = "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..64khantrukh_4 = "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..
65_"Khantrukh remembers..." ..65_"Khantrukh remembers..." ..
66"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..66"</p></rt><rt image=map:khantrukh.png><p line-spacing=3 font-size=12>" ..
67_[[ "There is an old saying:<br> 'A burden divided is easier to endure.'<br> A crossroads on the way between our headquarters and the lumberjack's hut would ease the work of our carriers."<br><br>-- NEW OBJECTIVE --<br> ]] ..67_[[ "There is an old saying:<br> 'A burden divided is easier to endure.'<br> A crossroads on the way between our headquarters and the lumberjack's hut would ease the work of our carriers."<br><br>-- NEW OBJECTIVE --<br> ]] ..
68_"* Place a flag in the middle of the road.<br> There is a flag symbol in the middle of the way you just built. You create a flag there by clicking on the symbol and then choosing the flag button in the menu that opens up. This divides the way the wood is transported into two parts with one carrier each.<br> When much wares are being transported between two points, additional flags in between make them arrive at their destination faster, thus improving your infrastructure.<br>" ..68_"* Place a flag in the middle of the road.<br> There is a flag symbol in the middle of the way you just built. You create a flag there by clicking on the symbol and then choosing the flag button in the menu that opens up. This divides the way the wood is transported into two parts with one carrier each.<br> When many wares are being transported between two points, additional flags in between make them arrive at their destination faster, thus improving your infrastructure.<br>" ..
69"</p></rt>"69"</p></rt>"
7070
71khantrukh_5 = "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..71khantrukh_5 = "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=8080FF>" ..
7272
=== modified file 'campaigns/t02.wmf/scripting/mission_thread.lua' (properties changed: -x to +x)
--- campaigns/t02.wmf/scripting/mission_thread.lua 2010-04-25 13:59:43 +0000
+++ campaigns/t02.wmf/scripting/mission_thread.lua 2010-04-30 14:39:36 +0000
@@ -209,7 +209,7 @@
209 This is a village of poor but friendly people who have settled in a safe209 This is a village of poor but friendly people who have settled in a safe
210 valley between two glaciers. They hunt and produce timber and grain but they210 valley between two glaciers. They hunt and produce timber and grain but they
211 do not have ores or even stones, so they are dependent on the infrequent211 do not have ores or even stones, so they are dependent on the infrequent
212 merchant that may pass by and provide them with whatever they can not212 merchant that may pass by and provide them with whatever they cannot
213 produce on their own. Their only protection is a guard hut at each entrance213 produce on their own. Their only protection is a guard hut at each entrance
214 to the valley. Therefore they realize that they may have to join a more214 to the valley. Therefore they realize that they may have to join a more
215 powerful society for protection in order to stay alive in this world.215 powerful society for protection in order to stay alive in this world.
216216
=== modified file 'campaigns/t02.wmf/scripting/mission_thread_texts.lua' (properties changed: -x to +x)
--- campaigns/t02.wmf/scripting/mission_thread_texts.lua 2010-03-13 22:33:12 +0000
+++ campaigns/t02.wmf/scripting/mission_thread_texts.lua 2010-04-30 14:39:36 +0000
@@ -9,7 +9,7 @@
9"<rt><p font-size=24 font-weight=bold font-face=FreeSerif font-color=2F9131>" ..9"<rt><p font-size=24 font-weight=bold font-face=FreeSerif font-color=2F9131>" ..
10_"Thron shakes his head..." ..10_"Thron shakes his head..." ..
11"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..11"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
12_[[ "The war goes on. More and more of our brothers and sisters flee the brutal war raging in the capital beneath the trees.<br> The stories they tell about the deeds of our kin are sad to hear. I've spent nights lying awake, restless, more tired I ever believed one could be. Yet whenever I close my eyes, I see the fortress my father built consumed by flames. The throne between the trees, the symbol of unity and peace among our kin became the wedge that drives us apart." ]] ..12_[[ "The war goes on. More and more of our brothers and sisters flee the brutal war raging in the capital beneath the trees.<br> The stories they tell about the deeds of our kin are sad to hear. I've spent nights lying awake, restless, more tired I ever believed one could be. Yet whenever I close my eyes, I see the fortress my father built consumed by flames. The Throne Among the Trees, the symbol of unity and peace among our kin, became the wedge that drives us apart." ]] ..
13"</p></rt>",13"</p></rt>",
14}14}
1515
@@ -18,7 +18,7 @@
18 title =_ "The story continues",18 title =_ "The story continues",
19 body = 19 body =
20"<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..20"<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
21_ [[ "Today my hunters brought men, women and little children who had hidden out in the forests, trying to escape the war, hate and revenge that rage among the tribes fighting each other like in old times, when we were no more but the wild beasts driven and controlled by instincts. None of my brothers will ever gain and hold control over the wooden throne, none of the tribes will be strong enough to subdue the other. There will be no end to this slaughtering, unless... is this it? As father told me?<br> Rise against whoever threatens our very existence, may it even be one of your blood or mind?" ]] ..21_ [[ "Today my hunters brought men, women and little children who had hidden out in the forests, trying to escape the war, hate and revenge that rage among the tribes fighting each other like in old times, when we were no more but wild beasts driven and controlled by instincts. None of my brothers will ever gain and hold control over the wooden throne, none of the tribes will be strong enough to subdue the other. There will be no end to this slaughtering, unless... is this it? As father told me?<br> Rise against whoever threatens our very existence, may it even be one of your blood or mind?" ]] ..
22"</p></rt>",22"</p></rt>",
23}23}
2424
2525
=== modified file 'campaigns/t03.wmf/scripting/texts.lua' (properties changed: -x to +x)
--- campaigns/t03.wmf/scripting/texts.lua 2010-04-25 18:33:38 +0000
+++ campaigns/t03.wmf/scripting/texts.lua 2010-04-30 14:39:36 +0000
@@ -126,7 +126,7 @@
126 body= "<rt><p line-spacing=3 font-size=12>" ..126 body= "<rt><p line-spacing=3 font-size=12>" ..
127_"* Destroy Kalitaths army and expand your territory to the east." ..127_"* Destroy Kalitaths army and expand your territory to the east." ..
128"<br>" ..128"<br>" ..
129_"-> To attack an enemy you must click on the door of an advarse military building. A menu will pop up allowing you to select the number of soldiers that should attack. When you are ready with setting the number, click on the cross ('start attack')" ..129_"-> To attack an enemy you must click on the door of an adversary's military building. A menu will pop up allowing you to select the number of soldiers that should attack. When you are ready with setting the number, click on the cross ('start attack')" ..
130"</p></rt>",130"</p></rt>",
131}131}
132132
@@ -148,7 +148,7 @@
148_"Thron looks worried..." ..148_"Thron looks worried..." ..
149"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..149"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
150150
151_[[ "The last days we came closer to our capital. Many people have already joined us on our march and set their hopes on me. However, I fear that we are not strong enough to take up the battle with my brothers.<br>For now we rest at the borders of the old forest and prepare for the coming days." ]] ..151_[[ "These last days we came closer to our capital. Many people have already joined us on our march and set their hopes on me. However, I fear that we are not strong enough to take up the battle with my brothers.<br>For now we rest at the borders of the old forest and prepare for the coming days." ]] ..
152"</p></rt>",152"</p></rt>",
153}153}
154154
@@ -186,7 +186,7 @@
186 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..186 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
187_"Thron speaks confidently." ..187_"Thron speaks confidently." ..
188"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..188"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
189_[[ "The frontier line of my forces has expanded to the edge of the forests. We have a long and cold winter and so many miles behind us. The fortification that we erected around Ondun will guarantee us fast supply of man and goods and once Al’thunran is in my hands, the two cities will be linked by a good and defendable infrastructure. Still I hope I will not walk alone on this mission, I hope Kailitat son of Kun will follow my call." ]] ..189_[[ "The frontier line of my forces has expanded to the edge of the forests. We have a long and cold winter and so many miles behind us. The fortification that we erected around Ondun will guarantee us a fast supply of men and goods and once Al’thunran is in my hands, the two cities will be linked by a good and defendable infrastructure. Still I hope I will not walk alone on this mission, I hope Kalitath son of Kun will follow my call." ]] ..
190"</p></rt>",190"</p></rt>",
191}191}
192192
@@ -194,7 +194,7 @@
194 posy=1,194 posy=1,
195 title=_"The story continues",195 title=_"The story continues",
196 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..196 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
197_[[ "I have sent men to meet Kalitath in this fortress. He has barricaded the former main entrance to the capital and is trying to set up a siege ring around Al’thunran. He will not let anyone enter or leave the city while the ring is intact. Until now, he has not answered any of my messages. But the time I wait won't be lost. I will further upgrade my soldiers and prepare for battle." ]] ..197_[[ "I have sent men to meet with Kalitath in his fortress. He has barricaded the former main entrance to the capital and is trying to set up a siege ring around Al’thunran. He will not let anyone enter or leave the city while the ring is intact. Until now, he has not answered any of my messages. But the time I wait won't be lost. I will further upgrade my soldiers and prepare for battle." ]] ..
198"</p></rt>",198"</p></rt>",
199}199}
200200
@@ -203,13 +203,13 @@
203 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=FF0000>" ..203 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=FF0000>" ..
204_"Boldreth shouts out!" ..204_"Boldreth shouts out!" ..
205"</p></rt><rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..205"</p></rt><rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..
206_[[ "This BASTARD! Only one man of our frontier patrol came back alive. He carried a message of Kalitath telling us that he will punish every move of our troops with their own blood! We cannot accept this behaviour. From now on there is war between Kalitath and us!" ]] ..206_[[ "This BASTARD! Only one man of our frontier patrol came back alive. He carried a message from Kalitath telling us that he will punish every move of our troops with their own blood! We cannot accept this behaviour. From now on there is war between Kalitath and us!" ]] ..
207"<br><br>" ..207"<br><br>" ..
208_"-- NEW OBJECTIVE --" ..208_"-- NEW OBJECTIVE --" ..
209"<br>" ..209"<br>" ..
210_"* Destroy Kalitaths army and expand your territory to the east." ..210_"* Destroy Kalitath's army and expand your territory to the east." ..
211"<br>" ..211"<br>" ..
212_"-> To attack an enemy you must click on the door of an advarse military building. A menu will pop up allowing you to select the number of soldiers that should attack. When you are ready with setting the number, click on the cross ('start attack')" ..212_"-> To attack an enemy you must click on the door of an adversary's military building. A menu will pop up allowing you to select the number of soldiers that should attack. When you are ready with setting the number, click on the cross ('start attack')" ..
213"</p></rt>",213"</p></rt>",
214}214}
215215
@@ -219,7 +219,7 @@
219 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..219 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
220_"Thron speaks:" ..220_"Thron speaks:" ..
221"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..221"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
222_[[ "The traitor has left his armies dying where they lay as he saw that he would not keep my forces back. Kalitath disappeared in the mess of the war, but I don’t care now. Shall he flee and be forgotten for all times as a tribeleader that would not bow before the wooden throne, that is mine to take now. Even more his flight brought us a big benefit: All year Kalitath was to busy fighting so that he did not even care to store enough food for all his men. Now that he fled the hunger brought some of his younger followers to desert. This group helds a strong fortification on the main ring. But there is more news: My scouts reported, that the two raging tribes of my brothers are in chaos and have barely noticed the new danger that is about to strike them. However they would not care if they noticed I guess, blinded by rage and hate, there is no sense left in them at all I believe." ]] ..222_[[ "The traitor has left his armies dying where they lay as he saw that he would not keep my forces back. Kalitath disappeared in the mess of the war, but I don’t care now. Shall he flee and be forgotten for all times as a tribeleader that would not bow before the wooden throne, that is mine to take now. Even more his flight brought us a big benefit: All year Kalitath was so busy fighting that he did not even care to store enough food for all his men. Now that he has fled, their hunger has brought some of his younger followers to desert. This group holds a strong fortification on the main ring. But there is more news: My scouts reported, that the two raging tribes of my brothers are in chaos and have barely noticed the new danger that is about to strike them. However they would not care if they noticed I guess, blinded by rage and hate, there is no sense left in them at all I believe." ]] ..
223"</p></rt>",223"</p></rt>",
224}224}
225225
@@ -229,7 +229,7 @@
229 body= "<rt><p font-size=24 font-weight=bold font-face=FreeSerif font-color=2F9131>" ..229 body= "<rt><p font-size=24 font-weight=bold font-face=FreeSerif font-color=2F9131>" ..
230_"Boldreth speaks:" ..230_"Boldreth speaks:" ..
231"</p></rt><rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..231"</p></rt><rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..
232_[[ "This morning I found Thron trouble-minded. He returned from his patrol late last night and sat back against a tree watching over the encampment. The number of quarrels and disputes keeps growing and the winter has us firmly under control. We should put food in our storage to survive the long, cold winter!" ]] ..232_[[ "This morning I found Thron trouble-minded. He returned from his patrol late last night and sat back against a tree watching over the encampment. The number of quarrels and disputes keeps growing and the winter has us firmly in its grip. We should put food in our storage to survive the long, cold winter!" ]] ..
233"</p></rt>",233"</p></rt>",
234}234}
235235
@@ -259,7 +259,7 @@
259 posy=1,259 posy=1,
260 title=_"Tracks",260 title=_"Tracks",
261 body= "<rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..261 body= "<rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..
262 _[[ "Thron told me that he discovered tracks in the snow to the northeast of our settlement. He instructed us to build a Donjon, to have a further visual range on the area around our hall to protect our people from sudden attacks." ]] ..262 _[[ "Thron told me that he discovered tracks in the snow to the northeast of our settlement. He instructed us to build a Donjon, to have a greater visual range on the area around our hall to protect our people from sudden attacks." ]] ..
263 "<br><br>" ..263 "<br><br>" ..
264_"-- NEW OBJECTIVE --" ..264_"-- NEW OBJECTIVE --" ..
265"<br>" ..265"<br>" ..
@@ -271,7 +271,7 @@
271 posy=1,271 posy=1,
272 title=_"Further explorations",272 title=_"Further explorations",
273 body= "<rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..273 body= "<rt image=map:boldreth.png><p line-spacing=3 font-size=12>" ..
274_[[ "The first fortification Thron ordered has just been completed. At the moment he seeks to bring trust and belief to those who live inside the walls of our new habitat, that we named 'Ondun', which means 'those who wait' in the old tongue. But Thron is not yet satisfied - and I fully understand his fears: The forests are deep and the frontier to Al’thunran is near. I am sure that there are thousand bigger dangers out there than the unknown tracks.<br>To overlook more of the area around our hall we should explore further and set up more guards and scouts to observe the frontier and keep an eye on the raging wars on our doorsteps. THEN we will be prepared once trouble seeks to capture our woods." ]] ..274_[[ "The first fortification Thron ordered has just been completed. At the moment he seeks to bring trust and belief to those who live inside the walls of our new habitat, that we named 'Ondun', which means 'those who wait' in the old tongue. But Thron is not yet satisfied - and I fully understand his fears: The forests are deep and the frontier to Al’thunran is near. I am sure that there are a thousand greater dangers out there than the unknown tracks.<br>To overlook more of the area around our hall we should explore further and set up more guards and scouts to observe the frontier and keep an eye on the raging wars on our doorsteps. THEN we will be prepared once trouble seeks to capture our woods." ]] ..
275"<br><br>" ..275"<br><br>" ..
276_"-- NEW OBJECTIVE --" ..276_"-- NEW OBJECTIVE --" ..
277"<br>" ..277"<br>" ..
@@ -295,7 +295,7 @@
295 posy=1,295 posy=1,
296 title=_"Mining economy completed",296 title=_"Mining economy completed",
297 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..297 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
298_[[ "I just got informed, that our mining economy started its work. These news brought a smile on my face - even if the hardest part is still waiting to be done, now our smiths will give their best to further ease our lives." ]] ..298_[[ "I just got informed, that our mining economy started its work. This news brought a smile to my face - even if the hardest part is still waiting to be done, now our smiths will give their best to further ease our lives." ]] ..
299"</p></rt>",299"</p></rt>",
300}300}
301301
@@ -345,7 +345,7 @@
345 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..345 body= "<rt><p font-size=24 font-face=FreeSerif font-weight=bold font-color=2F9131>" ..
346_"Thron looks worried." ..346_"Thron looks worried." ..
347"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..347"</p></rt><rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
348_[[ "My brothers and their soldiers are dead and left fire and destruction behind. In none of all the ruins I found any man or woman of the normal folk and so I just may hope that they fled from this cruel battleground and started a better life somewhere else. Nothing is left from that beauty I remember, only ruins remain from the old capital. I am sorrowful but also relieved. I never hoped to ever see Al'thunrans old beauty again - few months ago I even wondered whether I will ever be able to set my feet near to Al'thunran again. Now the old town is back in my hands and I will not hesitate to rebuild it with all forces my people have. I can't wait to see it again in it's old beauty." ]] ..348_[[ "My brothers and their soldiers are dead and left fire and destruction behind. In none of all the ruins could I find any man or woman of the normal folk and so I just may hope that they fled from this cruel battleground and started a better life somewhere else. Nothing is left from that beauty I remember, only ruins remain from the old capital. I am sorrowful but also relieved. I never hoped to ever see Al'thunran's old beauty again - it was only a few months ago that I wondered whether I would ever be able to set my feet in Al'thunran again. Now the old town is back in my hands and I will not hesitate to rebuild it with all the strength my people have. I can't wait to see it again in it's old beauty." ]] ..
349"<br><br>" ..349"<br><br>" ..
350_"--------------------- VICTORY! ----------------------" ..350_"--------------------- VICTORY! ----------------------" ..
351"<br><br>" ..351"<br><br>" ..
@@ -357,7 +357,7 @@
357 posy = 1,357 posy = 1,
358 title=_"Military assault",358 title=_"Military assault",
359 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..359 body= "<rt image=map:chieftain.png><p line-spacing=3 font-size=12>" ..
360_[[ "So be it, the generals are out to set up my troops and Boldreth himself will lead the first strike. I will ride by his side, to free Al’thunran of this war and bring peace back in our capital. When the young sun rises above the trees tomorrow morning, I will order the assault. By dusk, I will celebrate my victory in the wooden halls of the warlord and sacrifice a newborn lamb in the honour of my father whose eyes lie upon me today.<br>So be it!" ]] ..360_[[ "So be it, the generals are out to set up my troops and Boldreth himself will lead the first strike. I will ride by his side, to free Al’thunran of this war and bring peace back to our capital. When the young sun rises above the trees tomorrow morning, I will order the assault. By dusk, I will celebrate my victory in the wooden halls of the warlord and sacrifice a newborn lamb in the honour of my father whose eyes are set upon me today.<br>So be it!" ]] ..
361"<br><br>" ..361"<br><br>" ..
362_"-- NEW OBJECTIVE --" ..362_"-- NEW OBJECTIVE --" ..
363"<br>" ..363"<br>" ..
364364
=== modified file 'campaigns/tutorial01.wmf/elemental'
--- campaigns/tutorial01.wmf/elemental 2010-04-17 11:18:54 +0000
+++ campaigns/tutorial01.wmf/elemental 2010-04-30 14:39:36 +0000
@@ -2,7 +2,7 @@
2packet_version=12packet_version=1
3map_w=643map_w=64
4map_h=644map_h=64
5nr_players=15nr_players=2
6world=greenland6world=greenland
7name=_"Tutorial01"7name=_"Tutorial01"
8author="Winterwind, SirVer, Nasenbaer"8author="Winterwind, SirVer, Nasenbaer"
99
=== modified file 'campaigns/tutorial01.wmf/player_names'
--- campaigns/tutorial01.wmf/player_names 2010-04-13 19:19:45 +0000
+++ campaigns/tutorial01.wmf/player_names 2010-04-30 14:39:36 +0000
@@ -4,3 +4,9 @@
4[player_1]4[player_1]
5name=Player 15name=Player 1
6tribe=barbarians6tribe=barbarians
7
8[player_2]
9name=Sparing Partner
10tribe=empire
11ai="Defensive"
12
713
=== modified file 'campaigns/tutorial01.wmf/player_position'
--- campaigns/tutorial01.wmf/player_position 2010-04-13 19:19:45 +0000
+++ campaigns/tutorial01.wmf/player_position 2010-04-30 14:39:36 +0000
@@ -1,3 +1,5 @@
1[global]1[global]
2packet_version=22packet_version=2
3player_1=12 103player_1=12 10
4player_2=50 10
5
46
=== modified file 'campaigns/tutorial01.wmf/scripting/init.lua'
--- campaigns/tutorial01.wmf/scripting/init.lua 2010-04-27 08:20:50 +0000
+++ campaigns/tutorial01.wmf/scripting/init.lua 2010-04-30 14:39:36 +0000
@@ -22,18 +22,58 @@
22-- Constants22-- Constants
23first_lumberjack_field = wl.map.Field(16,10)23first_lumberjack_field = wl.map.Field(16,10)
24first_quarry_field = wl.map.Field(8,12)24first_quarry_field = wl.map.Field(8,12)
25conquer_field = wl.map.Field(19,15)25conquer_field = wl.map.Field(6,18)
26trainings_ground = wl.map.Field(33,57)
27
28-- Global variables
29registered_player_immovables = {}
30terminate_bad_boy_sentinel = false
31illegal_immovable_found = function(i) return false end
2632
27use("map", "texts")33use("map", "texts")
2834
29-- TODO: add objectives, there are none currently
30
31-- =================35-- =================
32-- Helper functions 36-- Helper functions
33-- =================37-- =================
38
39-- A small helper class to disable/enable autosaving and user interaction
40UserInputDisabler = {}
41function UserInputDisabler:new()
42 local rv = {}
43 setmetatable(rv, self)
44 self.__index = self
45
46 rv:establish_blocks()
47
48 return rv
49end
50function UserInputDisabler:establish_blocks()
51 self._ui_state = wl.ui.get_user_input_allowed()
52 self._as_state = wl.game.get_allow_autosaving()
53
54 wl.ui.set_user_input_allowed(false)
55 wl.game.set_allow_autosaving(false)
56end
57function UserInputDisabler:lift_blocks()
58 wl.ui.set_user_input_allowed(self._ui_state)
59 wl.game.set_allow_autosaving(self._as_state)
60end
61
62function _try_add_objective(i)
63 -- Add an objective that is defined in the table i to the players objectives.
64 -- Returns the new objective or nil. Does nothing if i does not specify an
65 -- objective.
66 local o = nil
67 if i.obj_name then
68 o = plr:add_objective(i.obj_name, i.obj_title, i.obj_body)
69 end
70 return o
71end
34function msg_box(i)72function msg_box(i)
35 wl.game.set_speed(1000)73 wl.game.set_speed(1000)
3674
75 local blocker = UserInputDisabler:new()
76
37 if i.field then77 if i.field then
38 scroll_smoothly_to(i.field.trn.trn.trn.trn)78 scroll_smoothly_to(i.field.trn.trn.trn.trn)
3979
@@ -50,46 +90,267 @@
5090
51 plr:message_box(i.title, i.body, i)91 plr:message_box(i.title, i.body, i)
5292
93 blocker:lift_blocks()
94
95 local o = _try_add_objective(i)
96
53 sleep(130)97 sleep(130)
98
99 return o
54end100end
55101
56function send_message(i)102function send_message(i)
57 plr:send_message(i.title, i.body, i)103 plr:send_message(i.title, i.body, i)
58104
105 local o = _try_add_objective(i)
59 sleep(130)106 sleep(130)
107 return o
60end108end
61 109
62function click_on_field(f, g_T)110function click_on_field(f, g_T, g_sleeptime)
63 sleep(500)111 local sleeptime = g_sleeptime or 500
112
113 local blocker = UserInputDisabler:new()
114
64 mouse_smoothly_to(f, g_T)115 mouse_smoothly_to(f, g_T)
65 sleep(500)116 sleep(sleeptime)
117
66 wl.ui.MapView():click(f)118 wl.ui.MapView():click(f)
67 sleep(500)119 sleep(sleeptime)
68end120
69121 blocker:lift_blocks()
70function click_on_panel(panel, g_T)122end
71 sleep(500)123
72 mouse_smoothly_to_panel(panel, g_T)124function click_on_panel(panel, g_T, g_sleeptime)
73 sleep(500)125 local sleeptime = g_sleeptime or 500
74 if panel.press then panel:press() sleep(250) end126
75 if panel.click then panel:click() end127 local blocker = UserInputDisabler:new()
76 sleep(500)128
77end129 sleep(sleeptime)
78130 if not panel.active then -- If this is a tab and already on, do nothing
79-- ======131 mouse_smoothly_to_panel(panel, g_T)
80-- Logic 132 sleep(sleeptime)
81-- ======133 if panel.press then panel:press() sleep(250) end
134 if panel.click then panel:click() end
135 sleep(sleeptime)
136 end
137
138 blocker:lift_blocks()
139end
140
141function warp_houses(descriptions)
142 local blocker = UserInputDisabler:new()
143
144 for idx, d in ipairs(descriptions) do
145 local name, x, y = d[1], d[2], d[3]
146 mouse_smoothly_to(wl.map.Field(x, y))
147 sleep(300)
148 prefilled_buildings(plr, d)
149 sleep(300)
150 end
151
152 blocker:lift_blocks()
153end
154
155function build_road(field, ...)
156 -- Build a road by clicking the UI. A little faster than before
157 mouse_smoothly_to(field, 400, 200)
158
159 local function _start_road(field)
160 wl.ui.MapView():click(field)
161 click_on_panel(
162 wl.ui.MapView().windows.field_action.buttons.build_road, 100, 200
163 )
164 end
165
166 _start_road(field)
167
168 for idx, d in ipairs{...} do
169 if field.immovable and field.immovable.player ~= plr then
170 field.immovable:remove()
171 end
172 if d == '|' or d == '.' then
173 mouse_smoothly_to(field, 400, 200)
174 wl.ui.MapView():click(field)
175 if d == '|' then
176 wl.ui.MapView():click(field)
177 click_on_panel(
178 wl.ui.MapView().windows.field_action.buttons.build_flag, 100, 200
179 )
180 _start_road(field)
181 end
182 else
183 field = field[d .. 'n']
184 end
185 end
186end
187
188function build_eastern_trainings_area()
189 -- Build some infrastructure as another example
190 local blocker = UserInputDisabler:new()
191
192 warp_houses{
193 {"fortress", 31, 63, soldiers = {[{3,5,0,2}] = 8 }},
194 {"warehouse", 33, 57,
195 soldiers = {
196 [{0,0,0,0}] = 1,
197 [{1,0,0,0}] = 1,
198 [{2,0,0,0}] = 1,
199 [{3,0,0,0}] = 1,
200 [{0,1,0,0}] = 1,
201 [{0,2,0,0}] = 1,
202 [{0,3,0,0}] = 1,
203 [{0,4,0,0}] = 1,
204 [{0,5,0,0}] = 1,
205 [{0,0,0,1}] = 1,
206 [{0,0,0,2}] = 1,
207 [{3,5,0,2}] = 30,
208 },
209 workers = {
210 builder = 1
211 },
212 wares = {
213 trunk = 40,
214 blackwood = 40,
215 cloth = 10,
216 gold = 10,
217 grout = 30,
218 raw_stone = 30,
219 thatchreed = 40,
220 }
221 },
222 {"trainingscamp", 31, 56, soldiers = {} },
223 {"sentry", 28, 57, soldiers = {[{3,5,0,2}] = 2 }},
224 {"sentry", 37, 61, soldiers = {[{3,5,0,2}] = 2 }},
225 }
226 -- Build the roads
227 build_road(wl.map.Field(31,57), "bl", "bl", "|", "br", "br", "|",
228 "r", "r", "|", "tr", "tr", "tl", ".")
229 build_road(wl.map.Field(29,58), "r", "br", ".")
230 build_road(wl.map.Field(38,62), "l", "l", "|", "l", "bl",
231 "|", "tl", "tl", ".")
232 build_road(wl.map.Field(32, 0), "tr", "tr", "tr", '.')
233
234 -- Add wares to the trainingssite so that it does something. Also
235 -- add buildwares to the warehouse
236 local ts = wl.map.Field(31,56).immovable
237 ts:set_wares(ts.valid_wares)
238
239 blocker:lift_blocks()
240end
241
242-- Remove all stones in a given environment. This is done
243-- in a loop for a nice optical effect
244function remove_all_stones(fields, g_sleeptime)
245 local sleeptime = g_sleeptime or 150
246 while #fields > 0 do
247 local idx = math.random(#fields)
248 local f = fields[idx]
249 local remove_field = true
250
251 if f.immovable then
252 local n = f.immovable.name:match("stones(%d*)")
253 if n then
254 n = tonumber(n)
255 f.immovable:remove()
256 if n > 1 then
257 remove_field = false
258 wl.map.create_immovable("stones" .. n-1, f)
259 end
260 sleep(sleeptime)
261 end
262 end
263
264 if remove_field then
265 table.remove(fields, idx)
266 end
267 end
268end
269
270-- ==============
271-- Sentry Thread
272-- ==============
273-- This thread makes sure that the player does not build stuff where he
274-- is not supposed to. He gets a message box when he tries and what he build
275-- gets immediately ripped. This thread can be disabled temporarily.
276function _fmt(f) return ("%i_%i"):format(f.x, f.y) end
277function register_immovable_as_allowed(i)
278 for idx, f in ipairs(i.fields) do
279 registered_player_immovables[_fmt(f)] = true
280 end
281
282 -- buildings and constructionsite have a flag
283 if i.building_type or i.type == "constructionsite" then
284 registered_player_immovables[_fmt(i.fields[1].brn)] = true
285 end
286end
287register_immovable_as_allowed(plr.starting_field.immovable)
288
289function bad_boy_sentry()
290 while not terminate_bad_boy_sentinel do
291 -- Check all fields.
292 local sent_msg = false
293 for idx,f in ipairs(plr.starting_field:region(8)) do
294 if f.immovable and f.immovable.player == plr and
295 not registered_player_immovables[_fmt(f)] then
296
297 -- Give the callback a chance to veto the deletion. Maybe
298 -- we expect the player to build something at the moment
299 if not illegal_immovable_found(f.immovable) then
300 print ("Killing", f.x .. '_' .. f.y)
301
302 -- scould the player
303 if not sent_msg then
304 msg_box(scould_player)
305 sent_msg = true
306 end
307
308 -- Remove the object again
309 f.immovable:remove()
310 end
311 end
312 end
313 sleep(1000)
314 end
315end
316
317-- Allows constructionsites for the given buildings, all others are invalid
318-- as is any other immovable build by the player
319function allow_constructionsite(i, buildings)
320 if i.type == "constructionsite" then
321 if not buildings then return i end
322 for idx,n in ipairs(buildings) do
323 if i.building == n then return i end
324 end
325 return false
326 elseif i.type == "flag" then
327 local tr = i.fields[1].tln.immovable
328 if tr and tr.type == "constructionsite" then
329 return allow_constructionsite(tr, buildings)
330 end
331 end
332
333 return false
334end
335
336-- ================
337-- Message threads
338-- ================
82function starting_infos()339function starting_infos()
83 sleep(100)340 sleep(100)
84341
85 msg_box(initial_message_01)342 msg_box(initial_message_01)
86 sleep(500)343 sleep(500)
87 msg_box(initial_message_02)344
345 local o = msg_box(initial_message_02)
346
88347
89 -- Wait for buildhelp to come on348 -- Wait for buildhelp to come on
90 while not wl.ui.MapView().buildhelp do349 while not wl.ui.MapView().buildhelp do
91 sleep(200)350 sleep(200)
92 end351 end
352 o.done = true
353
93 sleep(500)354 sleep(500)
94355
95 build_lumberjack()356 build_lumberjack()
@@ -98,12 +359,17 @@
98function build_lumberjack()359function build_lumberjack()
99 sleep(100)360 sleep(100)
100361
362 -- We take control, everything that we build is legal
363 illegal_immovable_found = function(i) return true end
364
101 msg_box(lumberjack_message_01)365 msg_box(lumberjack_message_01)
102366
367 local blocker = UserInputDisabler:new()
368
369 scroll_smoothly_to(first_lumberjack_field)
103 mouse_smoothly_to(first_lumberjack_field)370 mouse_smoothly_to(first_lumberjack_field)
104 sleep(500)371 sleep(500)
105 msg_box(lumberjack_message_02)372 msg_box(lumberjack_message_02)
106
107 sleep(500)373 sleep(500)
108374
109 click_on_field(first_lumberjack_field)375 click_on_field(first_lumberjack_field)
@@ -117,15 +383,32 @@
117 click_on_field(plr.starting_field.brn)383 click_on_field(plr.starting_field.brn)
118384
119 msg_box(lumberjack_message_04)385 msg_box(lumberjack_message_04)
386
387 register_immovable_as_allowed(first_lumberjack_field.immovable) -- hut + flag
388
389 local f = wl.map.Field(14,11)
390 register_immovable_as_allowed(f.immovable) -- road + everything on it
391
392 illegal_immovable_found = function(i) return false end
393
394 blocker:lift_blocks()
395
120 sleep(15000)396 sleep(15000)
121 397
122 msg_box(lumberjack_message_05)398 local o = msg_box(lumberjack_message_05)
399
400 local blocker = UserInputDisabler:new()
123 401
124 local f = wl.map.Field(14,11)402 local f = wl.map.Field(14,11)
403 scroll_smoothly_to(f)
125 mouse_smoothly_to(f)404 mouse_smoothly_to(f)
126405
406 blocker:lift_blocks()
407
127 -- Wait for flag408 -- Wait for flag
128 while not (f.immovable and f.immovable.type == "flag") do sleep(300) end409 while not (f.immovable and f.immovable.type == "flag") do sleep(300) end
410 o.done = true
411
129 sleep(300)412 sleep(300)
130 413
131 msg_box(lumberjack_message_06)414 msg_box(lumberjack_message_06)
@@ -139,7 +422,7 @@
139422
140function learn_to_move()423function learn_to_move()
141 -- Teaching the user how to scroll on the map424 -- Teaching the user how to scroll on the map
142 msg_box(inform_about_stones)425 local o = msg_box(inform_about_stones)
143 426
144 function _wait_for_move()427 function _wait_for_move()
145 local cx = wl.ui.MapView().viewpoint_x428 local cx = wl.ui.MapView().viewpoint_x
@@ -151,11 +434,13 @@
151 end434 end
152435
153 _wait_for_move()436 _wait_for_move()
437 o.done = true
154 sleep(3000) -- Give the player a chance to try this some more438 sleep(3000) -- Give the player a chance to try this some more
155439
156 msg_box(tell_about_right_drag_move)440 o = msg_box(tell_about_right_drag_move)
157441
158 _wait_for_move()442 _wait_for_move()
443 o.done = true
159 sleep(3000) -- Give the player a chance to try this some more444 sleep(3000) -- Give the player a chance to try this some more
160 445
161 msg_box(congratulate_and_on_to_quarry)446 msg_box(congratulate_and_on_to_quarry)
@@ -167,25 +452,22 @@
167 sleep(200)452 sleep(200)
168453
169 -- Teaching how to build a quarry and the nits and knacks of road building.454 -- Teaching how to build a quarry and the nits and knacks of road building.
170 msg_box(order_quarry_recap_how_to_build)455 local o = msg_box(order_quarry_recap_how_to_build)
171456
457 local cs = nil
172 -- Wait for the constructionsite to come up.458 -- Wait for the constructionsite to come up.
173 -- TODO: this needs to be done better, but a wrapping of the constructionsite459 illegal_immovable_found = function(i)
174 -- is needed for this. 460 cs = allow_constructionsite(i, {"quarry"})
175 -- TODO: check that the constructionsite is indeed for the correct building461 return cs
176 local cs = nil
177 while not cs do
178 for idx,f in ipairs(first_quarry_field:region(6)) do
179 if f.immovable and f.immovable.type == "constructionsite" then
180 cs = f
181 break
182 end
183 end
184 sleep(400)
185 end462 end
186463
464 -- Wait for the constructionsite to be placed
465 while not cs do sleep(300) end
466 o.done = true
467 register_immovable_as_allowed(cs)
468
187 local function _rip_road()469 local function _rip_road()
188 for idx,f in ipairs(cs:region(2)) do470 for idx,f in ipairs(cs.fields[1].brn:region(2)) do
189 if f.immovable and f.immovable.type == "road" then 471 if f.immovable and f.immovable.type == "road" then
190 click_on_field(f)472 click_on_field(f)
191 click_on_panel(wl.ui.MapView().windows.473 click_on_panel(wl.ui.MapView().windows.
@@ -196,6 +478,10 @@
196 end478 end
197 end479 end
198480
481 local blocker = UserInputDisabler:new()
482
483 illegal_immovable_found = function() return true end
484
199 msg_box(talk_about_roadbuilding_00)485 msg_box(talk_about_roadbuilding_00)
200 -- Showoff one-by-one roadbuilding486 -- Showoff one-by-one roadbuilding
201 click_on_field(wl.map.Field(9,12))487 click_on_field(wl.map.Field(9,12))
@@ -203,65 +489,93 @@
203 click_on_field(wl.map.Field(11,12))489 click_on_field(wl.map.Field(11,12))
204 click_on_field(wl.map.Field(12,12))490 click_on_field(wl.map.Field(12,12))
205 click_on_field(wl.map.Field(12,11))491 click_on_field(wl.map.Field(12,11))
492
206 sleep(3000)493 sleep(3000)
494
207 _rip_road()495 _rip_road()
208 496
209 msg_box(talk_about_roadbuilding_01)497 msg_box(talk_about_roadbuilding_01)
210 -- Showoff direct roadbuilding498 -- Showoff direct roadbuilding
211 click_on_field(cs.brn)499 click_on_field(cs.fields[1].brn)
212 click_on_panel(wl.ui.MapView().windows.field_action.buttons.build_road, 300)500 click_on_panel(wl.ui.MapView().windows.field_action.buttons.build_road, 300)
213 click_on_field(plr.starting_field.brn)501 click_on_field(plr.starting_field.brn)
502
214 sleep(3000)503 sleep(3000)
504
215 _rip_road()505 _rip_road()
216506
217 msg_box(talk_about_roadbuilding_02)507 blocker:lift_blocks()
218 508
219 -- TODO: Add information about census and statistics here509 local o = msg_box(talk_about_roadbuilding_02)
220 510
511 -- From now on, the player can build whatever he wants
512 terminate_bad_boy_sentinel = true
513
514 -- Wait a while
515 sleep( 120*1000 )
516
517 -- Interludium: talk about census and statistics
518 census_and_statistics(cs)
519
221 while #plr:get_buildings("quarry") < 1 do sleep(1400) end520 while #plr:get_buildings("quarry") < 1 do sleep(1400) end
521 o.done = true
222522
223 messages()523 messages()
224end524end
525
526function census_and_statistics(cs)
527 sleep(25000)
528
529 local blocker = UserInputDisabler:new()
530
531 wl.ui.MapView().census = false
532 wl.ui.MapView().statistics = false
533
534 msg_box(census_and_statistics_00)
535 -- Pick any empty field
536 local function _pick_empty_field()
537 local reg = cs.fields[1]:region(2)
538 local f
539 repeat
540 f = reg[math.random(#reg)]
541 until not f.immovable
542 return f
543 end
544
545 click_on_field(_pick_empty_field())
546 click_on_panel(wl.ui.MapView().windows.field_action.tabs.watch)
547 click_on_panel(wl.ui.MapView().windows.field_action.buttons.census)
548 sleep(300)
549 click_on_field(_pick_empty_field())
550 click_on_panel(wl.ui.MapView().windows.field_action.tabs.watch)
551 click_on_panel(wl.ui.MapView().windows.field_action.buttons.statistics)
552
553 msg_box(census_and_statistics_01)
554
555 blocker:lift_blocks()
556end
225557
226function messages()558function messages()
227 -- Teach the player about receiving messages559 -- Teach the player about receiving messages
228 sleep(10)560 sleep(10)
229561
230 send_message(teaching_about_messages)562 local o = send_message(teaching_about_messages)
231563
232 while #plr.inbox > 0 do sleep(200) end564 while #plr.inbox > 0 do sleep(200) end
233565 o.done = true
234 msg_box(closing_msg_window_00)566
567 sleep(500)
568
569 local o = msg_box(closing_msg_window_00)
235570
236 -- Wait for messages window to close571 -- Wait for messages window to close
237 while wl.ui.MapView().windows.messages do sleep(300) end572 while wl.ui.MapView().windows.messages do sleep(300) end
573 o.done = true
238 574
239 msg_box(closing_msg_window_01)575 msg_box(closing_msg_window_01)
240576
241 -- Remove all stones577 -- Remove all stones
242 local fields = first_quarry_field:region(6)578 remove_all_stones(first_quarry_field:region(6))
243 while #fields > 0 do
244 local idx = math.random(#fields)
245 local f = fields[idx]
246 local remove_field = true
247
248 if f.immovable then
249 temp, temp, n = f.immovable.name:find("stones(%d*)")
250 if n then
251 n = n + 0 -- trick to convert string to integer
252 f.immovable:remove()
253 if n > 1 then
254 remove_field = false
255 wl.map.create_immovable(("stones%i"):format(n-1), f)
256 sleep(150)
257 end
258 end
259 end
260
261 if remove_field then
262 table.remove(fields, idx)
263 end
264 end
265579
266 -- Wait for message to arrive580 -- Wait for message to arrive
267 while #plr.inbox < 1 do sleep(300) end581 while #plr.inbox < 1 do sleep(300) end
@@ -269,16 +583,155 @@
269 sleep(800)583 sleep(800)
270 msg_box(conclude_messages)584 msg_box(conclude_messages)
271585
586 sleep(3000)
272 expansion()587 expansion()
273end588end
274589
275function expansion() 590function expansion()
276 -- Teach about expanding your territory.591 -- Teach about expanding your territory.
277 sleep(10)592 sleep(10)
593
594 -- This is not really needed since the stones are already removed, but if
595 -- we're debugging and we start with this function it is most useful to have
596 -- the stones away already
597 remove_all_stones(first_quarry_field:region(6), 20)
278598
279 msg_box(introduce_expansion)599 local o = msg_box(introduce_expansion)
280600
281 while #conquer_field.owners < 1 do sleep(100) end601 while #conquer_field.owners < 1 do sleep(100) end
602 o.done = true
603
604 mining()
605end
606
607function mining()
608 -- Teach about geologist and resources
609 sleep(10)
610
611 msg_box(mining_00)
612
613 local function _find_good_flag_position()
614 fields = conquer_field:region(8)
615 while #fields > 0 do
616 local idx = math.random(#fields)
617 local f = fields[idx]
618
619 if f.terr:match("berg%d+") and f.terd:match("berg%d+") then
620 if pcall(function() plr:place_flag(f) end) then
621 f.immovable:remove()
622 return f
623 end
624 end
625
626 table.remove(fields, idx)
627 end
628 end
629
630 local function _find_nearby_flag()
631 for i=2,8 do
632 for idx, f in ipairs(conquer_field:region(i)) do
633 if f.immovable and f.immovable.type == "flag" then
634 return f
635 end
636 end
637 end
638 end
639
640 scroll_smoothly_to(conquer_field)
641
642 local dest = _find_good_flag_position()
643 local start = _find_nearby_flag()
644
645 -- Build a road, call a geologist
646 click_on_field(start)
647 click_on_panel(wl.ui.MapView().windows.field_action.tabs.roads)
648 click_on_panel(wl.ui.MapView().windows.field_action.buttons.build_road)
649 click_on_field(dest)
650 click_on_field(dest) -- second click
651 click_on_panel(wl.ui.MapView().windows.field_action.buttons.build_flag)
652 click_on_field(dest)
653 click_on_panel(wl.ui.MapView().windows.field_action.buttons.geologist)
654
655 sleep(6000)
656
657 msg_box(mining_01)
658
659 local function _wait_for_some_resi(wanted)
660 while 1 do
661 local cnt = 0
662 for idx, f in ipairs(dest:region(6)) do
663 if f.immovable and f.immovable.name:sub(1,4) == "resi" then
664 cnt = cnt + 1
665 if cnt >= wanted then return end
666 end
667 end
668 sleep(500)
669 end
670 end
671 _wait_for_some_resi(8)
672
673 scroll_smoothly_to(dest)
674
675 msg_box(mining_02)
676
677 training()
678end
679
680function training()
681 -- Teach about trainingsites and soldiers
682 sleep(300)
683
684 msg_box(warefare_and_training_00)
685
686 build_eastern_trainings_area()
687 sleep(8000)
688
689 msg_box(warefare_and_training_01)
690
691 sleep(5000)
692 local citadel_field = wl.map.Field(31, 63)
693 scroll_smoothly_to(citadel_field)
694
695 local o = msg_box(enhance_fortress)
696 while not (citadel_field.immovable and
697 citadel_field.immovable.name == "citadel") do sleep(800) end
698 o.done = true
699
700 -- Wait for soldiers to move in
701 local citadel = citadel_field.immovable
702 local break_out = false
703 while not break_out do
704 for k,v in pairs(citadel:get_soldiers("all")) do
705 break_out = true
706 break -- Break out if there is at least one soldier here
707 end
708
709 sleep(500)
710 end
711
712 -- Create enemy tribe
713 prefilled_buildings(wl.game.Player(2),
714 {"barrier", 25, 6},
715 {"sentry", 29, 16},
716 {"tower", 30, 21},
717 {"headquarters", 30, 27,
718 workers = {
719 carrier = 50,
720 },
721 soldiers = {
722 [{0,0,0,0}] = 15,
723 }
724 }
725 )
726
727 scroll_smoothly_to(citadel_field)
728 local o = msg_box(attack_enemey)
729
730 local plr2 = wl.game.Player(2)
731 while #plr2:get_buildings("headquarters") > 0 or not plr2.defeated do
732 sleep(3000)
733 end
734 o.done = true
282735
283 conclusion()736 conclusion()
284end737end
@@ -292,5 +745,6 @@
292745
293end746end
294747
748run(bad_boy_sentry)
295run(starting_infos)749run(starting_infos)
296750
297751
=== modified file 'campaigns/tutorial01.wmf/scripting/texts.lua' (properties changed: -x to +x)
--- campaigns/tutorial01.wmf/scripting/texts.lua 2010-04-27 07:47:43 +0000
+++ campaigns/tutorial01.wmf/scripting/texts.lua 2010-04-30 14:39:36 +0000
@@ -23,6 +23,11 @@
23 .. s .. "<br></p><p font-size=8> <br></p>"23 .. s .. "<br></p><p font-size=8> <br></p>"
24end24end
2525
26function h2(s)
27 return "<p font=FreeSerif font-size=12 font-weight=bold font-color=D1D1D1>"
28 .. s .. "<br></p><p font-size=4> <br></p>"
29end
30
26-- Simple flowing text. One Paragraph31-- Simple flowing text. One Paragraph
27function p(s)32function p(s)
28 return "<p line-spacing=3 font-size=12>" .. s .. "<br></p>" ..33 return "<p line-spacing=3 font-size=12>" .. s .. "<br></p>" ..
@@ -30,15 +35,26 @@
30end35end
3136
32-- =============37-- =============
33-- Textes below38-- Texts below
34-- =============39-- =============
40scould_player = {
41 title = _ "Nice and easy does it all the time",
42 body = rt(p(_
43[[I am sorry, but I have to rip this again. We might need the space here later
44on. If I am too slow for you, you might want to play a real game and just find
45everything out for yourself. Otherwise, please bear with me, I am not the
46youngest and quickest anymore.]]
47 )
48 )
49}
50
35initial_message_01 = {51initial_message_01 = {
36 title = _ "Welcome to the Widelands tutorial!",52 title = _ "Welcome to the Widelands tutorial!",
37 body = rt(53 body = rt(
38 h1(_"Welcome to Widelands!") ..54 h1(_"Welcome to Widelands!") ..
39 p(_55 p(_
40[[Widelands is a slow-paced build-up strategy with an emphasis on construction,56[[Widelands is a slow-paced build-up strategy with an emphasis on construction,
41 not destruction. This tutorial will get you through the basics of the game.]]57not destruction. This tutorial will get you through the basics of the game.]]
42 ) .. p(_58 ) .. p(_
43[[You can dismiss this box by left-clicking on the button below.]]59[[You can dismiss this box by left-clicking on the button below.]]
44 )60 )
@@ -52,23 +68,32 @@
52 h1(_"Let's dive right in!") ..68 h1(_"Let's dive right in!") ..
53 p(_69 p(_
54[[There are three different tribes in Widelands: the barbarians, the empire and70[[There are three different tribes in Widelands: the barbarians, the empire and
55 the atlanteans. All tribes have a different economy, strength and weaknesses,71the atlanteans. All tribes have a different economy, strength and weaknesses,
56 but the general gameplay is the same for all. We play the barbarians for now.]]72but the general gameplay is the same for all. We play the barbarians for now.]]
57 ) .. p(_73 ) .. p(_
58[[You usually start the game with one headquarters. This is the big building74[[You usually start the game with one headquarters. This is the big building
59 with the blue flag in front of it. The headquarters is a ware house that stores75with the blue flag in front of it. The headquarters is a ware house that stores
60 wares, workers and soldiers. Some wares are needed for building houses, others76wares, workers and soldiers. Some wares are needed for building houses, others
61 for making other wares. Obviously, the wares in the headquarters will not last77for making other wares. Obviously, the wares in the headquarters will not last
62 forever, so you must make sure to reproduce them. The most important wares in78forever, so you must make sure to reproduce them. The most important wares in
63 the early game are the basic build wares: trunks and raw stone. Let's make sure79the early game are the basic build wares: trunks and raw stone. Let's make sure
64 that we do not run out of trunks. For this, we need to build a lumberjack.]]80that we do not run out of trunks. For this, we need to build a lumberjack.]]
65 ) .. p(_81 ) .. p(_
66[[We need to find a nice place for the lumberjack. To make this easier, we82[[We need to find a nice place for the lumberjack. To make this easier, we
67 activate the build help. To do this, either click on the build help button83activate the build help. To do this, either click on the build help button
68 at the bottom of the screen which is the fourth one from the left. Or you84at the bottom of the screen which is the fourth one from the left. Or you
69 can use the SPACE key to toggle it.]]85can use the SPACE key to toggle it.]]
70 )86 )
71 ),87 ),
88 obj_name = "enable_buildhelp",
89 obj_title = _ "Enable the build help",
90 obj_body = rt(h1(_"Enable the build help") ..
91 p(
92[[It is easier to understand what is allowed to be built on which field when
93the build help symbols are enabled. Do so now either by pressing SPACE or by
94clicking the fourth button from the left at the very bottom of the screen.]]
95 )
96 )
72}97}
7398
74lumberjack_message_01 = {99lumberjack_message_01 = {
@@ -77,8 +102,8 @@
77 field = first_lumberjack_field,102 field = first_lumberjack_field,
78 body = rt(p(_103 body = rt(p(_
79[[There you go. I will explain about all those symbols in a minute. First, let104[[There you go. I will explain about all those symbols in a minute. First, let
80 me show you how to make a lumberjack's hut and how to connect it with a road.105me show you how to make a lumberjack's hut and how to connect it with a road.
81 There is a sweet spot for a lumberjack right next to those trees.]]106There is a sweet spot for a lumberjack right next to those trees.]]
82 )107 )
83 )108 )
84}109}
@@ -88,11 +113,11 @@
88 pos = "topright",113 pos = "topright",
89 body = rt(p(_114 body = rt(p(_
90[[First, I'll left-click on the symbol were I want the lumberjack to be built. A115[[First, I'll left-click on the symbol were I want the lumberjack to be built. A
91 window will appear where I can choose between buildings. Because I clicked a116window will appear where I can choose between buildings. Because I'll click a
92 yellow house symbol - it means that this field can house medium and small117yellow house symbol - which means that this field can house medium and small
93 buildings - I am presented with all medium buildings that I can build. I118buildings - I am presented with all medium buildings that I can build. I
94 go on to select the small buildings tab. Then I choose the lumberjack's hut.119go on to select the small buildings tab. Then I choose the lumberjack's hut.
95 Watch me, I'll go really slow: click - select tab - choose building.]]120Watch me, I'll go really slow: click - select tab - choose building.]]
96 )121 )
97 )122 )
98}123}
@@ -102,9 +127,9 @@
102 pos = "topright",127 pos = "topright",
103 body = rt(p(_128 body = rt(p(_
104[[That won't do yet. I still need to connect the lumberjack's hut to the129[[That won't do yet. I still need to connect the lumberjack's hut to the
105 rest of my road network. After I ordered a construction site, I am130rest of my road network. After I ordered a construction site, I am
106 automatically in road building mode, so all I have to do is click on the flag131automatically in road building mode, so all I have to do is click on the flag
107 in front of my headquarters.]]132in front of my headquarters.]]
108 )133 )
109 )134 )
110}135}
@@ -114,8 +139,8 @@
114 pos = "topright",139 pos = "topright",
115 body = rt(p(_140 body = rt(p(_
116[[Now watch closely as a builder leaves the headquarters and goes to the141[[Now watch closely as a builder leaves the headquarters and goes to the
117 construction site. Also a carrier will take position in between the two flags142construction site. Also a carrier will take position in between the two flags
118 and carry wares from one flag to the other.]]143and carry wares from one flag to the other.]]
119 )144 )
120 )145 )
121}146}
@@ -125,10 +150,18 @@
125 pos = "topright",150 pos = "topright",
126 body = rt(p(_151 body = rt(p(_
127[[Nice how they work, isn't it? But the poor carrier has a very long way to go.152[[Nice how they work, isn't it? But the poor carrier has a very long way to go.
128 We can make it easier for him (and more efficient for us) when we place another153We can make it easier for him (and more efficient for us) when we place another
129 flag on the road. You try it this time: click on the yellow flag symbol154flag on the road. You try it this time: click on the yellow flag symbol
130 in between the two blue flags we just placed and then click on the]]155in between the two blue flags we just placed and then click on the]]
131 )) .. rt("image=pics/menu_build_flag.png", p(_ "build flag symbol.")156 )) .. rt("image=pics/menu_build_flag.png", p(_ "build flag symbol.")
157 ),
158 obj_name = "build_flag_on_road_to_lumberjack",
159 obj_title = _ "Build a flag to divide the road to the lumberjack",
160 obj_body = rt(h1(_"Build a flag on the road") .. p(_
161[[The shorter your road segments are, the faster your wares will be transported.
162You should therefore make sure that your roads have as many flags as possible.
163Build a flag now in the middle of the road that connects your headquarters
164to your lumberjack's hut.]])
132 )165 )
133}166}
134167
@@ -137,8 +170,8 @@
137 pos = "topright",170 pos = "topright",
138 body = rt(p(_171 body = rt(p(_
139[[Well done! Let's wait till the hut is finished. If you want things to172[[Well done! Let's wait till the hut is finished. If you want things to
140 go faster, simply use the PAGE UP key on your keyboard to increase the game173go faster, simply use the PAGE UP key on your keyboard to increase the game
141 speed. You can use PAGE DOWN to make the game slower again.]]174speed. You can use PAGE DOWN to make the game slower again.]]
142 )175 )
143 )176 )
144}177}
@@ -148,8 +181,8 @@
148 pos = "topright",181 pos = "topright",
149 body = rt(p(_182 body = rt(p(_
150[[Excellent. The lumberjack's hut is done. A lumberjack will now move in and183[[Excellent. The lumberjack's hut is done. A lumberjack will now move in and
151 start chopping down trees, so our trunks income is secured for now. Now on to184start chopping down trees, so our trunks income is secured for now. Now on to
152 the raw stone.]]185the raw stone.]]
153 )186 )
154 )187 )
155}188}
@@ -159,13 +192,23 @@
159 body = rt(h1(_ "Getting a quarry up.")) ..192 body = rt(h1(_ "Getting a quarry up.")) ..
160 rt(p(_193 rt(p(_
161[[Stones can be mined in granite mines, but the easier way is to build a quarry194[[Stones can be mined in granite mines, but the easier way is to build a quarry
162 next to some stones laying around. As it happens, there is a pile of them195next to some stones laying around. As it happens, there is a pile of them
163 laying right to the west of your headquarters. I will teach you now how to196laying just to the west of your headquarters. I will teach you now how to
164 move your view over there]]197move your view over there.]]
165 ) .. p(_198 ) .. p(_
166[[There are two ways to move your view. The first one is using the cursor keys199[[There are two ways to move your view. The first one is using the cursor keys
167 on your keyboard. Go ahead and try this out, move the view using the cursor200on your keyboard. Go ahead and try this out, move the view using the cursor
168 keys]]201keys]]
202 )
203 ),
204 obj_name = "move_view_with_cursor_keys",
205 obj_title = _ "Move your view with the cursor keys",
206 obj_body = rt(h1(_"Moving your view") .. p(_
207[[Moving your view is essential to get a complete overview over your whole
208economy. There are two ways to move your view in widelands. The first one is
209to use the cursor keys on your keyboard. The second one is the more common and
210faster one: press-and-hold the right mouse button anywhere on the map, then move
211your mouse around and you'll see the view scroll.]]
169 )212 )
170 )213 )
171}214}
@@ -174,16 +217,19 @@
174 title = _ "Other ways to move the view",217 title = _ "Other ways to move the view",
175 body = rt(p(_218 body = rt(p(_
176[[Excellent. Now there is a faster way to move, using the mouse instead: Simply219[[Excellent. Now there is a faster way to move, using the mouse instead: Simply
177 right-click-and-hold anywhere on the map, then drag the mouse and instead220right-click-and-hold anywhere on the map, then drag the mouse and instead
178 of the cursor, the view will be moved. Try it.]]221of the cursor, the view will be moved. Try it.]]
179 )222 )
180 )223 ),
224 obj_name = "move_view_with_mouse",
225 obj_title = _ "Move your view with the mouse",
226 obj_body = inform_about_stones.obj_body,
181}227}
182228
183congratulate_and_on_to_quarry = {229congratulate_and_on_to_quarry = {
184 title = _ "Onward to the quarry",230 title = _ "Onward to the quarry",
185 body = rt(p(_231 body = rt(p(_
186[[Great. Now about the quarry...]]232[[Great. Now about that quarry...]]
187 )233 )
188 )234 )
189}235}
@@ -194,17 +240,17 @@
194 title = _ "How to build a quarry",240 title = _ "How to build a quarry",
195 body = rt(p(_241 body = rt(p(_
196[[Build a quarry next to those stones here. Remember how I did it earlier?242[[Build a quarry next to those stones here. Remember how I did it earlier?
197 Just click the place were you want the building to be, choose it from the243Just click the place were you want the building to be, choose it from the
198 window that appears and it is placed. Maybe it is a good time to explain about244window that appears and it is placed. Maybe it is a good time to explain about
199 all those build help symbols we activated earlier.]]245all those build help symbols we activated earlier.]]
200 ) .. p(_246 ) .. p(_
201[[You can build four things on fields in Widelands: Flags, small houses, medium247[[You can build four things on fields in Widelands: Flags, small houses, medium
202 houses and big houses. But not every field can hold anything. The build help248houses and big houses. But not every field can hold anything. The build help
203 eases recognition:]]249eases recognition:]]
204 )) .. rt("image=pics/big.png", p(_250 )) .. rt("image=pics/big.png", p(_
205[[Everything can be build on the green house symbol.]]251[[Everything can be built on the green house symbol.]]
206 )) .. rt("image=pics/medium.png", p(_252 )) .. rt("image=pics/medium.png", p(_
207[[Everything except for big buildings can be build on a yellow house symbol.]]253[[Everything except for big buildings can be built on a yellow house symbol.]]
208 )) .. rt("image=pics/small.png", p(_254 )) .. rt("image=pics/small.png", p(_
209[[Red building symbols can only hold small buildings and flags.]]255[[Red building symbols can only hold small buildings and flags.]]
210 )) .. rt("image=pics/set_flag.png", p(_256 )) .. rt("image=pics/set_flag.png", p(_
@@ -214,40 +260,54 @@
214 space for holding buildings, so choose your fields wisely.]]260 space for holding buildings, so choose your fields wisely.]]
215 )) .. rt(p(_261 )) .. rt(p(_
216[[Now go ahead, try it. The quarry is a small building, so if you click on a262[[Now go ahead, try it. The quarry is a small building, so if you click on a
217 medium or big building symbol, you will have to select the small buildings263medium or big building symbol, you will have to select the small buildings
218 tab first to find it. Go on, check it out!]]264tab first to find it. Go on, check it out!]]
265 )
266 ),
267 obj_name = "build_a_quarry",
268 obj_title = _ "Build a quarry next to the stones",
269 obj_body = rt(h1(_ "Build a quarry") .. p(_
270[[There are some stones to the west of your headquarters. Build a quarry right
271next to them. The quarry is a small building like the lumberjack's hut. You
272can therefore build it on any field that shows a red, yellow or green house
273when the build help is enabled (Press SPACE for that).]]) .. p(_
274[[Just click on any house symbol next to the stones, select the small buildings
275tab in the window that opens up, then click on the quarry symbol.]]
219 )276 )
220 )277 )
221}278}
222279
223talk_about_roadbuilding_00 = {280talk_about_roadbuilding_00 = {
224 pos = "topright",281 pos = "topright",
282 field = wl.map.Field(9,12),
225 title = _ "Road building",283 title = _ "Road building",
226 body = rt(p(_284 body = rt(p(_
227[[Excellent! Directly after you placed a building, you are in road building285[[Excellent! Directly after you placed a building, you are in road building
228 mode. The new road will start at the flag in front of your newly placed286mode. The new road will start at the flag in front of your newly placed
229 construction site. You can enter road building mode for any flag by287construction site. You can enter road building mode for any flag by
230 left-clicking on a flag and selecting]]288left-clicking on a flag and selecting]]
231 )) .. rt("image=pics/menu_build_way.png", p(_289 )) .. rt("image=pics/menu_build_way.png", p(_
232[[the road building symbol.]]290[[the road building symbol.]]
233 )) .. rt(p(_291 )) .. rt(p(_
234[[If you decide you do not want to build a road at this time, you can cancel292[[If you decide you do not want to build a road at this time, you can cancel
235 road building by clicking on the starting flag of the road and selecting]]293road building by clicking on the starting flag of the road and selecting]]
236 )) .. rt("image=pics/menu_abort.png", p(_294 )) .. rt("image=pics/menu_abort.png", p(_
237[[the abort symbol.]]295[[the abort symbol.]]
238 )) .. rt(p(_296 )) .. rt(p(_
239[[Now, you can either make it longer by one field at a time by left-clicking297[[Now, about this road. Remember: we are already in road building mode since you
240 multiple times on neighbouring fields for perfect control over the route the298just ordered the quarry. You can either make it longer by one field at a time
241 road takes like so:]]299by left-clicking multiple times on neighbouring fields for perfect control over
300the route the road takes like so:]]
242 ))301 ))
243}302}
244303
245talk_about_roadbuilding_01 = {304talk_about_roadbuilding_01 = {
246 pos = "topright",305 pos = "topright",
306 field = wl.map.Field(9,12),
247 title = _ "Road building",307 title = _ "Road building",
248 body = rt(p(_308 body = rt(p(_
249[[Alternatively, you can directly click the flag where309[[Alternatively, you can directly click the flag where
250 the road should end like so.]]310the road should end like so.]]
251 ))311 ))
252}312}
253313
@@ -256,23 +316,62 @@
256 title = _ "Road building",316 title = _ "Road building",
257 body = rt(p(_317 body = rt(p(_
258[[One more thing: around the field where your road would end you can see318[[One more thing: around the field where your road would end you can see
259 different markers. They have the following meaning:]]319different markers. They have the following meaning:]]
260 )) .. rt("image=pics/roadb_green.png", p(_320 )) .. rt("image=pics/roadb_green.png", p(_
261[[The terrain is flat here. Your carriers will be very swift on this terrain.]]321[[The terrain is flat here. Your carriers will be very swift on this terrain.]]
262 )) .. rt("image=pics/roadb_yellow.png", p(_322 )) .. rt("image=pics/roadb_yellow.png", p(_
263[[There is a small slope to climb to reach this field. This means you're323[[There is a small slope to climb to reach this field. This means you're
264 workers are faster walking downwards than they are walking upwards.]]324workers are faster walking downwards than they are walking upwards.]]
265 )) .. rt("image=pics/roadb_red.png", p(_325 )) .. rt("image=pics/roadb_red.png", p(_
266[[The connection between the fields is extremely steep. The speed increase in326[[The connection between the fields is extremely steep. The speed increase in
267 one direction is huge while the slowdown in the other is also substantial.]]327one direction is huge while the slowdown in the other is also substantial.]]
268 )) .. rt(p(_328 )) .. rt(p(_
269[[Keep the slopes in mind while placing roads and use them to your advantage.329[[Keep the slopes in mind while placing roads and use them to your advantage.
270 Also try to keep roads as short as possible and always remember to place as330Also try to keep roads as short as possible and always remember to place as
271 many flags as you can on road segments to share the load better.]]331many flags as you can on road segments to share the load better.]]
272 )) .. rt(p(_332 )) .. rt(p(_
273[[Now please rebuild the road between your quarry and your headquarters.333[[Now please rebuild the road between your quarry and your headquarters.
274 We'll wait until the quarry is completed.]]334We'll wait until the quarry is completed.]]
275 ))335 )),
336 obj_name = "build_road_to_quarry",
337 obj_title = _ "Connect the quarry to the headquarters",
338 obj_body = rt(h1(_"Connect your construction site") .. p(_
339[[Connect your quarry construction site to your headquarters with a road. You
340are directly in road building mode when you ordered a new site. But now, you
341aren't. To build a completely new road just click on the flag in front of your
342construction site, click on the build road icon then click on the flag in front
343of your headquarters.]]
344 )
345 )
346}
347
348census_and_statistics_00 = {
349 title = _ "Census and statistics",
350 body = rt(p(_
351[[While we wait, I'll quickly show you another useful feature. All construction
352sites look the same and some buildings look alike. It is sometimes hard to tell
353them apart. Widelands offers a feature to show label texts over the buildings.
354They are called the census and you can toggle them via the 'c' key or via
355the button on the watch tab of any field.]]
356 ) .. p(_
357[[Similar to this are building statistics which are also toggled via a
358button on the watch tab of any field. The hotkey for it is 's'. This will
359display an information string about the productivity of buildings or the
360progress of construction sites.]]
361 ) .. p(_
362[[Let me quickly enable those two for you. Remember: 'c' and 's' are the keys.
363Alternatively you can click on any field without a building on it, select the
364watch tab and then click on the corresponding buttons.]]
365 )
366)
367}
368
369census_and_statistics_01 = {
370 title = _ "Census and statistics",
371 body = rt(p(_
372[[Now we know what's going on. Let's wait for this quarry to finish.]]
373 )
374)
276}375}
277376
278teaching_about_messages = {377teaching_about_messages = {
@@ -281,24 +380,35 @@
281 body = rt(h1(_"Messages") ..380 body = rt(h1(_"Messages") ..
282 p(_381 p(_
283[[Hi, it's me again! This time, I sent you a message. Messages are sent to you382[[Hi, it's me again! This time, I sent you a message. Messages are sent to you
284 by Widelands to inform you about important events: empty mines, attacks on your383by Widelands to inform you about important events: empty mines, attacks on your
285 tribe, won or lost military buildings, resources found...]]384tribe, won or lost military buildings, resources found...]]
286 ) .. p(_385 ) .. p(_
287[[The message window can be toggled by the button on the very right at the386[[The message window can be toggled by the button on the very right at the
288 bottom of the screen. This button also changes appearance if new messages are387bottom of the screen. This button also changes appearance if new messages are
289 available, but there is also a bell sound played whenever you receive a new388available, but there is also a bell sound played whenever you receive a new
290 message.]]389message.]]
291 ) .. p(_390 ) .. p(_
292[[Currently, you have two messages. This one which you are currently reading and391[[Currently, you have two messages. This one which you are currently reading and
293 the one that informed you that a new headquarters was added to your economy.392the one that informed you that a new headquarters was added to your economy.
294 Let's learn how to archive messages: You can check them off in your inbox so393Let's learn how to archive messages: You can check them off in your inbox so
295 that they get a tick-symbol in front of them. Then, you can click the]]394that they get a tick-symbol in front of them. Then, you can click the]]
296 )) .. rt("image=pics/message_archive.png", p(_395 )) .. rt("image=pics/message_archive.png", p(_
297[[archive message button to move them into your archive.]]396[[archive message button to move them into your archive.]]
298 )) .. rt(p(_397 )) .. rt(p(_
299[[Archive all messages, including this one, that you currently have in your398[[Archive all messages, including this one, that you currently have in your
300 inbox.]]399 inbox.]]
301 )400 )
401 ),
402 obj_name = "archive_all_messages",
403 obj_title = _"Archive all messages in your inbox",
404 obj_body = rt(h1(_"Archive our inbox messages") .. p(_
405[[The message window is central to fully control your tribe's fortune. But you
406get a lot of messages in a real game. To keep your head straight, you should
407try to keep the inbox empty. Archive all your messages in the inbox now. To do
408so, open the messages window by pressing 'n' or clicking the right most button
409at the very bottom of the screen. Then mark all messages by checking the check
410box in front of them. Then, click the archive all button]]
411 )
302 )412 )
303}413}
304414
@@ -308,9 +418,17 @@
308 title = _"Closing windows",418 title = _"Closing windows",
309 body = rt(p(_419 body = rt(p(_
310[[Excellent. By the way: closing windows in Widelands is as easy as420[[Excellent. By the way: closing windows in Widelands is as easy as
311 right-clicking on them. This works with all windows except for story message421right-clicking on them. This works with all windows except for story message
312 windows like this one. Go ahead and try it. Close the messages window,422windows like this one. Go ahead and try it. First, close this window by pressing
313 please.]]423the button below, then right click into the messages window to close it.]]
424 )
425 ),
426 obj_name = "close_message_window",
427 obj_title = _ "Close the messages window",
428 obj_body = rt(h1(_"Close the messages window") .. p(_
429[[All windows in widelands can be closed by right clicking into them. Some
430windows can also be toggled with the buttons at the very bottom of the screen.
431Close the messages window now by right clicking into it.]]
314 )432 )
315 )433 )
316}434}
@@ -321,9 +439,9 @@
321 title = _ "Closing windows",439 title = _ "Closing windows",
322 body = rt(p(_440 body = rt(p(_
323[[Well done! Let's see how messages work in the real game, shall we? For this,441[[Well done! Let's see how messages work in the real game, shall we? For this,
324 I'll take all stones away from the poor stonemason in the quarry. He will then442I'll take all stones away from the poor stonemason in the quarry. He will then
325 send a message that he can't find any in his working area the next time he443send a message that he can't find any in his working area the next time he
326 tries to do some work.]]444tries to do some work.]]
327 )445 )
328 )446 )
329}447}
@@ -333,8 +451,9 @@
333 title = _ "Message arrived!",451 title = _ "Message arrived!",
334 body = rt(p(_452 body = rt(p(_
335[[A message has been sent to you. See how the button at the bottom of the453[[A message has been sent to you. See how the button at the bottom of the
336 screen has changed appearance? You should now burn this quarry down as it is454screen has changed appearance? You should now burn this quarry down as it is
337 no longer of any use and is just blocking space.]]455no longer of any use and is just blocking space. To do that, click on the
456quarry and select the destroy button.]]
338 ))457 ))
339}458}
340459
@@ -342,23 +461,225 @@
342 title = _ "Expanding your territory!",461 title = _ "Expanding your territory!",
343 body = rt(p(_462 body = rt(p(_
344[[There is one more thing I'd like to teach you now: Expanding your territory.463[[There is one more thing I'd like to teach you now: Expanding your territory.
345 The place that we start with around our headquarters is barely enough for a464The place that we start with around our headquarters is barely enough for a
346 basic build infrastructure and we do not have access to mountains which we465basic build infrastructure and we do not have access to mountains which we
347 need to mine minerals and coal. So we have to expand our territory]]466need to mine minerals and coal. So we have to expand our territory.]]
348 ) .. p(_467 ) .. p(_
349[[Expanding is as simple as building a military building at the corner of468[[Expanding is as simple as building a military building at the corner of
350 your territory. The barbarians have a few different military buildings:469your territory. The barbarians have a few different military buildings:
351 sentries, barriers, donjons, strongholds, fortresses and citadels. The bigger470sentries, barriers, donjons, strongholds, fortresses and citadels. The bigger
352 the building, the more expensive it is to build, the more land it conquers471the building, the more expensive it is to build, the more land it conquers
353 around itself and the more soldiers can be stationed there. The buildings also472around itself and the more soldiers can be stationed there. The buildings also
354 vary in their vision range: buildings with a tower see farther than others.]]473vary in their vision range: buildings with a tower see farther than others.]]
355 ) .. p(_474 ) .. p(_
356[[As soon as a military building is manned, it extends your land. You can then475[[As soon as a military building is manned, it extends your land. You can then
357 burn it down again if you need the place. But note that your land is then476burn it down again if you need the place. But note that your land is then
358 vulnerable: any military site from another player can conquer the land. You477vulnerable: any military site from another player can conquer the land. You
359 therefore need military sites to keep military influence over your land.]]478therefore need military sites to keep military influence over your land.]]
360 ) .. p(_479 ) .. p(_
361[[Let's try it out now: Build a military building on your eastern border.]]480[[Let's try it out now: Build a few military buildings on your south western
481border. We want to capture some of this mountain, so we can search for
482resources there. Bigger buildings will conquer more land which can be beneficial
483close to mountains because you can't build houses in mountains.]]
484 )
485 ),
486 obj_name = "conquer_mountain",
487 obj_title = _ "Conquer an area were we can build mines",
488 obj_body = rt(h1(_"Conquer the mountain to the south west") .. p(_
489[[For a full-fledged economy, we need coal, iron and gold. These can be found
490in mountains. Conquer some area on the mountains to the south-west of your
491headquarters by building some military buildings close to your border.]]
492 ) .. p(_
493[[You can choose from the following military buildings: sentry, stronghold,
494donjon, barrier and fortress. The bigger the building, the more expensive it is
495to be built. But it will also conquer a bigger region. Sometimes, it is useful
496to build a big military building next to a mountain so that you can reach
497fields farther up.]]
498 )
499 )
500}
501
502mining_00 = {
503 pos = "topright",
504 title = _ "Searching for resources",
505 body = rt(p(_
506[[Okay, now we own some of the area on this mountain. Mountains are very
507important, because they contain resources: coal, iron ore, goldstone and
508granite. Each tribe uses the resources differently, but all need mines to get
509the resources out of the ground.]]
510 ) .. p(_
511[[Let's search for resources in this mountain. First, we'll build a road into
512the mountains and place a flag. Then, we click on the flag and call a geologist
513to it. I'll show you how it's done.]]
514 )
515)
516}
517
518mining_01 = {
519 pos = "topright",
520 title = _"Waiting for the geologist",
521 body = rt(p(_
522[[The geologist will arrive shortly to the flag and start investigating the
523area in his surroundings. He will place the following markers for the various
524resources:]]
525 )) ..
526 rt("image=tribes/barbarians/resi_coal1/resi_00.png", p(_ "a bit of coal")) ..
527 rt("image=tribes/barbarians/resi_coal2/resi_00.png", p(_ "a lot of coal")) ..
528 rt("image=tribes/barbarians/resi_iron1/resi_00.png", p(_ "a bit of iron")) ..
529 rt("image=tribes/barbarians/resi_iron2/resi_00.png", p(_ "a lot of iron")) ..
530 rt("image=tribes/barbarians/resi_gold1/resi_00.png", p(_ "a bit of gold")) ..
531 rt("image=tribes/barbarians/resi_gold2/resi_00.png", p(_ "a lot of gold")) ..
532 rt("image=tribes/barbarians/resi_granit1/resi_00.png",
533 p(_ "a bit of granite")) ..
534 rt("image=tribes/barbarians/resi_granit2/resi_00.png",
535 p(_ "a lot of granite")) ..
536 rt("image=tribes/barbarians/resi_water1/resi_00.png", p(_ "water")) ..
537 rt("image=tribes/barbarians/resi_none/resi_00.png",
538 p(_ "nothing was found here"))
539 .. rt(p(_
540[[Let's wait and see what the geologist finds on the mountain.]]
541 )
542)
543}
544
545mining_02 = {
546 pos = "topright",
547 title = _ "Mining conclusion",
548 body = rt(p(_
549[[So our geologist found a lot of coal on this mountain. You should therefore
550build a coal mine here. Building a mine is like building a house. The build
551help symbol for where a mine can be built is]]
552 )) .. rt("image=pics/mine.png", p(_"this one.")) ..
553 rt(p(_
554[[Note that a mine needs rations to work. Rations are
555produced in taverns and taverns need meat, pitta bread, and fish to produce
556them. You will need a lot more infrastructure to get your mines working
557well. This infrastructure also varies from tribe to tribe. You'll get them
558explained in the introduction campaigns for the three tribes.]]
559 )
560)
561}
562
563warefare_and_training_00 = {
564 title = _ "Warfare and Training",
565 body = rt(h1(_ "Soldiers and Warefare") .. p(_
566[[On to the last topic now. We are going to talk about soldiers, their training
567and their profession: warfare. As mentioned, widelands is about building up,
568not burning down: therefore warfare is also more focused on the economics than
569the military strategies. Nevertheless, warfare offers one way to challenge
570other players and it has some game mechanics that deserve explanation. The
571economies of the tribes are explained in their individual tutorial campaigns.
572Ok, I am going to create us a little training ground with a training camp and a
573warehouse to the north east of here.]]) .. p(_
574[[If you want to come back to this eastern part of your realm, just scroll here
575via right-button scrolling or open the minimap by clicking on the]]
576 )) .. rt("image=pics/menu_toggle_minimap.png", p(_
577[[minimap button at the bottom of the screen. Alternatively you could also press
578'm' on your keyboard]]
579 )) .. (rt(p(_
580[[The minimap shows you the complete map in miniature. You can directly jump to
581any field by left-clicking on it. You can also toggle buildings, roads, flags
582and player indicators on and off inside the map.]]
583 ) .. p(_
584[[But I digress. Back to soldiers. What was I about to do? Oh yes, I wanted to
585build a small training scenario for you. Let's do that now.]]
586 )
587 )
588 )
589}
590
591warefare_and_training_01 = {
592 pos = "topright",
593 title = _ "Trainings camp and soldier stats",
594 body = rt(p(_
595[[There we go. Take a look at the soldiers that are on their way into our
596trainings camp. They look different than normal workers: they have a health bar
597over their head that displays their remaining hitpoints and they have four
598symbols which symbolize the individual soldier's current levels in the four
599different categories hitpoints, attack, defense and evade.]]
600 ) .. p(_
601[[A soldier is created as any normal worker: a carrier grabs a tool in a
602warehouse as soon as a request for a certain profession is not fulfilled. The
603tool to create a barbarian soldier is an axe. The newly created soldier is of
604level 0. To make the soldier better in any of the four categories, training is
605needed. Training happens in training sites like the trainings camp or the
606battle arena: soldiers go there (as our little fellows are currently doing),
607consume some wares and advance a level in one category. If a barbarian soldier
608is fully trained, he has level 3 hitpoints, level 5 attack, level 0 defense and
609level 2 evade. This is one fearsome warrior then! The individual statistics
610have the following meaning:]]
611 ) .. h2(_"Hitpoints:") .. p(_
612[[The total life of a soldier. A barbarian soldier starts with ~130 hitpoints,
613with each hitpoint level he gains 28 hitpoints.]]
614 ) .. h2(_"Attack:") .. p(_
615[[The amount of damage a soldier inflicts upon a successful attack on the
616enemy. A barbarian soldier with attack level 0 inflicts ~14 hitpoints damage
617when he succeeds to hit an enemy. For each attack level, he gains 7 damage.
618]]
619 ) .. h2(_"Defense:") .. p(_
620[[Defense is the value that is subtracted from the attack value. The barbarians
621can not train in this skill and therefore have always defense level 0 which
622means that they always get 3 hitpoints subtracted from the damage inflicted. If
623an attacker with an attack value of 15 hitpoints hits a barbarian soldier, the
624barbarian would lose 15 - 3 = 12 hitpoints. The 3 hitpoints that are subtracted
625are because of the defense ability.]]
626 ) .. h2(_"Evade:") .. p(_
627[[Evade is the chance that the soldier is able to dodge an attack. It is 25% for
628a level 0 evade barbarian and increases in steps of 15% for each level.]]
629 )
630 )
631}
632
633enhance_fortress = {
634 pos = "topright",
635 title = _ "Enhance this fortress",
636 body = rt(h1(_ "Enhancing buildings") .. p(_
637[[I will create an enemy for you soon, but let's make sure you are prepared.
638This fortress is already quite strong and conquers a lot of space. But there is
639an even bigger building: the citadel.]]
640 ) .. p(_
641[[Citadels can not be built directly. Instead, you have to construct a fortress
642first and then enhance it to a citadel. To do so, click on the fortress, then
643choose the enhance to citadel button. Your soldiers will leave the citadel
644while the construction is going on. This means that your fortress has no
645military influence any more. If an enemy builds a military building nearby,
646your construction site could burn down. No sweat, that won't happen here.]]
647 ) .. p(_
648[[Enhance your fortress to a citadel now. Remember that you can speed time up
649by using PAGE_UP, building a citadel takes a while.]]
650 )
651 ),
652 obj_name = "enhance_fortress",
653 obj_title = _"Enhance your fortress to a citadel",
654 obj_body = rt(h1(_ "Enhance your fortress") .. p(_
655[[Enhance your fortress to a mighty citadel. The citadel can house 12 soldiers
656and is the biggest military building the barbarians can build. It also costs a
657lot and takes a long time to build. It is most suited to guard strategically
658important points like constricted points or mountains.]]
659 )
660 )
661}
662
663attack_enemey = {
664 pos = "topright",
665 title = _ "Defeat your enemy",
666 body = rt(h1(_ "Defeat the enemy") .. p(_
667[[I created a sparring partner for you: It is an empire tribe close to your
668citadel. To attack its buildings, click on the door of your target building,
669choose the number of soldiers that you wish to send and click on the attack
670button. Your soldiers will come from all nearby military buildings. Likewise,
671the defenders will come from all nearby military buildings of the enemy and
672intercept your forces.]]
673 ) .. p(_
674[[Attack and conquer all military buildings of the enemy and destroy its
675headquarters.]]
676 )
677 ),
678 obj_name = "defeated_the_empire",
679 obj_title = _ "Defeat the enemy tribe",
680 obj_body = rt(h1(_"Defeat your enemy") .. p(_
681[[Defeat the nearby enemy. To attack a building, click on its doors, choose the
682number of attacking soldiers, then send them via the attack button.]]
362 )683 )
363 )684 )
364}685}
@@ -367,24 +688,24 @@
367 title = _ "Conclusion",688 title = _ "Conclusion",
368 body = rt(h1(_"Conclusion") ..689 body = rt(h1(_"Conclusion") ..
369 p(_690 p(_
370[[This concludes the tutorial. There is some stuff we have not covered: mining,691[[This concludes the tutorial. There is some stuff we have not covered here --
371 training of soldiers, enhancing buildings, warfare, the statistics, the692we have not even built a single producing building even though producing wares
372 mini-map. We have not even build a single producing building even though693is the most important thing in Widelands -- but you've learned the ropes. You
373 producing wares is the most important thing in Widelands. But you can learn694can learn about the remaining stuff while you go through the individual tribe's
374 these while you go through the individual tribe's introduction campaigns. Each695introduction campaigns. Each consists of some scenarios explaining the tribes
375 consists of some scenarios introducing the tribes and their economy while696and their economy while introducing the background story of Widelands. Have fun
376 introducing the background story of Widelands.]]697playing!]]
377 ) .. p(_698 ) .. p(_
378[[You can continue playing this map or you can end this game whenever you like.699[[You can continue playing this map or you can end this game whenever you like.
379 To leave this game and return to the main menu click on the]]700To leave this game and return to the main menu click on the]]
380 )) .. rt("image=pics/menu_options_menu.png", p(_701 )) .. rt("image=pics/menu_options_menu.png", p(_
381[[options menu button on the very left at the bottom of the screen.702[[options menu button on the very left at the bottom of the screen.
382 Then click the]]703Then click the]]
383 )) .. rt("image=pics/menu_exit_game.png", p(_704 )) .. rt("image=pics/menu_exit_game.png", p(_
384[[exit game button.]]705[[exit game button.]]
385 )) .. rt(p(_706 )) .. rt(p(_
386[[Thanks for playing this tutorial. Enjoy Widelands and remember707[[Thanks for playing this tutorial. Enjoy Widelands and remember
387 to visit us at]]708to visit us at]]
388 )) .. rt("text-align=center",709 )) .. rt("text-align=center",
389 "<p font-size=24 font-decoration=underline>http://www.widelands.org</p>"710 "<p font-size=24 font-decoration=underline>http://www.widelands.org</p>"
390 )711 )
391712
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2010-04-18 13:13:49 +0000
+++ src/economy/flag.cc 2010-04-30 14:39:36 +0000
@@ -243,6 +243,17 @@
243}243}
244244
245/**245/**
246 * Return all positions we occupy on the map. For a Flag, this is only one
247*/
248BaseImmovable::PositionList Flag::get_positions
249 (const Editor_Game_Base &) const throw ()
250{
251 PositionList rv;
252 rv.push_back(m_position);
253 return rv;
254}
255
256/**
246 * Return neighbouring flags.257 * Return neighbouring flags.
247*/258*/
248void Flag::get_neighbours(RoutingNodeNeighbours & neighbours)259void Flag::get_neighbours(RoutingNodeNeighbours & neighbours)
249260
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2010-04-18 12:16:52 +0000
+++ src/economy/flag.h 2010-04-30 14:39:36 +0000
@@ -74,6 +74,7 @@
74 virtual Flag & base_flag();74 virtual Flag & base_flag();
7575
76 Coords get_position() const {return m_position;}76 Coords get_position() const {return m_position;}
77 virtual PositionList get_positions (const Editor_Game_Base &) const throw ();
77 void get_neighbours(RoutingNodeNeighbours &);78 void get_neighbours(RoutingNodeNeighbours &);
78 int32_t get_waitcost() const {return m_item_filled;}79 int32_t get_waitcost() const {return m_item_filled;}
7980
8081
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2010-04-05 21:51:37 +0000
+++ src/economy/road.cc 2010-04-30 14:39:36 +0000
@@ -122,6 +122,24 @@
122 return true;122 return true;
123}123}
124124
125BaseImmovable::PositionList Road::get_positions
126 (const Editor_Game_Base & egbase) const throw()
127{
128 Map & map = egbase.map();
129 Coords curf = map.get_fcoords(m_path.get_start());
130
131 PositionList rv;
132 const Path::Step_Vector::size_type nr_steps = m_path.get_nsteps();
133 for (Path::Step_Vector::size_type steps = 0; steps < nr_steps + 1; ++steps)
134 {
135 if (steps > 0 && steps < m_path.get_nsteps())
136 rv.push_back(curf);
137
138 if (steps < m_path.get_nsteps())
139 map.get_neighbour(curf, m_path[steps], &curf);
140 }
141 return rv;
142}
125143
126static std::string const road_name = "road";144static std::string const road_name = "road";
127std::string const & Road::name() const throw () {return road_name;}145std::string const & Road::name() const throw () {return road_name;}
128146
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2010-03-28 09:39:54 +0000
+++ src/economy/road.h 2010-04-30 14:39:36 +0000
@@ -78,6 +78,7 @@
78 char const * type_name() const throw () {return "road";}78 char const * type_name() const throw () {return "road";}
79 virtual int32_t get_size () const throw ();79 virtual int32_t get_size () const throw ();
80 virtual bool get_passable() const throw ();80 virtual bool get_passable() const throw ();
81 virtual PositionList get_positions(const Editor_Game_Base &) const throw ();
81 std::string const & name() const throw ();82 std::string const & name() const throw ();
8283
83 virtual Flag & base_flag();84 virtual Flag & base_flag();
8485
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2010-04-01 10:59:34 +0000
+++ src/logic/building.cc 2010-04-30 14:39:36 +0000
@@ -459,6 +459,32 @@
459}459}
460460
461461
462/**
463 * Return all positions on the map that we occupy
464 */
465BaseImmovable::PositionList Building::get_positions
466 (const Editor_Game_Base & egbase) const throw ()
467{
468 PositionList rv;
469
470 rv.push_back(m_position);
471 if (get_size() == BIG) {
472 Map & map = egbase.map();
473 Coords neighb;
474
475 map.get_ln(m_position, &neighb);
476 rv.push_back(neighb);
477
478 map.get_tln(m_position, &neighb);
479 rv.push_back(neighb);
480
481 map.get_trn(m_position, &neighb);
482 rv.push_back(neighb);
483 }
484 return rv;
485}
486
487
462/*488/*
463===============489===============
464Remove the building from the world now, and create a fire in its place if490Remove the building from the world now, and create a fire in its place if
465491
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2010-04-03 16:44:44 +0000
+++ src/logic/building.h 2010-04-30 14:39:36 +0000
@@ -165,7 +165,9 @@
165165
166 virtual Flag & base_flag();166 virtual Flag & base_flag();
167 virtual uint32_t get_playercaps() const throw ();167 virtual uint32_t get_playercaps() const throw ();
168
168 virtual Coords get_position() const throw () {return m_position;}169 virtual Coords get_position() const throw () {return m_position;}
170 virtual PositionList get_positions (const Editor_Game_Base &) const throw ();
169171
170 std::string const & name() const throw ();172 std::string const & name() const throw ();
171 const std::string & descname() const throw () {return descr().descname();}173 const std::string & descname() const throw () {return descr().descname();}
172174
=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc 2010-04-19 09:39:05 +0000
+++ src/logic/immovable.cc 2010-04-30 14:39:36 +0000
@@ -348,6 +348,15 @@
348 return IMMOVABLE;348 return IMMOVABLE;
349}349}
350350
351BaseImmovable::PositionList Immovable::get_positions
352 (const Editor_Game_Base &) const throw ()
353{
354 PositionList rv;
355
356 rv.push_back(m_position);
357 return rv;
358}
359
351int32_t Immovable::get_size() const throw ()360int32_t Immovable::get_size() const throw ()
352{361{
353 return descr().get_size();362 return descr().get_size();
354363
=== modified file 'src/logic/immovable.h'
--- src/logic/immovable.h 2010-03-28 13:19:24 +0000
+++ src/logic/immovable.h 2010-04-30 14:39:36 +0000
@@ -56,6 +56,15 @@
5656
57 virtual int32_t get_size () const throw () = 0;57 virtual int32_t get_size () const throw () = 0;
58 virtual bool get_passable() const throw () = 0;58 virtual bool get_passable() const throw () = 0;
59
60 typedef std::vector<Coords> PositionList;
61 /**
62 * Return all coordinates occupied by this Immovable. We gurantee that the
63 * list always contains one entry and the first one is the main position
64 * if one can be chosen as main.
65 */
66 virtual PositionList get_positions
67 (const Editor_Game_Base &) const throw () = 0;
59 virtual void draw68 virtual void draw
60 (const Editor_Game_Base &, RenderTarget &, const FCoords, const Point)69 (const Editor_Game_Base &, RenderTarget &, const FCoords, const Point)
61 = 0;70 = 0;
@@ -127,6 +136,7 @@
127 Immovable(const Immovable_Descr &);136 Immovable(const Immovable_Descr &);
128137
129 Coords get_position() const {return m_position;}138 Coords get_position() const {return m_position;}
139 virtual PositionList get_positions (const Editor_Game_Base &) const throw ();
130140
131 virtual int32_t get_type () const throw ();141 virtual int32_t get_type () const throw ();
132 char const * type_name() const throw () {return "immovable";}142 char const * type_name() const throw () {return "immovable";}
133143
=== modified file 'src/logic/legacy.cc'
--- src/logic/legacy.cc 2010-01-14 18:22:23 +0000
+++ src/logic/legacy.cc 2010-04-30 14:39:36 +0000
@@ -352,6 +352,15 @@
352 virtual bool get_passable() const throw () {return true;}352 virtual bool get_passable() const throw () {return true;}
353 virtual void draw (Editor_Game_Base const &, RenderTarget &, FCoords, Point)353 virtual void draw (Editor_Game_Base const &, RenderTarget &, FCoords, Point)
354 {}354 {}
355 virtual PositionList get_positions (const Editor_Game_Base &) const throw ()
356 {
357 // This violates what I had in mind for get_positions, but since this is
358 // attic code and get_positions was added long after this code was gone
359 // I guess it is save to return an empty list here.
360 PositionList rv;
361 return rv;
362 }
363
355364
356 struct Loader : public BaseImmovable::Loader {365 struct Loader : public BaseImmovable::Loader {
357 virtual void load(FileRead & fr, uint8_t const version) {366 virtual void load(FileRead & fr, uint8_t const version) {
@@ -425,6 +434,14 @@
425 virtual bool get_passable() const throw () {return true;}434 virtual bool get_passable() const throw () {return true;}
426 virtual void draw (Editor_Game_Base const &, RenderTarget &, FCoords, Point)435 virtual void draw (Editor_Game_Base const &, RenderTarget &, FCoords, Point)
427 {}436 {}
437 virtual PositionList get_positions (const Editor_Game_Base &) const throw ()
438 {
439 // This violates what I had in mind for get_positions, but since this is
440 // attic code and get_positions was added long after this code was gone
441 // I guess it is save to return an empty list here.
442 PositionList rv;
443 return rv;
444 }
428445
429 struct Loader : public BaseImmovable::Loader {446 struct Loader : public BaseImmovable::Loader {
430 virtual void load(FileRead & fr, uint8_t const version) {447 virtual void load(FileRead & fr, uint8_t const version) {
431448
=== modified file 'src/save_handler.cc'
--- src/save_handler.cc 2009-09-06 11:57:37 +0000
+++ src/save_handler.cc 2010-04-30 14:39:36 +0000
@@ -36,6 +36,9 @@
36void SaveHandler::think(Widelands::Game & game, int32_t realtime) {36void SaveHandler::think(Widelands::Game & game, int32_t realtime) {
37 initialize(realtime);37 initialize(realtime);
3838
39 if (not m_allow_autosaving) // Is autosaving allowed atm?
40 return;
41
39 int32_t const autosaveInterval =42 int32_t const autosaveInterval =
40 g_options.pull_section("global").get_int43 g_options.pull_section("global").get_int
41 ("autosave", DEFAULT_AUTOSAVE_INTERVAL * 60);44 ("autosave", DEFAULT_AUTOSAVE_INTERVAL * 60);
4245
=== modified file 'src/save_handler.h'
--- src/save_handler.h 2009-09-30 17:38:02 +0000
+++ src/save_handler.h 2010-04-30 14:39:36 +0000
@@ -33,11 +33,13 @@
33class SaveHandler {33class SaveHandler {
34 int32_t m_lastSaveTime;34 int32_t m_lastSaveTime;
35 bool m_initialized;35 bool m_initialized;
36 bool m_allow_autosaving;
3637
37 void initialize(int32_t currenttime);38 void initialize(int32_t currenttime);
3839
40
39public:41public:
40 SaveHandler() : m_initialized(false) {}42 SaveHandler() : m_initialized(false), m_allow_autosaving(true) {}
41 void think(Widelands::Game &, int32_t currenttime);43 void think(Widelands::Game &, int32_t currenttime);
42 std::string create_file_name(std::string dir, std::string filename);44 std::string create_file_name(std::string dir, std::string filename);
43 bool save_game45 bool save_game
@@ -46,6 +48,8 @@
46 std::string * error = 0);48 std::string * error = 0);
4749
48 static std::string get_base_dir() {return "save";}50 static std::string get_base_dir() {return "save";}
51 void set_allow_autosaving(bool t) {m_allow_autosaving = t;}
52 bool get_allow_autosaving() {return m_allow_autosaving;}
49};53};
5054
51#endif55#endif
5256
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2010-04-25 18:47:42 +0000
+++ src/scripting/lua_game.cc 2010-04-30 14:39:36 +0000
@@ -571,11 +571,14 @@
571 }571 }
572#undef CHECK_ARG572#undef CHECK_ARG
573573
574 std::string title = luaL_checkstring(L, 2);
575 std::string body = luaL_checkstring(L, 3);
576
574 uint32_t cspeed = game.gameController()->desiredSpeed();577 uint32_t cspeed = game.gameController()->desiredSpeed();
575 game.gameController()->setDesiredSpeed(0);578 game.gameController()->setDesiredSpeed(0);
576579
577 std::string title = luaL_checkstring(L, 2);580 game.save_handler().set_allow_autosaving(false);
578 std::string body = luaL_checkstring(L, 3);581
579 Story_Message_Box * mb =582 Story_Message_Box * mb =
580 new Story_Message_Box583 new Story_Message_Box
581 (game.get_ipl(), luaL_checkstring(L, 2), luaL_checkstring(L, 3),584 (game.get_ipl(), luaL_checkstring(L, 2), luaL_checkstring(L, 3),
@@ -586,9 +589,12 @@
586589
587 // Manually force the game to reevaluate it's current state,590 // Manually force the game to reevaluate it's current state,
588 // especially time information.591 // especially time information.
589 game.think();592 game.gameController()->think();
590593
591 game.gameController()->setDesiredSpeed(cspeed);594 game.gameController()->setDesiredSpeed(cspeed);
595
596 game.save_handler().set_allow_autosaving(true);
597
592 return 1;598 return 1;
593}599}
594600
@@ -1581,11 +1587,11 @@
1581}1587}
15821588
1583/* RST1589/* RST
1584 .. function:: get_speed(speed)1590.. function:: get_speed(speed)
15851591
1586 Gets the current game speed1592 Gets the current game speed
15871593
1588 :returns: :const:`nil`1594 :returns: :const:`nil`
1589*/1595*/
1590// UNTESTED1596// UNTESTED
1591static int L_get_speed(lua_State * L) {1597static int L_get_speed(lua_State * L) {
@@ -1593,11 +1599,43 @@
1593 return 1;1599 return 1;
1594}1600}
15951601
1602/* RST
1603 .. function:: set_allow_autosaving(b)
1604
1605 Disable or enable auto-saving. When you show off UI features in a
1606 tutorial or scenario, you have to disallow auto-saving because UI
1607 elements can now be saved.
1608
1609 :arg b: allow autosaving or disallow it
1610 :type b: :class:`boolean`
1611*/
1612// UNTESTED
1613static int L_set_allow_autosaving(lua_State * L) {
1614 get_game(L).save_handler().set_allow_autosaving
1615 (luaL_checkboolean(L, -1));
1616 return 0;
1617}
1618
1619/* RST
1620 .. function:: get_allow_autosaving
1621
1622 Returns the current state of autosaving.
1623
1624 :returns: :class:`boolean`
1625*/
1626// UNTESTED
1627static int L_get_allow_autosaving(lua_State * L) {
1628 lua_pushboolean(L, get_game(L).save_handler().get_allow_autosaving());
1629 return 1;
1630}
1631
1596const static struct luaL_reg wlgame [] = {1632const static struct luaL_reg wlgame [] = {
1597 {"run_coroutine", &L_run_coroutine},1633 {"run_coroutine", &L_run_coroutine},
1598 {"get_time", &L_get_time},1634 {"get_time", &L_get_time},
1599 {"get_speed", &L_get_speed},1635 {"get_speed", &L_get_speed},
1600 {"set_speed", &L_set_speed},1636 {"set_speed", &L_set_speed},
1637 {"set_allow_autosaving", &L_set_allow_autosaving},
1638 {"get_allow_autosaving", &L_get_allow_autosaving},
1601 {0, 0}1639 {0, 0}
1602};1640};
16031641
16041642
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2010-04-25 12:56:53 +0000
+++ src/scripting/lua_map.cc 2010-04-30 14:39:36 +0000
@@ -74,12 +74,14 @@
74 case Map_Object::BUILDING:74 case Map_Object::BUILDING:
75 {75 {
76 const char * type_name = bi->type_name();76 const char * type_name = bi->type_name();
77 if (!strcmp(type_name, "warehouse"))77 if (!strcmp(type_name, "constructionsite"))
78 return CAST_TO_LUA(Warehouse);78 return CAST_TO_LUA(ConstructionSite);
79 else if (!strcmp(type_name, "productionsite"))79 else if (!strcmp(type_name, "productionsite"))
80 return CAST_TO_LUA(ProductionSite);80 return CAST_TO_LUA(ProductionSite);
81 else if (!strcmp(type_name, "militarysite"))81 else if (!strcmp(type_name, "militarysite"))
82 return CAST_TO_LUA(MilitarySite);82 return CAST_TO_LUA(MilitarySite);
83 else if (!strcmp(type_name, "warehouse"))
84 return CAST_TO_LUA(Warehouse);
83 else if (!strcmp(type_name, "trainingsite"))85 else if (!strcmp(type_name, "trainingsite"))
84 return CAST_TO_LUA(TrainingSite);86 return CAST_TO_LUA(TrainingSite);
85 else87 else
@@ -914,6 +916,7 @@
914const PropertyType<L_BaseImmovable> L_BaseImmovable::Properties[] = {916const PropertyType<L_BaseImmovable> L_BaseImmovable::Properties[] = {
915 PROP_RO(L_BaseImmovable, size),917 PROP_RO(L_BaseImmovable, size),
916 PROP_RO(L_BaseImmovable, name),918 PROP_RO(L_BaseImmovable, name),
919 PROP_RO(L_BaseImmovable, fields),
917 {0, 0, 0},920 {0, 0, 0},
918};921};
919922
@@ -964,6 +967,28 @@
964 return 1;967 return 1;
965}968}
966969
970/* RST
971 .. attribute:: fields
972
973 (RO) An :class:`array` of :class:`~wl.map.Field` that is occupied by this
974 Immovable. If the immovable occupies more than one field (roads or big
975 buildings for example) the first entry in this list will be the main field
976*/
977int L_BaseImmovable::get_fields(lua_State * L) {
978 Editor_Game_Base & egbase = get_egbase(L);
979
980 BaseImmovable::PositionList pl = get(L, egbase)->get_positions(egbase);
981
982 lua_createtable(L, pl.size(), 0);
983 uint32_t idx = 1;
984 container_iterate_const(BaseImmovable::PositionList, pl, f) {
985 lua_pushuint32(L, idx++);
986 to_lua<L_Field>(L, new L_Field(f->x, f->y));
987 lua_rawset(L, -3);
988 }
989 return 1;
990}
991
967/*992/*
968 ==========================================================993 ==========================================================
969 LUA METHODS994 LUA METHODS
@@ -1352,6 +1377,55 @@
1352 ==========================================================1377 ==========================================================
1353 */1378 */
13541379
1380/* RST
1381ConstructionSite
1382-----------------
1383
1384.. class:: ConstructionSite
1385
1386 Child of: :class:`Building`
1387
1388 A ConstructionSite as it appears in Game. This is only a minimal wrapping at
1389 the moment
1390*/
1391const char L_ConstructionSite::className[] = "ConstructionSite";
1392const MethodType<L_ConstructionSite> L_ConstructionSite::Methods[] = {
1393 {0, 0},
1394};
1395const PropertyType<L_ConstructionSite> L_ConstructionSite::Properties[] = {
1396 PROP_RO(L_ConstructionSite, building),
1397 {0, 0, 0},
1398};
1399
1400/*
1401 ==========================================================
1402 PROPERTIES
1403 ==========================================================
1404 */
1405/* RST
1406 .. attribute:: building
1407
1408 (RO) The name of the building that is constructed here
1409*/
1410int L_ConstructionSite::get_building(lua_State * L) {
1411 lua_pushstring(L, get(L, get_game(L))->building().name());
1412 return 1;
1413}
1414
1415/*
1416 ==========================================================
1417 LUA METHODS
1418 ==========================================================
1419 */
1420
1421/*
1422 ==========================================================
1423 C METHODS
1424 ==========================================================
1425 */
1426
1427
1428
13551429
1356/* RST1430/* RST
1357Warehouse1431Warehouse
@@ -2255,6 +2329,13 @@
2255 add_parent<L_Road, L_MapObject>(L);2329 add_parent<L_Road, L_MapObject>(L);
2256 lua_pop(L, 1); // Pop the meta table2330 lua_pop(L, 1); // Pop the meta table
22572331
2332 register_class<L_ConstructionSite>(L, "map", true);
2333 add_parent<L_ConstructionSite, L_Building>(L);
2334 add_parent<L_ConstructionSite, L_PlayerImmovable>(L);
2335 add_parent<L_ConstructionSite, L_BaseImmovable>(L);
2336 add_parent<L_ConstructionSite, L_MapObject>(L);
2337 lua_pop(L, 1); // Pop the meta table
2338
2258 register_class<L_Warehouse>(L, "map", true);2339 register_class<L_Warehouse>(L, "map", true);
2259 add_parent<L_Warehouse, L_Building>(L);2340 add_parent<L_Warehouse, L_Building>(L);
2260 add_parent<L_Warehouse, L_PlayerImmovable>(L);2341 add_parent<L_Warehouse, L_PlayerImmovable>(L);
22612342
=== modified file 'src/scripting/lua_map.h'
--- src/scripting/lua_map.h 2010-04-08 13:22:53 +0000
+++ src/scripting/lua_map.h 2010-04-30 14:39:36 +0000
@@ -26,11 +26,12 @@
2626
27#include "economy/flag.h"27#include "economy/flag.h"
28#include "economy/road.h"28#include "economy/road.h"
29#include "logic/constructionsite.h"
29#include "logic/game.h"30#include "logic/game.h"
30#include "logic/warehouse.h"31#include "logic/militarysite.h"
31#include "logic/productionsite.h"32#include "logic/productionsite.h"
32#include "logic/militarysite.h"
33#include "logic/trainingsite.h"33#include "logic/trainingsite.h"
34#include "logic/warehouse.h"
3435
35#include "luna.h"36#include "luna.h"
3637
@@ -120,6 +121,7 @@
120 */121 */
121 int get_size(lua_State * L);122 int get_size(lua_State * L);
122 int get_name(lua_State * L);123 int get_name(lua_State * L);
124 int get_fields(lua_State * L);
123125
124 /*126 /*
125 * Lua Methods127 * Lua Methods
@@ -348,6 +350,33 @@
348};350};
349351
350352
353class L_ConstructionSite : public L_Building
354{
355public:
356 LUNA_CLASS_HEAD(L_ConstructionSite);
357
358 L_ConstructionSite() {}
359 L_ConstructionSite(Widelands::ConstructionSite & mo) : L_Building(mo) {
360 }
361 L_ConstructionSite(lua_State * L) : L_Building(L) {}
362 virtual ~L_ConstructionSite() {}
363
364 /*
365 * Properties
366 */
367 int get_building(lua_State *);
368
369 /*
370 * Lua Methods
371 */
372
373 /*
374 * C Methods
375 */
376 CASTED_GET(ConstructionSite);
377};
378
379
351class L_Warehouse : public L_Building,380class L_Warehouse : public L_Building,
352 public L_HasWares, public L_HasWorkers, public L_HasSoldiers381 public L_HasWares, public L_HasWorkers, public L_HasSoldiers
353{382{
354383
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2010-04-26 15:18:43 +0000
+++ src/scripting/lua_ui.cc 2010-04-30 14:39:36 +0000
@@ -503,6 +503,8 @@
503 PROP_RW(L_MapView, viewpoint_x),503 PROP_RW(L_MapView, viewpoint_x),
504 PROP_RW(L_MapView, viewpoint_y),504 PROP_RW(L_MapView, viewpoint_y),
505 PROP_RW(L_MapView, buildhelp),505 PROP_RW(L_MapView, buildhelp),
506 PROP_RW(L_MapView, census),
507 PROP_RW(L_MapView, statistics),
506 {0, 0, 0},508 {0, 0, 0},
507};509};
508510
@@ -559,6 +561,37 @@
559 return 0;561 return 0;
560}562}
561563
564/* RST
565 .. attribute:: census
566
567 (RW) True if the census strings are shown on buildings, false otherwise
568*/
569int L_MapView::get_census(lua_State * L) {
570 lua_pushboolean(L, get()->get_display_flag(Interactive_Base::dfShowCensus));
571 return 1;
572}
573int L_MapView::set_census(lua_State * L) {
574 get()->set_display_flag
575 (Interactive_Base::dfShowCensus, luaL_checkboolean(L, -1));
576 return 0;
577}
578
579/* RST
580 .. attribute:: statistics
581
582 (RW) True if the statistics strings are shown on buildings, false
583 otherwise
584*/
585int L_MapView::get_statistics(lua_State * L) {
586 lua_pushboolean(L, get()->get_display_flag
587 (Interactive_Base::dfShowStatistics));
588 return 1;
589}
590int L_MapView::set_statistics(lua_State * L) {
591 get()->set_display_flag
592 (Interactive_Base::dfShowStatistics, luaL_checkboolean(L, -1));
593 return 0;
594}
562595
563/*596/*
564 * Lua Functions597 * Lua Functions
@@ -589,7 +622,37 @@
589 * ========================================================================622 * ========================================================================
590 */623 */
591624
625/* RST
626.. function:: set_user_input_allowed(b)
627
628 Allow or disallow user input. Be warned, setting this will make that
629 mouse movements and keyboard presses are completely ignored. Only
630 scripted stuff will still happen.
631
632 :arg b: :const:`true` or :const:`false`
633 :type b: :class:`boolean`
634*/
635static int L_set_user_input_allowed(lua_State * L) {
636 UI::Panel::set_allow_user_input(luaL_checkboolean(L, -1));
637 return 0;
638}
639/* RST
640.. method:: get_user_input_allowed
641
642 Return the current state of this flag.
643
644 :returns: :const:`true` or :const:`false`
645 :rtype: :class:`boolean`
646*/
647static int L_get_user_input_allowed(lua_State * L) {
648 lua_pushboolean(L, UI::Panel::allow_user_input());
649 return 1;
650}
651
652
592const static struct luaL_reg wlui [] = {653const static struct luaL_reg wlui [] = {
654 {"set_user_input_allowed", &L_set_user_input_allowed},
655 {"get_user_input_allowed", &L_get_user_input_allowed},
593 {0, 0}656 {0, 0}
594};657};
595658
596659
=== modified file 'src/scripting/lua_ui.h'
--- src/scripting/lua_ui.h 2010-04-26 15:18:43 +0000
+++ src/scripting/lua_ui.h 2010-04-30 14:39:36 +0000
@@ -188,6 +188,10 @@
188 int set_viewpoint_y(lua_State *);188 int set_viewpoint_y(lua_State *);
189 int get_buildhelp(lua_State * L);189 int get_buildhelp(lua_State * L);
190 int set_buildhelp(lua_State * L);190 int set_buildhelp(lua_State * L);
191 int get_census(lua_State * L);
192 int set_census(lua_State * L);
193 int get_statistics(lua_State * L);
194 int set_statistics(lua_State * L);
191195
192 /*196 /*
193 * Lua Methods197 * Lua Methods
194198
=== modified file 'src/scripting/scripting.cc'
--- src/scripting/scripting.cc 2010-04-25 18:47:42 +0000
+++ src/scripting/scripting.cc 2010-04-30 14:39:36 +0000
@@ -40,6 +40,11 @@
40#endif40#endif
4141
42// TODO: add wl.editor to documentation42// TODO: add wl.editor to documentation
43// TODO: position or field should be on the immovable classes.
44// Check out what this BaseImmovable <-> Immovable thing is all about.
45// TODO: road must offer some access to it's fields for this to work.
46// TODO: also big buildings occupy more space: i suggest some occupied fields property
47// TODO: and also a field property
4348
44/*49/*
45============================================50============================================
4651
=== modified file 'src/scripting/test/ts.wmf/scripting/test_baseimmovables.lua'
--- src/scripting/test/ts.wmf/scripting/test_baseimmovables.lua 2010-04-08 14:04:31 +0000
+++ src/scripting/test/ts.wmf/scripting/test_baseimmovables.lua 2010-04-30 14:39:36 +0000
@@ -94,6 +94,8 @@
94-- -- ==============94-- -- ==============
95-- -- Property tests95-- -- Property tests
96-- -- ==============96-- -- ==============
97-- TODO: add tests for immovable.fields
98-- TODO: add also tests for big buildings
97immovable_property_tests = lunit.TestCase("Immovable sizes")99immovable_property_tests = lunit.TestCase("Immovable sizes")
98function immovable_property_tests:setup()100function immovable_property_tests:setup()
99 self.none = wl.map.create_immovable("pebble1", wl.map.Field(19, 10))101 self.none = wl.map.create_immovable("pebble1", wl.map.Field(19, 10))
100102
=== added file 'src/scripting/test/ts.wmf/scripting/test_constructionsite.lua'
--- src/scripting/test/ts.wmf/scripting/test_constructionsite.lua 1970-01-01 00:00:00 +0000
+++ src/scripting/test/ts.wmf/scripting/test_constructionsite.lua 2010-04-30 14:39:36 +0000
@@ -0,0 +1,46 @@
1-- =========================
2-- Constructionsite Functionality
3-- =========================
4constructionsite_tests = lunit.TestCase("constructionsite tests")
5function constructionsite_tests:setup()
6 self.f1 = wl.map.Field(8,10)
7 self.f2 = wl.map.Field(12,10)
8 self.p = wl.game.Player(1)
9
10 self.p:place_building("lumberjacks_hut", self.f1, true)
11 self.p:place_building("fortress", self.f2, true)
12
13 self.l = self.f1.immovable
14 self.f = self.f2.immovable
15end
16
17function constructionsite_tests:test_upcasting_from_immovable_to_building()
18 local i = self.f1.immovable
19 assert_equal(i, self.l)
20 assert_not_equal(nil, i.building)
21end
22
23function constructionsite_tests:teardown()
24 pcall(function() self.f1.brn.immovable:remove() end)
25 pcall(function() self.f2.brn.immovable:remove() end)
26end
27
28function constructionsite_tests:test_name()
29 assert_equal("constructionsite", self.l.name)
30 assert_equal("constructionsite", self.f.name)
31end
32function constructionsite_tests:test_type()
33 assert_equal("constructionsite", self.l.type)
34 assert_equal("constructionsite", self.f.type)
35end
36
37function constructionsite_tests:test_size()
38 assert_equal("small", self.l.size)
39 assert_equal("big", self.f.size)
40end
41
42function constructionsite_tests:test_building()
43 assert_equal("lumberjacks_hut", self.l.building)
44 assert_equal("fortress", self.f.building)
45end
46
047
=== modified file 'src/scripting/test/ts.wmf/scripting/test_flag.lua'
--- src/scripting/test/ts.wmf/scripting/test_flag.lua 2010-03-24 12:08:42 +0000
+++ src/scripting/test/ts.wmf/scripting/test_flag.lua 2010-04-30 14:39:36 +0000
@@ -9,7 +9,8 @@
9flag_tests = lunit.TestCase("flag tests")9flag_tests = lunit.TestCase("flag tests")
10function flag_tests:setup()10function flag_tests:setup()
11 self.p = wl.game.Player(1)11 self.p = wl.game.Player(1)
12 self.f = self.p:place_flag(wl.map.Field(13,10), 1)12 self.field = wl.map.Field(13,10)
13 self.f = self.p:place_flag(self.field, 1)
13end14end
14function flag_tests:teardown()15function flag_tests:teardown()
15 pcall(self.f.remove, self.f)16 pcall(self.f.remove, self.f)
@@ -21,6 +22,11 @@
21function flag_tests:test_type()22function flag_tests:test_type()
22 assert_equal("flag", self.f.type)23 assert_equal("flag", self.f.type)
23end24end
25function flag_tests:test_fields()
26 local f = self.f.fields
27 assert_equal(1, #f)
28 assert_equal(self.field, f[1])
29end
24function flag_tests:test_no_wares_on_creation()30function flag_tests:test_no_wares_on_creation()
25 local rv = self.f:get_wares("all")31 local rv = self.f:get_wares("all")
26 cnt = 032 cnt = 0
2733
=== modified file 'src/scripting/test/ts.wmf/scripting/test_immovables.lua'
--- src/scripting/test/ts.wmf/scripting/test_immovables.lua 2010-04-08 14:04:31 +0000
+++ src/scripting/test/ts.wmf/scripting/test_immovables.lua 2010-04-30 14:39:36 +0000
@@ -9,6 +9,7 @@
9 include "test_road"9 include "test_road"
1010
11 -- Buildings11 -- Buildings
12 include "test_constructionsite"
12 include "test_warehouse"13 include "test_warehouse"
13 include "test_productionsite"14 include "test_productionsite"
14 include "test_militarysite"15 include "test_militarysite"
1516
=== modified file 'src/scripting/test/ts.wmf/scripting/test_road.lua'
--- src/scripting/test/ts.wmf/scripting/test_road.lua 2010-03-24 12:08:42 +0000
+++ src/scripting/test/ts.wmf/scripting/test_road.lua 2010-04-30 14:39:36 +0000
@@ -76,8 +76,8 @@
7676
77 self.start_flag = self.p:place_flag(self.f)77 self.start_flag = self.p:place_flag(self.f)
7878
79 self.r = self.p:place_road(self.start_flag, "r", "r")79 self.r = self.p:place_road(self.start_flag, "r", "r", "br", "br")
80 self.end_flag = self.f.rn.rn.immovable80 self.end_flag = self.f.rn.rn.brn.brn.immovable
81end81end
82function road_tests:teardown()82function road_tests:teardown()
83 flags = {self.start_flag, self.end_flag}83 flags = {self.start_flag, self.end_flag}
@@ -87,7 +87,14 @@
87end87end
8888
89function road_tests:test_length()89function road_tests:test_length()
90 assert_equal(2, self.r.length)90 assert_equal(4, self.r.length)
91end
92function road_tests:test_field()
93 local f = self.r.fields
94 assert_equal(#f, 3)
95 assert_equal(self.f.rn, f[1])
96 assert_equal(self.f.rn.rn, f[2])
97 assert_equal(self.f.rn.rn.brn, f[3])
91end98end
92function road_tests:test_roadtype()99function road_tests:test_roadtype()
93 assert_equal("normal", self.r.road_type)100 assert_equal("normal", self.r.road_type)
@@ -110,7 +117,7 @@
110function road_tests:test_road_upcasting()117function road_tests:test_road_upcasting()
111 i = self.f.rn.immovable118 i = self.f.rn.immovable
112 assert_equal(i, self.r)119 assert_equal(i, self.r)
113 assert_equal(2, i.length)120 assert_equal(4, i.length)
114end121end
115122
116-- ====================123-- ====================
117124
=== modified file 'src/scripting/test/ts.wmf/scripting/test_ui.lua'
--- src/scripting/test/ts.wmf/scripting/test_ui.lua 2010-04-26 15:18:43 +0000
+++ src/scripting/test/ts.wmf/scripting/test_ui.lua 2010-04-30 14:39:36 +0000
@@ -161,6 +161,8 @@
161mv_tests = lunit.TestCase("MapView tests")161mv_tests = lunit.TestCase("MapView tests")
162function mv_tests:setup()162function mv_tests:setup()
163 self.mv = wl.ui.MapView()163 self.mv = wl.ui.MapView()
164 self.mv.census = false
165 self.mv.buildhelp = false
164 for n,w in pairs(self.mv.windows) do w:close() end166 for n,w in pairs(self.mv.windows) do w:close() end
165end167end
166168
@@ -169,4 +171,18 @@
169 assert_not_equal(nil, self.mv.windows.field_action)171 assert_not_equal(nil, self.mv.windows.field_action)
170end172end
171173
174function mv_tests:test_census()
175 self.mv.census = 1
176 assert_equal(true, self.mv.census)
177 assert_equal(false, self.mv.statistics)
178end
179
180function mv_tests:test_statistics()
181 self.mv.statistics = 1
182 assert_equal(true, self.mv.statistics)
183 assert_equal(false, self.mv.census)
184end
185
186
187
172188
173189
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2010-04-20 20:50:37 +0000
+++ src/ui_basic/panel.cc 2010-04-30 14:39:36 +0000
@@ -31,6 +31,11 @@
31Panel * Panel::_modal = 0;31Panel * Panel::_modal = 0;
32Panel * Panel::_g_mousegrab = 0;32Panel * Panel::_g_mousegrab = 0;
33Panel * Panel::_g_mousein = 0;33Panel * Panel::_g_mousein = 0;
34
35// The following variable can be set to false. If so, all mouse and keyboard
36// events are ignored and not passed on to any widget. This is only useful
37// for scripts that want to show off functionality without the user interfering.
38bool Panel::_g_allow_user_input = true;
34PictureID Panel::s_default_cursor = g_gr->get_no_picture();39PictureID Panel::s_default_cursor = g_gr->get_no_picture();
3540
3641
@@ -824,6 +829,9 @@
824 */829 */
825void Panel::do_mousein(bool const inside)830void Panel::do_mousein(bool const inside)
826{831{
832 if (not _g_allow_user_input)
833 return;
834
827 if (!inside && _mousein) {835 if (!inside && _mousein) {
828 _mousein->do_mousein(false);836 _mousein->do_mousein(false);
829 _mousein = false;837 _mousein = false;
@@ -837,6 +845,9 @@
837 * Returns whether the event was processed.845 * Returns whether the event was processed.
838 */846 */
839bool Panel::do_mousepress(const Uint8 btn, int32_t x, int32_t y) {847bool Panel::do_mousepress(const Uint8 btn, int32_t x, int32_t y) {
848 if (not _g_allow_user_input)
849 return true;
850
840 x -= _lborder;851 x -= _lborder;
841 y -= _tborder;852 y -= _tborder;
842 if (_flags & pf_top_on_click)853 if (_flags & pf_top_on_click)
@@ -851,6 +862,9 @@
851 return handle_mousepress(btn, x, y);862 return handle_mousepress(btn, x, y);
852}863}
853bool Panel::do_mouserelease(const Uint8 btn, int32_t x, int32_t y) {864bool Panel::do_mouserelease(const Uint8 btn, int32_t x, int32_t y) {
865 if (not _g_allow_user_input)
866 return true;
867
854 x -= _lborder;868 x -= _lborder;
855 y -= _tborder;869 y -= _tborder;
856 if (_g_mousegrab != this)870 if (_g_mousegrab != this)
@@ -866,6 +880,9 @@
866 (Uint8 const state,880 (Uint8 const state,
867 int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff)881 int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff)
868{882{
883 if (not _g_allow_user_input)
884 return true;
885
869 x -= _lborder;886 x -= _lborder;
870 y -= _tborder;887 y -= _tborder;
871 if (_g_mousegrab != this)888 if (_g_mousegrab != this)
@@ -886,6 +903,9 @@
886 */903 */
887bool Panel::do_key(bool const down, SDL_keysym const code)904bool Panel::do_key(bool const down, SDL_keysym const code)
888{905{
906 if (not _g_allow_user_input)
907 return true;
908
889 if (_focus) {909 if (_focus) {
890 if (_focus->do_key(down, code))910 if (_focus->do_key(down, code))
891 return true;911 return true;
@@ -950,10 +970,16 @@
950 * panel.970 * panel.
951*/971*/
952void Panel::ui_mousepress(const Uint8 button, int32_t x, int32_t y) {972void Panel::ui_mousepress(const Uint8 button, int32_t x, int32_t y) {
973 if (not _g_allow_user_input)
974 return;
975
953 if (Panel * const p = ui_trackmouse(x, y))976 if (Panel * const p = ui_trackmouse(x, y))
954 p->do_mousepress(button, x, y);977 p->do_mousepress(button, x, y);
955}978}
956void Panel::ui_mouserelease(const Uint8 button, int32_t x, int32_t y) {979void Panel::ui_mouserelease(const Uint8 button, int32_t x, int32_t y) {
980 if (not _g_allow_user_input)
981 return;
982
957 if (Panel * const p = ui_trackmouse(x, y))983 if (Panel * const p = ui_trackmouse(x, y))
958 p->do_mouserelease(button, x, y);984 p->do_mouserelease(button, x, y);
959}985}
@@ -966,6 +992,9 @@
966 (Uint8 const state,992 (Uint8 const state,
967 int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff)993 int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff)
968{994{
995 if (not _g_allow_user_input)
996 return;
997
969 if (!xdiff && !ydiff)998 if (!xdiff && !ydiff)
970 return;999 return;
9711000
@@ -988,6 +1017,9 @@
988 */1017 */
989void Panel::ui_key(bool const down, SDL_keysym const code)1018void Panel::ui_key(bool const down, SDL_keysym const code)
990{1019{
1020 if (not _g_allow_user_input)
1021 return;
1022
991 _modal->do_key(down, code);1023 _modal->do_key(down, code);
992}1024}
9931025
9941026
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2010-04-26 15:06:30 +0000
+++ src/ui_basic/panel.h 2010-04-30 14:39:36 +0000
@@ -208,6 +208,8 @@
208 void set_snapparent(bool snapparent);208 void set_snapparent(bool snapparent);
209 bool get_snapparent() const {return _flags & pf_snap_parent_size;}209 bool get_snapparent() const {return _flags & pf_snap_parent_size;}
210210
211 inline static void set_allow_user_input(bool t) {_g_allow_user_input=t;}
212 inline static bool allow_user_input(void) {return _g_allow_user_input;}
211213
212protected:214protected:
213 void die();215 void die();
@@ -230,6 +232,7 @@
230 (const Uint8 state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);232 (const Uint8 state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
231 bool do_key(bool down, SDL_keysym code);233 bool do_key(bool down, SDL_keysym code);
232234
235
233 Panel * _parent;236 Panel * _parent;
234 Panel * _next, * _prev;237 Panel * _next, * _prev;
235 Panel * _fchild, * _lchild; // first, last child238 Panel * _fchild, * _lchild; // first, last child
@@ -269,6 +272,7 @@
269 static Panel * _modal;272 static Panel * _modal;
270 static Panel * _g_mousegrab;273 static Panel * _g_mousegrab;
271 static Panel * _g_mousein;274 static Panel * _g_mousein;
275 static bool _g_allow_user_input;
272 static PictureID s_default_cursor;276 static PictureID s_default_cursor;
273};277};
274278
275279
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2010-04-24 13:39:38 +0000
+++ src/wlapplication.cc 2010-04-30 14:39:36 +0000
@@ -622,8 +622,6 @@
622 break;622 break;
623623
624 case SDL_MOUSEMOTION:624 case SDL_MOUSEMOTION:
625 // All the interesting stuff is now in Sys_PollEvent()
626
627 m_mouse_position = Point(ev.motion.x, ev.motion.y);625 m_mouse_position = Point(ev.motion.x, ev.motion.y);
628626
629 if ((ev.motion.xrel or ev.motion.yrel) and cb and cb->mouse_move)627 if ((ev.motion.xrel or ev.motion.yrel) and cb and cb->mouse_move)
630628
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2010-04-25 18:47:42 +0000
+++ src/wui/interactive_base.cc 2010-04-30 14:39:36 +0000
@@ -301,7 +301,7 @@
301 // If one of the arrow keys is pressed, scroll here301 // If one of the arrow keys is pressed, scroll here
302 const uint32_t scrollval = 10;302 const uint32_t scrollval = 10;
303303
304 if (keyboard_free()) {304 if (keyboard_free() && Panel::allow_user_input()) {
305 if (get_key_state(SDLK_UP))305 if (get_key_state(SDLK_UP))
306 set_rel_viewpoint(Point(0, -scrollval));306 set_rel_viewpoint(Point(0, -scrollval));
307 if (get_key_state(SDLK_DOWN))307 if (get_key_state(SDLK_DOWN))
@@ -590,7 +590,10 @@
590 // Build the path as requested590 // Build the path as requested
591 ref_cast<Game, Editor_Game_Base>(egbase()).send_player_build_road591 ref_cast<Game, Editor_Game_Base>(egbase()).send_player_build_road
592 (m_road_build_player, *new Widelands::Path(*m_buildroad));592 (m_road_build_player, *new Widelands::Path(*m_buildroad));
593 if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {593 if
594 (allow_user_input() and
595 (get_key_state(SDLK_LCTRL) or get_key_state(SDLK_RCTRL)))
596 {
594 // place flags597 // place flags
595 Map const & map = egbase().map();598 Map const & map = egbase().map();
596 std::vector<Coords> const & c_vector =599 std::vector<Coords> const & c_vector =

Subscribers

People subscribed via source and target branches

to status/vote changes: