Merge lp:~widelands-dev/widelands/bug-1426465-scenario-timings into lp:widelands

Proposed by GunChleoc on 2016-11-17
Status: Merged
Merged at revision: 8213
Proposed branch: lp:~widelands-dev/widelands/bug-1426465-scenario-timings
Merge into: lp:widelands
Diff against target: 1086 lines (+193/-170)
13 files modified
data/campaigns/atl01.wmf/scripting/mission_thread.lua (+43/-30)
data/campaigns/bar01.wmf/scripting/mission_thread.lua (+30/-34)
data/campaigns/bar01.wmf/scripting/starting_conditions.lua (+1/-1)
data/campaigns/bar01.wmf/scripting/texts.lua (+12/-8)
data/campaigns/bar02.wmf/scripting/mission_thread.lua (+13/-13)
data/campaigns/emp01.wmf/scripting/mission_thread.lua (+5/-5)
data/campaigns/emp02.wmf/scripting/mission_thread.lua (+8/-8)
data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua (+14/-26)
data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua (+22/-16)
data/campaigns/tutorial02_warfare.wmf/scripting/texts.lua (+4/-1)
data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua (+5/-5)
data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua (+17/-23)
data/scripting/messages.lua (+19/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1426465-scenario-timings
Reviewer Review Type Date Requested Status
TiborB 2016-11-17 Approve on 2016-12-09
Review via email: mp+311119@code.launchpad.net

Commit message

Tweaked timings in tutorials and scenarios:

- New function set_objective_done that adds a configurable sleep time
  when marking an objective as done
- Barbarian scenario 1: Shifted story messages back to reduce the barrage
  at the start of the scenario.
  Also, more felling axes to make clearing the trees easier.
- Atlantean scenario : Trigger warehouse objective earlier, so we can
  expand faster and have some horses ready when racing for the lake.
- Warfare Tutorial: Build trainingsites concurrently in order to save time.
- Economy tutorial: Sleep longer for the stock window.

To post a comment you must log in.
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1621. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/176654850.
Appveyor build 1459. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1426465_scenario_timings-1459.

bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

('The read operation timed out',)

bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1621. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/176654850.
Appveyor build 1459. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1426465_scenario_timings-1459.

8150. By GunChleoc on 2016-11-30

Merged trunk.

8151. By GunChleoc on 2016-11-30

Changed titles for briefing messages 5-7 in Barbarian scenario 1.

8152. By GunChleoc on 2016-11-30

Do not trigger the warehouse + horse farm objective unless we have a farm + well.

8153. By GunChleoc on 2016-11-30

Military tutorial: Trainig camp success now explains abut base attach rather thaqn evade - evade can't be trained at the trainingcamp. Fixed interleaving of dismantle sentry message with battlearena success messages.

8154. By GunChleoc on 2016-11-30

Sleep first, then mark objective done.

8155. By GunChleoc on 2016-11-30

Tutorial1: Sleep longer before building flag, sleep shorter before conclusion.

8156. By GunChleoc on 2016-11-30

Tutorial4: Sleep longer around the tavern incident.

8157. By GunChleoc on 2016-11-30

Added comment - We have a crash.

8158. By GunChleoc on 2016-11-30

Merged trunk.

bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1672. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/180199443.
Appveyor build 1512. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1426465_scenario_timings-1512.

bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

('The read operation timed out',)

bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1672. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/180199443.
Appveyor build 1512. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1426465_scenario_timings-1512.

bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

('The read operation timed out',)

bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1672. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/180199443.
Appveyor build 1512. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1426465_scenario_timings-1512.

TiborB (tiborb95) wrote :

Code looks good to me. Of course the NOCOM should be removed, it even does not relate to the changes in the branch.
Not tested.

review: Approve
8159. By GunChleoc on 2016-12-06

Merged trunk.

8160. By GunChleoc on 2016-12-10

Removed NOCOM comment.

8161. By GunChleoc on 2016-12-10

Merged trunk.

GunChleoc (gunchleoc) wrote :

Thanks!

This was tested on the forum before I added the last tweaks, so since the crash is not caused by this branch, let's get this in.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/campaigns/atl01.wmf/scripting/mission_thread.lua'
2--- data/campaigns/atl01.wmf/scripting/mission_thread.lua 2015-11-03 18:52:00 +0000
3+++ data/campaigns/atl01.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
4@@ -18,38 +18,51 @@
5 end
6
7 function build_warehouse_and_horsefarm()
8- local fields = {
9+ -- Make sure that we can feed the horses at all.
10+ while not check_for_buildings(p1, {
11+ atlanteans_farm = 1,
12+ atlanteans_well = 1,
13+ }) do sleep(2500) end
14+
15+ -- Sleeps until one of the given fields is owned by p1.
16+ local function wait_for_owns_a_field(fields)
17+ local fowned = nil
18+ while not fowned do
19+ for idx, f in ipairs(fields) do
20+ if f.owner == p1 then
21+ fowned = f
22+ break
23+ end
24+ end
25+ sleep(5000)
26+ end
27+ end
28+
29+ wait_for_owns_a_field({
30+ map:get_field(60, 139),
31+ map:get_field(98, 128),
32+ map:get_field(120, 126)
33+ })
34+
35+ msg_boxes(horsefarm_and_warehouse_story)
36+ local o = add_campaign_objective(obj_horsefarm_and_warehouse)
37+ while not check_for_buildings(p1, {
38+ atlanteans_horsefarm = 1,
39+ atlanteans_warehouse = 1,
40+ }) do sleep(2384) end
41+ set_objective_done(o)
42+
43+ -- Now check if the water should rise
44+ wait_for_owns_a_field({
45 map:get_field(42, 88),
46 map:get_field(64, 105),
47 map:get_field(93, 89),
48 map:get_field(90, 66),
49- }
50+ })
51
52- local fowned = nil
53- while not fowned do
54- for idx, f in ipairs(fields) do
55- if f.owner == p1 then
56- fowned = f
57- break
58- end
59- end
60- sleep(3213)
61- end
62 -- Has been started from the very beginning
63- expand_objective.done = true
64+ set_objective_done(expand_objective)
65 let_the_water_rise = true
66-
67- local pts = wait_for_roadbuilding_and_scroll(fowned)
68- msg_boxes(horsefarm_and_warehouse_story)
69- -- Go back to where we were
70- timed_scroll(array_reverse(pts))
71-
72- local o = add_campaign_objective(obj_horsefarm_and_warehouse)
73- while not check_for_buildings(p1, {
74- atlanteans_horsefarm = 1,
75- atlanteans_warehouse = 1,
76- }) do sleep(2384) end
77- o.done = true
78 end
79
80 function build_training()
81@@ -60,7 +73,7 @@
82 atlanteans_dungeon = 1,
83 atlanteans_labyrinth = 1
84 }) do sleep(3874) end
85- o.done = true
86+ set_objective_done(o)
87
88 msg_boxes(training_story_end)
89 end
90@@ -79,7 +92,7 @@
91 atlanteans_armorsmithy = 1,
92 atlanteans_toolsmithy = 1,
93 }) do sleep(3478) end
94- o.done = true
95+ set_objective_done(o)
96
97 sleep(15 * 60 * 1000) -- sleep a while
98 run(build_training)
99@@ -105,7 +118,7 @@
100 atlanteans_fishbreeders_house = 1,
101 atlanteans_smokery = 2,
102 }) do sleep(2789) end
103- o.done = true
104+ set_objective_done(o)
105
106 msg_boxes(food_story_ended_messages)
107 end
108@@ -122,7 +135,7 @@
109 atlanteans_gold_spinning_mill = 1,
110 atlanteans_weaving_mill = 1
111 }) do sleep(6273) end
112- o.done = true
113+ set_objective_done(o)
114
115 msg_boxes(spidercloth_story_ended_messages)
116
117@@ -140,7 +153,7 @@
118 atlanteans_quarry = 1,
119 atlanteans_sawmill = 1,
120 }) do sleep(3731) end
121- o.done = true
122+ set_objective_done(o)
123
124 run(make_spidercloth_production)
125
126
127=== modified file 'data/campaigns/bar01.wmf/scripting/mission_thread.lua'
128--- data/campaigns/bar01.wmf/scripting/mission_thread.lua 2016-01-28 05:24:34 +0000
129+++ data/campaigns/bar01.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
130@@ -24,26 +24,31 @@
131 plr:reveal_fields(al_thunran:region(8))
132 message_box_objective(plr, briefing_msg_02) -- Al'thunran
133 plr:reveal_fields(grave:region(4))
134- message_box_objective(plr, briefing_msg_03) -- grave
135- message_box_objective(plr, briefing_msg_04)
136-
137- message_box_objective(plr, briefing_msg_05)
138- message_box_objective(plr, briefing_msg_06)
139- message_box_objective(plr, briefing_msg_07)
140-
141+ message_box_objective(plr, briefing_msg_03) -- grave, Boldreth
142+ message_box_objective(plr, briefing_msg_04) -- wait
143 -- introduction of Khantrukh
144 message_box_objective(plr, briefing_msg_08)
145
146 message_box_objective(plr, order_msg_ranger)
147 local obj = add_campaign_objective(obj_build_rangers)
148
149+ -- Try not to interrupt the player actions with a message, so we wait generously
150+ sleep(50000)
151+ message_box_objective(plr, briefing_msg_05) -- war goes on
152+ message_box_objective(plr, briefing_msg_06) -- brothers brought men
153+ sleep(50000)
154+ message_box_objective(plr, briefing_msg_07) -- still living in huts and barracks
155+ sleep(50000)
156+ message_box_objective(plr, msg_story_2) -- winter is upon us
157+ sleep(10000)
158+
159 while not check_for_buildings(plr, {barbarians_rangers_hut = 2}) do sleep(500) end
160- obj.done = true
161+ set_objective_done(obj)
162
163 plr:allow_buildings{"barbarians_sentry", "barbarians_barrier"}
164
165- message_box_objective(plr, order_msg_1)
166- message_box_objective(plr, order_msg_2)
167+ message_box_objective(plr, order_msg_1) -- Boldreth, swords rusty
168+ message_box_objective(plr, order_msg_2) -- Kantrukh, rocks
169
170 -- Reveal the rocks
171 local rocks = wl.Game().map:get_field(27, 48)
172@@ -57,12 +62,15 @@
173 -- Move back
174 timed_scroll(array_reverse(way), 10)
175
176+ sleep(50000)
177+ message_box_objective(plr, msg_story_1)
178+
179 -- Now, wait till the quarry comes up
180 local f = wl.Game().map:get_field(27,48):region(6)
181 while not check_for_buildings(plr, { barbarians_quarry = 1 }, f) do
182 sleep(5000)
183 end
184- obj.done = true
185+ set_objective_done(obj)
186
187 message_box_objective(plr, order_msg_5_quarry)
188
189@@ -98,7 +106,7 @@
190 while not check_for_buildings(plr, {barbarians_coalmine = 1, barbarians_ironmine = 1}) do
191 sleep(5000)
192 end
193- o.done = true
194+ set_objective_done(o)
195 message_box_objective(plr, order_msg_7_mines_up)
196 message_box_objective(plr, order_msg_8_mines_up)
197 message_box_objective(plr, order_msg_9_hunter)
198@@ -127,8 +135,7 @@
199 and #rv.barbarians_tavern >= 1 then break end
200 sleep(5331)
201 end
202- obj_bf.done = true
203- sleep(5000)
204+ set_objective_done(obj_bf)
205 message_box_objective(plr, story_msg4)
206 end)
207
208@@ -146,7 +153,7 @@
209 sleep(4234)
210 end
211 message_box_objective(plr, order_msg_12_farming_began)
212- obj_farming.done = true
213+ set_objective_done(obj_farming)
214 end)
215
216 -- Enable food production
217@@ -171,7 +178,7 @@
218 while #plr:get_buildings("barbarians_smelting_works") < 1 do
219 sleep(6223)
220 end
221- o.done = true
222+ set_objective_done(o)
223
224 -- Information about making mines deeper
225 -- Wait until the player has an experienced worker.
226@@ -218,7 +225,7 @@
227 end
228 sleep(5421)
229 end
230- obj.done = true
231+ set_objective_done(obj)
232 enhance_buildings_done = true
233 end)
234
235@@ -238,6 +245,7 @@
236 end
237 sleep(5421)
238 end
239+ sleep(5000)
240
241 message_box_objective(plr, order_msg_16_blackwood)
242 plr:allow_buildings{"barbarians_wood_hardener"}
243@@ -245,10 +253,10 @@
244 -- So that player has really little, but still enough to expand a bit
245 local o = add_campaign_objective(obj_better_material_1)
246
247- sleep(30*1000)
248+ sleep(50000)
249 message_box_objective(plr, story_msg1)
250 while #plr:get_buildings("barbarians_wood_hardener") < 1 do sleep(5421) end
251- o.done = true
252+ set_objective_done(o)
253
254 message_box_objective(plr, order_msg_17_grout)
255 plr:allow_buildings{"barbarians_lime_kiln", "barbarians_well", "barbarians_charcoal_kiln"}
256@@ -267,7 +275,7 @@
257 end
258 sleep(5421)
259 end
260- o.done = true
261+ set_objective_done(o)
262
263 message_box_objective(plr, order_msg_18_reed)
264 plr:allow_buildings{"barbarians_reed_yard"}
265@@ -275,7 +283,7 @@
266 while #plr:get_buildings("barbarians_reed_yard") < 1 do sleep(5421) end
267
268 message_box_objective(plr, order_msg_19_all_material)
269- o.done = true
270+ set_objective_done(o)
271
272 build_materials_done = true
273 end
274@@ -299,23 +307,12 @@
275 while not check_for_buildings(plr, { barbarians_cattlefarm = 1 }) do
276 sleep(2323)
277 end
278- o.done = true
279+ set_objective_done(o)
280
281 cattle_farm_done = true
282 end
283
284
285--- ======================
286--- Throns story messages
287--- ======================
288-function story_messages_thread()
289- wake_me(180 * 1000)
290- message_box_objective(plr, msg_story_2)
291-
292- wake_me(600 * 1000)
293- message_box_objective(plr, msg_story_1)
294-end
295-
296 -- =================
297 -- Mission complete
298 -- =================
299@@ -333,7 +330,6 @@
300 run(introduction_thread)
301 run(mines_and_food_thread)
302 run(build_materials_thread)
303-run(story_messages_thread)
304
305 include "map:scripting/secret_village.lua" -- starts the thread
306
307
308=== modified file 'data/campaigns/bar01.wmf/scripting/starting_conditions.lua'
309--- data/campaigns/bar01.wmf/scripting/starting_conditions.lua 2015-10-31 12:11:44 +0000
310+++ data/campaigns/bar01.wmf/scripting/starting_conditions.lua 2016-12-10 09:41:21 +0000
311@@ -46,7 +46,7 @@
312 barbarians_gardener = 1,
313 barbarians_geologist = 4,
314 barbarians_lime_burner = 1,
315- barbarians_lumberjack = 3,
316+ barbarians_lumberjack = 6,
317 barbarians_miner = 4,
318 barbarians_ranger = 2,
319 barbarians_stonemason = 2
320
321=== modified file 'data/campaigns/bar01.wmf/scripting/texts.lua'
322--- data/campaigns/bar01.wmf/scripting/texts.lua 2016-10-05 05:26:40 +0000
323+++ data/campaigns/bar01.wmf/scripting/texts.lua 2016-12-10 09:41:21 +0000
324@@ -187,7 +187,7 @@
325 -- TRANSLATORS: Thron
326 _[[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, preventing greed or despair from destroying the bonds between us as well.]]),
327 field = grave,
328- position = "topleft"
329+ position = "topleft",
330 }
331
332
333@@ -195,35 +195,38 @@
334 title = _"The Story Begins",
335 body = thron(
336 -- TRANSLATORS: Thron
337- _[[As father told me, there are times to fight and times to lie and wait, trying not to fall asleep or die before the right time comes. And so I do wait.]])
338+ _[[As father told me, there are times to fight and times to lie and wait, trying not to fall asleep or die before the right time comes. And so I do wait.]]),
339+ position = "topleft",
340 }
341
342
343 briefing_msg_05 = {
344- title = _"The Story Begins",
345+ title = _"Thron is Contemplating the War",
346 body = thron(_"Thron is shaking his head…",
347 -- TRANSLATORS: Thron
348 _([[Yet the war goes on. More and more of our brothers and sisters flee the brutal war raging in the capital beneath the trees.]])
349 .. paragraphdivider() ..
350 -- TRANSLATORS: Thron
351 _([[The stories they tell about the deeds of our kin are sad to hear. I’ve spent nights lying awake, restless, more tired than 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.]])),
352- field = sf -- scroll back when showing this and the next few message boxes
353+ field = al_thunran,
354+ position = "topleft",
355 }
356
357
358 briefing_msg_06 = {
359- title = _"The Story Begins",
360+ title = _"Thron is Contemplating the War",
361 body = thron(
362 -- TRANSLATORS: Thron
363 _([[Today my hunters brought men, women and little children before me 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 olden 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 slaughter, unless… is this it? As father told me?]])
364 .. paragraphdivider() ..
365 -- TRANSLATORS: Thron
366- _([[To rise against whoever threatens our very existence, even though it may be one of your own blood or mind?]]))
367+ _([[To rise against whoever threatens our very existence, even though it may be one of your own blood or mind?]])),
368+ field = sf,
369 }
370
371
372 briefing_msg_07 = {
373- title = _"The Story Begins",
374+ title = _"Thron is Considering the Future",
375 body = thron(
376 -- TRANSLATORS: Thron
377 _([[Boldreth seems more and more torn as the days go by. The spirits of my fellows sink as the cold season approaches, and we are still living in no more than huts and barracks. I never intended to stay out here in the wilderness for so long – but I never thought my brothers would engage in this senseless battle for so long either.]])
378@@ -240,7 +243,8 @@
379 _[[Hail, chieftain. I am Khantrukh and have seen many winters pass. Please allow me to aid you with my counsel through these darkened days.]]
380 .. paragraphdivider() ..
381 -- TRANSLATORS: Khantrukh
382- _[[Only the gods know for 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 short and cold…]])
383+ _[[Only the gods know for 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 short and cold…]]),
384+ field = sf -- scroll back when showing this and the next few message boxes
385 }
386
387
388
389=== modified file 'data/campaigns/bar02.wmf/scripting/mission_thread.lua'
390--- data/campaigns/bar02.wmf/scripting/mission_thread.lua 2016-05-06 09:44:37 +0000
391+++ data/campaigns/bar02.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
392@@ -30,7 +30,7 @@
393 local o = add_campaign_objective(obj_build_cattlefarm)
394 while not check_for_buildings(p1, {barbarians_cattlefarm = 1}) do
395 sleep(1223) end
396- o.done = true
397+ set_objective_done(o)
398
399 end
400
401@@ -48,7 +48,7 @@
402 while not check_for_buildings(p1, {barbarians_sentry=1}, game.map:get_field(57,36):region(6)) do
403 sleep(1500)
404 end
405- o.done = true
406+ set_objective_done(o)
407 sleep(3000)
408
409 campaign_message_box(briefing_msg_1)
410@@ -73,7 +73,7 @@
411 barbarians_farm = 1,
412 barbarians_bakery = 1,
413 }) do sleep(3413) end
414- o.done = true
415+ set_objective_done(o)
416 campaign_message_box(story_note_1)
417
418 sleep(600000) -- 10 minutes
419@@ -111,7 +111,7 @@
420 p1:hide_fields(fields)
421
422 while not check_for_buildings(p1, {barbarians_tower=1}) do sleep(2341) end
423- o.done = true
424+ set_objective_done(o)
425 campaign_message_box(order_msg_3_explore_further)
426 -- "explore further" is active untill "Boldreth shout out", so the player always has one open objectve.
427 exploration_objective = add_campaign_objective(obj_explore_further)
428@@ -178,7 +178,7 @@
429 end
430 sleep(4139)
431 end
432- o.done = true
433+ set_objective_done(o)
434 campaign_message_box(story_note_2)
435
436 sleep(100000)
437@@ -211,7 +211,7 @@
438 while not check_for_buildings(p1, {barbarians_trainingcamp = 1, barbarians_battlearena = 1}) do
439 sleep(6523)
440 end
441- o.done = true
442+ set_objective_done(o)
443 end
444 function check_weapon_productions_obj(o)
445 while true do
446@@ -225,15 +225,15 @@
447 end
448 sleep(6523)
449 end
450- o.done = true
451+ set_objective_done(o)
452 end
453 function check_warehouse_obj(o)
454 while not check_for_buildings(p1, {barbarians_warehouse = 1}) do sleep(3827) end
455- o.done = true
456+ set_objective_done(o)
457 end
458 function check_helmsmithy_obj(o)
459 while not check_for_buildings(p1, {barbarians_helmsmithy = 1}) do sleep(3827) end
460- o.done = true
461+ set_objective_done(o)
462 end
463
464 function fortress()
465@@ -247,7 +247,7 @@
466
467 while #p1:get_buildings("barbarians_fortress") == 0 do sleep(6523) end
468
469- o.done = true
470+ set_objective_done(o)
471 campaign_message_box(story_note_3)
472 end
473
474@@ -294,7 +294,7 @@
475 )
476 do sleep(7829) end
477 -- "explore further" is done
478- exploration_objective.done = true
479+ set_objective_done(exploration_objective)
480
481 campaign_message_box(order_msg_7_destroy_kalitaths_army)
482 local o = add_campaign_objective(obj_destroy_kalitaths_army)
483@@ -302,7 +302,7 @@
484 while not check_player_completely_defeated(p2) do
485 sleep(7837)
486 end
487- o.done = true
488+ set_objective_done(o)
489 end
490
491 function renegade_fortresses()
492@@ -345,7 +345,7 @@
493 sleep(6733)
494 end
495
496- o.done = true
497+ set_objective_done(o)
498 end
499
500 function mission_complete()
501
502=== modified file 'data/campaigns/emp01.wmf/scripting/mission_thread.lua'
503--- data/campaigns/emp01.wmf/scripting/mission_thread.lua 2016-01-28 05:24:34 +0000
504+++ data/campaigns/emp01.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
505@@ -30,7 +30,7 @@
506 p1:allow_buildings{"empire_blockhouse"}
507 local o = add_campaign_objective(obj_build_blockhouse)
508 while #p1:get_buildings("empire_blockhouse") < 1 do sleep(3249) end
509- o.done = true
510+ set_objective_done(o)
511
512 -- Blockhouse is completed now
513 campaign_message_box(saledus_2)
514@@ -38,7 +38,7 @@
515 o = add_campaign_objective(obj_build_lumberjack)
516 campaign_message_box(amalea_1)
517 while #p1:get_buildings("empire_lumberjacks_house") < 1 do sleep(3249) end
518- o.done = true
519+ set_objective_done(o)
520
521 -- Lumberjack is now build
522 campaign_message_box(amalea_2)
523@@ -46,14 +46,14 @@
524 o = add_campaign_objective(obj_build_sawmill_and_lumberjacks)
525 while not check_for_buildings(p1, { empire_lumberjacks_house = 3, empire_sawmill = 1})
526 do sleep(2343) end
527- o.done = true
528+ set_objective_done(o)
529
530 -- Now the lady demands a forester after having us cut down the whole forest.
531 campaign_message_box(amalea_3)
532 o = add_campaign_objective(obj_build_forester)
533 p1:allow_buildings{"empire_foresters_house"}
534 while not check_for_buildings(p1, { empire_foresters_house = 1 }) do sleep(2434) end
535- o.done = true
536+ set_objective_done(o)
537
538
539 -- Now a quarry
540@@ -61,7 +61,7 @@
541 o = add_campaign_objective(obj_build_quarry)
542 p1:allow_buildings{"empire_quarry"}
543 while not check_for_buildings(p1, { empire_quarry = 1 }) do sleep(2434) end
544- o.done = true
545+ set_objective_done(o)
546
547 -- All buildings done. Got home
548 campaign_message_box(saledus_4)
549
550=== modified file 'data/campaigns/emp02.wmf/scripting/mission_thread.lua'
551--- data/campaigns/emp02.wmf/scripting/mission_thread.lua 2016-01-28 05:24:34 +0000
552+++ data/campaigns/emp02.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
553@@ -28,7 +28,7 @@
554 }) do sleep(2342) end
555
556 campaign_message_box(diary_page_6)
557- o_woodeconomy.done = true
558+ set_objective_done(o_woodeconomy)
559 end)
560
561
562@@ -39,7 +39,7 @@
563 -- Check for completeness of the quarry
564 run(function()
565 while not check_for_buildings(p1, {empire_quarry=1}) do sleep(3423) end
566- o_quarry.done = true
567+ set_objective_done(o_quarry)
568
569 campaign_message_box(diary_page_7)
570 end)
571@@ -100,7 +100,7 @@
572 #rv.empire_piggery + #rv.empire_bakery) > 0 then break end
573 sleep(4857)
574 end
575- o.done = true
576+ set_objective_done(o)
577 end
578
579 function mining_infrastructure()
580@@ -159,7 +159,7 @@
581 #rv.empire_weaponsmithy > 0 then break end
582 sleep(4948)
583 end
584- o.done = true
585+ set_objective_done(o)
586 mining_infrastructure_done = true
587 end
588
589@@ -182,7 +182,7 @@
590
591 -- sleep while not owning 26, 21
592 while wl.Game().map:get_field(26,21).owner ~= p1 do sleep(3243) end
593- o.done = true
594+ set_objective_done(o)
595
596 -- Marble Mountains
597 local marblemountains = wl.Game().map:get_field(35,19)
598@@ -195,7 +195,7 @@
599 p1:allow_buildings{"empire_marblemine", "empire_marblemine_deep"}
600 o = add_campaign_objective(obj_build_marblemine)
601 run(function() while not check_for_buildings(p1, {empire_marblemine = 1})
602- do sleep(2133) end o.done = true end)
603+ do sleep(2133) end set_objective_done(o, 0) end)
604
605 -- Go back to where we were
606 timed_scroll(array_reverse(pts))
607@@ -239,7 +239,7 @@
608 end
609 sleep(2342)
610 end
611- o.done = true
612+ set_objective_done(o)
613
614 -- Wait till the mining infrastructure is also up
615 while not mining_infrastructure_done do
616@@ -254,7 +254,7 @@
617 wl.Game().map:get_field(60,65):region(6))
618 do sleep(2435) end
619
620- o.done = true
621+ set_objective_done(o)
622
623 -- Show victory message
624 campaign_message_box(diary_page_10)
625
626=== modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua'
627--- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 16:18:25 +0000
628+++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
629@@ -17,11 +17,9 @@
630 while not wl.ui.MapView().buildhelp do
631 sleep(200)
632 end
633- o.done = true
634+ set_objective_done(o, 500)
635 wl.ui.MapView():abort_road_building()
636
637- sleep(500)
638-
639 build_lumberjack()
640 end
641
642@@ -69,7 +67,7 @@
643
644 blocker:lift_blocks()
645
646- sleep(15000)
647+ sleep(30000)
648
649 if not (f.immovable and f.immovable.descr.type_name == "flag") then
650 -- only show this if the user has not already built a flag
651@@ -86,9 +84,7 @@
652
653 -- Wait for flag
654 while not (f.immovable and f.immovable.descr.type_name == "flag") do sleep(300) end
655- o.done = true
656-
657- sleep(300)
658+ set_objective_done(o, 300)
659
660 message_box_objective(plr, lumberjack_message_06)
661 else
662@@ -120,14 +116,12 @@
663 end
664
665 _wait_for_move()
666- o.done = true
667- sleep(3000) -- Give the player a chance to try this some more
668+ set_objective_done(o)
669
670 o = message_box_objective(plr, tell_about_right_drag_move)
671
672 _wait_for_move()
673- o.done = true
674- sleep(3000) -- Give the player a chance to try this some more
675+ set_objective_done(o)
676
677 o = message_box_objective(plr, tell_about_minimap)
678
679@@ -135,8 +129,7 @@
680 while not wl.ui.MapView().windows.minimap do sleep(100) end
681 while wl.ui.MapView().windows.minimap do sleep(100) end
682
683- o.done = true
684- sleep(500)
685+ set_objective_done(o, 500)
686
687 message_box_objective(plr, congratulate_and_on_to_quarry)
688
689@@ -161,7 +154,7 @@
690 -- Wait for the constructionsite to be placed
691 while not cs do sleep(200) end
692
693- o.done = true
694+ set_objective_done(o, 0)
695 register_immovable_as_allowed(cs)
696
697 local function _rip_road()
698@@ -238,7 +231,7 @@
699 census_and_statistics()
700
701 while #plr:get_buildings("barbarians_quarry") < 2 do sleep(1400) end
702- o.done = true
703+ set_objective_done(o, 0)
704
705 messages()
706 end
707@@ -271,7 +264,7 @@
708 if not second_quarry_field.immovable then message_box_objective(plr,quarry_illegally_destroyed) return end
709 end
710
711- o.done = true
712+ set_objective_done(o, 0)
713 register_immovable_as_allowed(cs)
714 end
715
716@@ -310,15 +303,13 @@
717 local o = add_campaign_objective(teaching_about_messages)
718
719 while #plr.inbox > 0 do sleep(200) end
720- o.done = true
721-
722- sleep(500)
723+ set_objective_done(o, 500)
724
725 local o = message_box_objective(plr, closing_msg_window_00)
726
727 -- Wait for messages window to close
728 while wl.ui.MapView().windows.messages do sleep(300) end
729- o.done = true
730+ set_objective_done(o, 0)
731
732 message_box_objective(plr, closing_msg_window_01)
733
734@@ -351,9 +342,7 @@
735 terminate_bad_boy_sentinel = true
736
737 while #plr:get_buildings("barbarians_quarry") > 0 do sleep(200) end
738- o.done = true
739-
740- sleep(3000)
741+ set_objective_done(o)
742
743 expansion()
744 end
745@@ -382,15 +371,14 @@
746 sleep(500)
747 end
748
749- o.done = true
750- sleep(4000)
751+ set_objective_done(o)
752 message_box_objective(plr, military_building_finished)
753
754 conclusion()
755 end
756
757 function conclusion()
758- sleep(10000) -- to give the player time to see his expanded area
759+ sleep(5000) -- to give the player time to see his expanded area
760
761 -- Conclude the tutorial with final words and information
762 -- on how to quit
763
764=== modified file 'data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua'
765--- data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua 2015-10-31 12:11:44 +0000
766+++ data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
767@@ -9,35 +9,41 @@
768 training()
769 end
770
771+local trainingcamp_done = false
772+local battlearena_done = false
773+
774+function training2()
775+ -- Teach about trainingsites and soldiers' abilities - concurrent part 2
776+ sleep(2*60*1000)
777+ o = message_box_objective(plr, trainingcamp1)
778+ while #plr:get_buildings("barbarians_trainingcamp") == 0 do sleep(500) end
779+ set_objective_done(o)
780+ message_box_objective(plr, trainingcamp2)
781+ trainingcamp_done = true
782+end
783+
784 function training()
785 -- Teach about trainingsites and soldiers' abilities
786 sleep(5000) -- to let soldiers walk
787
788 message_box_objective(plr, abilities)
789 local o = message_box_objective(plr, battlearena1)
790+ run(training2)
791+
792 while #plr:get_buildings("barbarians_battlearena") == 0 do sleep(500) end
793- o.done = true
794+ set_objective_done(o, 0)
795 message_box_objective(plr, battlearena2)
796-
797- o = message_box_objective(plr, trainingcamp1)
798- while #plr:get_buildings("barbarians_trainingcamp") == 0 do sleep(500) end
799- o.done = true
800- message_box_objective(plr, trainingcamp2)
801-
802- sleep(300)
803-
804- military_buildings()
805+ battlearena_done = true
806 end
807
808 function military_buildings()
809+ while not trainingcamp_done or not battlearena_done do sleep(3000) end
810 message_box_objective(plr, heroes_rookies)
811 message_box_objective(plr, soldier_capacity)
812 local o = message_box_objective(plr, dismantle)
813
814 while #plr:get_buildings("barbarians_sentry") > 1 do sleep(200) end
815- o.done = true
816-
817- sleep(2000)
818+ set_objective_done(o)
819
820 enhance_fortress()
821 end
822@@ -49,7 +55,7 @@
823 local o = message_box_objective(plr, fortress_enhancement)
824 while not (citadel_field.immovable and
825 citadel_field.immovable.descr.name == "barbarians_citadel") do sleep(800) end
826- o.done = true
827+ set_objective_done(o, 0)
828
829 create_enemy()
830
831@@ -91,14 +97,14 @@
832 while #plr2:get_buildings("empire_headquarters") > 0 do
833 sleep(3000)
834 end
835- o.done = true
836+ set_objective_done(o)
837
838 conclusion()
839 end
840
841 function conclusion()
842- sleep(4000)
843 message_box_objective(plr, conclude_tutorial)
844 end
845
846 run(intro)
847+run (military_buildings)
848
849=== modified file 'data/campaigns/tutorial02_warfare.wmf/scripting/texts.lua'
850--- data/campaigns/tutorial02_warfare.wmf/scripting/texts.lua 2016-09-14 10:54:05 +0000
851+++ data/campaigns/tutorial02_warfare.wmf/scripting/texts.lua 2016-12-10 09:41:21 +0000
852@@ -13,6 +13,9 @@
853 local tribe = wl.Game():get_tribe_description("barbarians")
854 local soldier = wl.Game():get_worker_description(tribe.soldier)
855
856+local empire_tribe = wl.Game():get_tribe_description("empire")
857+local empire_soldier = wl.Game():get_worker_description(empire_tribe.soldier)
858+
859 -- =============
860 -- Texts below
861 -- =============
862@@ -118,7 +121,7 @@
863 p(_[[Great, our training camp has now been finished, too. Now nothing will hinder us from getting the strongest warriors the world has ever seen.]]) ..
864 p(_[[To train in the training camp, our soldiers need food like in the battle arena, but no strong beer. Instead, they need different axes for attack training and helmets for health training.]]) ..
865 p(_[[This equipment is produced in smithies out of coal, iron, and sometimes gold. You will learn more about this in the second scenario of the Barbarian campaign.]]) ..
866- p(_[[You should also keep in mind that each of the three tribes in Widelands has its own way of training, so the buildings and wares are different. Also, the ability levels cannot be compared: an Imperial soldier with evade level 0 has a 30% chance of evading, while a Barbarian soldier at the same level only has a 25% chance.]])
867+ p(_[[You should also keep in mind that each of the three tribes in Widelands has its own way of training, so the buildings and wares are different. Also, the ability levels cannot be compared: an Imperial soldier has a base attack of %1% at level 0, while a Barbarian soldier at the same level only has a base attack of %2%.]]:bformat(empire_soldier.base_min_attack, soldier.base_min_attack))
868 )
869 }
870
871
872=== modified file 'data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua'
873--- data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua 2016-08-03 10:20:20 +0000
874+++ data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
875@@ -21,7 +21,7 @@
876 local o = message_box_objective(plr, tell_about_port_building)
877
878 while #plr:get_buildings("atlanteans_port") < 2 do sleep(200) end
879- o.done = true
880+ set_objective_done(o)
881
882 build_ships()
883 end
884@@ -32,7 +32,7 @@
885 plr:allow_buildings{"atlanteans_shipyard"}
886
887 while #plr:get_buildings("atlanteans_shipyard") < 1 do sleep(200) end
888- o.done = true
889+ set_objective_done(o)
890
891 local o = message_box_objective(plr, tell_about_ships)
892
893@@ -40,7 +40,7 @@
894 while #plr:get_ships() < 1 do sleep(30*1000) end
895 sleep(5*60*1000)
896
897- o.done = true
898+ set_objective_done(o)
899
900 expedition()
901 end
902@@ -58,12 +58,12 @@
903 end
904
905 while not _ship_ready_for_expedition() do sleep(1000) end
906- o.done = true
907+ set_objective_done(o)
908
909 o = message_box_objective(plr, expedition3)
910
911 while #plr:get_buildings("atlanteans_port") < 3 do sleep(200) end
912- o.done = true
913+ set_objective_done(o)
914
915 -- places 5 signs with iron to show the player he really found some iron ore
916 local fields = map:get_field(97,35):region(3)
917
918=== modified file 'data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua'
919--- data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2015-10-31 12:11:44 +0000
920+++ data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2016-12-10 09:41:21 +0000
921@@ -13,16 +13,15 @@
922 function burn_tavern_down()
923 sleep(500)
924 scroll_smoothly_to(tavern_field)
925- sleep(250)
926+ sleep(1000)
927 tavern_field.immovable:destroy()
928- sleep(50)
929+ sleep(1000)
930 message_box_objective(plr, tavern_burnt_down)
931- sleep(2000)
932+ sleep(500)
933 local o = message_box_objective(plr, building_stat)
934 while not mv.windows.building_statistics do sleep(100) end
935- o.done = true
936+ set_objective_done(o, wl.Game().real_speed)
937
938- sleep(wl.Game().real_speed) -- The building statistics window needs some time to build up
939 o = message_box_objective(plr,explain_building_stat)
940 -- We cannot create several objectives with the same name. Therefore, we create o2 here once and change its visibility
941 local o2 = add_campaign_objective(reopen_building_stat_obj)
942@@ -39,28 +38,26 @@
943 sleep(200)
944 end
945 while mv.windows.building_statistics do sleep(100) end
946- o.done = true
947+ set_objective_done(o, 0)
948
949- sleep(2000)
950 o = message_box_objective(plr, inventory1)
951 while not mv.windows.stock_menu do sleep(200) end
952- o.done = true
953+ set_objective_done(o, wl.Game().real_speed)
954
955 o = message_box_objective(plr, inventory2)
956 -- We cannot create several objectives with the same name. Therefore, we create o2 here once and change its visibility
957 o2 = add_campaign_objective(reopen_stock_menu_obj)
958 o2.visible = false
959- while not o.done do
960+ while not mv.windows.stock_menu.tabs["wares_in_warehouses"].active do
961 if not mv.windows.stock_menu then
962 o2.visible = true
963 message_box_objective(plr, reopen_stock_menu)
964 while not mv.windows.stock_menu do sleep(200) end
965 o2.visible = false
966 end
967- if mv.windows.stock_menu.tabs["wares_in_warehouses"].active then o.done = true end
968 sleep(200)
969 end
970-
971+ set_objective_done(o, 0)
972 message_box_objective(plr, inventory3)
973
974 sleep(2000)
975@@ -70,57 +67,54 @@
976 message_box_objective(plr, ware_encyclopedia) -- a small insert
977
978 while #plr:get_buildings("empire_tavern") < 2 do sleep(500) end
979- o.done = true
980+ set_objective_done(o, 0)
981
982 plan_the_future()
983 end
984
985 function plan_the_future()
986- sleep(2000)
987 message_box_objective(plr, building_priority_settings)
988 sleep(30*1000) -- give the user time to try it out
989
990 local o = message_box_objective(plr, ware_stats1)
991 while not mv.windows.ware_statistics do sleep(200) end
992- o.done = true
993+ set_objective_done(o, 0)
994
995 o = message_box_objective(plr, ware_stats2)
996 local o2 = add_campaign_objective(reopen_ware_stats1_obj)
997 o2.visible = false
998- while not o.done do
999+ while not mv.windows.ware_statistics.tabs["economy_health"].active do
1000 if not mv.windows.ware_statistics then
1001 o2.visible = true
1002 message_box_objective(plr, reopen_ware_stats1)
1003 while not mv.windows.ware_statistics do sleep(200) end
1004 o2.visible = false
1005 end
1006- if mv.windows.ware_statistics.tabs["economy_health"].active then o.done = true end
1007 sleep(200)
1008 end
1009+ set_objective_done(o, 0)
1010
1011 o = message_box_objective(plr, ware_stats3)
1012 o2 = add_campaign_objective(reopen_ware_stats2_obj)
1013 o2.visible = false
1014- while not o.done do
1015+ while not mv.windows.ware_statistics.tabs["stock"].active do
1016 if not mv.windows.ware_statistics then
1017 o2.visible = true
1018 message_box_objective(plr, reopen_ware_stats2)
1019 while not mv.windows.ware_statistics do sleep(200) end
1020 o2.visible = false
1021 end
1022- if mv.windows.ware_statistics.tabs["stock"].active then o.done = true end
1023 sleep(200)
1024 end
1025+ set_objective_done(o, 0)
1026
1027 o = message_box_objective(plr, ware_stats4)
1028 while mv.windows.ware_statistics do sleep(500) end
1029- o.done = true
1030-
1031- sleep(2000)
1032+ set_objective_done(o)
1033
1034 o = message_box_objective(plr, economy_settings1)
1035 while not mv.windows.economy_options do sleep(200) end
1036- o.done = true
1037+ set_objective_done(o, 0)
1038 message_box_objective(plr, economy_settings2)
1039 o = message_box_objective(plr, economy_settings3)
1040
1041@@ -141,7 +135,7 @@
1042 end
1043 sleep(500)
1044 end
1045- o.done = true
1046+ set_objective_done(o)
1047
1048 -- if the minimum_storage_per_warehouse feature is introduced, use the gold mountain to the northeast for explanation
1049 conclude()
1050
1051=== modified file 'data/scripting/messages.lua'
1052--- data/scripting/messages.lua 2016-01-28 05:24:34 +0000
1053+++ data/scripting/messages.lua 2016-12-10 09:41:21 +0000
1054@@ -69,6 +69,7 @@
1055 message_box(wl.Game().players[1], message.title, message.body, message)
1056 end
1057
1058+
1059 -- RST
1060 -- .. function:: add_campaign_objective(objective)
1061 --
1062@@ -87,6 +88,24 @@
1063 end
1064
1065 -- RST
1066+-- .. function:: set_objective_done(objective[, sleeptime])
1067+--
1068+-- Sets an objectve as done and sleeps for a bit.
1069+--
1070+-- :arg objective: The objective to be marked as done.
1071+-- :arg sleeptime: The milliseconds to sleep. Defaults to 3000.
1072+--
1073+function set_objective_done(objective, sleeptime)
1074+ if not sleeptime then
1075+ sleep(3000)
1076+ else
1077+ sleep(sleeptime)
1078+ end
1079+ objective.done = true
1080+end
1081+
1082+
1083+-- RST
1084 -- .. function:: message_box_objective(player, message)
1085 --
1086 -- Calls message_box(player, message.title, message.body, message). Also adds an objective defined in obj_name, obj_title and obj_body.

Subscribers

People subscribed via source and target branches

to status/vote changes: