File: SeqOutro.c

package info (click to toggle)
openclonk 8.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,656 kB
  • sloc: cpp: 180,484; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 148; sh: 101; javascript: 34
file content (450 lines) | stat: -rw-r--r-- 14,782 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
// Outro sequence for this tutorial.

#appendto Sequence

public func Outro_Init(int for_plr)
{
	this.plr = for_plr;
	// Store villagers.
	this.village_head = Dialogue->FindByName("VillageHead")->GetDialogueTarget();
	this.farmer = Dialogue->FindByName("Farmer")->GetDialogueTarget();
	this.lookout = Dialogue->FindByName("Lookout")->GetDialogueTarget();
	this.lumberjack = Dialogue->FindByName("Lumberjack")->GetDialogueTarget();
	this.fireman = Dialogue->FindByName("Fireman")->GetDialogueTarget();
	this.builder = Dialogue->FindByName("Builder")->GetDialogueTarget();
	// Create two airplanes with pilots and let them fly from left to right.
	this.airplane1 = CreateObject(Airplane, AbsX(40), AbsY(160));
	this.pilot1 = CreateObject(Clonk);
	this.pilot1->SetSkin(2);
	this.pilot1->Enter(this.airplane1);
	this.pilot1->SetAction("Walk");
	this.pilot1->SetColor(0xff000000);
	this.airplane1->PlaneMount(this.pilot1);
	this.airplane1->FaceRight();
	this.airplane1->StartInstantFlight(90, 15);
	this.airplane1->SetXDir(12);
	this.airplane1->SetYDir(-1);
	this.airplane1->MakeInvincible();
	this.airplane1->SetColor(0xff000000);
	this.airplane1.BorderBound = 0;
	this.airplane2 = CreateObject(Airplane, AbsX(0), AbsY(190));
	this.pilot2 = CreateObject(Clonk);
	this.pilot2->SetSkin(2);
	this.pilot2->Enter(this.airplane2);
	this.pilot2->SetAction("Walk");
	this.pilot2->SetColor(0xff000000);
	this.airplane2->PlaneMount(this.pilot2);
	this.airplane2->FaceRight();
	this.airplane2->StartInstantFlight(90, 15);
	this.airplane2->SetXDir(12);
	this.airplane2->SetYDir(-1);
	this.airplane2->MakeInvincible();
	this.airplane2->SetColor(0xff000000);
	this.airplane2.BorderBound = 0;
	// Each plane has a henchman which will kidnap the wipfs.
	this.henchman1 = CreateObject(Clonk);
	this.henchman1->SetAlternativeSkin("Leather");
	this.henchman1->Enter(this.airplane1);
	this.henchman1->SetAction("Walk");
	this.henchman1->SetColor(0xff000000);
	this.henchman1->CreateContents(Blunderbuss)->CreateContents(LeadBullet);
	this.henchman2 = CreateObject(Clonk);
	this.henchman2->SetAlternativeSkin("Leather");
	this.henchman2->Enter(this.airplane2);
	this.henchman2->SetAction("Walk");
	this.henchman2->SetColor(0xff000000);
	this.henchman2->CreateContents(Blunderbuss)->CreateContents(LeadBullet);
	
	// Another henchman which will control the lookout.
	this.henchman3 = CreateObject(Clonk);
	this.henchman3->SetAlternativeSkin("Leather");	
	this.henchman3->Enter(this.airplane2);
	this.henchman3->SetAction("Walk");
	this.henchman3->SetColor(0xff000000);
	this.henchman3->CreateContents(Blunderbuss)->CreateContents(LeadBullet);
	
	// The faction leader which will do the talking.
	this.leader = CreateObject(Clonk);
	this.leader->SetAlternativeSkin("Doctor");
	this.leader->SetName("Gotham");
	this.leader->Enter(this.airplane1);
	this.leader->SetAction("Walk");
	this.leader->SetColor(0xff000000);
	this.leader->CreateContents(Blunderbuss)->CreateContents(LeadBullet);
	
	// There is also a kidnapper on an airship with a lorry to collect the wipfs.
	// The third henchman shoots down the balloons.
	this.airship = CreateObject(Airship, AbsX(20), AbsY(280));
	this.lorry = CreateObject(Lorry, AbsX(32), AbsY(280));
	this.kidnapper = CreateObject(Clonk, AbsX(30), AbsY(280));
	this.kidnapper->SetSkin(3);
	this.kidnapper->SetAction("Walk");
	this.kidnapper->SetCommand("Grab", this.airship);
	this.kidnapper->SetColor(0xff000000);
	this.airship->ControlRight(this.kidnapper);
	return true;
}

public func Outro_JoinPlayer(int plr)
{
	SetPlayerZoomByViewRange(plr, LandscapeWidth(), nil, PLRZOOM_Set | PLRZOOM_LimitMax);
	return;
}

public func Outro_Start()
{
	return ScheduleNext(4);
}

public func Outro_1()
{
	MessageBox("$MsgVillageHeadNoise$", GetCrew(this.plr, 0), this.village_head, this.plr, true);
	return ScheduleNext(72);
}

public func Outro_2()
{
	MessageBox("$MsgFarmerAirplanes$", GetCrew(this.plr, 0), this.farmer, this.plr, true);
	// Fireman and lumberjack flee into wooden cabin.
	this.fireman->SetCommand("Enter", this.fireman->FindObject(Find_ID(WoodenCabin), Find_AnyLayer(), Sort_Distance()));
	this.lumberjack->SetCommand("Enter", this.lumberjack->FindObject(Find_ID(WoodenCabin), Find_AnyLayer(), Sort_Distance()));
	// Builder flees into the mine.
	this.builder->SetCommand("MoveTo", this.builder->FindObject(Find_ID(Foundry), Find_AnyLayer(), Sort_Distance()));
	return ScheduleNext(36);
}

public func Outro_3()
{
	// Exit the leader from the airplane on a balloon.
	this.leader->Exit();
	var balloon = this.leader->CreateContents(Balloon);
	balloon->ControlUseStart(this.leader);
	this.leader->GetActionTarget()->ControlDown(this.leader);
	return ScheduleNext(36);
}

public func Outro_4()
{
	// Exit henchman from the airplanes on balloons.
	this.henchman1->Exit();
	var balloon = this.henchman1->CreateContents(Balloon);
	balloon->ControlUseStart(this.henchman1);
	this.henchman1->GetActionTarget()->ControlDown(this.henchman1);
	this.henchman2->Exit();
	var balloon = this.henchman2->CreateContents(Balloon);
	balloon->ControlUseStart(this.henchman2);
	this.henchman2->GetActionTarget()->ControlDown(this.henchman2);
	// Let henchmen aim at the farmer.
	AddEffect("AimBlunderbussAt", this.henchman1, 100, 1, this, nil, this.farmer, 356);
	AddEffect("AimBlunderbussAt", this.henchman2, 100, 1, this, nil, this.farmer, 356);
	// Let leader aim at the village head.
	AddEffect("AimBlunderbussAt", this.leader, 100, 1, this, nil, this.village_head);
	return ScheduleNext(78);
}

public func Outro_5()
{
	MessageBox("$MsgEvilLeaderItsUs$", GetCrew(this.plr, 0), this.leader, this.plr, true);
	// Exit a third henchman from the airplane on a balloon.
	this.henchman3->Exit();
	var balloon = this.henchman3->CreateContents(Balloon);
	balloon->ControlUseStart(this.henchman3);
	this.henchman3->GetActionTarget()->ControlDown(this.henchman3);
	return ScheduleNext(20);
}

public func Outro_6()
{
	// Third henchman aims at lookout
	AddEffect("AimBlunderbussAt", this.henchman3, 100, 1, this, nil, this.lookout, 280);
	return ScheduleNext(100);
}

public func Outro_7()
{
	return ScheduleNext(36);
}

public func Outro_8()
{
	MessageBox("$MsgVillageHeadWhy$", GetCrew(this.plr, 0), this.village_head, this.plr, true);
	return ScheduleNext(36);
}

public func Outro_9()
{
	// Third henchman tells lookout to drop the weapon.
	this.henchman3->Message("$MsgHenchman3DropBlunderbuss$");
	return ScheduleNext(18);
}

public func Outro_10()
{
	// First and second henchman scare off farmer.
	this.henchman1->Message("$MsgHenchman1RunGirl$");
	this.henchman2->Message("$MsgHenchman2Wipfs$");
	return ScheduleNext(18);
}

public func Outro_11()
{
	// Lookout surrenders.
	this.lookout->Message("$MsgLookoutSurrender$");
	this.lookout->SetCommand("Drop", this.lookout->Contents());
	return ScheduleNext(18);
}

public func Outro_12()
{
	// Farmer runs off into the mines.
	this.farmer->SetCommand("MoveTo", this.farmer->FindObject(Find_ID(ToolsWorkshop), Find_AnyLayer(), Sort_Distance()));
	this.farmer->Message("$MsgFarmerComment$");
	return ScheduleNext(100);
}

public func Outro_13()
{
	MessageBox("$MsgEvilLeaderWipfs$", GetCrew(this.plr, 0), this.leader, this.plr, true);
	this.airship->ControlStop(this.kidnapper);
	AddEffect("TieWipfToBalloon", this.henchman1, 100, 5, this);
	AddEffect("TieWipfToBalloon", this.henchman2, 100, 5, this);
	return ScheduleNext(108);
}

public func Outro_14()
{
	MessageBox("$MsgVillageHeadManiac$", GetCrew(this.plr, 0), this.village_head, this.plr, true);
	ScheduleCall(this, "MessageBox", 108, 0, "$MsgEvilLeader$", GetCrew(this.plr, 0), this.leader, this.plr, true);
	ScheduleCall(this, "MessageBox", 216, 0, "$MsgPlayerDontTakeWipf$", GetCrew(this.plr, 0), GetCrew(this.plr, 0), this.plr, true);
	ScheduleCall(this, "MessageBox", 356, 0, "$MsgEvilLeaderBegging$", GetCrew(this.plr, 0), this.leader, this.plr, true);
	return ScheduleNext(4);
}

public func Outro_15()
{
	// Wait until all wipfs are up then move airship.
	if (!FindObject(Find_ID(Wipf), Find_InRect(AbsX(632), AbsY(280), 216, 112), Find_AnyLayer()))
	{
		AddEffect("MoveAirshipToWipf", this.kidnapper, 100, 5, this);
		return ScheduleNext(10);
	}
	return ScheduleSame(10);
}

public func Outro_16()
{
	if (FindObject(Find_ID(Wipf), Find_NoContainer(), Find_InRect(AbsX(632), AbsY(0), 216, 352), Find_Property("tied_up")))
		return ScheduleSame(10);
	return ScheduleNext(10);
}

public func Outro_17()
{
	this.airship->ControlRight(this.kidnapper);
	this.airship->ControlUp(this.kidnapper);
	this.kidnapper->Message("$MsgKidnapperGotThem$");
	ScheduleCall(this.kidnapper, "RemoveObject", 300, 0);	
	ScheduleCall(this.airship, "RemoveObject", 300, 0);	
	ScheduleCall(this.lorry, "RemoveObject", 300, 0);	
		
	var boompack = this.henchman3->CreateContents(Boompack);
	boompack->SetFuel(10000);
	boompack->ControlUse(this.henchman3, -8, -40);
	boompack->SetDirectionDeviation();
	this.henchman3->Message("$MsgHenchman3SeeYa$");
	RemoveAll(Find_Container(this.henchman3));
	ScheduleCall(this.henchman3, "RemoveObject", 120, 0);
	ScheduleCall(boompack, "RemoveObject", 120, 0);
	
	this.henchman1->SetCommand("MoveTo", nil, 632, 382);
	this.henchman2->SetCommand("MoveTo", nil, 632, 382);
	return ScheduleNext(70);
}

public func Outro_18()
{
	var boompack = this.henchman2->CreateContents(Boompack);
	boompack->SetFuel(10000);
	boompack->ControlUse(this.henchman2, -10, -40);
	boompack->SetDirectionDeviation();
	this.henchman2->Message("$MsgHenchman3SeeYa$");
	RemoveAll(Find_Container(this.henchman2));
	ScheduleCall(this.henchman2, "RemoveObject", 100, 0);
	ScheduleCall(boompack, "RemoveObject", 100, 0);	
	return ScheduleNext(10);
}

public func Outro_19()
{
	MessageBox("$MsgEvilLeaderBye$", GetCrew(this.plr, 0), this.leader, this.plr, true);
		
	var boompack = this.henchman1->CreateContents(Boompack);
	boompack->SetFuel(10000);
	boompack->ControlUse(this.henchman1, -10, -40);
	boompack->SetDirectionDeviation();
	this.henchman1->Message("$MsgHenchman3SeeYa$");
	RemoveAll(Find_Container(this.henchman1));
	ScheduleCall(this.henchman1, "RemoveObject", 120, 0);
	ScheduleCall(boompack, "RemoveObject", 120, 0);
	
	RemoveEffect("AimBlunderbussAt", this.leader);
	return ScheduleNext(36);
}

public func Outro_20()
{
	var boompack = this.leader->CreateContents(Boompack);
	boompack->SetFuel(10000);
	boompack->ControlUse(this.leader, -8, -40);
	boompack->SetDirectionDeviation();
	RemoveAll(Find_Container(this.leader));
	ScheduleCall(this.leader, "RemoveObject", 120, 0);
	ScheduleCall(boompack, "RemoveObject", 120, 0);
	return ScheduleNext(188);
}

public func Outro_21()
{	
	// Show last guide message and then stop the sequence and fulfill the goal.
	GameCall("ShowLastGuideMessage");
	return ScheduleNext(108);
}

public func Outro_22()
{
	return Stop();
}

public func Outro_Stop()
{
	// Fulfill the tutorial goal.
	var goal = FindObject(Find_ID(Goal_Tutorial));
	if (goal)
		goal->Fulfill();
	return true;
}


/*-- Effects --*/

public func FxAimBlunderbussAtStart(object target, proplist effect, int temp, object aim, int length)
{
	if (temp)
		return FX_OK;
	effect.aim_target = aim;
	effect.aim_length = length;
	effect.blunderbuss = FindObject(Find_ID(Blunderbuss), Find_Container(target));
	effect.blunderbuss.loaded = true;
	effect.blunderbuss->ControlUseStart(target, effect.aim_target->GetX() - target->GetX(), effect.aim_target->GetY() - target->GetY());
	return FX_OK;
}

public func FxAimBlunderbussAtTimer(object target, proplist effect, int time)
{
	effect.blunderbuss->ControlUseHolding(target, effect.aim_target->GetX() - target->GetX(), effect.aim_target->GetY() - target->GetY());
	if (effect.aim_length != nil && time >= effect.aim_length)
		return FX_Execute_Kill;	
	return FX_OK;
}

public func FxAimBlunderbussAtStop(object target, proplist effect, int reason, bool temp)
{
	if (temp)
		return FX_OK;
	effect.blunderbuss->ControlUseCancel(target, effect.aim_target->GetX() - target->GetX(), effect.aim_target->GetY() - target->GetY());
	return FX_OK;
}


public func FxTieWipfToBalloonStart(object target, proplist effect, int temp)
{
	if (temp)
		return FX_OK;
	effect.wait_time = 0;
	return FX_OK;
}

public func FxTieWipfToBalloonTimer(object target, proplist effect, int time)
{
	if (effect.wait_time > 0)
	{
		effect.wait_time -= effect.Interval;
		return FX_OK;
	}
	
	if (!effect.wipf)
	{
		effect.wipf = target->FindObject(Find_ID(Wipf), Find_InRect(target->AbsX(632), target->AbsY(260), 216, 132), Find_AnyLayer(), Find_Not(Find_Or(Find_Property("tied_up"), Find_Property("tie_target"))), Sort_Distance());
		if (!effect.wipf)
			return FX_Execute_Kill;
		effect.wipf.tie_target = true;
	}

	if (ObjectDistance(target, effect.wipf) < 10)
	{
		effect.wipf->SetObjectLayer();
		effect.wipf.Collectible = true;
		var balloon = effect.wipf->CreateContents(Balloon);
		balloon->HangWipfOnBalloon(effect.wipf);
		target->Message(Translate(Format("MsgHenchmanGotWipf%d", 1 + Random(3))));
		effect.wipf.tied_up = true;
		effect.wipf = nil;
		effect.wait_time = 36;
		return FX_OK;
	}
	
	target->SetCommand("MoveTo", nil, effect.wipf->GetX(), effect.wipf->GetY());
	return FX_OK;
}

public func FxTieWipfToBalloonStop(object target, proplist effect, int reason, bool temp)
{
	if (temp)
		return FX_OK;
	return FX_OK;
}


public func FxMoveAirshipToWipfStart(object target, proplist effect, int temp)
{
	if (temp)
		return FX_OK;

	return FX_OK;
}

public func FxMoveAirshipToWipfTimer(object target, proplist effect, int time)
{
	var right_wipf = FindObject(Find_ID(Wipf), Find_NoContainer(), Find_InRect(AbsX(616), AbsY(0), 248, 280), Find_Property("tied_up"), Sort_Reverse(Sort_Func("GetX")));
	if (!right_wipf)
		return FX_Execute_Kill;
	if (Abs(this.airship->GetX() - right_wipf->GetX()) < 8)
	{
		this.airship->ControlStop(this.kidnapper);
		// Shoot blunderbuss.
		if (!right_wipf.shot)
		{
			var blunderbuss = FindObject(Find_ID(Blunderbuss), Find_Container(this.henchman3));
			blunderbuss.BulletsPerShot = 1;
			blunderbuss.BulletSpread = 0;
			blunderbuss.loaded = true;
			blunderbuss->ControlUseStart(target, right_wipf->GetX() - this.henchman3->GetX(), right_wipf->GetY() - this.henchman3->GetY() - 24);
			blunderbuss->ControlUseHolding(target, right_wipf->GetX() - this.henchman3->GetX(), right_wipf->GetY() - this.henchman3->GetY() - 24);
			blunderbuss->ControlUseStop(target, right_wipf->GetX() - this.henchman3->GetX(), right_wipf->GetY() - this.henchman3->GetY() - 24);
			right_wipf.shot = true;
		}
		return FX_OK;
	}
	if (this.airship->GetX() > right_wipf->GetX())
		this.airship->ControlLeft(this.kidnapper);
	else
		this.airship->ControlRight(this.kidnapper);
	return FX_OK;
}

public func FxMoveAirshipToWipfStop(object target, proplist effect, int reason, bool temp)
{
	if (temp)
		return FX_OK;
	return FX_OK;
}