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
1=== modified file 'campaigns/t03.wmf/scripting/mission_thread.lua'
2--- campaigns/t03.wmf/scripting/mission_thread.lua 2014-03-15 13:36:42 +0000
3+++ campaigns/t03.wmf/scripting/mission_thread.lua 2014-07-21 14:49:19 +0000
4@@ -2,11 +2,22 @@
5 -- Various mission threads
6 -- =======================================================================
7
8+game = wl.Game()
9 -- Mountain and frontier fields
10-mountain = wl.Game().map:get_field(71,14)
11-fr1 = wl.Game().map:get_field(81,108)
12-fr2 = wl.Game().map:get_field(85,1)
13-fr3 = wl.Game().map:get_field(85,11)
14+mountain = game.map:get_field(71,14)
15+fr1 = game.map:get_field(81,108)
16+fr2 = game.map:get_field(85,1)
17+fr3 = game.map:get_field(85,11)
18+
19+function check_conquered_footprints()
20+ if p1:seen_field(game.map:get_field(65, 28))
21+ then
22+ sleep(2129)
23+ if p1:sees_field(game.map:get_field(65, 28))
24+ then return true end
25+ end
26+ return false
27+end
28
29 function remember_cattlefarm()
30 sleep(100)
31@@ -16,7 +27,7 @@
32 p1:allow_buildings{"cattlefarm"}
33 local o = add_obj(obj_build_cattlefarm)
34 while not check_for_buildings(p1, {cattlefarm = 1}) do
35- sleep(1234) end
36+ sleep(1223) end
37 o.done = true
38
39 end
40@@ -36,7 +47,9 @@
41 "farm",
42 "well",
43 "bakery",
44+ "sentry",
45 }
46+
47 local o = add_obj(obj_build_small_food_economy)
48 while not check_for_buildings(p1, {
49 fishers_hut = 1,
50@@ -44,7 +57,7 @@
51 well = 1,
52 farm = 1,
53 bakery = 1,
54- }) do sleep(3412) end
55+ }) do sleep(3413) end
56 o.done = true
57 send_msg(story_note_1)
58
59@@ -54,22 +67,22 @@
60
61 function foottracks()
62 -- Hunter build and some time passed or expanded east
63- local game = wl.Game()
64 while true do
65- if (game.time > 900000 and #p1:get_buildings("hunters_hut") > 0)
66- or p1:seen_field(wl.Game().map:get_field(65, 28))
67+ if game.time > 900000 and #p1:get_buildings("hunters_hut") > 0
68+ then break end
69+ if check_conquered_footprints()
70 then break end
71 sleep(4239)
72 end
73
74 local fields = array_combine(
75- wl.Game().map:get_field(67, 19):region(2),
76- wl.Game().map:get_field(65, 19):region(2),
77- wl.Game().map:get_field(69, 18):region(2)
78+ game.map:get_field(67, 19):region(2),
79+ game.map:get_field(65, 19):region(2),
80+ game.map:get_field(69, 18):region(2)
81 )
82 p1:reveal_fields(fields)
83
84- local pts = scroll_smoothly_to(wl.Game().map:get_field(67,19))
85+ local pts = scroll_smoothly_to(game.map:get_field(67,19))
86
87 send_msg(order_msg_2_build_a_donjon)
88 local o = add_obj(obj_build_a_donjon)
89@@ -79,13 +92,14 @@
90 timed_scroll(array_reverse(pts), 10)
91
92 -- Hide the tracks again
93- sleep(5000)
94+ sleep(5003)
95 p1:hide_fields(fields)
96
97 while not check_for_buildings(p1, {donjon=1}) do sleep(2341) end
98 o.done = true
99 send_msg(order_msg_3_explore_further)
100- 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)
103
104 p1:allow_buildings{"sentry", "barrier"}
105
106@@ -99,7 +113,6 @@
107
108 sleep(3244)
109 end
110- o.done = true
111 end
112
113 function mining_and_trainingsites()
114@@ -107,12 +120,12 @@
115
116 -- Show the other mountains permanently
117 p1:reveal_fields(array_combine(
118- wl.Game().map:get_field(77, 98):region(7),
119- wl.Game().map:get_field(79, 6):region(5),
120- wl.Game().map:get_field(82, 20):region(6))
121+ game.map:get_field(77, 98):region(7),
122+ game.map:get_field(79, 6):region(5),
123+ game.map:get_field(82, 20):region(6))
124 )
125
126- local pts = scroll_smoothly_to(wl.Game().map:get_field(82,20))
127+ local pts = scroll_smoothly_to(game.map:get_field(82,20))
128
129 send_msg(order_msg_4_build_mining_economy)
130 local o = add_obj(obj_build_mining_economy)
131@@ -125,6 +138,7 @@
132 "smelting_works",
133 "metalworks",
134 "burners_house",
135+ "micro-brewery",
136 }
137
138 timed_scroll(array_reverse(pts), 10)
139@@ -163,7 +177,6 @@
140 "deeper_goldmine",
141 "deeper_oremine",
142 "warehouse",
143- "micro-brewery",
144 "brewery",
145 }
146 run(check_warehouse_obj, add_obj(obj_build_a_warehouse))
147@@ -215,10 +228,10 @@
148 function expansion()
149 -- While enemy has not been seen
150 while not (
151- p1:seen_field(wl.Game().map:get_field(95, 91)) or
152- p1:seen_field(wl.Game().map:get_field(96, 107)) or
153- p1:seen_field(wl.Game().map:get_field(96, 8)) or
154- p1:seen_field(wl.Game().map:get_field(96, 19))
155+ p1:seen_field(game.map:get_field(95, 91)) or
156+ p1:seen_field(game.map:get_field(96, 107)) or
157+ p1:seen_field(game.map:get_field(96, 8)) or
158+ p1:seen_field(game.map:get_field(96, 19))
159 )
160 do sleep(8374) end
161
162@@ -231,9 +244,20 @@
163 send_msg(story_msg_6)
164 end
165
166+-- checks if all military buildings are drestroyed (the build-in function "defeated" only checks if all warehouses are destroyed)
167+function check_player_completely_defeated(dp)
168+ if #dp:get_buildings("fortress") > 0 then return false end
169+ if #dp:get_buildings("citadel") > 0 then return false end
170+ if #dp:get_buildings("donjon") > 0 then return false end
171+ if #dp:get_buildings("barrier") > 0 then return false end
172+ if #dp:get_buildings("sentry") > 0 then return false end
173+ if #dp:get_buildings("warehouse") > 0 then return false end
174+ return true
175+end
176+
177 function kalitath()
178 -- While no contact with kalithat
179- local map = wl.Game().map
180+ local map = game.map
181 while not (
182 p1:seen_field(map:get_field( 92, 91)) or
183 p1:seen_field(map:get_field(102, 103)) or
184@@ -242,18 +266,22 @@
185 p1:seen_field(map:get_field(103, 17)) or
186 p1:seen_field(map:get_field( 96, 30))
187 )
188- do sleep(7834) end
189+ do sleep(7829) end
190+ -- "explore further" is done
191+ exploration_objective.done = true
192
193 send_msg(order_msg_7_destroy_kalitaths_army)
194 local o = add_obj(obj_destroy_kalitaths_army)
195
196- while not p2.defeated do sleep(7837) end
197+ while not check_player_completely_defeated(p2) do
198+ sleep(7837)
199+ end
200 o.done = true
201 end
202
203 function renegade_fortresses()
204 -- Wait till we see the fortresses
205- local map = wl.Game().map
206+ local map = game.map
207 while not (
208 p1:seen_field(map:get_field(111, 88 )) or
209 p1:seen_field(map:get_field(110, 97 )) or
210@@ -262,7 +290,7 @@
211 p1:seen_field(map:get_field(114, 14 )) or
212 p1:seen_field(map:get_field(116, 21 ))
213 )
214- do sleep(6834) end
215+ do sleep(6833) end
216
217 prefilled_buildings(p1,
218 {"barrier", 118, 100, soldiers =
219@@ -285,18 +313,21 @@
220 local o = add_obj(obj_military_assault_on_althunran)
221
222 timed_scroll(array_reverse(pts))
223- sleep(500)
224+ sleep(503)
225
226- while not (p3.defeated and p4.defeated) do
227- sleep(6734)
228+ while not (check_player_completely_defeated(p3) and check_player_completely_defeated(p4)) do
229+ sleep(6733)
230 end
231
232 o.done = true
233 end
234
235 function mission_complete()
236- local map = wl.Game().map
237- while not (p2.defeated and p3.defeated and p4.defeated) do
238+ local map = game.map
239+ while not (
240+ check_player_completely_defeated(p2) and
241+ check_player_completely_defeated(p3) and
242+ check_player_completely_defeated(p4)) do
243 sleep(8923)
244 end
245

Subscribers

People subscribed via source and target branches

to status/vote changes: