-
Notifications
You must be signed in to change notification settings - Fork 3
/
Conversation.Classes.pas
592 lines (471 loc) · 12.7 KB
/
Conversation.Classes.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
//
// Contains enums, class declarations, etc.
//
unit Conversation.Classes;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, ConEditPlus.Consts,
System.Types, System.Generics.Collections;
function conXMLDateTime(): string;
type TEventType =
(
ET_Speech,
ET_Choice,
ET_SetFlag,
ET_CheckFlag,
ET_CheckObject,
ET_TransferObject,
ET_MoveCamera,
ET_Animation,
ET_Trade,
ET_Jump,
ET_Random,
ET_Trigger,
ET_AddGoal,
ET_AddNote,
ET_AddSkillPoints,
ET_AddCredits,
ET_CheckPersona,
ET_Comment,
ET_End
);
// Camera Types
type TCameraTypes =
(
CT_Predefined, // 0
CT_Speakers, // 1
CT_Actor, // 2
CT_Random // 3
);
// Predefined Camera Positions
type TCameraPositions =
(
CP_SideTight,
CP_SideMid,
CP_SideAbove,
CP_SideAbove45,
CP_ShoulderLeft,
CP_ShoulderRight,
CP_HeadShotTight,
CP_HeadShotMid,
CP_HeadShotLeft,
CP_HeadShotRight,
CP_HeadShotSlightRight,
CP_HeadShotSlightLeft,
CP_StraightAboveLookingDown,
CP_StraightBelowLookingUp,
CP_BelowLookingUp
);
type TCameraTransitions =
(
TR_Jump,
TR_Spline
);
type TAnimationModes =
(
AM_Loop, // 0 = Loop
AM_Once // 1 = Once. Integer, 4 bytes.
);
type TConditions =
(
EC_Less,
EC_LessEqual,
EC_Equal,
EC_GreaterEqual,
EC_Greater
);
// Event Persona types
type TPersonaTypes =
(
EP_Credits,
EP_Health,
EP_SkillPoints
);
type TEventHighlightType =
(
EHT_None, // do not highlight
EHT_Related, // Highlight as related (yellow gradient)
EHT_Error // Error, some labels are missing
);
// for use in TConversation and TConEventCheckFlag
type TFlag = record
flagIndex: Integer;
flagName: string;
flagValue: Boolean;
flagExpiration: Integer;
end;
TConBaseObject = class(TObject) // base class!
public
destructor Destroy(); override;
end;
TChoiceItemObject = class(TConBaseObject) // for editing Choice Items, use as listview item.data
public
Index: Integer;
textline: string;
bDisplayAsSpeech: Boolean;
bSkillNeeded: Integer; // 4 bytes. if -1, then Skill is not required. Otherwise there will be skill id from table and skillName.
// 0 - true, -1 false
// was Boolean before ConEditExport ver. 7
Skill: string; // skillName
SkillLevel: Integer; // from 0 to 3
GoToLabel: string;
mp3: string;
RequiredFlags: array of TFlag;
end;
TConEvent = class(TConBaseObject)
EventIdx: Integer; // looks like Index (was Unknown0)
unknown1: Integer; // Checked decompiled convos, looks like Index + 1.
EventLabel: string; // can't use "Label"...
EventType: TEventType; // speech, choice, etc...
EventHighlightType: TEventHighlightType; // To highlight events (related/error)
end;
TConEventSpeech = class(TConEvent) // 00 // Speech event
ActorIndex: Integer;
ActorValue: string;
ActorToIndex: Integer;
ActorToValue: string;
TextLine: string;
mp3File: string;
bContinued: Boolean; // not used
bBold: Boolean; // not used
SpeechFont: Integer; // not used
LineWrapCount: Integer; // To adjust height
public
constructor Create();
end;
TConEventChoice = class(TConEvent) // 01
choice_unk0: Integer; // 4 bytes
bClearScreen: boolean;
Choices: array of TChoiceItemObject;
NumChoices: Integer; // for height of this item in the events list
NumFlagsRefs: Integer; // same
public
constructor Create();
destructor Destroy(); override;
end;
TConEventSetFlag = class(TConEvent) // 02
SetFlags: array of TFlag;
numFlags: Integer;
public
constructor Create();
end;
TConEventCheckFlag = class(TConEvent) // 03
numFlags: Integer;
FlagsToCheck: array of TFlag;
GotoLabel: string;
public
constructor Create();
end;
TConEventCheckObject = class(TConEvent) // 04
ObjectIndex: Integer;
ObjectValue: string;
GoToLabel: string;
public
constructor Create();
end;
TConEventTransferObject = class(TConEvent) // 05
ObjectIndex: Integer;
ObjectValue: string;
Amount: Integer;
ActorFromIndex: Integer;
ActorFromValue: string;
ActorToIndex: Integer;
ActorToValue: string;
GotoLabel: string;
public
constructor Create();
end;
TConEventMoveCamera = class(TConEvent) // 06
CameraType: TCameraTypes;
CameraAngle: TCameraPositions;
CameraTransition: TCameraTransitions;
public
constructor Create();
end;
TConEventAnimation = class(TConEvent) // 07
ActorIndex: Integer;
ActorValue: string;
AnimSequence: string;
AnimPlayMode: TAnimationModes;
AnimPlayForSeconds: Integer;
bAnimWaitToFinish: Boolean;
public
constructor Create();
end;
TConEventTrade = class(TConEvent) // 08
TradeActorIndex: Integer;
TradeActorValue: string;
public
constructor Create();
end;
TConEventJump = class(TConEvent) // 09
gotoLabel: string;
conversationId: Integer;
currentConversationId: Integer;
public
constructor Create();
end;
TConEventRandom = class(TConEvent) // 10
numLabels: Integer;
GoToLabels: array of string;
bCycle: Boolean;
bCycleOnce: Boolean;
bCycleRandom: Boolean;
public
constructor Create();
end;
TConEventTrigger = class(TConEvent) // 11
TriggerTag: string;
public
constructor Create();
end;
TConEventAddGoal = class(TConEvent) // 12
GoalName: string;
bComplete: Boolean;
GoalText: string;
LineWrapCount: Integer; // To adjust height
bPrimaryGoal: Boolean;
public
constructor Create();
end;
TConEventAddNote = class(TConEvent) // 13
TextLine: string;
LineWrapCount: Integer; // To adjust height
public
constructor Create();
end;
TConEventAddSkillPoints = class(TConEvent) // 14
Points: Integer;
TextLine: string;
LineWrapCount: Integer; // To adjust height
public
constructor Create();
end;
TConEventAddCredits = class(TConEvent) // 15
Credits: Integer;
public
constructor Create();
end;
TConEventCheckPersona = class(TConEvent) // 16
AttrToCheck: TPersonaTypes;
Condition: TConditions;
CheckValue: Integer;
CheckGoToLabel: string;
public
constructor Create();
end;
TConEventComment = class(TConEvent) // 17
TextLine: string;
LineWrapCount: Integer; // To adjust height
public
constructor Create();
end;
TConEventEnd = class(TConEvent) // 18
public
constructor Create();
end;
// Every TConversation contains events like End, TransferObject, etc.
TConversation = class(TConBaseObject)
unknown0: Integer; // Äëÿ .con ôàéëîâ, 4 áàéòà. Âûãëÿäèò òàê áóäòî ýòî äóáëèêàò numEventList!
id: Integer;
conName: string; // Conversation Name
conDescription: string; // missing in XML version?
conCreatedByDate: string;
conCreatedByName: string; // Who created this conversation
conModifiedByDate: string;
conModifiedByName: string;
// conversation has only one owner
conOwnerIndex: Integer;
conOwnerName: string; // Name of Actor owner
// How conversation is activated + options
bInfoLink: Boolean; // True if this is a DataLink conversation
conNotes: string; // Did anyone ever used Notes and Description fields?
bOnlyOnce: Boolean; // Flag to display conversation only once
bFirstPerson: Boolean;
bNonInteract: Boolean; // True if non-interactive conversation
bRandomCamera: Boolean;
bCanInterrupt: Boolean;
bCannotInterrupt: Boolean;
bPCBumps: Boolean;
bPCFrobs: Boolean; // Invoke by Frobbing
bNPCSees: Boolean;
bNPCEnters: Boolean;
distance: Integer;
// flags...
conDependsOnFlags: array of TFlag;
// events...
numEventList: Integer; // 4 bytes
Events: array of TConEvent;
constructor Create();
destructor Destroy(); override;
end;
// Contains base information about conversation file.
TConFileParameters = class (TObject)
fpFileVersion: Integer;
fpCreatedByName: string;
fpCreatedByDate: string;
fpModifiedByDate: string;
fpModifiedByName: string;
fpAudioPackage: string;
fpNotes: string;
var fpMissions: array of Integer;
tablesSize: Integer; // for .con files
var fpActors: TStringList;
var fpFlags: TStringList; //TStringList contains strings and automatically adds indexes, this is exactly what I need!
var fpSkills: TStringList;
var fpObjects: TStringList;
{public declarations}
public
constructor Create();
destructor Destroy(); override;
procedure Clear();
end;
// default values for flags
const
DefaultFlag: TFlag = (flagIndex: -1; flagName: ''; flagValue: False; flagExpiration: 0);
implementation
destructor TConBaseObject.Destroy();
begin
inherited;
end;
constructor TConEventSpeech.Create(); // 00
begin
EventType:= ET_Speech;
end;
constructor TConEventChoice.Create(); // 01
begin
EventType:= ET_Choice;
end;
constructor TConEventSetFlag.Create(); // 02
begin
EventType:= ET_SetFlag;
end;
constructor TConEventCheckFlag.Create(); // 03
begin
EventType := ET_CheckFlag;
end;
constructor TConEventCheckObject.Create(); // 04
begin
EventType := ET_CheckObject;
end;
constructor TConEventTransferObject.Create(); // 05
begin
EventType := ET_TransferObject;
end;
constructor TConEventMoveCamera.Create(); // 06
begin
EventType := ET_MoveCamera;
end;
constructor TConEventAnimation.Create(); // 07
begin
EventType := ET_Animation;
end;
constructor TConEventTrade.Create(); // 08
begin
EventType := ET_Trade;
end;
constructor TConEventJump.Create(); // 09
begin
EventType := ET_Jump;
end;
constructor TConEventRandom.Create(); // 10
begin
EventType := ET_Random;
end;
constructor TConEventTrigger.Create(); // 11
begin
EventType := ET_Trigger;
end;
constructor TConEventAddGoal.Create(); // 12
begin
EventType := ET_AddGoal;
end;
constructor TConEventAddNote.Create(); // 13
begin
EventType := ET_AddNote;
end;
constructor TConEventAddSkillPoints.Create(); // 14
begin
EventType := ET_AddSkillPoints;
end;
constructor TConEventAddCredits.Create(); // 15
begin
EventType := ET_AddCredits;
end;
constructor TConEventCheckPersona.Create(); // 16
begin
EventType := ET_CheckPersona;
end;
constructor TConEventComment.Create(); // 17
begin
EventType := ET_Comment;
end;
constructor TConEventEnd.Create(); // 18
begin
EventType:= ET_End;
end;
constructor TConversation.Create();
begin
conCreatedByDate := conXMLDateTime();
conModifiedByDate := conXMLDateTime();
// defaults from OG ConEdit
bOnlyOnce := True;
bPCFrobs := True;
bPCBumps := True;
inherited;
end;
constructor TConFileParameters.Create(); // create required lists here. Also fill some fields.
begin
fpFileVersion := CEP_CONXML_FILE_VERSION;
fpCreatedByDate := conXMLDateTime();
fpActors := TStringList.Create();
fpFlags := TStringList.Create();
fpSkills := TStringList.Create();
fpObjects := TStringList.Create();
inherited;
end;
destructor TConFileParameters.Destroy(); // îñâîáîäèòü ïàìÿòü ïðè óíè÷òîæåííèè îáúåêòà
begin
fpActors.Free();
fpFlags.Free();
fpSkills.Free();
fpObjects.Free();
inherited;
end;
procedure TConFileParameters.Clear(); // clear everything and set current date + time
begin
fpCreatedByName:= '';
fpCreatedByDate:= conXMLDateTime();
fpModifiedByName:= '';
fpModifiedByDate:= conXMLDateTime();
fpAudioPackage:= '';
fpNotes:='';
fpActors.Clear();
fpFlags.Clear();
fpSkills.Clear();
fpObjects.Clear();
end;
function conXMLDateTime(): string;
var
currDateTime: string;
begin
currDateTime := DateTimeToStr(Now());
Result := currDateTime;
end;
destructor TConversation.Destroy();
begin
for var i := 0 to High(Events) do
if Assigned(Events[i]) = True then
Events[i].Free(); // Îñâîáîæäàåì îáúåêò
SetLength(Events, 0); // Î÷èùàåì ìàññèâ
inherited;
end;
destructor TConEventChoice.Destroy();
begin
for var i:= 0 to High(Choices) do
if Assigned(Choices[i]) then
Choices[i].Free();
SetLength(Choices, 0);
inherited;
end;
end.