-
Notifications
You must be signed in to change notification settings - Fork 1
/
MapObj_Lib.pas
4076 lines (3617 loc) · 101 KB
/
MapObj_Lib.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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit MapObj_Lib;
interface
(***************************************)
(* TFK Objects version 1.0.1.6*)
(***************************************)
(* Created by Neoff *)
(* mail : neoff@fryazino.net *)
(* site : http://tfk.mirgames.ru *)
(***************************************)
//{6 âåðñèÿ áèáëèîòåêè âêëþ÷àåò ïîääåðæêó íîâîé ôèçèêè TFK â âèäå
//îáúåêòîâ Triangle è Elevator :) êîòîðûå íåïðîíèöàåìû äëÿ ïóëü áëàãîäàðÿ math_lib è weapon_lib
{È ÅÙÅ ÐÀÇ ÏÎÂÒÎÐßÞ - Â FSTRUCT ÎÁÚÅÊÒÀ ÍÅ ÕÐÀÍÈÒÑß REAL-TIME ÏÅÐÅÌÅÍÍÛÕ!!!
ÒÀÊ ×ÒÎ ÍÈÊÀÊÈÕ fstruct.active:=true áûòü íå äîëæíî. active óæå äëÿ äðóãîãî èñïîëüçóåòñÿ - Neoff}
{OBJECT MANIFEST
êàæäûé îáúåêò èìååò òàðãåò ïðè êîòîðîì îí àêòèâèðóåòñÿ (targetname) è òàðãåò êîòîðûé îí
èñïîëüçóåò ïîñëå àêòèâàöèè(target).
procedure Activate èìååò ðàçëè÷íûé âèä äëÿ àêòèâèðîâàíèÿ èãðîêîì è àêòèâèðîâàíèÿ äðóãèì îáúåêòîì
òèï àêòèâàöèè äðóãèì îáúåêòîì(Active: byte):
0 - îáúåêò íå ìîæåò áûòü àêòèâèðîâàí/äåàêòèâèðîâàí
1, 2 - îáúåêò àêòèâèðóåòñÿ/äåàêòèâèðóåòñÿ
íà÷àëüíîå ïîëîæåíèå îáúåêòà îïðåäåëÿåòñÿ ðàçëè÷íûìè ïåðåìåííûìè â çàâèñèìîñòè îò îüúåêòà.
ïîñëå àêòèâàöèè/äåàêòèâàöèè îáúåêò ëèáî âîçâðàòèòñÿ â íà÷. ïîëîæåíèå
÷åðåç wait òàêòîâ, ëèáî, åñëè wait=0 òî îí îñòàíåòñÿ â òåêóùåì ïîëîæåíèè.
îáúåêò àêòèâèðóåò äðóãèå îáúåêòû (ñ òàðãåòîì target) ïîñëå waittarget òàêòîâ,
åñëè êîíå÷íî îí ñïåöèàëüíîãî òèïà (êíîïêà, òðèããåð).
Äëÿ íîâûõ îáúåêòîâ ïåðåõîä ê ëþáîìó ïîëîæåíèþ îáîçíà÷àåòñÿ ñâîèì òàðãåòîì.
Ñì. ëèôò :)
}
{Äàííûé ìàíèôåñò ðàñïðîñòðàíÿåòñÿ íà âñå íîâåéøèå îáúåêòû.
Ëèôò ðàáîòàåò ïî íåìó ;) }
uses
Windows, OpenGL,
Engine_Reg,
Constants_Lib,
Func_Lib,
Type_Lib,
Graph_Lib,
Math_Lib,
ObjAnim_Lib,
ObjSound_Lib,
Demo_Lib,
Particle_lib;
const
ObjCaseSize = 54;
NULLTARGET = 65535;
type
TObjType = (otNone, otRespawn, otJumpPad,
otArmor, otHealth, otPowerUp, otWeapon, otAmmo,
otPortal, otButton, otNFKDoor, otTrigger, otDeathLine,
otWater, otElevator, otTriangle,
otAreaPush, otAreaPain, otLava, otArenaEnd, otAreaTeleport, otTeleportWay,
otEmptyBricks, otBackBricks, otLightLine, otBloodGen, otWeather,
otCTFFlag, otTrain, otTrainPoint, otBelt, otAnimation, otSoundTrigger, otDestroyer,
otMonster, otTeleport);
TSetObjType = set of TObjType;
var
ChildObjects: TSetObjType = [otNone, otRespawn, otJumpPad,
otArmor, otHealth, otPowerUp, otWeapon, otAmmo, otPortal,
otButton, otNFKDoor, otTrigger, otDeathLine, otWater,
otAreaPush, otAreaPain, otLava, otArenaEnd, otLightLine, otBloodGen, otBelt, otAnimation,
otSoundTrigger, otTriangle, otDestroyer, otTeleport];
ShootObjs: TSetObjType = [otButton, otNFKDoor, otTrigger, otElevator,
otArenaEnd, otBloodGen, otDestroyer, otMonster];
ItemObjs: TSetObjType = [otArmor, otHealth, otPowerUp, otWeapon, otAmmo];
NetObjs : TSetObjType = [otArmor, otHealth, otPowerUp, otWeapon, otAmmo, otElevator, otTrain, otTrainPoint, otDestroyer];
GeometryObjs : TSetObjType = [otNFKDoor, otElevator, otTriangle, otTrain];
//çäåñü ñïèñêè îáúåêòîâ äëÿ ðàçëè÷íûõ ðåæèìîâ:
GameALLObjs : TSetObjType =
[otNone, otRespawn, otJumpPad,
otPortal, otButton, otNFKDoor, otTrigger, otDeathLine,
otWater, otElevator, otTriangle,
otAreaPush, otAreaPain, otLava, otAreaTeleport, otTeleportWay,
otEmptyBricks, otBackBricks, otLightLine, otBloodGen, otWeather,
otTrain, otTrainPoint, otBelt, otAnimation, otSoundTrigger, otDestroyer, otTeleport];
GameNotRAObjs : TSetObjType = [otArmor, otHealth, otPowerUp, otWeapon, otAmmo];
GameTDMObjs : TSetObjType = [];
GameCTFObjs : TSetObjType = [];
GameDOMObjs : TSetObjType = [];
GameTRIXObjs : TSetObjType = [otArenaEnd];
GameSPObjs : TSetObjType = [otArenaEnd, otMonster];
type
TDemoObjRec =
record
reserved: array [0..7] of word;
end;
string32= string[32];
string50= string[50];
TMapObjStruct = record
x, y, width, height: word; //4
active: byte;//1
orient: byte;//1
target_name, target: word;
wait, waittarget: word; //4
itemID, count: word;//4
case ObjType: TObjType of
otNone: (reserved:array [0..ObjCaseSize-2] of byte; team: byte);
otRespawn: ( resp_weapons, resp_Ammo: TWPNArray; resp_mode, resp_health, resp_armor: byte );
otArmor: (temp: word);
otJumpPad: (jumpspeed, jumpspeedx: single);
otPortal, otTeleport: (gotox, gotoy: word);
otButton: (color: byte);
otTrigger: (execcmd: string50; onlyplayer: boolean);
otNFKDoor: (opened: boolean);
otWeapon: (weaponID: word);
otDeathLine: (angle, maxlen: single; damage, damagewait: integer);//deathline, lightline
otElevator, otTrain: (elevspeed: single; elevx, elevy: smallint;
etargetname1, etargetname2, etarget1, etarget2: word;
eactive: boolean; edestination: word);
otTrainpoint: (tpindex, tpnext: word; orientchange: boolean; speedchange: boolean; speedvalue: single);
otAreaPush: (pushspeedx, pushspeedy: smallint; pushwait: word);
otAreaPain: (paindamage, painwait: word; painactive: boolean);
otArenaEnd: ( nextmap: string32 );
otBackBricks: (plane: byte);
otBloodGen: (bloodangle, bloodL: single; bloodwait, bloodtype, bloodcount: word);//deathline, lightline, bloodgen
otBelt: (beltspeedx, beltspeedy: single; beltactive: boolean);
otAnimation: (animcount, animwait: integer);
otSoundTrigger: (soundname: string32; soundradius:word; soundloop, fullsound: boolean);
otDestroyer: (partscount: byte; partshealth: word);
otMonster: (monster_health, monster_damage: word; monster_mode: byte; monster_speed: single;
monster_color: byte);
otWater: (min_level, max_level, cur_level: word);
end;
PMapObjStruct = ^TMapObjStruct;
type
//ôèçè÷åñêèé îáúåêò - ýòî âñåãî ëèøü ðåêîðä â êîòîðûé ìîæåò áûòü çàïèñàíà
//èíôîðìàöèÿ î êîíòàêòèðóþùåì îáúåêòå.
TPhysObj =
record
frect: TMathRect;
dpos: PPoint2f;
normal: TPoint2f;
floatpos: TPoint2f; //ÄËß ÍÎÐÌÀËÜÍÎÃÎ ÎÊÐÓÃËÅÍÈß
dis_hor, dis_top, dis_bottom: boolean; //disable horizontal checking
end;
const
NullPoint : TPoint2f = (x: 0; y: 0);
type
TCustomMapObj = class
constructor Create(struct_: TMapObjStruct);
destructor Destroy; override;
protected
FActive : boolean;
FStruct : TMapObjStruct; // Ñòðóêòóðà îáúåêòà
FPlane : TPlane; // "îòäàë¸ííîñòü" îáúåêòà :)
FObjRect : TRect; // Äëÿ îòñå÷åíèÿ ïðè îòðèñîâêå
FActivateRect : TRect; // Àêòèâíàÿ çîíà îáúåêòà (äëÿ àêòèâàöèè)
FActivateMode : boolean; // Ìåòîä àêòèâàöèè
//true - äîëæåí áûòü ÂÅÑÜ èãðîê
//false - äîëæíà áûòü ëèøü ÷àñòü èãðîêà
fupdated: boolean;
function GetActivateRect: TRect;
public
//ñòàâèì äåôîëòíûå òàéìåðû
timer: integer;
fNetSize : byte; //â word'àõ
fOwner, fOwner2: TCustomMapObj;
startrect: TRect;
anim : TObjTex; // Àíèìàöèÿ îáúåêòà
tag: integer;
//íî îí ðàçíûé â ðàçíûõ òî÷êàõ îáúåêòà.
function Activate(sender: TObject) : boolean; virtual;
procedure Restart; virtual;
procedure Draw; virtual;
procedure Update; virtual;
property Struct: TMapObjStruct read FStruct;
property x : word read FStruct.x;
property y : word read FStruct.y;
property width : word read FStruct.width;
property height : word read FStruct.height;
property ObjType: TObjType read FStruct.ObjType;
property Target_Name: word read FStruct.Target_Name;
property Target: word read FStruct.Target;
property Plane : TPlane read FPlane;
property ObjRect : TRect read FObjRect write FObjRect;
property Activated : boolean read FActive;
property ActivateRect : TRect read GetActivateRect;
property ActivateMode : boolean read FActivateMode;
property Active: boolean read factive;
procedure SetActive(const Value: boolean);
//ñîõðàíåíèå ñîñòîÿíèÿ â ñòðóêòóðó
function SaveToRec(var rec: TDemoObjRec): boolean;virtual;
procedure LoadFromRec(rec: TDemoObjRec);virtual;
procedure SaveNet(var w: array of word);virtual;
procedure LoadNet(w: array of word);virtual;
function Updated: boolean;
property Team: byte read fstruct.team;
function targ_Activate(sender: TObject): boolean;virtual;
function targ_Deactivate(sender: TObject): boolean;virtual;
function player_Activate(sender: TObject): boolean;virtual;
end;
TGeometryObj= class(TCustomMapObj)
public
function Blocked : boolean; virtual;
function BlockedAt(x, y: single) : boolean; virtual; //x, y -êîîðäèíàòû íà êàðòå
function PhysObj(x, y: smallint): TPhysObj; virtual; //ÔÈÇÈ×ÅÑÊÈÉ rect. îáúÿñíÿòü äîëãî,
//íîâûå ñâîéñòâà ôèçèêè
procedure phys_clipX(var ph: TPhysRect);virtual;
procedure phys_clipY(var ph: TPhysRect);virtual;
end;
TRespawn = class(TCustomMapObj)
private
timer: integer;
public
constructor Create(struct_: TMapObjStruct);
function Activate(sender: TObject): boolean;override;
procedure Restart;override;
procedure Update;override;
property resp_mode: byte read fstruct.resp_mode;
property resp_weapons: TWPNArray read fstruct.resp_weapons;
property resp_ammo: TWPNArray read fstruct.resp_ammo;
property resp_health: byte read fstruct.resp_health;
property resp_armor: byte read fstruct.resp_armor;
end;
TPortal = class(TCustomMapObj)
constructor create(struct_: TMapObjStruct);
public
procedure Draw; override;
procedure Update; override;
function Activate(sender: TObject): boolean; override;
end;
TTeleport = class(TPortal)
constructor create(struct_: TMapObjStruct);
public
mirror : TObjTex;
procedure Draw; override;
// procedure Update; override;
// function Activate(sender: TObject): boolean; override;
end;
TButton = class(TCustomMapObj)
constructor Create(struct_: TMapObjStruct);
protected
sound : TSound; // Çâóê ïðè àêòèâàöèè
targtimer : integer;
public
procedure Restart; override;
procedure Draw; override;
procedure Update; override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
function targ_Activate(sender: TObject): boolean;override;
function targ_Deactivate(sender: TObject): boolean;override;
function player_Activate(sender: TObject): boolean;override;
end;
//ÄÂÅÐÜ NFK!!!!
TNFKDoor = class(TGeometryObj)
constructor Create(struct_:TMapObjStruct);
protected
soundopen : TSound; // Çâóê îòêðûòèÿ
soundclose : TSound; // Çâóê çàêðûòèÿ
public
pl_timer : integer;
procedure Restart; override;
procedure Draw; override;
procedure Update; override;
function Blocked : boolean; override;
function BlockedAt(x, y: single) : boolean; override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure phys_clipX(var ph: TPhysRect);override;
procedure phys_clipY(var ph: TPhysRect);override;
function targ_Activate(sender: TObject): boolean;override;
function targ_Deactivate(sender: TObject): boolean;override;
function player_Activate(sender: TObject): boolean;override;
end;
TCustomTrigger = class(TCustomMapObj)
public
constructor Create(struct_: TMapObjStruct);
procedure Draw; override;
end;
TTrigger = class(TCustomTrigger)
constructor Create(struct_: TMapObjStruct);
protected
targtimer: integer;
public
procedure Restart;override;
procedure Update;override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
function targ_Activate(sender: TObject): boolean;override;
function targ_Deactivate(sender: TObject): boolean;override;
function player_Activate(sender: TObject): boolean;override;
end;
TJumpPad = class(TCustomMapObj)
constructor Create(struct_:TMapObjStruct);
protected
sound : TSound;
sndtimer: integer;
public
procedure Draw; override;
procedure Update; override;
function Activate(sender: TObject): boolean; override;
end;
TDeathLineObj = class(TCustomMapObj)
protected
fLine: TObject;
x0, y0: single;
len: single;
emptybrick: boolean;
public
constructor Create(struct_:TMapObjStruct);
procedure Restart;override;
procedure Update; override;
procedure Draw;override;
function targ_Activate(sender: TObject): boolean;override;
function targ_Deactivate(sender: TObject): boolean;override;
end;
TLightLineObj = class(TDeathLineObj)
public
function targ_Activate(sender: TObject): boolean;override;
end;
TBricksObj = class(TGeometryObj)
constructor Create(struct_:TMapObjStruct);
destructor Destroy;override;
protected
brk, mask: array of word;
blocks: boolean;
public
function Block_b(bx, by: smallint): boolean;virtual;
function _Block_b(bx, by: smallint): boolean;virtual;
function __Block_b(bx, by: smallint): boolean;virtual;
procedure TakeBricks;
procedure Draw;override;
function Blocked: boolean;override;
end;
TElevatorObj = class(TBricksObj)
protected
stopped: boolean;
timer, t0: integer;
elevstopping: boolean;
pos, dpos, fracpos: TPoint2f;
//ãëîáàëüíûå ïàðàìåòðû
v0, a, l0: single;//ñêîðîñòü, óñêîðåíèå è îáùèé ïóòü
v : single; //òåêóùàÿ ñêîðîñòü
h: smallint; //èä¸ò òóäà èëè îáðàòíî?
public
constructor Create(struct_:TMapObjStruct);
procedure Restart;override;
procedure Draw;override;
procedure Update;override;
procedure Go;virtual;
procedure FixPos;
function Speed: TPoint2f;
function OnTarget1(sender: TObject): boolean;
function OnTarget2(sender: TObject): boolean;
function Activate(sender: TObject): boolean; override;
function PhysObj(x, y: smallint) : TPhysObj; override;
function BlockedAt(x, y: single) : boolean; override;
procedure phys_clipX(var ph: TPhysRect);override;
procedure phys_clipY(var ph: TPhysRect);override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
end;
TTrainPointObj = class(TCustomMapObj)
private
ftimer, ftargtimer: integer;
public
constructor Create(struct_:TMapObjStruct);
property NextPoint: word read fstruct.tpnext;
property Index: word read fstruct.tpindex;
function Activate(sender: TObject): boolean;override;
procedure ActivateTrain;
procedure Update;override;
property ChangeOrient: boolean read fstruct.orientchange;
property ChangeSpeed: boolean read fstruct.speedchange;
property Speed: single read fstruct.speedvalue;
procedure restart;override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
end;
TTrainObj = class(TElevatorObj)
private
// nextpoint: TTrainPointObj;
speed: single;
train_orient: integer;
public
constructor Create(struct_:TMapObjStruct);
procedure Go;override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure Update;override;
procedure Restart;override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
end;
TBelt = class (TBricksObj)
private
smx, smy: single;
minx, miny: integer;
bx, by: integer;
public
sspeed: TPoint2f;
constructor Create(struct_:TMapObjStruct);
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
procedure Update;override;
procedure Restart;override;
procedure Draw;override;
function PhysObj(x, y: smallint) : TPhysObj; override;
function BlockedAt(x, y: single) : boolean; override;
function Block_b(bx, by: smallint): boolean;override;
function __Block_b(bx, by: smallint): boolean;override;
end;
TAnimationObj = class(TBricksObj)
protected
anim: integer;
public
procedure Update;override;
procedure Restart;override;
procedure Draw;override;
function BlockedAt(x, y: single) : boolean; override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
end;
TTriangleObj =
class(TGeometryObj)
protected
vx, vy: array [0..3] of smallint;
tex: byte;
public
normal: TPoint2f;
constructor Create(struct_:TMapObjStruct);
function BlockedAt(x, y: single): boolean;override;
function PhysObj(x, y: smallint): TPhysObj;override;
procedure phys_clipX(var ph: TPhysRect);override;
procedure phys_clipY(var ph: TPhysRect);override;
function VectorIntersect(x, y, angle: single; var s: single): boolean;
procedure Draw;override;
end;
TAreaPain =class(TCustomTrigger)
protected
paintimer:word;
public
procedure Restart;override;
procedure Update;override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
function player_Activate(sender: TObject): boolean;override;
end;
TArenaEnd =class(TCustomTrigger)
public
function Activate(sender: TObject): boolean; override;
end;
TAreaPush = class(TCustomTrigger)
protected
pushtimer: integer;
public
procedure Restart; override;
procedure Update;override;
function player_Activate(sender: TObject): boolean;override;
end;
TAreaTeleport = class(TCustomTrigger)
public
function Activate(sender: TObject): boolean; override;
end;
TAreaTeleportWay = class(TCustomTrigger)
public
constructor Create(struct_:TMapObjStruct);
function Activate(sender: TObject): boolean;override;
end;
TBloodGen = class(TCustomMapObj)
private
spos, sdpos: TPoint2f;
timer: integer;
light: TP_Light;
public
constructor Create(struct_: TMapObjStruct);
procedure Restart;override;
procedure Update;override;
procedure draw;override;
function targ_Activate(sender: TObject): boolean;override;
function targ_Deactivate(sender: TObject): boolean;override;
end;
TCustomLiquid = class(TCustomMapObj)
constructor Create(struct_: TMapObjStruct);
private
Speed : single; // Ñêîðîñòü òå÷åíèÿ
Density : single; // Ïëîòíîñòü
Tex : TObjTex;
level, up: integer;// óðîâåíü æèäêîñòè!!!
public
procedure Update;override;
procedure Restart;override;
procedure Draw;override;
function targ_Activate(sender: TObject): boolean;override;
end;
TWaterObj = class(TCustomLiquid)
constructor Create(struct_: TMapObjStruct);
destructor Destroy; override;
private
State : boolean;
Wait : integer;
Waves : array [boolean] of array of integer; // âîëíû
public
function player_Activate(sender: TObject): boolean; override;
procedure Update;override;
procedure Draw;override;
procedure Restart;override;
procedure Smooth;
procedure Wave(x, a: integer);//â êàêîì x ïîñòàâèòü âîëíó, è êàêóþ
procedure Wave2(x, a: integer);//ñëîæåíèå âîëí
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
end;
TLavaObj = class(TCustomLiquid)
constructor Create(struct_: TMapObjStruct);
destructor Destroy; override;
private
lTex : TObjTex;
Wave : array [0..2] of array of array of single;
W_X, W_W : integer;
W_Y, W_H : integer;
public
function player_Activate(sender: TObject): boolean; override;
procedure Update;override;
procedure Draw;override;
end;
TWeather = class(TCustomMapObj)
constructor Create(struct_: TMapObjStruct);
private
timer: integer;
public
procedure Restart; override;
procedure Update; override;
procedure Draw; override;
end;
TSoundTrigger = class(TCustomMapObj)
constructor Create(struct_: TMapObjStruct);
protected
snd : integer;
psnd : integer;
timer : integer;
public
function Activate(sender: TObject): boolean; override;
procedure Draw;override;
procedure Update;override;
procedure restart;override;
end;
TDestroyerObj = class(TCustomTrigger)
constructor Create(struct_: TMapObjStruct);
protected
brk, mask: array of word;
health: integer;
public
function Activate(sender: TObject): boolean; override;
function Hit(damage: integer): boolean;
procedure Charge;
procedure DestroyIt;
procedure TakeBricks;
procedure Draw;override;
procedure restart;override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
procedure SaveNet(var w: array of word);override;
procedure LoadNet(w: array of word);override;
end;
TMonsterObj = class(TCustomMapObj)
constructor Create(struct_: TMapObjStruct);
protected
xx, yy, sx, sy, speed, angle: single;
health: integer;
w, h: integer;
pl: TObject;
timer, smoketimer: integer;
alpha: single;
frame: integer;
fire: integer;
light: TP_Light;
delta: single;
resp: boolean;
public
function Activate(sender: TObject): boolean; override;
procedure Draw;override;
function Hit(damage: integer): boolean;
function Blocked: boolean;
procedure Update;override;
procedure restart;override;
function SaveToRec(var rec: TDemoObjRec): boolean;override;
procedure LoadFromRec(rec: TDemoObjRec);override;
end;
function ObjStruct(otype: TObjType; x, y, w, h: integer): TMapObjStruct;
function ObjGameMask(struct: TMapObjStruct): byte;
implementation
uses
Map_Lib, player_lib, Real_Lib, weapon_Lib, ItemObj_Lib,
TFKEntries, Phys_Lib, Bot_Lib, Math, Game_Lib;
function ObjGameMask(struct: TMapObjStruct): byte;
begin
if struct.objtype in GameALLObjs then
Result:=255
else
begin
Result:=0;
if struct.objtype in GameNotRAObjs then
Result:=Result+255-GT_RAIL
else
begin
if struct.objtype in GameTDMObjs then
Result:=Result+GT_TDM;
if struct.objtype in GameCTFObjs then
Result:=Result+GT_CTF;
if struct.objtype in GameDOMObjs then
Result:=Result+GT_DOM;
if struct.objtype in GameTRIXObjs then
Result:=Result+GT_TRIX;
if struct.objtype in GameSPObjs then
Result:=Result+GT_SINGLE;
end;
end;
end;
function ObjStruct(otype: TObjType; x, y, w, h: integer): TMapObjStruct;
begin
Result.ObjType:=otype;
Result.x:=x;
Result.y:=y;
Result.width:=w;
Result.height:=h;
end;
var
// Óêàçûâàåò, ÷òî â äàííûé ìîìåíò îòðèñîâûâàåòñÿ òåëåïîðò...
// Òèïà ãëîáàëüíûé ôëàã, íî íóæåí òîëüêî òåëåïîðòàì :)
TeleportDraw : boolean;
{ TCustomMapObj }
constructor TCustomMapObj.Create(struct_: TMapObjStruct);
begin
FStruct := Struct_;
FPlane := pNone; //XProger: Ýòî ïîêà âðåìåííî...
FObjRect := Rect(0, 0, 0, 0);
FActivateRect := Rect(0, 0, 0, 0);
FActivateMode := false;
FActive:=false;
fNetSize:=0;
fOwner:=nil;
end;
destructor TCustomMapObj.Destroy;
begin
if anim <> nil then
anim.Free;
end;
function TCustomMapObj.Activate(sender: TObject):boolean;
begin
//àêòèâàöèÿ îáúåêòà êíîïêîé èëè ÷åì-ëèáî åùå
if sender is TPlayer then
begin
Result:=player_Activate(sender);
if not Result then Exit;
end;
if timer>0 then
Result:=false
else
begin
if factive then
Result:=targ_Deactivate(sender)
else
Result:=targ_Activate(sender);
if Result then
timer:=fstruct.wait;
end;
end;
procedure TCustomMapObj.Restart;
begin
factive:=fstruct.active and 4>0;
timer:=0;
end;
procedure TCustomMapObj.Draw;
begin
// XProger: Ðèñóåò îáúåêò ïî åãî ObjRect
// Â ïðåäêàõ âûçûâàåòñÿ êàê inherited
// Neoff: TCustomMapObj íå èìååò ïðåäêîâ... òîëüêî ïîòîìêîâ ;)
// XProger: äà ïîäóìàåøü, îïèñàëñÿ... ;)
if (FObjRect.Width = 0) or (FObjRect.Height = 0) then Exit;
glBegin(GL_QUADS);
glTexCoord2f(0, height);
glVertex2f(FObjRect.X, FObjRect.Y);
glTexCoord2f(width, height);
glVertex2f(FObjRect.X + FObjRect.Width, FObjRect.Y);
glTexCoord2f(width, 0);
glVertex2f(FObjRect.X + FObjRect.Width, ObjRect.Y + ObjRect.Height);
glTexCoord2f(0, 0);
glVertex2f(FObjRect.X, ObjRect.Y + ObjRect.Height);
glEnd;
end;
procedure TCustomMapObj.Update;
begin
if fOwner <> nil then
begin
fObjRect.X := startrect.X + (fOwner.ObjRect.X - fOwner.startrect.X);
fObjRect.Y := startrect.Y + (fOwner.ObjRect.Y - fOwner.startrect.Y);
end;
if timer>0 then
begin
dec(timer);
if timer=0 then
if factive then targ_Deactivate(Self)
else targ_Activate(self);
end;
end;
function TCustomMapObj.SaveToRec(var rec: TDemoObjRec): boolean;
begin
Result:=true;
rec.reserved[0]:=timer and 32767+ord(factive)*32768;
end;
procedure TCustomMapObj.LoadFromRec(rec: TDemoObjRec);
begin
timer:=rec.reserved[0] and 32767;
factive:=rec.reserved[0] and 32768>0;
if factive then targ_Activate(Self);
end;
function TCustomMapObj.GetActivateRect: TRect;
begin
Result.Width := FActivateRect.Width;
Result.Height := FActivateRect.Height;
Result.X := X * 32 + FActivateRect.X + FObjRect.X - startrect.X;
Result.Y := Y * 16 + FActivateRect.Y + FObjRect.Y - startrect.Y;
end;
function TCustomMapObj.Updated: boolean;
begin
result:=fupdated;
fupdated:=false;
end;
procedure TCustomMapObj.LoadNet(w: array of word);
begin
timer:=w[0] and 32767;
factive:=w[0] and 32768>0;
if factive then targ_Activate(Self);
end;
procedure TCustomMapObj.SaveNet(var w: array of word);
begin
w[0]:=timer and 32767+ord(factive)*32768;
end;
procedure TCustomMapObj.SetActive(const Value: boolean);
begin
factive := Value;
end;
function TCustomMapObj.player_Activate(sender: TObject): boolean;
begin
//
Result:=true;
end;
function TCustomMapObj.targ_Activate(sender: TObject): boolean;
begin
Result:=true;
factive:=true;
end;
function TCustomMapObj.targ_Deactivate(sender: TObject): boolean;
begin
Result:=true;
factive:=false;
end;
{ TGeometryObj }
function TGeometryObj.Blocked: boolean;
begin
//abstract
Result:=false;
end;
function TGeometryObj.BlockedAt(x, y: single): boolean;
begin
//abstract
Result:=false;
end;
function TGeometryObj.PhysObj(x, y: smallint): TPhysObj;
begin
//abstract
with Result, frect do
begin
x1 := fObjRect.x;
y1 := fObjRect.y;
x2 := fObjRect.x + FObjRect.Width;
y2 := fObjRect.y + FObjRect.Height;
dpos := @NullPoint;
normal := NullPoint;
floatpos := NullPoint;
dis_bottom := false;
dis_top := false;
dis_hor := false;
end;
end;
procedure TGeometryObj.phys_clipX(var ph: TPhysRect);
begin
end;
procedure TGeometryObj.phys_clipY(var ph: TPhysRect);
begin
end;
{ TOldTeleport }
constructor TPortal.Create(struct_: TMapObjStruct);
const
xstep = 5; // Äëÿ ïðîñ÷¸òà àêòèâàöèîííîãî ðåêòà
ystep = 4;
begin
inherited Create(struct_);
//ãðóçèì òåêñòóðó
anim := TObjTex.Create('textures\obj\portal', 1, 0, 5, true, false, nil);
FObjRect := Rect(x*32 - 16, y*16 - 32, 64, 64);
FActivateRect := Rect(-xstep, -32-ystep, 32+2*xstep, 48+2*ystep);
FActivateMode := true;
StartRect := ObjRect;
end;
function TPortal.Activate(sender: TObject):boolean;
begin
Result := false;
if sender is TPlayer then
with TPlayer(sender) do
begin
Particle_Add(TP_Portal.Create(Pos)); // âñïûøêà
if fOwner2<>nil then
begin
MoveTo(
struct.gotox*32 + fOwner2.fobjrect.x - fOwner2.startrect.x,
struct.gotoy*16 + fOwner2.fobjrect.y - fOwner2.startrect.y);
dPos:=Point2f(dpos.x+TElevatorObj(fOwner2).dpos.x, TElevatorObj(fOwner2).dpos.y);
end
else
begin
MoveTo(struct.gotox*32, struct.gotoy*16);
dpos:=Point2f(dpos.x, 0);
end;
if odd(fstruct.orient) then RotateX;
if fstruct.orient>=2 then RotateY;
Result := true;
end;
end;
procedure TPortal.Draw;
begin
// ðèñóåì òåëåïîðò
xglTex_Enable(anim.CurFrame);
glColor4f(1, 1, 1, 1);
inherited;
end;
procedure TPortal.Update;
begin
anim.Update;
inherited;
end;
{ TTeleport }
constructor TTeleport.Create(struct_: TMapObjStruct);
const
xstep = 5; // Äëÿ ïðîñ÷¸òà àêòèâàöèîííîãî ðåêòà
ystep = 4;
begin
inherited Create(struct_);
//ãðóçèì òåêñòóðó