Merge lp:~f-thiessen/widelands/barbarian3 into lp:widelands

Proposed by Ferdinand T.
Status: Merged
Merged at revision: 7125
Proposed branch: lp:~f-thiessen/widelands/barbarian3
Merge into: lp:widelands
Diff against target: 244 lines (+66/-35)
1 file modified
campaigns/t03.wmf/scripting/mission_thread.lua (+66/-35)
To merge this branch: bzr merge lp:~f-thiessen/widelands/barbarian3
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+227436@code.launchpad.net

Description of the change

This fixes some bugs with the third barbarian campaign:
* Now it is needed to conquer all military buildings of the enemies (bug 1298411)
* Event "Build a Donjohn" triggers now not so early (bug 1276247)
* "explore further" is now active until the "Boldreth shouts out!" event (bug 674839)

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Couple of nits.

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

Tangent for you too: I added you to the team now. Please push future branches to ~widelands-dev/widelands/ instead of your private user space. This allows others to add in-source comment and collaborate on your work.

Welcome to the team :)

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have an idea for check_player_completly_defeated - see inline comment

Revision history for this message
Ferdinand T. (f-thiessen) wrote :

Thank you for adding to the group ;)
I think I fixed the issues, sorry for the weird English.
The check_player_completely_defeated function is in my opinion ok, because this are the building the enemies have (hard-coded in start conditions of this campaign, and the AI is not allowed to build new and/or other buildings).
But for a flexible function your suggestion would be helpful!

Revision history for this message
SirVer (sirver) wrote :

Looks good! Thanks for fixing this issues.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'campaigns/t03.wmf/scripting/mission_thread.lua'
--- campaigns/t03.wmf/scripting/mission_thread.lua 2014-03-15 13:36:42 +0000
+++ campaigns/t03.wmf/scripting/mission_thread.lua 2014-07-21 14:49:19 +0000
@@ -2,11 +2,22 @@
2-- Various mission threads2-- Various mission threads
3-- =======================================================================3-- =======================================================================
44
5game = wl.Game()
5-- Mountain and frontier fields6-- Mountain and frontier fields
6mountain = wl.Game().map:get_field(71,14)7mountain = game.map:get_field(71,14)
7fr1 = wl.Game().map:get_field(81,108)8fr1 = game.map:get_field(81,108)
8fr2 = wl.Game().map:get_field(85,1)9fr2 = game.map:get_field(85,1)
9fr3 = wl.Game().map:get_field(85,11)10fr3 = game.map:get_field(85,11)
11
12function check_conquered_footprints()
13 if p1:seen_field(game.map:get_field(65, 28))
14 then
15 sleep(2129)
16 if p1:sees_field(game.map:get_field(65, 28))
17 then return true end
18 end
19 return false
20end
1021
11function remember_cattlefarm()22function remember_cattlefarm()
12 sleep(100)23 sleep(100)
@@ -16,7 +27,7 @@
16 p1:allow_buildings{"cattlefarm"}27 p1:allow_buildings{"cattlefarm"}
17 local o = add_obj(obj_build_cattlefarm)28 local o = add_obj(obj_build_cattlefarm)
18 while not check_for_buildings(p1, {cattlefarm = 1}) do29 while not check_for_buildings(p1, {cattlefarm = 1}) do
19 sleep(1234) end30 sleep(1223) end
20 o.done = true31 o.done = true
2132
22end33end
@@ -36,7 +47,9 @@
36 "farm",47 "farm",
37 "well",48 "well",
38 "bakery",49 "bakery",
50 "sentry",
39 }51 }
52
40 local o = add_obj(obj_build_small_food_economy)53 local o = add_obj(obj_build_small_food_economy)
41 while not check_for_buildings(p1, {54 while not check_for_buildings(p1, {
42 fishers_hut = 1,55 fishers_hut = 1,
@@ -44,7 +57,7 @@
44 well = 1,57 well = 1,
45 farm = 1,58 farm = 1,
46 bakery = 1,59 bakery = 1,
47 }) do sleep(3412) end60 }) do sleep(3413) end
48 o.done = true61 o.done = true
49 send_msg(story_note_1)62 send_msg(story_note_1)
5063
@@ -54,22 +67,22 @@
5467
55function foottracks()68function foottracks()
56 -- Hunter build and some time passed or expanded east69 -- Hunter build and some time passed or expanded east
57 local game = wl.Game()
58 while true do70 while true do
59 if (game.time > 900000 and #p1:get_buildings("hunters_hut") > 0)71 if game.time > 900000 and #p1:get_buildings("hunters_hut") > 0
60 or p1:seen_field(wl.Game().map:get_field(65, 28))72 then break end
73 if check_conquered_footprints()
61 then break end74 then break end
62 sleep(4239)75 sleep(4239)
63 end76 end
6477
65 local fields = array_combine(78 local fields = array_combine(
66 wl.Game().map:get_field(67, 19):region(2),79 game.map:get_field(67, 19):region(2),
67 wl.Game().map:get_field(65, 19):region(2),80 game.map:get_field(65, 19):region(2),
68 wl.Game().map:get_field(69, 18):region(2)81 game.map:get_field(69, 18):region(2)
69 )82 )
70 p1:reveal_fields(fields)83 p1:reveal_fields(fields)
7184
72 local pts = scroll_smoothly_to(wl.Game().map:get_field(67,19))85 local pts = scroll_smoothly_to(game.map:get_field(67,19))
7386
74 send_msg(order_msg_2_build_a_donjon)87 send_msg(order_msg_2_build_a_donjon)
75 local o = add_obj(obj_build_a_donjon)88 local o = add_obj(obj_build_a_donjon)
@@ -79,13 +92,14 @@
79 timed_scroll(array_reverse(pts), 10)92 timed_scroll(array_reverse(pts), 10)
8093
81 -- Hide the tracks again94 -- Hide the tracks again
82 sleep(5000)95 sleep(5003)
83 p1:hide_fields(fields)96 p1:hide_fields(fields)
8497
85 while not check_for_buildings(p1, {donjon=1}) do sleep(2341) end98 while not check_for_buildings(p1, {donjon=1}) do sleep(2341) end
86 o.done = true99 o.done = true
87 send_msg(order_msg_3_explore_further)100 send_msg(order_msg_3_explore_further)
88 o = add_obj(obj_explore_further)101 -- "explore further" is active untill "Boldreth shout out", so the player always has one open objectve.
102 exploration_objective = add_obj(obj_explore_further)
89103
90 p1:allow_buildings{"sentry", "barrier"}104 p1:allow_buildings{"sentry", "barrier"}
91105
@@ -99,7 +113,6 @@
99113
100 sleep(3244)114 sleep(3244)
101 end115 end
102 o.done = true
103end116end
104117
105function mining_and_trainingsites()118function mining_and_trainingsites()
@@ -107,12 +120,12 @@
107120
108 -- Show the other mountains permanently121 -- Show the other mountains permanently
109 p1:reveal_fields(array_combine(122 p1:reveal_fields(array_combine(
110 wl.Game().map:get_field(77, 98):region(7),123 game.map:get_field(77, 98):region(7),
111 wl.Game().map:get_field(79, 6):region(5),124 game.map:get_field(79, 6):region(5),
112 wl.Game().map:get_field(82, 20):region(6))125 game.map:get_field(82, 20):region(6))
113 )126 )
114127
115 local pts = scroll_smoothly_to(wl.Game().map:get_field(82,20))128 local pts = scroll_smoothly_to(game.map:get_field(82,20))
116129
117 send_msg(order_msg_4_build_mining_economy)130 send_msg(order_msg_4_build_mining_economy)
118 local o = add_obj(obj_build_mining_economy)131 local o = add_obj(obj_build_mining_economy)
@@ -125,6 +138,7 @@
125 "smelting_works",138 "smelting_works",
126 "metalworks",139 "metalworks",
127 "burners_house",140 "burners_house",
141 "micro-brewery",
128 }142 }
129143
130 timed_scroll(array_reverse(pts), 10)144 timed_scroll(array_reverse(pts), 10)
@@ -163,7 +177,6 @@
163 "deeper_goldmine",177 "deeper_goldmine",
164 "deeper_oremine",178 "deeper_oremine",
165 "warehouse",179 "warehouse",
166 "micro-brewery",
167 "brewery",180 "brewery",
168 }181 }
169 run(check_warehouse_obj, add_obj(obj_build_a_warehouse))182 run(check_warehouse_obj, add_obj(obj_build_a_warehouse))
@@ -215,10 +228,10 @@
215function expansion()228function expansion()
216 -- While enemy has not been seen229 -- While enemy has not been seen
217 while not (230 while not (
218 p1:seen_field(wl.Game().map:get_field(95, 91)) or231 p1:seen_field(game.map:get_field(95, 91)) or
219 p1:seen_field(wl.Game().map:get_field(96, 107)) or232 p1:seen_field(game.map:get_field(96, 107)) or
220 p1:seen_field(wl.Game().map:get_field(96, 8)) or233 p1:seen_field(game.map:get_field(96, 8)) or
221 p1:seen_field(wl.Game().map:get_field(96, 19))234 p1:seen_field(game.map:get_field(96, 19))
222 )235 )
223 do sleep(8374) end236 do sleep(8374) end
224237
@@ -231,9 +244,20 @@
231 send_msg(story_msg_6)244 send_msg(story_msg_6)
232end245end
233246
247-- checks if all military buildings are drestroyed (the build-in function "defeated" only checks if all warehouses are destroyed)
248function check_player_completely_defeated(dp)
249 if #dp:get_buildings("fortress") > 0 then return false end
250 if #dp:get_buildings("citadel") > 0 then return false end
251 if #dp:get_buildings("donjon") > 0 then return false end
252 if #dp:get_buildings("barrier") > 0 then return false end
253 if #dp:get_buildings("sentry") > 0 then return false end
254 if #dp:get_buildings("warehouse") > 0 then return false end
255 return true
256end
257
234function kalitath()258function kalitath()
235 -- While no contact with kalithat259 -- While no contact with kalithat
236 local map = wl.Game().map260 local map = game.map
237 while not (261 while not (
238 p1:seen_field(map:get_field( 92, 91)) or262 p1:seen_field(map:get_field( 92, 91)) or
239 p1:seen_field(map:get_field(102, 103)) or263 p1:seen_field(map:get_field(102, 103)) or
@@ -242,18 +266,22 @@
242 p1:seen_field(map:get_field(103, 17)) or266 p1:seen_field(map:get_field(103, 17)) or
243 p1:seen_field(map:get_field( 96, 30))267 p1:seen_field(map:get_field( 96, 30))
244 )268 )
245 do sleep(7834) end269 do sleep(7829) end
270 -- "explore further" is done
271 exploration_objective.done = true
246272
247 send_msg(order_msg_7_destroy_kalitaths_army)273 send_msg(order_msg_7_destroy_kalitaths_army)
248 local o = add_obj(obj_destroy_kalitaths_army)274 local o = add_obj(obj_destroy_kalitaths_army)
249275
250 while not p2.defeated do sleep(7837) end276 while not check_player_completely_defeated(p2) do
277 sleep(7837)
278 end
251 o.done = true279 o.done = true
252end280end
253281
254function renegade_fortresses()282function renegade_fortresses()
255 -- Wait till we see the fortresses283 -- Wait till we see the fortresses
256 local map = wl.Game().map284 local map = game.map
257 while not (285 while not (
258 p1:seen_field(map:get_field(111, 88 )) or286 p1:seen_field(map:get_field(111, 88 )) or
259 p1:seen_field(map:get_field(110, 97 )) or287 p1:seen_field(map:get_field(110, 97 )) or
@@ -262,7 +290,7 @@
262 p1:seen_field(map:get_field(114, 14 )) or290 p1:seen_field(map:get_field(114, 14 )) or
263 p1:seen_field(map:get_field(116, 21 ))291 p1:seen_field(map:get_field(116, 21 ))
264 )292 )
265 do sleep(6834) end293 do sleep(6833) end
266294
267 prefilled_buildings(p1,295 prefilled_buildings(p1,
268 {"barrier", 118, 100, soldiers =296 {"barrier", 118, 100, soldiers =
@@ -285,18 +313,21 @@
285 local o = add_obj(obj_military_assault_on_althunran)313 local o = add_obj(obj_military_assault_on_althunran)
286314
287 timed_scroll(array_reverse(pts))315 timed_scroll(array_reverse(pts))
288 sleep(500)316 sleep(503)
289317
290 while not (p3.defeated and p4.defeated) do318 while not (check_player_completely_defeated(p3) and check_player_completely_defeated(p4)) do
291 sleep(6734)319 sleep(6733)
292 end320 end
293321
294 o.done = true322 o.done = true
295end323end
296324
297function mission_complete()325function mission_complete()
298 local map = wl.Game().map326 local map = game.map
299 while not (p2.defeated and p3.defeated and p4.defeated) do327 while not (
328 check_player_completely_defeated(p2) and
329 check_player_completely_defeated(p3) and
330 check_player_completely_defeated(p4)) do
300 sleep(8923)331 sleep(8923)
301 end332 end
302333

Subscribers

People subscribed via source and target branches

to status/vote changes: