1#textdomain wesnoth-sota
2
3# During the opening, characters move in and out of the trapdoors leading below decks,
4# and into the passenger cabin doors as well. Macros open and close the various doors as
5# necessary. A menu item is provided to remove the terrain image that
6# contains the ship's sails. The macro for that is in utils because it is also used for
7# the next scenario. The ship terrain is fairly complicated, but the terrain files have
8# more details. The ship is the reason for SotA-only bats: Normal bats are drawn above
9# all terrain, but that looks wrong with the ship sails, so SotA bats are drawn on a
10# lower z-level.
11
12[scenario]
13    name= _ "Becalmed"
14    map_data="{campaigns/Secrets_of_the_Ancients/maps/04_Becalmed.map}"
15
16    id=04_Becalmed
17    next_scenario=05_Blackwater
18
19    [story]
20        [part]
21            [background_layer]
22                image=story/book.png
23                scale=no
24            [/background_layer]
25            story= _ "22 III, 23 YW
26
27Research sometimes requires experiments, so I began. I forced my will into the life-force pathways of the bandit, thus turning him into my puppet. He resisted, but on account of my recent practice, my will proved the stronger. More strangely, the inside of his body also resisted, attacking me, the invader. However, since I wasn’t physically there, it ended up attacking itself! Over a period of hours, slabs of flesh became weak and threatened to fall off his frame. I was obliged to stitch them in place."
28        [/part]
29        [part]
30            [background_layer]
31                image=story/black-background.png
32                scale=no
33                base_layer=yes
34            [/background_layer]
35            [image]
36                file=portraits/ardonna.png
37                x,y=64,0
38                scale=no
39            [/image]
40            [image]
41                file=portraits/undead/ghoul.png~FL()
42                x,y=320,0
43                scale=no
44            [/image]
45            story= _ "Some of the bandit’s companions had perished in better condition than the leader, and I got the idea to add their flesh to my puppet. I stitched on muscles where they seemed to fit, and used enchantments to improve the bonding, thus improving the strength of the creature. At first, each new piece of flesh caused another violent reaction from the body’s defenses. Eventually, the reactions weakened, and the body stabilized in its new configuration, though by this time it was suppurating and unrecognizable. The mind inside gibbered at what it had become, but the bandit had wished for me a fate worse than death, so it didn’t seem unfair."
46        [/part]
47        [part]
48            [background_layer]
49                image=story/alduin-dock.jpg
50                scale=no
51            [/background_layer]
52            story= _ "Working through the next day in the bandit’s own keep, I repeated the procedure on several of his gravely wounded companions, though none of them became as strong a specimen as the leader. One of them didn’t survive, but it was no loss — I conscripted him into my army anyway. Then, I made my way to the docks, and under the cover of night, loaded my army into the hold of the waiting ship. The following afternoon, I embarked as a normal passenger."
53        [/part]
54        [part]
55            [background_layer]
56                image=story/becalmed.jpg
57                scale=no
58            [/background_layer]
59            story= _ "25 III, 23 YW
60
61The journey started well enough, but on the dawn following our departure, the wind died completely, and we were stranded. There was enough food for the paying passengers for a couple days of this, but none for my companions, and the living ones soon got hungry. When one of the crew disappeared on the second evening, I suspected the cause. I was not wrong."
62        [/part]
63        {JOURNEY_PART 4}
64    [/story]
65
66    # This is the same as the default schedule, but starts at dusk.
67    {DUSK}
68    {FIRST_WATCH}
69    {SECOND_WATCH}
70    {DAWN}
71    {MORNING}
72    {AFTERNOON}
73
74    [time_area]
75        [time]
76            id=lower_deck
77            name= _ "Underground"
78            image=misc/time-schedules/schedule-underground.png
79            lawful_bonus=-25
80            red=-35
81            green=-30
82            blue=-25
83        [/time]
84        x=14, 0-99
85        y=12, 13-99
86    [/time_area]
87
88    {DEFAULT_MUSIC_PLAYLIST}
89    {TURNS 14 15 16}
90
91    [side]
92        {SIDE_1_ARDONNA_EARLY}
93        # We are assuming substantial gold from the previous scenario:
94        {GOLD 60 40 20}
95        facing=ne
96    [/side]
97
98    [side]
99        side=2
100        controller=ai
101        team_name=bad
102        user_team_name= _ "Ship’s Crew"
103        type=Sea Captain
104        name= _ "Rudic"
105        id=Rudic
106        profile=portraits/captain.png
107        recruit=Sailor
108        {GOLD 80 110 150}
109        income=6
110        facing=sw
111        color=white
112    [/side]
113
114    # These two sides are only to provide color and ellipses for the other ship
115    # passengers. The units look out of place without them.
116    [side]
117        side=3
118        team_name=good
119        controller=null
120        hidden=yes
121        color=teal
122        [unit]
123            type=Noble
124            x,y=11, 7
125            facing=se
126        [/unit]
127    [/side]
128
129    [side]
130        side=4
131        team_name=good
132        controller=null
133        hidden=yes
134        color=orange
135        [unit]
136            type=Dunefolk
137            x,y=12, 16
138            facing=se
139        [/unit]
140    [/side]
141
142    {STARTING_VILLAGES 2 8}
143
144#define OPEN_TRAP_DOORS X Y
145    [remove_item]
146        x,y={X},{Y}
147        image=items/trap-doors-closed.png
148    [/remove_item]
149    [item]
150        x,y={X},{Y}
151        image=items/trap-doors-open.png
152    [/item]
153#enddef
154
155#define CLOSE_TRAP_DOORS X Y
156    [remove_item]
157        x,y={X},{Y}
158        image=items/trap-doors-open.png
159    [/remove_item]
160    [item]
161        x,y={X},{Y}
162        image=items/trap-doors-closed.png
163    [/item]
164#enddef
165
166    # *************************** PRESTART ***************************
167    [event]
168        name=prestart
169        {FREEZE_UNIT Rudic}  # Otherwise, he attacks suicidally on the first turn!
170
171        [item]
172            x,y=10,8
173            image=items/trap-doors-closed.png
174        [/item]
175        [item]
176            x,y=14,6
177            image=items/trap-doors-closed.png
178        [/item]
179        [item]
180            x,y=13,15
181            image=items/trap-doors-closed.png
182        [/item]
183
184        [unit]
185            type=Ghoul
186            side=1
187            name= _ "Garcyn"
188            x,y=recall,recall
189            [modifications]
190                {TRAIT_STRONG}
191            [/modifications]
192        [/unit]
193
194        [objectives]
195            side=1
196            [objective]
197                description= _ "Defeat the enemy leader"
198                condition=win
199            [/objective]
200
201            {HOW_TO_LOSE_WITH_ARDONNA}
202
203            [gold_carryover]
204                bonus=yes
205                carryover_percentage=40
206            [/gold_carryover]
207
208            [note]
209                description= _ "You can recruit from anywhere on the two highest decks."
210            [/note]
211            [note]
212                description= _ "Barrels act as villages."
213            [/note]
214            [note]
215                description= _ "Right-click to simplify the ship graphics."
216            [/note]
217        [/objectives]
218
219        [set_variable]
220            name=sails_hidden
221            value=no
222        [/set_variable]
223        {SHOW_SAILS_MENU_ITEM -1}
224        {HIDE_SAILS_MENU_ITEM -1}
225
226        [tunnel]
227            [source]
228                x,y=10,8
229            [/source]
230            [target]
231                x,y=10,16
232            [/target]
233            [filter]
234            [/filter]
235            pass_allied_units=yes
236        [/tunnel]
237        [tunnel]
238            [source]
239                x,y=14,6
240            [/source]
241            [target]
242                x,y=14,14
243            [/target]
244            [filter]
245            [/filter]
246            pass_allied_units=yes
247        [/tunnel]
248
249        [item]
250            x,y=11,12
251            halo=map-border.png
252        [/item]
253    [/event]
254
255    # *************************** PLAY ***************************
256#define MOVE_TO_LOWER_DECK X Y
257    [move_unit]
258        x,y={X},{Y}
259        to_x=14
260        to_y=6
261    [/move_unit]
262    [teleport]
263        [filter]
264            x,y=14,6
265        [/filter]
266        x,y=14,14
267        animate=yes
268    [/teleport]
269    [move_unit]
270        x,y=14,15
271        to_x=13
272        to_y=16
273    [/move_unit]
274#enddef
275
276    # This next event scripts the first turn AI moves. If we don't do this, sometimes too
277    # many units go to the lower deck, and sometimes none do. This has a large impact on
278    # the difficulty of the scenario. Also, the ai units would box in the player's units and
279    # block the trapdoor.
280    [event]
281        name=side 2 turn 1 refresh
282
283        # If Ardonna has (stupidly) moved onto the main deck, the scripted moves
284        # will cause the ai to ignore her zone of control and the ai units could
285        # move behind her. To prevent this, we will skip the scripted moves and let
286        # the ai attack her if she has moved off her deck or in range.
287        [if]
288            [have_unit]
289                id=Ardonna
290                [filter_location]
291                    terrain=*^Zfoc  # Ship forecastle
292                    [or]
293                        # She can take one of the first two barrels on the
294                        # lower deck. The AI can't possibly kill her, so it
295                        # will stick to the script. She's fair game on the
296                        # third barrel though.
297                        x=1-10
298                        y=11-99
299                    [/or]
300                    [or]
301                        # She also doesn't get *immediately* attacked if she
302                        # is just guarding her trapdoor.
303                        x=9,10
304                        y=8
305                    [/or]
306                [/filter_location]
307            [/have_unit]
308
309            [then]
310                [move_unit]
311                    x,y=15,6
312                    to_x=11
313                    to_y=7
314                [/move_unit]
315                [move_unit]
316                    y=6
317                    to_x=13
318                    to_y=8
319                [/move_unit]
320                {MOVE_TO_LOWER_DECK 14 5}
321                {MOVE_TO_LOWER_DECK 15 5}
322
323                [modify_unit]
324                    [filter]
325                        side=2
326                    [/filter]
327                    moves=0
328                [/modify_unit]
329            [/then]
330        [/if]
331    [/event]
332
333#undef MOVE_TO_LOWER_DECK
334
335    # Force more newly-recruited units to guard the lower deck:
336    [event]
337        name=side 2 turn 1 end
338        [micro_ai]
339            side=2
340            ai_type=zone_guardian
341            action=add
342            [filter]
343                y=6
344            [/filter]
345            [filter_location]
346                x=0-99
347                y=0-12
348            [/filter_location]
349            [filter_location_enemy]
350                x=0-99
351                y=13-99
352            [/filter_location_enemy]
353        [/micro_ai]
354    [/event]
355
356    # We need an event for each trap door, going each direction. The code for each is very
357    # similar so we can make all four with one macro.
358#define CREATE_TRAP_DOOR Y1 Y2 TRAP_X TRAP_Y
359    [event]
360        name=exit_hex
361        first_time_only=no
362        [if]
363            # Checking the unit's x position is not necessary. There is only one
364            # way the unit's y position can change by the amount being used here:
365            [variable]
366                name=y1
367                equals={Y1}
368            [/variable]
369            [and]
370                [variable]
371                    name=y2
372                    equals={Y2}
373                [/variable]
374            [/and]
375            [then]
376                {OPEN_TRAP_DOORS {TRAP_X} {TRAP_Y}}
377            [/then]
378        [/if]
379        [allow_undo][/allow_undo]
380    [/event]
381#enddef
382
383    {CREATE_TRAP_DOOR 8 16 10 8}
384    {CREATE_TRAP_DOOR 16 8 10 8}
385    {CREATE_TRAP_DOOR 6 14 14 6}
386    {CREATE_TRAP_DOOR 14 6 14 6}
387
388#undef CREATE_TRAP_DOOR
389
390    [event]
391        name=moveto
392        first_time_only=no
393        {CLOSE_TRAP_DOORS 10 8}
394        {CLOSE_TRAP_DOORS 14 6}
395        [allow_undo][/allow_undo]
396    [/event]
397
398    # *************************** OPENING / ENDING ***************************
399#define OPEN_DOOR X Y
400    [item]
401        x,y={X},{Y}
402        image=items/door-open-bottom.png
403        redraw=no
404    [/item]
405    [item]
406        x={X}
407        y="$({Y}-1)"
408        image=items/door-open-top.png
409    [/item]
410    [redraw][/redraw]
411#enddef
412
413#define CLOSE_DOOR X Y
414    [remove_item]
415        x={X}
416        y="$({Y}-1)"
417    [/remove_item]
418    [remove_item]
419        x,y={X},{Y}
420    [/remove_item]
421#enddef
422
423#define PLACE_SAILOR
424    {NEAREST_HEX 16 6 3 (terrain=*^Zpoo
425    [not][filter][/filter][/not]) location}
426    [unit]
427        x=$location.x
428        y=$location.y
429        type=Sailor
430        side=2
431        facing=sw
432    [/unit]
433    [clear_variable]
434        name=location
435    [/clear_variable]
436#enddef
437
438    [event]
439        name=start
440
441        [scroll_to]
442            x,y=12,6
443        [/scroll_to]
444
445        [delay]
446            time=1000
447        [/delay]
448
449        [allow_recruit]
450            side=1
451            type=Ghoul
452        [/allow_recruit]
453        [message]
454            speaker=narrator
455            image=portraits/undead/ghoul.png~SCALE(93, 93)
456            message= _ "You can now recruit ghouls!"
457        [/message]
458
459        [scroll_to]
460            x,y=12,15
461        [/scroll_to]
462
463        [delay]
464            time=700
465        [/delay]
466
467        # Joc the sailor comes upstairs to talk to the captain:
468        {OPEN_TRAP_DOORS 13 15}
469        [delay]
470            time=400
471        [/delay]
472        [move_unit_fake]
473            type=Sailor
474            side=2
475            x=13, 14
476            y=15, 14
477        [/move_unit_fake]
478        {CLOSE_TRAP_DOORS 13 15}
479        {OPEN_TRAP_DOORS 14 6}
480        [move_unit_fake]
481            type=Sailor
482            side=2
483            x=14, 16
484            y=6,  6
485        [/move_unit_fake]
486        [unit]
487            side=2
488            x,y=16, 6
489            type=Sailor
490            name=_ "Joc"
491            id=Joc
492            facing=nw
493        [/unit]
494        {CLOSE_TRAP_DOORS 14 6}
495
496        [message]
497            speaker=Joc
498            message= _ "I found Janryn in the hold. Or, ah... some of him. He’s dead. I didn’t stay to find out what killed him, but there was someone shuffling around in the shadows, and he smelled foul."
499        [/message]
500        [message]
501            speaker=Rudic
502            message= _ "Murderous stowaways on my ship? I won’t have it! Go round up the rest of the crew and get them up here. We’re going hunting. All passengers are confined to quarters immediately."
503        [/message]
504
505        # Joc goes back down and through the bottom trap door:
506        [kill]
507            id=Joc
508        [/kill]
509        {OPEN_TRAP_DOORS 14 6}
510        [move_unit_fake]
511            type=Sailor
512            side=2
513            x=16, 14
514            y=6,  6
515        [/move_unit_fake]
516        {CLOSE_TRAP_DOORS 14 6}
517        {OPEN_TRAP_DOORS 13 15}
518        [move_unit_fake]
519            type=Sailor
520            side=2
521            x=14, 13
522            y=14, 15
523        [/move_unit_fake]
524        {CLOSE_TRAP_DOORS 13 15}
525
526        # The other two passengers go through doors and disappear:
527        [kill]
528            side=4
529        [/kill]
530        {OPEN_DOOR 14 13}
531        [move_unit_fake]
532            type=Dunefolk
533            side=4
534            x=12, 14
535            y=16,  13
536        [/move_unit_fake]
537        {CLOSE_DOOR 14 13}
538
539        {OPEN_TRAP_DOORS 10 8}
540        [kill]
541            side=3
542        [/kill]
543        [move_unit_fake]
544            type=Noble
545            side=3
546            x=11, 10
547            y=7,  8
548        [/move_unit_fake]
549        {CLOSE_TRAP_DOORS 10 8}
550        {OPEN_DOOR 16 14}
551        [move_unit_fake]
552            type=Noble
553            side=4
554            x=10, 16
555            y=16,  14
556        [/move_unit_fake]
557        {CLOSE_DOOR 16 14}
558
559        {REPEAT 5 {PLACE_SAILOR}}
560
561        [message]
562            speaker=Rudic
563            message= _ "You! Dark girl. Why are you not in your cabin?"
564        [/message]
565        [message]
566            speaker=Ardonna
567            message= _ "What if I said something in defense of the stowaways?"
568        [/message]
569        [message]
570            speaker=Rudic
571            message= _ "I would pitch you over the side with them. What do you know?"
572        [/message]
573        [message]
574            speaker=Ardonna
575            message= _ "They are my companions, and the poor things are just terribly hungry. I’m sorry we didn’t pay the full amount, but maybe we can reach some arrangement."
576        [/message]
577        [message]
578            speaker=Rudic
579            message= _ "They killed my crew member and played me for a fool! The only arrangement that suits me is the lot of you off my ship, preferably at the bottom of the sea."
580        [/message]
581        [message]
582            speaker=Ardonna
583            message= _ "Oh dear. We must do this again. Come to me my friends! If you are still hungry, feed on a passenger first."
584        [/message]
585    [/event]
586
587    [event]
588        name=die
589        [filter]
590            id=Rudic
591        [/filter]
592
593        [message]
594            speaker=Ardonna
595            message= _ "Good riddance. But, with the captain dead, who will sail the ship and guide us into port now?"
596        [/message]
597        [message]
598            speaker=Ardonna
599            message= _ "Rise Captain, and please retain your memories."
600        [/message]
601
602        [store_unit]
603            [filter]
604                id=Rudic
605            [/filter]
606            variable=rudic_stored
607            kill=yes
608        [/store_unit]
609        [unit]
610            # wmllint: who RECALL_LOYAL_UNITS is Bone Captain
611            type=Bone Captain
612            id=Bone Captain
613            side=1
614            x=$rudic_stored.x
615            y=$rudic_stored.y
616            name= _ "Rudic"
617            {IS_LOYAL}
618            [modifications]
619                {TRAIT_LOYAL}
620            [/modifications]
621            animate=yes
622        [/unit]
623        [clear_variable]
624            name=rudic_stored
625        [/clear_variable]
626
627        [message]
628            speaker=Ardonna
629            message= _ "Can you still sail this ship?"
630        [/message]
631        [message]
632            speaker=Bone Captain
633            image=portraits/bone-captain1.png
634            message= _ "Sail. Yes. Need wind."
635        [/message]
636        [message]
637            speaker=Ardonna
638            message= _ "Oh! It worked! Take us to port, Captain, as soon as you do have the wind."
639        [/message]
640    [/event]
641
642    [event]
643        name=enemies defeated
644        [endlevel]
645            result=victory
646            bonus=yes
647            {NEW_GOLD_CARRYOVER 40}
648        [/endlevel]
649    [/event]
650
651    {HERO_DEATHS}
652    {MANAGE_PROFILE}
653
654#undef PLACE_SAILOR
655#undef OPEN_DOOR
656#undef CLOSE_DOOR
657#undef OPEN_TRAP_DOORS
658#undef CLOSE_TRAP_DOORS
659[/scenario]
660