-
Notifications
You must be signed in to change notification settings - Fork 3
/
ConFile.Writer.pas
634 lines (509 loc) · 25.9 KB
/
ConFile.Writer.pas
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
unit ConFile.Writer;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Dialogs, winapi.ActiveX, ConEditPlus.Consts, Conversation.Classes, system.TypInfo,
vcl.ComCtrls, MainWindow;
procedure SaveConFile(newFile: string);
procedure WriteString(cw: TBinaryWriter; str: String);
procedure WriteDouble(cw: TBinaryWriter; dbl: Double);
procedure WriteInteger(cw: TBinaryWriter; Int: Integer);
procedure WriteLongBool(cw: TBinaryWriter; LBool: LongBool);
procedure WriteCommonEventFields(cw: TBinaryWriter; Event: TConEvent);
function DateTimeStrToDouble(str: string): Double;
function GetTablesSize(): Integer;
procedure SaveConFileHeader(ConWrite: TBinaryWriter);
procedure SaveSpeech(ConWrite: TBinaryWriter; eventSpeech: TConEventSpeech); // 00
procedure SaveChoice(ConWrite: TBinaryWriter; eventChoice: TConEventChoice); // 01
procedure SaveSetFlag(ConWrite: TBinaryWriter; eventSetFlag: TConEventSetFlag); // 02
procedure SaveCheckFlag(ConWrite: TBinaryWriter; eventCheckFlag: TConEventCheckFlag); // 03
procedure SaveCheckObject(ConWrite: TBinaryWriter; eventCheckObj: TConEventCheckObject); // 04
procedure SaveTransObject(ConWrite: TBinaryWriter; eventTransObject: TConEventTransferObject); // 05
procedure SaveMoveCam(ConWrite: TBinaryWriter; eventMoveCam: TConEventMoveCamera); // 06
procedure SavePlayAnim(ConWrite: TBinaryWriter; eventPlayAnim: TConEventAnimation); // 07
procedure SaveTrade(ConWrite: TBinaryWriter; eventTrade: TConEventTrade); // 08
procedure SaveJump(ConWrite: TBinaryWriter; eventJump: TConEventJump); // 09
procedure SaveRandom(ConWrite: TBinaryWriter; eventRandom: TConEventRandom); //10
procedure SaveTrigger(ConWrite: TBinaryWriter; eventTrigger: TConEventTrigger); //11
procedure SaveAddGoal(ConWrite: TBinaryWriter; eventAddGoal: TConEventAddGoal); // 12
procedure SaveAddNote(ConWrite: TBinaryWriter; eventAddNote: TConEventAddNote); // 13
procedure SaveAddSkillPts(ConWrite: TBinaryWriter; eventAddSkillPts: TConEventAddSkillPoints); // 14
procedure SaveAddCredits(ConWrite: TBinaryWriter; eventAddCredits: TConEventAddCredits); // 15
procedure SaveCheckPersona(ConWrite: TBinaryWriter; eventCheckPersona: TConEventCheckPersona); // 16
procedure SaveComment(ConWrite: TBinaryWriter; eventComment: TConEventComment); // 17
procedure SaveEnd(ConWrite: TBinaryWriter; eventEnd: TConEventEnd); // 18
implementation
function DateTimeStrToDouble(str: string): Double;
begin
Result := StrToDateTime(str);
end;
function GetTablesSize(): Integer;
var
tempStream: TFileStream;
tempWriter: TBinaryWriter;
begin
var tempDirectory := GetEnvironmentVariable('TEMP');
var tempFile:= IncludeTrailingPathDelimiter(tempDirectory) + 'tables.bin';
frmMain.AddLog('Use tempFile = ' + tempFile);
tempStream := TFileStream.Create(tempFile, fmOpenWrite or fmCreate);
tempWriter := TBinaryWriter.Create(tempStream, TEncoding.ANSI, False);
try
WriteInteger(tempWriter, frmMain.conFileParameters.fpActors.Count); // actors > NumRecords
for var a := 0 to frmMain.conFileParameters.fpActors.Count -1 do
begin
WriteInteger(tempWriter, a); // Index
WriteString(tempWriter, frmMain.conFileParameters.fpActors.Strings[a]); // size of string + string
end;
WriteInteger(tempWriter, frmMain.conFileParameters.fpFlags.Count); // flags > NumRecords
for var f := 0 to frmMain.conFileParameters.fpFlags.Count -1 do
begin
WriteInteger(tempWriter, f);
WriteString(tempWriter, frmMain.conFileParameters.fpFlags.Strings[f]);
end;
WriteInteger(tempWriter, frmMain.conFileParameters.fpSkills.Count); // Skills > NumRecords
for var s := 0 to frmMain.conFileParameters.fpSkills.Count -1 do
begin
WriteInteger(tempWriter, s);
WriteString(tempWriter, frmMain.conFileParameters.fpSkills.Strings[s]);
end;
WriteInteger(tempWriter, frmMain.conFileParameters.fpObjects.Count); // Objects > NumRecords
for var o := 0 to frmMain.conFileParameters.fpObjects.Count -1 do
begin
WriteInteger(tempWriter, o);
WriteString(tempWriter, frmMain.conFileParameters.fpObjects.Strings[o]);
end;
// end of tables
var DataSize := tempStream.Size;
frmMain.AddLog('Tables DataSize = ' + DataSize.ToString);
Result := DataSize;
tempWriter.Close();
finally
tempWriter.Free();
tempStream.Free();
// todo: remove temporary file or find other way to get tables size
end;
end;
procedure SaveConFileHeader(ConWrite: TBinaryWriter); // save information
begin
var tablesSize := GetTablesSize();
var fileHdrBytes: TBytes;
SetLength(fileHdrBytes, Length(conFileHeader));
for var th := 0 to Length(conFileHeader) -1 do
fileHdrBytes[th] := conFileHeader[th];
ConWrite.Write(fileHdrBytes); // Header
WriteInteger(ConWrite, CEP_CONXML_FILE_VERSION); // version
WriteDouble(ConWrite, DateTimeStrToDouble(frmMain.conFileParameters.fpCreatedByDate));
WriteString(ConWrite, frmMain.conFileParameters.fpCreatedByName);
WriteDouble(ConWrite, DateTimeStrToDouble(frmMain.conFileParameters.fpModifiedByDate));
WriteString(ConWrite, frmMain.conFileParameters.fpModifiedByName);
WriteString(ConWrite, frmMain.conFileParameters.fpAudioPackage);
WriteString(ConWrite, frmMain.conFileParameters.fpNotes);
WriteInteger(ConWrite, Length(frmMain.conFileParameters.fpMissions)); // numMissions
for var m := 0 to High(frmMain.conFileParameters.fpMissions) do
begin
WriteInteger(ConWrite, frmMain.conFileParameters.fpMissions[m]);
end;
// write tables here...
WriteInteger(ConWrite, tablesSize); // tables data size. Also Unrecognized1 in .xml version
WriteInteger(ConWrite, frmMain.conFileParameters.fpActors.Count); // actors > NumRecords
for var a := 0 to frmMain.conFileParameters.fpActors.Count -1 do
begin
WriteInteger(ConWrite, a); // Index
WriteString(ConWrite, frmMain.conFileParameters.fpActors.Strings[a]); // size of string + string
end;
WriteInteger(ConWrite, frmMain.conFileParameters.fpFlags.Count); // flags > NumRecords
for var f := 0 to frmMain.conFileParameters.fpFlags.Count -1 do
begin
WriteInteger(ConWrite, f);
WriteString(ConWrite, frmMain.conFileParameters.fpFlags.Strings[f]);
end;
WriteInteger(ConWrite, frmMain.conFileParameters.fpSkills.Count); // Skills > NumRecords
for var s := 0 to frmMain.conFileParameters.fpSkills.Count -1 do
begin
WriteInteger(ConWrite, s);
WriteString(ConWrite, frmMain.conFileParameters.fpSkills.Strings[s]);
end;
WriteInteger(ConWrite, frmMain.conFileParameters.fpObjects.Count); // Objects > NumRecords
for var o := 0 to frmMain.conFileParameters.fpObjects.Count -1 do
begin
WriteInteger(ConWrite, o);
WriteString(ConWrite, frmMain.conFileParameters.fpObjects.Strings[o]);
end;
end;
procedure SaveSpeech(ConWrite: TBinaryWriter; eventSpeech: TConEventSpeech); // 00
begin
WriteCommonEventFields(ConWrite, eventSpeech);
WriteInteger(ConWrite, eventSpeech.ActorIndex); // speaker id
WriteString(ConWrite, eventSpeech.ActorValue); // speaker Name
WriteInteger(ConWrite, eventSpeech.ActorToIndex); // speaking to id
WriteString(ConWrite, eventSpeech.ActorToValue); // speaking to name
WriteString(ConWrite, eventSpeech.TextLine); // speech text
WriteString(ConWrite, eventSpeech.mp3File); // Sound
WriteLongBool(ConWrite, eventSpeech.bContinued); // not implemented in game
WriteLongBool(ConWrite, eventSpeech.bBold); //
WriteInteger(ConWrite, eventSpeech.SpeechFont); //
end;
procedure SaveChoice(ConWrite: TBinaryWriter; eventChoice: TConEventChoice); // 01
begin
WriteCommonEventFields(ConWrite, eventChoice);
WriteInteger(ConWrite, eventChoice.choice_unk0); // choice_unk0
WriteLongBool(ConWrite, eventChoice.bClearScreen); // bClearScreen
WriteInteger(ConWrite, eventChoice.NumChoices); // numChoiceList
for var chi := 0 to eventChoice.NumChoices -1 do
begin
WriteInteger(ConWrite, eventChoice.Choices[chi].Index); // unk0
WriteString(ConWrite, eventChoice.Choices[chi].textline); // choiceText
WriteLongBool(ConWrite, eventChoice.Choices[chi].bDisplayAsSpeech); // bDisplayAsSpeech
if eventChoice.Choices[chi].bSkillNeeded = -1 then
begin
WriteInteger(ConWrite, -1); // skill is not required, so write skillName.id = -1
end;
if eventChoice.Choices[chi].bSkillNeeded >= 0 then
begin
WriteInteger(ConWrite, eventChoice.Choices[chi].bSkillNeeded); // skill required, so write skillName.id
WriteString(ConWrite, eventChoice.Choices[chi].Skill); // skillName
WriteInteger(ConWrite, eventChoice.Choices[chi].SkillLevel); // skilllevelNeeded
end;
WriteString(ConWrite, eventChoice.Choices[chi].GoToLabel); // choiceLabel
WriteString(ConWrite, eventChoice.Choices[chi].mp3); // soundPath
var numFlagRefListChi := Length(eventChoice.Choices[chi].RequiredFlags);
WriteInteger(ConWrite, numFlagRefListChi); // numFlagRefList
for var NFRCh := 0 to numFlagRefListChi -1 do
begin
WriteInteger(ConWrite, eventChoice.Choices[chi].RequiredFlags[NFRCh].flagIndex);
WriteString(ConWrite, eventChoice.Choices[chi].RequiredFlags[NFRCh].flagName);
WriteLongBool(ConWrite, eventChoice.Choices[chi].RequiredFlags[NFRCh].flagValue);
WriteInteger(ConWrite, eventChoice.Choices[chi].RequiredFlags[NFRCh].flagExpiration);
end;
end;
end;
procedure SaveSetFlag(ConWrite: TBinaryWriter; eventSetFlag: TConEventSetFlag); // 02
begin
WriteCommonEventFields(ConWrite, eventSetFlag);
var numFlagRefListSF := Length(eventSetFlag.SetFlags);
WriteInteger(ConWrite, numFlagRefListSF); // numFlagRefList
for var NFRSF := 0 to numFlagRefListSF -1 do
begin
WriteInteger(ConWrite, eventSetFlag.SetFlags[NFRSF].flagIndex);
WriteString(ConWrite, eventSetFlag.SetFlags[NFRSF].flagName);
WriteLongBool(ConWrite, eventSetFlag.SetFlags[NFRSF].flagValue);
WriteInteger(ConWrite, eventSetFlag.SetFlags[NFRSF].flagExpiration);
end;
end;
procedure SaveCheckFlag(ConWrite: TBinaryWriter; eventCheckFlag: TConEventCheckFlag); // 03
begin
WriteCommonEventFields(ConWrite, eventCheckFlag);
var numFlagRefListCHF := Length(eventCheckFlag.FlagsToCheck);
WriteInteger(ConWrite, numFlagRefListCHF); // numFlagRefList
for var NFRCHF := 0 to numFlagRefListCHF -1 do
begin
WriteInteger(ConWrite, eventCheckFlag.FlagsToCheck[NFRCHF].flagIndex);
WriteString(ConWrite, eventCheckFlag.FlagsToCheck[NFRCHF].flagName);
WriteLongBool(ConWrite, eventCheckFlag.FlagsToCheck[NFRCHF].flagValue);
WriteInteger(ConWrite, eventCheckFlag.FlagsToCheck[NFRCHF].flagExpiration);
end;
WriteString(ConWrite, eventCheckFlag.GotoLabel); // setLabel
end;
procedure SaveCheckObject(ConWrite: TBinaryWriter; eventCheckObj: TConEventCheckObject); // 04
begin
WriteCommonEventFields(ConWrite, eventCheckObj);
WriteInteger(ConWrite, eventCheckObj.ObjectIndex); // objectName.id
WriteString(ConWrite, eventCheckObj.ObjectValue); // objectName.Name
WriteString(ConWrite, eventCheckObj.GoToLabel); // failLabel
end;
procedure SaveTransObject(ConWrite: TBinaryWriter; eventTransObject: TConEventTransferObject); // 05
begin
WriteCommonEventFields(ConWrite, eventTransObject);
WriteInteger(ConWrite, eventTransObject.ObjectIndex); // objectName.id
WriteString(ConWrite, eventTransObject.ObjectValue); // objectName.Name
WriteInteger(ConWrite, eventTransObject.Amount); // TransferCount
WriteInteger(ConWrite, eventTransObject.ActorFromIndex);
WriteString(ConWrite, eventTransObject.ActorFromValue);
WriteInteger(ConWrite, eventTransObject.ActorToIndex);
WriteString(ConWrite, eventTransObject.ActorToValue);
WriteString(ConWrite, eventTransObject.GotoLabel); // failLabel
end;
procedure SaveMoveCam(ConWrite: TBinaryWriter; eventMoveCam: TConEventMoveCamera); // 06
begin
WriteCommonEventFields(ConWrite, eventMoveCam);
WriteInteger(ConWrite, Ord(eventMoveCam.CameraType)); // cameraType
if eventMoveCam.CameraType = CT_Random then
WriteInteger(ConWrite, 0)
else
WriteInteger(ConWrite, Ord(eventMoveCam.CameraAngle)); // cameraPosition
WriteInteger(ConWrite, -1); // cameraTransition was not implemented anyway, so just write -1
end;
procedure SavePlayAnim(ConWrite: TBinaryWriter; eventPlayAnim: TConEventAnimation); // 07
begin
WriteCommonEventFields(ConWrite, eventPlayAnim);
WriteInteger(ConWrite, eventPlayAnim.ActorIndex); // eventOwnerName.id
WriteString(ConWrite, eventPlayAnim.ActorValue); // eventOwnerName.Name
WriteString(ConWrite, eventPlayAnim.AnimSequence); // seqStr
case eventPlayAnim.AnimPlayMode of
AM_Loop: WriteInteger(ConWrite, 0);
AM_Once: WriteInteger(ConWrite, 1);
// AM_Loop: WriteLongBool(ConWrite, True);
// AM_Once: WriteLongBool(ConWrite, False);
end;
// WriteInteger(ConWrite, Ord(eventPlayAnim.AnimPlayMode)); // Once or Loop, as Integer
// WriteLongBool(ConWrite, eventPlayAnim.bAnimPlayOnce); // playMode.
// WriteLongBool(ConWrite, not eventPlayAnim.bAnimPlayOnce); // playMode. // WTF? Maybe convert it to Enum?
WriteInteger(ConWrite, eventPlayAnim.AnimPlayForSeconds); // This field is missing in ConEventAnimation.uc (by default)
WriteLongBool(ConWrite, eventPlayAnim.bAnimWaitToFinish); // bFinishAnim
end;
procedure SaveTrade(ConWrite: TBinaryWriter; eventTrade: TConEventTrade); // 08
begin
//
end;
procedure SaveJump(ConWrite: TBinaryWriter; eventJump: TConEventJump); // 09
begin
WriteCommonEventFields(ConWrite, eventJump);
WriteString(ConWrite, eventJump.gotoLabel); // jumpLabel
WriteInteger(ConWrite, eventJump.conversationId); // conId
end;
procedure SaveRandom(ConWrite: TBinaryWriter; eventRandom: TConEventRandom); //10
begin
WriteCommonEventFields(ConWrite, eventRandom);
var numRandomLabels := Length(eventRandom.GoToLabels);
WriteInteger(ConWrite, numRandomLabels);
for var NRL := 0 to numRandomLabels -1 do
WriteString(ConWrite, eventRandom.GoToLabels[NRL]);
WriteLongBool(ConWrite, eventRandom.bCycle); // cycle events
WriteLongBool(ConWrite, eventRandom.bCycleOnce);
WriteLongBool(ConWrite, eventRandom.bCycleRandom);
end;
procedure SaveTrigger(ConWrite: TBinaryWriter; eventTrigger: TConEventTrigger); //11
begin
WriteCommonEventFields(ConWrite, eventTrigger);
WriteString(ConWrite, eventTrigger.TriggerTag);
end;
procedure SaveAddGoal(ConWrite: TBinaryWriter; eventAddGoal: TConEventAddGoal); // 12
begin
WriteCommonEventFields(ConWrite, eventAddGoal);
WriteString(ConWrite, eventAddGoal.GoalName);
var bGoalCompleted := eventAddGoal.bComplete;
WriteLongBool(ConWrite, bGoalCompleted);
if (bGoalCompleted = False) then
begin
WriteString(ConWrite, eventAddGoal.GoalText);
WriteLongBool(ConWrite, eventAddGoal.bPrimaryGoal);
end;
end;
procedure SaveAddNote(ConWrite: TBinaryWriter; eventAddNote: TConEventAddNote); // 13
begin
WriteCommonEventFields(ConWrite, eventAddNote);
WriteString(ConWrite, eventAddNote.TextLine); // noteText
end;
procedure SaveAddSkillPts(ConWrite: TBinaryWriter; eventAddSkillPts: TConEventAddSkillPoints); // 14
begin
WriteCommonEventFields(ConWrite, eventAddSkillPts);
WriteInteger(ConWrite, eventAddSkillPts.Points); // pointsToAdd
WriteString(ConWrite, eventAddSkillPts.TextLine); // awardMessage
end;
procedure SaveAddCredits(ConWrite: TBinaryWriter; eventAddCredits: TConEventAddCredits); // 15
begin
WriteCommonEventFields(ConWrite, eventAddCredits);
WriteInteger(ConWrite, eventAddCredits.Credits);
end;
procedure SaveCheckPersona(ConWrite: TBinaryWriter; eventCheckPersona: TConEventCheckPersona); // 16
begin
WriteCommonEventFields(ConWrite, eventCheckPersona);
WriteInteger(ConWrite, Ord(eventCheckPersona.AttrToCheck)); // personaType
WriteInteger(ConWrite, Ord(eventCheckPersona.Condition));
WriteInteger(ConWrite, eventCheckPersona.CheckValue);
WriteString(ConWrite, eventCheckPersona.CheckGoToLabel); // JumpLabel
end;
procedure SaveComment(ConWrite: TBinaryWriter; eventComment: TConEventComment); // 17
begin
WriteCommonEventFields(ConWrite, eventComment);
WriteString(ConWrite, eventComment.TextLine); // comment
end;
procedure SaveEnd(ConWrite: TBinaryWriter; eventEnd: TConEventEnd); // 18
begin
WriteCommonEventFields(ConWrite, eventEnd);
end;
procedure SaveConFile(newFile: string);
var
fileStr: TFileStream;
ConWrite: TBinaryWriter;
begin
fileStr := TFileStream.Create(newFile, fmOpenWrite or fmCreate);
ConWrite := TBinaryWriter.Create(fileStr, TEncoding.ANSI, False);
try
SaveConFileHeader(ConWrite);
var numConversations := frmMain.ConversationsList.Count;
var convList := frmMain.ConversationsList;
WriteInteger(ConWrite, numConversations); // unknown3, same as numConversations?
WriteInteger(ConWrite, numConversations); // numConversations
for var nc := 0 to numConversations -1 do
begin
//WriteInteger(ConWrite, convList.Items[nc].id); // unknown0
WriteInteger(ConWrite, Length(convList.Items[nc].Events)); // unknown0
WriteInteger(ConWrite, convList.Items[nc].id);
WriteString(ConWrite, convList.Items[nc].conName);
WriteString(ConWrite, convList.Items[nc].conDescription);
WriteDouble(ConWrite, DateTimeStrToDouble(convList.Items[nc].conCreatedByDate)); // createdOn
WriteString(ConWrite, convList.Items[nc].conCreatedByName); // createdBy
WriteDouble(ConWrite, DateTimeStrToDouble(convList.Items[nc].conModifiedByDate)); // lastModifiedOn
WriteString(ConWrite, convList.Items[nc].conModifiedByName); // lastModifiedBy
WriteInteger(ConWrite, convList.Items[nc].conOwnerIndex); // OwnerName id
WriteString(ConWrite, convList.Items[nc].conOwnerName); // OwnerName
WriteLongBool(ConWrite, convList.Items[nc].bInfoLink);
WriteString(ConWrite, convList.Items[nc].conNotes); // notes
WriteLongBool(ConWrite, convList.Items[nc].bOnlyOnce); // bDisplayOnce
WriteLongBool(ConWrite, convList.Items[nc].bFirstPerson);
WriteLongBool(ConWrite, convList.Items[nc].bNonInteract);
WriteLongBool(ConWrite, convList.Items[nc].bRandomCamera);
WriteLongBool(ConWrite, convList.Items[nc].bCanInterrupt);
WriteLongBool(ConWrite, convList.Items[nc].bCannotInterrupt);
WriteLongBool(ConWrite, convList.Items[nc].bPCBumps);
WriteLongBool(ConWrite, convList.Items[nc].bPCFrobs);
WriteLongBool(ConWrite, convList.Items[nc].bNPCSees);
WriteLongBool(ConWrite, convList.Items[nc].bNPCEnters);
WriteInteger(ConWrite, convList.Items[nc].distance); // Radius
var numFlagRefList := Length(convList.Items[nc].conDependsOnFlags); // array size
WriteInteger(ConWrite, numFlagRefList); // write numFlagRefList
for var nfr := 0 to numFlagRefList -1 do
begin
WriteInteger(ConWrite, convList.Items[nc].conDependsOnFlags[nfr].flagIndex);
WriteString(ConWrite, convList.Items[nc].conDependsOnFlags[nfr].flagName);
WriteLongBool(ConWrite, convList.Items[nc].conDependsOnFlags[nfr].flagValue);
WriteInteger(ConWrite, convList.Items[nc].conDependsOnFlags[nfr].flagExpiration);
end;
var numEventList := Length(convList.Items[nc].Events); // array size
WriteInteger(ConWrite, numEventList); // write numEventList
for var NEL := 0 to numEventList -1 do
begin
if convList.Items[nc].Events[NEL].EventType = ET_Speech then // 00
begin
var eventSpeech := TConEventSpeech(convList.Items[nc].Events[NEL]);
SaveSpeech(ConWrite, eventSpeech);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Choice then //01
begin
var eventChoice := TConEventChoice(convList.Items[nc].Events[NEL]);
SaveChoice(ConWrite, eventChoice);
end;
if convList.Items[nc].Events[NEL].EventType = ET_SetFlag then // 02
begin
var eventSetFlag := TConEventSetFlag(convList.Items[nc].Events[NEL]);
SaveSetFlag(ConWrite, eventSetFlag);
end;
if convList.Items[nc].Events[NEL].EventType = ET_CheckFlag then // 03
begin
var eventCheckFlag := TConEventCheckFlag(convList.Items[nc].Events[NEL]);
SaveCheckFlag(ConWrite, eventCheckFlag);
end;
if convList.Items[nc].Events[NEL].EventType = ET_CheckObject then // 04
begin
var eventCheckObject := TConEventCheckObject(convList.Items[nc].Events[NEL]);
SaveCheckObject(ConWrite, eventCheckObject);
end;
if convList.Items[nc].Events[NEL].EventType = ET_TransferObject then // 05
begin
var eventTransObject := TConEventTransferObject(convList.Items[nc].Events[NEL]);
SaveTransObject(ConWrite, eventTransObject);
end;
if convList.Items[nc].Events[NEL].EventType = ET_MoveCamera then // 06
begin
var eventMoveCam := TConEventMoveCamera(convList.Items[nc].Events[NEL]);
SaveMoveCam(ConWrite, eventMoveCam);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Animation then // 07
begin
var eventAnim := TConEventAnimation(convList.Items[nc].Events[NEL]);
SavePlayAnim(ConWrite, eventAnim);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Trade then // 08
begin
// not implemented (at least for now)
end;
if convList.Items[nc].Events[NEL].EventType = ET_Jump then // 09
begin
var eventJump := TConEventJump(convList.Items[nc].Events[NEL]);
SaveJump(ConWrite, eventJump);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Random then // 10
begin
var eventRandom := TConEventRandom(convList.Items[nc].Events[NEL]);
SaveRandom(ConWrite, eventRandom);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Trigger then // 11
begin
var eventTrigger := TConEventTrigger(convList.Items[nc].Events[NEL]);
SaveTrigger(ConWrite, eventTrigger);
end;
if convList.Items[nc].Events[NEL].EventType = ET_AddGoal then // 12
begin
var eventAddGoal := TConEventAddGoal(convList.Items[nc].Events[NEL]);
SaveAddGoal(ConWrite, eventAddGoal);
end;
if convList.Items[nc].Events[NEL].EventType = ET_AddNote then // 13
begin
var eventAddNote := TConEventAddNote(convList.Items[nc].Events[NEL]);
SaveAddNote(ConWrite, eventAddNote);
end;
if convList.Items[nc].Events[NEL].EventType = ET_AddSkillPoints then // 14
begin
var eventAddSkillPoints := TConEventAddSkillPoints(convList.Items[nc].Events[NEL]);
SaveAddSkillPts(ConWrite, eventAddSkillPoints);
end;
if convList.Items[nc].Events[NEL].EventType = ET_AddCredits then // 15
begin
var eventAddCredits := TConEventAddCredits(convList.Items[nc].Events[NEL]);
SaveAddCredits(ConWrite, eventAddCredits);
end;
if convList.Items[nc].Events[NEL].EventType = ET_CheckPersona then // 16
begin
var eventCheckPersona := TConEventCheckPersona(convList.Items[nc].Events[NEL]);
SaveCheckPersona(ConWrite, eventCheckPersona);
end;
if convList.Items[nc].Events[NEL].EventType = ET_Comment then // 17
begin
var eventComment := TConEventComment(convList.Items[nc].Events[NEL]);
SaveComment(ConWrite, eventComment);
end;
if convList.Items[nc].Events[NEL].EventType = ET_End then // 18
begin
var eventEnd := TConEventEnd(convList.Items[nc].Events[NEL]);
SaveEnd(ConWrite, eventEnd);
end;
end;
end;
ConWrite.Close();
finally
ConWrite.Free();
fileStr.Free();
end;
end;
procedure WriteString(cw: TBinaryWriter; str: String);
begin
var StrSize := Length(str);
if StrSize = 0 then
begin
cw.Write(Integer(0));
Exit();
end;
cw.Write(Integer(StrSize)); // write size of string...
cw.Write(TEncoding.ANSI.GetBytes(str)); // and string
end;
procedure WriteDouble(cw: TBinaryWriter; dbl: Double);
begin
cw.Write(Double(dbl));
end;
procedure WriteInteger(cw: TBinaryWriter; Int: Integer);
begin
cw.Write(Integer(Int));
end;
procedure WriteLongBool(cw: TBinaryWriter; LBool: LongBool);
begin
cw.Write(Integer(LBool));
end;
procedure WriteCommonEventFields(cw: TBinaryWriter; Event: TConEvent);
begin
WriteInteger(cw, Event.EventIdx);
WriteInteger(cw, Event.unknown1);
WriteInteger(cw, Ord(Event.EventType));
WriteString(cw, Event.EventLabel);
end;
end.