Merge lp:~widelands-dev/widelands/reveal_hide_animations into lp:widelands
- reveal_hide_animations
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8543 |
Proposed branch: | lp:~widelands-dev/widelands/reveal_hide_animations |
Merge into: | lp:widelands |
Prerequisite: | lp:~widelands-dev/widelands/bug-1687100-reveal_fields |
Diff against target: |
784 lines (+283/-107) 22 files modified
data/campaigns/bar01.wmf/scripting/init.lua (+1/-0) data/campaigns/bar01.wmf/scripting/mission_thread.lua (+8/-3) data/campaigns/bar01.wmf/scripting/texts.lua (+0/-3) data/campaigns/bar02.wmf/scripting/mission_thread.lua (+21/-9) data/campaigns/bar02.wmf/scripting/texts.lua (+1/-0) data/campaigns/emp01.wmf/scripting/mission_thread.lua (+10/-6) data/campaigns/emp02.wmf/scripting/mission_thread.lua (+11/-12) data/campaigns/emp02.wmf/scripting/texts.lua (+5/-0) data/campaigns/emp03.wmf/scripting/helper_functions.lua (+0/-53) data/campaigns/emp03.wmf/scripting/mission_thread.lua (+6/-5) data/campaigns/tutorial01_basic_control.wmf/scripting/init.lua (+1/-0) data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua (+1/-0) data/campaigns/tutorial02_warfare.wmf/scripting/init.lua (+1/-0) data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua (+1/-0) data/campaigns/tutorial03_seafaring.wmf/scripting/init.lua (+1/-0) data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua (+2/-0) data/campaigns/tutorial04_economy.wmf/scripting/init.lua (+1/-0) data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua (+6/-2) data/campaigns/tutorial04_economy.wmf/scripting/starting_conditions.lua (+23/-10) data/scripting/field_animations.lua (+173/-0) data/scripting/infrastructure.lua (+4/-1) src/scripting/lua_game.cc (+6/-3) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/reveal_hide_animations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GunChleoc | Approve | ||
Review via email: mp+327062@code.launchpad.net |
Commit message
Adding lua-animations for reveal/hide fields; Adjusted Tutorials and Campaigns to use it.
Description of the change
Added a file "field_
- Added RST documentation for the functions
- Adjusted all tutorials and campaigns to use the animations. The animations are used mostly when a game is started.
- Modified campaign emp03 which uses prior the initial implementations to use now the new ones. In this campaign i have also removed a useless animation.
Prerequisite branch is https:/
For testing one has to compile https:/
bunnybot (widelandsofficial) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
A couple of nits, code LGTM otherwise. Needs testing.
kaputtnik (franku) wrote : | # |
Many thanks for the review :-)
Regarding the use of 'local' i added local to the other variables too and tested this.
Of course i have tested all the changes, but having an additional test is better.
GunChleoc (gunchleoc) wrote : | # |
I have done some testing now, so this is ready to go in as soon as somebody does a code review on the prerequisite branch.
hessenfarmer (stephan-lutz) wrote : | # |
I'm not happy with the code changes in empire 03 mission.
1. I wanted intentionally to reveal more land around the ruin of the fortress as already seen by the player, like if theres has been send a scout or an intelligence agent.
2. the line to hide the region around the starting filed is absolutely intentional as otherwise it would just reveal it and not in aconcentric way due to the sight of the HQ is exactly the radius for the concentric reveal. but concentric fits better to the story of lifting the fog after a hard storm.
kaputtnik (franku) wrote : | # |
> 1. I wanted intentionally to reveal more land around the ruin of the
> fortress as already seen by the player,
When playtesting i found that revealing randomly has not really an effect because most of the fields are already seen by the player. Additionally calling reveal_randomly() do now hide the fields automatically before revealing. So after discovering the key-field some parts get hidden and immediately revealed again. That looked not good.
But you are right, revealing some more fields around the ruin is better -> I used the standard function reveal_fields() now (https:/
> 2. the line to hide the region around the starting filed is absolutely intentional
All reveal_* functions do now hide the given region automatically before revealing. I have implemented this to prevent typing each time two lines of code (1. hide, 2. reveal). This is much easier to use now. So calling hide_fields() isn't needed there. This is tested and revealing in a concentric way do work as expected.
kaputtnik (franku) wrote : | # |
I have played the empire3 campaign until the end and i think all looks good now :-)
GunChleoc (gunchleoc) wrote : | # |
Code still LGTM. @hessenfarmer, would you give it another spin to see if you're happy?
hessenfarmer (stephan-lutz) wrote : | # |
Thanks kaputtnik for the explanations.
I did not know about your new code to hide automatically before reveal and I'm fully happy with the standard reveal function regarding the ruins. If you kaputtnik playtested it, I believe in your experience as an artist that it looks good ;-). Many thanks for the animations anyhow. They fit so well in the storyline of empire mission 3.
So from my side it should be fine now and I can keep with my new hobby (playtesting frisian tribe).
Off topic:
I'm working on a new scenario (maybe empire 4). shall I create a new bug for the wishlist to possibly share ideas and files with the dev team? I probably need some special coding and some advice on different topics.
kaputtnik (franku) wrote : | # |
Yes, add a new bug/whishlist for an empire4, or whatever, campaign.
I would love to see the campaigns growing :-)
GunChleoc (gunchleoc) wrote : | # |
Yes, a new bug is best for technical discussion. We can open a forum topic later, when the scenario has advanced enough for playtesting.
SirVer (sirver) wrote : | # |
What is the status of this branch? Is it ready for reviewing?
kaputtnik (franku) wrote : | # |
Gun did the review already, but reviewing by a another person can't be wrong.
Before merging this branch the prerequisite branch needs reviewing and merged: https:/
GunChleoc (gunchleoc) wrote : | # |
Given that we're short-handed on code reviewers, I'd rather you just reviewed the other branch: https:/
It's a prerequisite for this branch, which is providing the datadir for the other branch.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2703. State: failed. Details: https:/
Appveyor build 2518. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2730. State: passed. Details: https:/
Appveyor build 2542. State: failed. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2777. State: passed. Details: https:/
Appveyor build 2589. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
I just had a merge conflict while merging trunk. @kaputtnik, could you please check if the documentation for lua_map is still OK and then merge?
kaputtnik (franku) wrote : | # |
Looks good :-)
@bunnybot merge
Preview Diff
1 | === modified file 'data/campaigns/bar01.wmf/scripting/init.lua' |
2 | --- data/campaigns/bar01.wmf/scripting/init.lua 2016-12-27 23:04:02 +0000 |
3 | +++ data/campaigns/bar01.wmf/scripting/init.lua 2017-12-19 17:04:59 +0000 |
4 | @@ -8,6 +8,7 @@ |
5 | include "scripting/objective_utils.lua" |
6 | include "scripting/infrastructure.lua" |
7 | include "scripting/messages.lua" |
8 | +include "scripting/field_animations.lua" |
9 | |
10 | -- ========== |
11 | -- Constants |
12 | |
13 | === modified file 'data/campaigns/bar01.wmf/scripting/mission_thread.lua' |
14 | --- data/campaigns/bar01.wmf/scripting/mission_thread.lua 2016-12-29 10:31:07 +0000 |
15 | +++ data/campaigns/bar01.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
16 | @@ -15,15 +15,20 @@ |
17 | -- ===================================================== |
18 | |
19 | function introduction_thread() |
20 | + reveal_concentric(plr, sf, 13) |
21 | sleep(2000) |
22 | |
23 | message_box_objective(plr, briefing_msg_01) |
24 | -- these buildings are still burning, but only for a while |
25 | map:place_immovable("destroyed_building",map:get_field(7,41),"tribes") |
26 | map:place_immovable("destroyed_building",map:get_field(5,52),"tribes") |
27 | - plr:reveal_fields(al_thunran:region(8)) |
28 | + scroll_to_field(al_thunran) |
29 | + reveal_concentric(plr, al_thunran, 8, true, 50) |
30 | message_box_objective(plr, briefing_msg_02) -- Al'thunran |
31 | - plr:reveal_fields(grave:region(4)) |
32 | + scroll_to_field(sf) |
33 | + sleep(1000) |
34 | + scroll_to_field(grave) |
35 | + reveal_concentric(plr, grave, 4) |
36 | message_box_objective(plr, briefing_msg_03) -- grave, Boldreth |
37 | message_box_objective(plr, briefing_msg_04) -- wait |
38 | -- introduction of Khantrukh |
39 | @@ -52,8 +57,8 @@ |
40 | |
41 | -- Reveal the rocks |
42 | local rocks = wl.Game().map:get_field(27, 48) |
43 | - plr:reveal_fields(rocks:region(6)) |
44 | local prior_center = scroll_to_field(rocks) |
45 | + reveal_concentric(plr, rocks, 5) |
46 | message_box_objective(plr, order_msg_3) |
47 | obj = add_campaign_objective(obj_claim_northeastern_rocks) |
48 | message_box_objective(plr, order_msg_4) |
49 | |
50 | === modified file 'data/campaigns/bar01.wmf/scripting/texts.lua' |
51 | --- data/campaigns/bar01.wmf/scripting/texts.lua 2016-11-30 20:07:08 +0000 |
52 | +++ data/campaigns/bar01.wmf/scripting/texts.lua 2017-12-19 17:04:59 +0000 |
53 | @@ -172,9 +172,7 @@ |
54 | .. paragraphdivider() .. |
55 | -- TRANSLATORS: Thron |
56 | _[[The red lights flash in the darkness and dance to the rhythm of the war drums that haunt me even in my nightmares.]]), |
57 | - field = al_thunran, |
58 | position = "topleft", |
59 | - scroll_back = true |
60 | } |
61 | |
62 | |
63 | @@ -186,7 +184,6 @@ |
64 | .. paragraphdivider() .. |
65 | -- TRANSLATORS: Thron |
66 | _[[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.]]), |
67 | - field = grave, |
68 | position = "topleft", |
69 | } |
70 | |
71 | |
72 | === modified file 'data/campaigns/bar02.wmf/scripting/mission_thread.lua' |
73 | --- data/campaigns/bar02.wmf/scripting/mission_thread.lua 2017-01-17 08:52:14 +0000 |
74 | +++ data/campaigns/bar02.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
75 | @@ -3,13 +3,17 @@ |
76 | -- ======================================================================= |
77 | |
78 | include "scripting/messages.lua" |
79 | +include "scripting/field_animations.lua" |
80 | |
81 | -game = wl.Game() |
82 | +local game = wl.Game() |
83 | -- Mountain and frontier fields |
84 | -mountain = game.map:get_field(71,14) |
85 | -fr1 = game.map:get_field(81,108) |
86 | -fr2 = game.map:get_field(85,1) |
87 | -fr3 = game.map:get_field(85,11) |
88 | +local mountain = game.map:get_field(71,14) |
89 | +local fr1 = game.map:get_field(81,108) |
90 | +local fr2 = game.map:get_field(85,1) |
91 | +local fr3 = game.map:get_field(85,11) |
92 | + |
93 | +-- Starting field |
94 | +local sf = game.map.player_slots[1].starting_field |
95 | |
96 | function check_conquered_footprints() |
97 | if p1:seen_field(game.map:get_field(65, 28)) |
98 | @@ -35,6 +39,7 @@ |
99 | end |
100 | |
101 | function initial_message_and_small_food_economy() |
102 | + reveal_concentric(p1, sf, 13) |
103 | wake_me(2000) |
104 | campaign_message_box(story_msg_1) |
105 | |
106 | @@ -95,10 +100,17 @@ |
107 | game.map:get_field(65, 19):region(2), |
108 | game.map:get_field(69, 18):region(2) |
109 | ) |
110 | - p1:reveal_fields(fields) |
111 | - |
112 | - local prior_center = scroll_to_field(game.map:get_field(67,19)) |
113 | - |
114 | + |
115 | + p1:hide_fields(fields) |
116 | + local prior_center = scroll_to_field(game.map:get_field(65,19)) |
117 | + -- reveal the tracks one by one from right to left |
118 | + sleep(1000) |
119 | + reveal_concentric(p1, game.map:get_field(69, 19), 1, false) |
120 | + sleep(1000) |
121 | + reveal_concentric(p1, game.map:get_field(67, 19), 1, false) |
122 | + sleep(1000) |
123 | + reveal_concentric(p1, game.map:get_field(65, 19), 1, false) |
124 | + sleep(1000) |
125 | campaign_message_box(order_msg_2_build_a_tower) |
126 | local o = add_campaign_objective(obj_build_a_tower) |
127 | p1:forbid_buildings{"barbarians_sentry"} |
128 | |
129 | === modified file 'data/campaigns/bar02.wmf/scripting/texts.lua' |
130 | --- data/campaigns/bar02.wmf/scripting/texts.lua 2017-06-25 06:54:53 +0000 |
131 | +++ data/campaigns/bar02.wmf/scripting/texts.lua 2017-12-19 17:04:59 +0000 |
132 | @@ -259,6 +259,7 @@ |
133 | |
134 | order_msg_2_build_a_tower = { |
135 | posy = 1, |
136 | + posx = 1, |
137 | title = _"Tracks", |
138 | body = boldreth(_"Boldreth says:", |
139 | -- TRANSLATORS: Boldreth |
140 | |
141 | === modified file 'data/campaigns/emp01.wmf/scripting/mission_thread.lua' |
142 | --- data/campaigns/emp01.wmf/scripting/mission_thread.lua 2017-05-09 05:47:20 +0000 |
143 | +++ data/campaigns/emp01.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
144 | @@ -1,30 +1,34 @@ |
145 | include "scripting/messages.lua" |
146 | include "map:scripting/helper_functions.lua" |
147 | +include "scripting/field_animations.lua" |
148 | |
149 | function mission_thread() |
150 | sleep(1000) |
151 | |
152 | -- Initial messages |
153 | local sea = wl.Game().map:get_field(50,25) |
154 | + local ship = p1:place_ship(sea) |
155 | + p1:hide_fields(sea:region(6),true) |
156 | scroll_to_field(sea,0) |
157 | |
158 | campaign_message_box(diary_page_1) |
159 | sleep(200) |
160 | |
161 | -- Show the sea |
162 | - p1:reveal_fields(sea:region(6)) |
163 | - local ship = p1:place_ship(sea) |
164 | + reveal_concentric(p1, sea, 5) |
165 | sleep(1000) |
166 | campaign_message_box(diary_page_2) |
167 | - -- Hide the sea after 2 seconds |
168 | - run(function() sleep(2000) p1:hide_fields(sea:region(6), true) end) |
169 | + sleep(500) |
170 | + hide_concentric(p1, sea, 5) |
171 | + ship:remove() |
172 | |
173 | -- Back home |
174 | include "map:scripting/starting_conditions.lua" |
175 | + p1:hide_fields(wl.Game().map.player_slots[1].starting_field:region(13),true) |
176 | scroll_to_field(wl.Game().map.player_slots[1].starting_field) |
177 | campaign_message_box(diary_page_3) |
178 | - ship:remove() |
179 | - |
180 | + sleep(1000) |
181 | + reveal_concentric(p1, wl.Game().map.player_slots[1].starting_field, 13) |
182 | sleep(400) |
183 | |
184 | -- Check for trees and remove them |
185 | |
186 | === modified file 'data/campaigns/emp02.wmf/scripting/mission_thread.lua' |
187 | --- data/campaigns/emp02.wmf/scripting/mission_thread.lua 2017-03-16 21:54:07 +0000 |
188 | +++ data/campaigns/emp02.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
189 | @@ -3,8 +3,10 @@ |
190 | -- ======================================================================= |
191 | |
192 | include "scripting/messages.lua" |
193 | +include "scripting/field_animations.lua" |
194 | |
195 | function building_materials() |
196 | + reveal_concentric(p1, wl.Game().map.player_slots[1].starting_field, 13) |
197 | sleep(1000) |
198 | campaign_message_box(diary_page_5) |
199 | |
200 | @@ -111,16 +113,15 @@ |
201 | -- Reveal the other mountains |
202 | local coal_mountain = wl.Game().map:get_field(49,22) |
203 | local iron_mountain = wl.Game().map:get_field(38,37) |
204 | - p1:reveal_fields(coal_mountain:region(6)) |
205 | + |
206 | + wait_for_roadbuilding_and_scroll(coal_mountain) |
207 | + reveal_concentric(p1, coal_mountain, 6, false) |
208 | p1:reveal_fields(iron_mountain:region(6)) |
209 | run(function() sleep(5000) |
210 | p1:hide_fields(coal_mountain:region(6)) |
211 | p1:hide_fields(iron_mountain:region(6)) |
212 | end) |
213 | |
214 | - local move_point = wl.Game().map:get_field(49,22) |
215 | - wait_for_roadbuilding_and_scroll(move_point) |
216 | - |
217 | campaign_message_box(saledus_3) |
218 | p1:allow_buildings{ |
219 | "empire_coalmine", |
220 | @@ -166,13 +167,11 @@ |
221 | function expand_and_build_marblemine() |
222 | sleep(40000) |
223 | |
224 | + -- Move to the shipparts |
225 | local shipparts = wl.Game().map:get_field(15,46) |
226 | - p1:reveal_fields(shipparts:region(5)) |
227 | + local prior_center = wait_for_roadbuilding_and_scroll(wl.Game().map:get_field(12,43)) |
228 | + reveal_concentric(p1, shipparts, 5) |
229 | run(function() sleep(10000) p1:hide_fields(shipparts:region(5)) end) |
230 | - |
231 | - -- Move to the shipparts |
232 | - local prior_center = wait_for_roadbuilding_and_scroll(shipparts) |
233 | - |
234 | campaign_message_box(saledus_1) |
235 | local o = add_campaign_objective(obj_build_military_buildings) |
236 | p1:allow_buildings{"empire_blockhouse", "empire_sentry"} |
237 | @@ -186,11 +185,11 @@ |
238 | |
239 | -- Marble Mountains |
240 | local marblemountains = wl.Game().map:get_field(35,19) |
241 | - p1:reveal_fields(marblemountains:region(5)) |
242 | + |
243 | + prior_center = wait_for_roadbuilding_and_scroll(marblemountains) |
244 | + reveal_concentric(p1, marblemountains, 5, false) |
245 | run(function() sleep(10000) p1:hide_fields(marblemountains:region(5)) end) |
246 | |
247 | - prior_center = wait_for_roadbuilding_and_scroll(marblemountains) |
248 | - |
249 | campaign_message_box(saledus_2) |
250 | p1:allow_buildings{"empire_marblemine", "empire_marblemine_deep"} |
251 | o = add_campaign_objective(obj_build_marblemine) |
252 | |
253 | === modified file 'data/campaigns/emp02.wmf/scripting/texts.lua' |
254 | --- data/campaigns/emp02.wmf/scripting/texts.lua 2017-01-05 21:38:03 +0000 |
255 | +++ data/campaigns/emp02.wmf/scripting/texts.lua 2017-12-19 17:04:59 +0000 |
256 | @@ -160,6 +160,7 @@ |
257 | |
258 | saledus_1 = { |
259 | title =_ "Dangerous Ship Parts", |
260 | + posx = 1, |
261 | posy = 1, |
262 | body= saledus(_"Saledus looks unhappy", |
263 | -- TRANSLATORS: Saledus |
264 | @@ -174,6 +175,8 @@ |
265 | } |
266 | |
267 | saledus_2 = { |
268 | + posx = 1, |
269 | + posy = 1, |
270 | title =_ "Marble on the Mountain", |
271 | body= saledus(_"Saledus smiles", |
272 | -- TRANSLATORS: Saledus |
273 | @@ -188,6 +191,8 @@ |
274 | } |
275 | |
276 | saledus_3 = { |
277 | + posx = 1, |
278 | + posy = 1, |
279 | title =_ "Further Mountains", |
280 | body= saledus(_"Saledus is excited", |
281 | -- TRANSLATORS: Saledus |
282 | |
283 | === modified file 'data/campaigns/emp03.wmf/scripting/helper_functions.lua' |
284 | --- data/campaigns/emp03.wmf/scripting/helper_functions.lua 2017-05-16 10:16:22 +0000 |
285 | +++ data/campaigns/emp03.wmf/scripting/helper_functions.lua 2017-12-19 17:04:59 +0000 |
286 | @@ -62,56 +62,3 @@ |
287 | end |
288 | return rv |
289 | end |
290 | - |
291 | -function concentric_reveal(plr, center, max_radius, delay) |
292 | - if not delay then delay = 100 end |
293 | - local steps = 0 |
294 | - while steps < max_radius do |
295 | - plr:reveal_fields(center:region(steps)) |
296 | - steps = steps + 1 |
297 | - sleep(delay) |
298 | - end |
299 | -end |
300 | - |
301 | -function concentric_hide(plr, center, max_radius, delay) |
302 | - if not delay then delay = 100 end |
303 | - while max_radius > 0 do |
304 | - local to_hide = center:region(max_radius, max_radius - 1) |
305 | - plr:hide_fields(to_hide, true) |
306 | - sleep(delay) |
307 | - max_radius = max_radius -1 |
308 | - end |
309 | - -- Hide the remaining field |
310 | - plr:hide_fields({center},true) |
311 | -end |
312 | - |
313 | -function random_reveal(plr, region, time) |
314 | - -- if no time is given the default '1000' (1 sec) is used |
315 | - if not time then time = 1000 end |
316 | - -- Calculate the sleep time as an integer |
317 | - delay = math.floor(time / #region) |
318 | - -- Create a table with randomized fields |
319 | - -- This is done for efficiency reasons |
320 | - rand_tbl = {} |
321 | - while #region > 0 do |
322 | - f = math.random(1, #region) |
323 | - table.insert(rand_tbl, region[f]) |
324 | - table.remove(region, f) |
325 | - end |
326 | - --reveal field by field: |
327 | - for i, f in ipairs(rand_tbl) do |
328 | - plr:reveal_fields({f}) |
329 | - sleep(delay) |
330 | - end |
331 | -end |
332 | - |
333 | -function random_hide(plr, region, time) |
334 | - if not time then time = 1000 end |
335 | - delay = math.floor(time / #region) |
336 | - while #region > 0 do |
337 | - f = math.random(1, #region) |
338 | - plr:hide_fields({region[f]}, true) |
339 | - table.remove(region, f) |
340 | - sleep(delay) |
341 | - end |
342 | -end |
343 | |
344 | === modified file 'data/campaigns/emp03.wmf/scripting/mission_thread.lua' |
345 | --- data/campaigns/emp03.wmf/scripting/mission_thread.lua 2017-05-17 09:03:50 +0000 |
346 | +++ data/campaigns/emp03.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
347 | @@ -1,5 +1,7 @@ |
348 | include "scripting/messages.lua" |
349 | include "map:scripting/helper_functions.lua" |
350 | +include "scripting/field_animations.lua" |
351 | + |
352 | |
353 | -- Some objectives need to be waited for in separate threads |
354 | local obj_build_port_and_shipyard_done = false |
355 | @@ -276,7 +278,7 @@ |
356 | while not p1:sees_field(ruins) do sleep(3000) end |
357 | scroll_to_field(ruin_fortress,5) |
358 | sleep(500) |
359 | - random_reveal(p1, ruin_fortress:region(5), 1000) |
360 | + p1:reveal_fields(ruin_fortress:region(5)) |
361 | sleep(500) |
362 | campaign_message_box(saledus_12) |
363 | |
364 | @@ -307,7 +309,7 @@ |
365 | campaign_message_box(diary_page_1) |
366 | |
367 | -- Show the sea |
368 | - random_reveal(p1, sea:region(5), 1000) |
369 | + reveal_randomly(p1, sea:region(5), 1000) |
370 | sleep(100) |
371 | local ship = p1:place_ship(sea) |
372 | sleep(2500) |
373 | @@ -317,15 +319,14 @@ |
374 | sleep(400) |
375 | ship:remove() |
376 | sleep(300) |
377 | - random_hide(p1, sea:region(6), 1000) |
378 | + hide_randomly(p1, sea:region(6), 1000) |
379 | sleep(300) |
380 | |
381 | -- Scroll to the place where the ship is finally stranded |
382 | scroll_to_field(sf) |
383 | -- Now we place the shipwreck headquarters and fill it with workers and wares |
384 | include "map:scripting/starting_conditions.lua" |
385 | - p1:hide_fields(sf:region(13), true) |
386 | - concentric_reveal(p1, sf, 13, 100) |
387 | + reveal_concentric(p1, sf, 13, 100) |
388 | campaign_message_box(diary_page_3) |
389 | sleep(400) |
390 | campaign_message_box(saledus) |
391 | |
392 | === modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/init.lua' |
393 | --- data/campaigns/tutorial01_basic_control.wmf/scripting/init.lua 2016-01-28 05:24:34 +0000 |
394 | +++ data/campaigns/tutorial01_basic_control.wmf/scripting/init.lua 2017-12-19 17:04:59 +0000 |
395 | @@ -10,6 +10,7 @@ |
396 | include "scripting/messages.lua" |
397 | include "scripting/table.lua" |
398 | include "scripting/ui.lua" |
399 | +include "scripting/field_animations.lua" |
400 | |
401 | -- Constants |
402 | sf = map.player_slots[1].starting_field |
403 | |
404 | === modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua' |
405 | --- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-12-29 10:31:07 +0000 |
406 | +++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
407 | @@ -3,6 +3,7 @@ |
408 | -- ================ |
409 | |
410 | function starting_infos() |
411 | + reveal_concentric(plr, sf, 13, true, 80) |
412 | map:place_immovable("debris00",second_quarry_field, "world") |
413 | -- so that the player cannot build anything here |
414 | |
415 | |
416 | === modified file 'data/campaigns/tutorial02_warfare.wmf/scripting/init.lua' |
417 | --- data/campaigns/tutorial02_warfare.wmf/scripting/init.lua 2016-01-28 05:24:34 +0000 |
418 | +++ data/campaigns/tutorial02_warfare.wmf/scripting/init.lua 2017-12-19 17:04:59 +0000 |
419 | @@ -11,6 +11,7 @@ |
420 | include "scripting/messages.lua" |
421 | include "scripting/table.lua" |
422 | include "scripting/ui.lua" |
423 | +include "scripting/field_animations.lua" |
424 | |
425 | include "map:scripting/starting_conditions.lua" |
426 | |
427 | |
428 | === modified file 'data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua' |
429 | --- data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua 2017-06-19 05:53:03 +0000 |
430 | +++ data/campaigns/tutorial02_warfare.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
431 | @@ -3,6 +3,7 @@ |
432 | -- ================ |
433 | |
434 | function intro() |
435 | + reveal_concentric(plr, wl.Game().map:get_field(32, 59), 15) |
436 | sleep(1000) |
437 | message_box_objective(plr, introduction) |
438 | |
439 | |
440 | === modified file 'data/campaigns/tutorial03_seafaring.wmf/scripting/init.lua' |
441 | --- data/campaigns/tutorial03_seafaring.wmf/scripting/init.lua 2016-01-28 05:24:34 +0000 |
442 | +++ data/campaigns/tutorial03_seafaring.wmf/scripting/init.lua 2017-12-19 17:04:59 +0000 |
443 | @@ -12,6 +12,7 @@ |
444 | include "scripting/messages.lua" |
445 | include "scripting/table.lua" |
446 | include "scripting/ui.lua" |
447 | +include "scripting/field_animations.lua" |
448 | |
449 | sf = map.player_slots[1].starting_field |
450 | second_port_field = map:get_field(37, 27) |
451 | |
452 | === modified file 'data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua' |
453 | --- data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua 2016-10-23 11:31:25 +0000 |
454 | +++ data/campaigns/tutorial03_seafaring.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
455 | @@ -3,6 +3,8 @@ |
456 | -- =============== |
457 | |
458 | function introduction() |
459 | + fields = get_sees_fields(plr) |
460 | + reveal_randomly(plr, fields, 2000) |
461 | additional_port_space.terr = "summer_water" -- disable the port space |
462 | sleep(1000) |
463 | message_box_objective(plr, intro_south) |
464 | |
465 | === modified file 'data/campaigns/tutorial04_economy.wmf/scripting/init.lua' |
466 | --- data/campaigns/tutorial04_economy.wmf/scripting/init.lua 2016-01-28 05:24:34 +0000 |
467 | +++ data/campaigns/tutorial04_economy.wmf/scripting/init.lua 2017-12-19 17:04:59 +0000 |
468 | @@ -12,6 +12,7 @@ |
469 | include "scripting/messages.lua" |
470 | include "scripting/table.lua" |
471 | include "scripting/ui.lua" |
472 | +include "scripting/field_animations.lua" |
473 | |
474 | map = wl.Game().map |
475 | mv = wl.ui.MapView() |
476 | |
477 | === modified file 'data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua' |
478 | --- data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2017-01-21 21:10:21 +0000 |
479 | +++ data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2017-12-19 17:04:59 +0000 |
480 | @@ -3,7 +3,13 @@ |
481 | -- =============== |
482 | |
483 | function introduction() |
484 | + init_player() |
485 | + fields = get_sees_fields(plr) |
486 | + reveal_randomly(plr, fields, 2000) |
487 | + remaining_roads() |
488 | + |
489 | sleep(1000) |
490 | + |
491 | message_box_objective(plr, intro1) |
492 | message_box_objective(plr, intro2) |
493 | |
494 | @@ -156,6 +162,4 @@ |
495 | message_box_objective(plr, conclusion) |
496 | end |
497 | |
498 | - |
499 | -run(init_player) |
500 | run(introduction) |
501 | |
502 | === modified file 'data/campaigns/tutorial04_economy.wmf/scripting/starting_conditions.lua' |
503 | --- data/campaigns/tutorial04_economy.wmf/scripting/starting_conditions.lua 2016-11-01 13:58:24 +0000 |
504 | +++ data/campaigns/tutorial04_economy.wmf/scripting/starting_conditions.lua 2017-12-19 17:04:59 +0000 |
505 | @@ -138,30 +138,21 @@ |
506 | {"empire_fortress",71,66}, |
507 | {"empire_fortress",75,72} |
508 | ) |
509 | - plr:place_building("empire_quarry", map:get_field(87,36), true, true) -- a construction site |
510 | |
511 | plr:conquer(map:get_field(111,34),3) -- some remaining fields inside |
512 | |
513 | connected_road(plr,map:get_field(97,54).immovable,"tr,tr|tr,tl") |
514 | - connected_road(plr,map:get_field(98,52).immovable,"br,r|r,r|tr,r,tr|tr,r|r,r|tr,tr|tr,tr|tr,tr|r,r|r,r|r,r|br,br|r,r") |
515 | - connected_road(plr,map:get_field(99,53).immovable,"tr,tr|tr,tr|tl,tr|tr,tr|tr,tr|tr,tl|tl,tl|l,l|l,l|l,l|l,bl") |
516 | - connected_road(plr,map:get_field(97,54).immovable,"bl,br|br,bl,bl|bl,bl|bl,l|bl,bl|br,bl|bl,bl,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,tl|l,l|l,tl|tl,tl") |
517 | - connected_road(plr,map:get_field(97,56).immovable,"r,br|br,r|r,r|r,tr|r,r|br,br|br,r") |
518 | connected_road(plr,map:get_field(97,54).immovable,"l,l|l,tl|tl,tl|bl,l|l,bl") |
519 | connected_road(plr,map:get_field(88,49).immovable,"br,br|r,br") |
520 | connected_road(plr,map:get_field(92,51).immovable,"tr,tl|tr,tl,tl|tr,tr|tr,tr|tr,tr") |
521 | - connected_road(plr,map:get_field(94,42).immovable,"tl,l|tl,tl|l,l|l,tl,tl|tr,tr|tr,tr,tr") |
522 | connected_road(plr,map:get_field(75,73).immovable,"tr,tr|tr,r|tr,tr") |
523 | connected_road(plr,map:get_field(92,54).immovable,"tr,r") |
524 | connected_road(plr,map:get_field(93,58).immovable,"tr,tr|tr,tr") |
525 | - connected_road(plr,map:get_field(102,45).immovable,"br,r|br,r|br,bl,bl") |
526 | connected_road(plr,map:get_field(105,47).immovable,"tr,tl|r,r|br,r") |
527 | - connected_road(plr,map:get_field(116,44).immovable,"tr,tr|tr,tr|r,r") |
528 | connected_road(plr,map:get_field(105,45).immovable,"tr,tr|tr,tr|r,tr|tr,r|tr,tr|tr,tr|tr,tr|r,r|tr,tr|tr,tl|l,tl,tl|l,tl|l,tl,tl") |
529 | connected_road(plr,map:get_field(114,22).immovable,"br,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,bl|bl,l") |
530 | connected_road(plr,map:get_field(105,42).immovable,"br,r") |
531 | connected_road(plr,map:get_field(111,37).immovable,"br,r|r,br|bl,bl|bl,bl,bl") |
532 | - connected_road(plr,map:get_field(106,59).immovable,"bl,bl|bl,br|bl,bl|l,bl,bl|bl,br|br,br|r,r|br,bl|br,br|br,br,bl|l,l|bl,bl|l,tl|tl,tl|tl,tl|tr,tr,tr|tr,r") |
533 | connected_road(plr,map:get_field(100,78).immovable,"tr,r|r,r") |
534 | connected_road(plr,map:get_field(104,48).immovable,"r,tr") |
535 | connected_road(plr,map:get_field(105,52).immovable,"tr,tl") |
536 | @@ -169,4 +160,26 @@ |
537 | connected_road(plr,map:get_field(112,32).immovable,"l,l") |
538 | connected_road(plr,map:get_field(115,25).immovable,"bl,bl") |
539 | connected_road(plr,map:get_field(97,54).immovable,"r,r,tr") |
540 | -end |
541 | + connected_road(plr,map:get_field(97,54).immovable,"bl,br|br,bl,bl|bl,bl|bl,l|bl,bl|br,bl|bl,bl,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,l|l,tl|l,l|l,tl|tl,tl") |
542 | + connected_road(plr,map:get_field(98,52).immovable,"br,r|r,r|tr,r,tr|tr,r|r,r|tr,tr|tr,tr|tr,tr|r,r|r,r|r,r|br,br") |
543 | + connected_road(plr,map:get_field(99,53).immovable,"tr,tr|tr,tr|tl,tr|tr,tr|tr,tr|tr,tl") |
544 | + connected_road(plr,map:get_field(95,40).immovable,"tr,r") |
545 | + connected_road(plr,map:get_field(97,56).immovable,"r,br|br,r|r,r|r,tr|r,r|br,br") |
546 | + connected_road(plr,map:get_field(94,42).immovable,"tl,l|tl,tl|l,l|l,tl,tl|tr,tr|tr,tr,tr") |
547 | + connected_road(plr,map:get_field(102,45).immovable,"br,r|br,r|br,bl,bl") |
548 | + connected_road(plr,map:get_field(116,44).immovable,"tr,tr|tr,tr") |
549 | + connected_road(plr,map:get_field(106,59).immovable,"bl,bl|bl,br|bl,bl|l,bl,bl|bl,br|br,br|r,r|br,bl|br,br|br,br,bl|l,l|bl,bl|l,tl|tl,tl|tl,tl|tr,tr,tr|tr,r") |
550 | +end |
551 | + |
552 | +-- Roads to mines and constructionsites mess up the hide field function, so we add them later |
553 | +function remaining_roads() |
554 | +-- Mines |
555 | + connected_road(plr,map:get_field(119,46).immovable,"l,l") |
556 | + connected_road(plr,map:get_field(103,41).immovable,"tl,tl|l,l|l,l|l,l") |
557 | + connected_road(plr,map:get_field(108,60).immovable,"l,tl") |
558 | + connected_road(plr,map:get_field(120,40).immovable,"l,l") |
559 | + |
560 | +-- Constructionsite |
561 | + plr:place_building("empire_quarry", map:get_field(87,36), true, true) |
562 | +end |
563 | + |
564 | |
565 | === added file 'data/scripting/field_animations.lua' |
566 | --- data/scripting/field_animations.lua 1970-01-01 00:00:00 +0000 |
567 | +++ data/scripting/field_animations.lua 2017-12-19 17:04:59 +0000 |
568 | @@ -0,0 +1,173 @@ |
569 | +-- RST |
570 | +-- .. _field_animations: |
571 | +-- |
572 | +-- field_animations.lua |
573 | +-- -------------------- |
574 | +-- |
575 | +-- This script contains some animations to reveal and hide fields seen |
576 | +-- by a player. This functions are currently used in the campaigns and scenarios |
577 | +-- to tell the prologue to a story. |
578 | + |
579 | +-- RST |
580 | +-- .. function:: reveal_randomly(player, region, time) |
581 | +-- |
582 | +-- Reveal a given region field by field, where the fields |
583 | +-- are chosen randomly. The region will be hidden before being revealed. |
584 | +-- The animation runs the specified time. |
585 | +-- See also :meth:`wl.map.Field.region` |
586 | +-- |
587 | +-- :arg player: The player who gets sight to the region |
588 | +-- :arg region: The region that has to be revealed |
589 | +-- :type region: :class:`array` of :class:`wl.map.Fields` |
590 | +-- :arg time: Optional. The time the whole animation will run. |
591 | +-- Defaults to 1000 (1 sec) |
592 | + |
593 | +function reveal_randomly(plr, region, time) |
594 | + -- If no 'time' is given use a default |
595 | + time = time or 1000 |
596 | + |
597 | + -- Make sure the region is hidden |
598 | + plr:hide_fields(region, true) |
599 | + |
600 | + -- Turn off buildhelp during animation |
601 | + local buildhelp_state = wl.ui.MapView().buildhelp |
602 | + if buildhelp_state then |
603 | + wl.ui.MapView().buildhelp = false |
604 | + end |
605 | + |
606 | + -- Calculate delay as integer |
607 | + local delay = math.floor(time / #region) |
608 | + -- Make sure 'delay' is valid |
609 | + if delay < 1 then delay = 1 end |
610 | + |
611 | + -- Reveal field by field |
612 | + while #region > 0 do |
613 | + local t = {} |
614 | + local id = math.random(1, #region) |
615 | + table.insert(t, region[id]) |
616 | + plr:reveal_fields(t) |
617 | + sleep(delay) |
618 | + table.remove(region, id) |
619 | + end |
620 | + -- Restore buildhelp status |
621 | + wl.ui.MapView().buildhelp = buildhelp_state |
622 | +end |
623 | + |
624 | +-- RST |
625 | +-- .. function:: hide_randomly(player, region, time) |
626 | +-- |
627 | +-- Hide a given region field by field, where the fields |
628 | +-- are chosen randomly. The animation runs the specified time regardless |
629 | +-- how big the given region is. So region(6) and region(13) will take |
630 | +-- the same time. See also :meth:`wl.map.Field.region` |
631 | +-- |
632 | +-- :arg player: The player whose sight gets hidden |
633 | +-- :arg region: The region that will be hidden |
634 | +-- :type region: :class:`array` of :class:`wl.map.Fields` |
635 | +-- :arg time: Optional. The time the whole animation will run. |
636 | +-- Defaults to 1000 (1 sec) |
637 | + |
638 | +function hide_randomly(plr, region, time) |
639 | + time = time or 1000 |
640 | + -- Turn off buildhelp |
641 | + wl.ui.MapView().buildhelp = false |
642 | + |
643 | + local delay = math.floor(time / #region) |
644 | + if delay < 1 then delay = 1 end |
645 | + while #region > 0 do |
646 | + local id = math.random(1, #region) |
647 | + plr:hide_fields({region[id]},true) |
648 | + table.remove(region, id) |
649 | + sleep(delay) |
650 | + end |
651 | +end |
652 | + |
653 | +-- RST |
654 | +-- .. function:: reveal_concentric(player, center, max_radius, hide, delay) |
655 | +-- |
656 | +-- Reveal a part of the map in a concentric way beginning from center onto |
657 | +-- max_radius. The region get hidden prior revealing as default. |
658 | +-- |
659 | +-- :arg player: The player who gets sight to the region |
660 | +-- :arg center: The field from where the animation should start revealing |
661 | +-- :arg max_radius: The last ring to reveal |
662 | +-- :arg hide: Optional, if `false` automatic hiding is disabled |
663 | +-- :type hide: :class:`boolean` |
664 | +-- :arg delay: Optional, defaults to 100. The delay between revealing each |
665 | +-- ring. If you want to set the delay, you must also set `hide` |
666 | + |
667 | +function reveal_concentric(plr, center, max_radius, hide, delay) |
668 | + delay = delay or 100 |
669 | + if hide == nil then hide = true end |
670 | + |
671 | + local buildhelp_state = wl.ui.MapView().buildhelp |
672 | + if buildhelp_state then |
673 | + -- Turn off buildhelp during animation |
674 | + wl.ui.MapView().buildhelp = false |
675 | + end |
676 | + |
677 | + if hide then |
678 | + plr:hide_fields(center:region(max_radius), true) |
679 | + end |
680 | + |
681 | + local radius = 0 |
682 | + while radius <= max_radius do |
683 | + plr:reveal_fields(center:region(radius)) |
684 | + radius = radius + 1 |
685 | + sleep(delay) |
686 | + end |
687 | + wl.ui.MapView().buildhelp = buildhelp_state |
688 | +end |
689 | + |
690 | +-- RST |
691 | +-- .. function:: hide_concentric(player, center, max_radius, delay) |
692 | +-- |
693 | +-- Hide a part of the map in a concentric way beginning from max_radius onto |
694 | +-- center. |
695 | +-- |
696 | +-- :arg player: The player whose sight gets hidden |
697 | +-- :arg center: The field where the animation should end hiding |
698 | +-- :arg max_radius: The first ring to hide |
699 | +-- :arg delay: Optional, defaults to 100. The delay between revealing each |
700 | +-- ring |
701 | + |
702 | +function hide_concentric(plr, center, max_radius, delay) |
703 | + delay = delay or 100 |
704 | + -- Turn off buildhelp |
705 | + wl.ui.MapView().buildhelp = false |
706 | + while max_radius > 0 do |
707 | + local to_hide = center:region(max_radius, max_radius - 1) |
708 | + plr:hide_fields(to_hide, true) |
709 | + sleep(delay) |
710 | + max_radius = max_radius -1 |
711 | + end |
712 | + -- Hide the remaining field |
713 | + plr:hide_fields({center},true) |
714 | +end |
715 | + |
716 | +-- RST |
717 | +-- .. function:: get_sees_fields(player) |
718 | +-- |
719 | +-- Gather all fields a player can see in the current view. The current view |
720 | +-- is the whole area of the map in the current game window. You can use this |
721 | +-- function to get an unregular (non hexagonal) region and feed e.g. |
722 | +-- :meth:`reveal_randomly()` with it. |
723 | +-- |
724 | +-- :arg player: The player for whom the fields get gathered |
725 | +-- :returns: A table containing all visible fields in the current view |
726 | + |
727 | +function get_sees_fields(plr) |
728 | + local sees_fields = {} |
729 | + for x=0, wl.Game().map.width-1 do |
730 | + for y=0, wl.Game().map.height-1 do |
731 | + f = wl.Game().map:get_field(x,y) |
732 | + if wl.ui.MapView():is_visible(f) then |
733 | + -- Gather only fields which are seen in the view |
734 | + if plr:sees_field(f) then |
735 | + table.insert(sees_fields, f) |
736 | + end |
737 | + end |
738 | + end |
739 | + end |
740 | + return sees_fields |
741 | +end |
742 | |
743 | === modified file 'data/scripting/infrastructure.lua' |
744 | --- data/scripting/infrastructure.lua 2017-05-06 19:21:47 +0000 |
745 | +++ data/scripting/infrastructure.lua 2017-12-19 17:04:59 +0000 |
746 | @@ -33,7 +33,10 @@ |
747 | -- the roads. Otherwise no carriers will be created. |
748 | -- :type create_carriers: :class:`boolean` |
749 | function connected_road(p, start, cmd, g_create_carriers) |
750 | - create_carriers = g_create_carriers or true |
751 | + create_carriers = true |
752 | + if g_create_carriers ~= nil then |
753 | + create_carriers = g_create_carriers |
754 | + end |
755 | |
756 | if cmd:sub(-1) ~= "|" then |
757 | cmd = cmd .. "|" |
758 | |
759 | === modified file 'src/scripting/lua_game.cc' |
760 | --- src/scripting/lua_game.cc 2017-12-19 14:35:00 +0000 |
761 | +++ src/scripting/lua_game.cc 2017-12-19 17:04:59 +0000 |
762 | @@ -564,8 +564,9 @@ |
763 | /* RST |
764 | .. method:: reveal_fields(fields) |
765 | |
766 | - Make these fields visible for the current player. If the fields were previously hidden via |
767 | - `hide_fields`, restores the exact vision that they had before that was done. |
768 | + Make these fields visible for the current player. The fields will remain |
769 | + visible until they are hidden again. See also :ref:`field_animations` for |
770 | + animated revealing. |
771 | |
772 | :arg fields: The fields to reveal |
773 | :type fields: :class:`array` of :class:`wl.map.Fields` |
774 | @@ -591,7 +592,9 @@ |
775 | /* RST |
776 | .. method:: hide_fields(fields) |
777 | |
778 | - Make these fields hidden for the current player. |
779 | + Make these fields hidden for the current player if they are not |
780 | + seen by a military building. See also :ref:`field_animations` for |
781 | + animated hiding. |
782 | |
783 | :arg fields: The fields to hide |
784 | :type fields: :class:`array` of :class:`wl.map.Fields` |
Continuous integration builds have changed state:
Travis build 2436. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 251684050. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ reveal_ hide_animations -2263.
Appveyor build 2263. State: success. Details: https:/