3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, g_basic
, e_graphics
, MAPREADER
, MAPSTRUCT
,
9 MAPWRITER
, e_log
, MAPDEF
, utils
;
40 Direction
: TDirection
;
46 Direction
: TDirection
;
53 TexturePanel
: Integer;
72 TMonsterSizeDelta
= record
84 COLOR_EDGE
: Integer = $000000;
85 ALPHA_EDGE
: Byte = 96;
86 ALPHA_LINE
: Byte = 208;
87 ALPHA_AREA
: Byte = 96;
89 TEXTURE_NAME_WATER
= '_water_0';
90 TEXTURE_NAME_ACID1
= '_water_1';
91 TEXTURE_NAME_ACID2
= '_water_2';
92 TEXTURE_SPECIAL_NONE
= DWORD(-1);
93 TEXTURE_SPECIAL_WATER
= DWORD(-2);
94 TEXTURE_SPECIAL_ACID1
= DWORD(-3);
95 TEXTURE_SPECIAL_ACID2
= DWORD(-4);
96 TEXTURE_SPECIAL_NOTEXTURE
= DWORD(-8);
98 ItemSize
: Array [ITEM_MEDKIT_SMALL
..ITEM_MAX
] of Array [0..1] of Byte =
99 (((14), (15)), // MEDKIT_SMALL
100 ((28), (19)), // MEDKIT_LARGE
101 ((28), (19)), // MEDKIT_BLACK
102 ((31), (16)), // ARMOR_GREEN
103 ((31), (16)), // ARMOR_BLUE
104 ((25), (25)), // SPHERE_BLUE
105 ((25), (25)), // SPHERE_WHITE
106 ((24), (47)), // SUIT
107 ((14), (27)), // OXYGEN
108 ((25), (25)), // INVUL
109 ((62), (24)), // WEAPON_SAW
110 ((63), (12)), // WEAPON_SHOTGUN1
111 ((54), (13)), // WEAPON_SHOTGUN2
112 ((54), (16)), // WEAPON_CHAINGUN
113 ((62), (16)), // WEAPON_ROCKETLAUNCHER
114 ((54), (16)), // WEAPON_PLASMA
115 ((61), (36)), // WEAPON_BFG
116 ((54), (16)), // WEAPON_SUPERPULEMET
117 (( 9), (11)), // AMMO_BULLETS
118 ((28), (16)), // AMMO_BULLETS_BOX
119 ((15), ( 7)), // AMMO_SHELLS
120 ((32), (12)), // AMMO_SHELLS_BOX
121 ((12), (27)), // AMMO_ROCKET
122 ((54), (21)), // AMMO_ROCKET_BOX
123 ((15), (12)), // AMMO_CELL
124 ((32), (21)), // AMMO_CELL_BIG
125 ((22), (29)), // AMMO_BACKPACK
126 ((16), (16)), // KEY_RED
127 ((16), (16)), // KEY_GREEN
128 ((16), (16)), // KEY_BLUE
129 (( 1), ( 1)), // WEAPON_KASTET
130 ((43), (16)), // WEAPON_PISTOL
131 ((14), (18)), // BOTTLE
132 ((16), (15)), // HELMET
133 ((32), (24)), // JETPACK
134 ((25), (25)), // INVIS
135 ((53), (20)), // WEAPON_FLAMETHROWER
136 ((13), (20))); // AMMO_FUELCAN
138 AreaSize
: Array [AREA_PLAYERPOINT1
..AREA_BLUETEAMPOINT
] of TRectWH
=
139 ((X
:15; Y
:12; Width
:34; Height
:52), // PLAYERPOINT1
140 (X
:15; Y
:12; Width
:34; Height
:52), // PLAYERPOINT2
141 (X
:15; Y
:12; Width
:34; Height
:52), // DMPOINT
142 (X
:15; Y
:11; Width
:34; Height
:52), // REDFLAG
143 (X
:15; Y
:11; Width
:34; Height
:52), // BLUEFLAG
144 (X
:15; Y
:11; Width
:34; Height
:52), // DOMFLAG
145 (X
:15; Y
:12; Width
:34; Height
:52), // REDTEAMPOINT
146 (X
:15; Y
:12; Width
:34; Height
:52)); // BLUETEAMPOINT
148 MonsterSize
: Array [MONSTER_DEMON
..MONSTER_MAN
] of TRectWH
=
149 ((X
: 7; Y
: 8; Width
: 50; Height
: 52), // DEMON
150 (X
: 15; Y
: 10; Width
: 34; Height
: 50), // IMP
151 (X
: 15; Y
: 8; Width
: 34; Height
: 52), // ZOMBY
152 (X
: 15; Y
: 8; Width
: 34; Height
: 52), // SERG
153 (X
: 24; Y
: 9; Width
: 80; Height
: 110), // CYBER
154 (X
: 15; Y
: 4; Width
: 34; Height
: 56), // CGUN
155 (X
: 39; Y
: 32; Width
: 50; Height
: 64), // BARON
156 (X
: 39; Y
: 32; Width
: 50; Height
: 64), // KNIGHT
157 (X
: 34; Y
: 36; Width
: 60; Height
: 56), // CACO
158 (X
: 16; Y
: 14; Width
: 32; Height
: 36), // SOUL
159 (X
: 34; Y
: 36; Width
: 60; Height
: 56), // PAIN
160 (X
: 23; Y
: 14; Width
: 210; Height
: 100), // SPIDER
161 (X
: 14; Y
: 17; Width
: 100; Height
: 42), // BSP
162 (X
: 28; Y
: 34; Width
: 72; Height
: 60), // MANCUB
163 (X
: 30; Y
: 28; Width
: 68; Height
: 72), // SKEL
164 (X
: 30; Y
: 28; Width
: 68; Height
: 72), // VILE
165 (X
: 6; Y
: 11; Width
: 20; Height
: 10), // FISH
166 (X
: 20; Y
: 13; Width
: 24; Height
: 36), // BARREL
167 (X
: 30; Y
: 26; Width
: 68; Height
: 76), // ROBO
168 (X
: 15; Y
: 6; Width
: 34; Height
: 52)); // MAN
170 MonsterSizeDelta
: Array [MONSTER_DEMON
..MONSTER_MAN
] of TMonsterSizeDelta
=
171 ((X
: 1; Y
: 4; Width
: 64), // DEMON
172 (X
: 8; Y
: -4; Width
: 64), // IMP
173 (X
: 1; Y
: -4; Width
: 64), // ZOMBY
174 (X
: 0; Y
: -4; Width
: 64), // SERG
175 (X
: 2; Y
: -6; Width
: 128), // CYBER
176 (X
: -1; Y
: -2; Width
: 64), // CGUN
177 (X
: 4; Y
: 0; Width
: 128), // BARON
178 (X
: 4; Y
: 0; Width
: 128), // KNIGHT
179 (X
: 0; Y
: -4; Width
: 128), // CACO
180 (X
: 1; Y
: -10; Width
: 64), // SOUL
181 (X
: -1; Y
: -3; Width
: 128), // PAIN
182 (X
: -4; Y
: -4; Width
: 256), // SPIDER
183 (X
: 0; Y
: -1; Width
: 128), // BSP
184 (X
: -2; Y
: -7; Width
: 128), // MANCUB
185 (X
: -1; Y
: 4; Width
: 128), // SKEL
186 (X
: 5; Y
: -21; Width
: 128), // VILE
187 (X
: -1; Y
: 0; Width
: 32), // FISH
188 (X
: 0; Y
: -15; Width
: 64), // BARREL
189 (X
: -2; Y
: -26; Width
: 128), // ROBO
190 (X
: 0; Y
: -6; Width
: 64)); // MAN
195 gAlphaTriggerLine
: Byte;
196 gAlphaTriggerArea
: Byte;
197 gAlphaMonsterRect
: Byte;
198 gAlphaAreaRect
: Byte;
199 drEdge
: Array[0..3] of Byte;
200 gPanels
: Array of TPanel
;
201 gItems
: Array of TItem
;
202 gAreas
: Array of TArea
;
203 gMonsters
: Array of TMonster
;
204 gTriggers
: Array of TTrigger
;
206 MapOffset
: TPoint
= (X
: 0; Y
: 0);
207 SelectedObjects
: Array of TMapObject
= nil;
209 procedure LoadSky(Res
: String);
211 function AddItem(Item
: TItem
): DWORD
;
212 function AddPanel(Panel
: TPanel
): DWORD
;
213 function AddArea(Area
: TArea
): DWORD
;
214 function AddMonster(Monster
: TMonster
): DWORD
;
215 function AddTrigger(Trigger
: TTrigger
): DWORD
;
217 procedure RemoveObject(ID
: DWORD
; ObjectType
: Byte);
218 function PanelInShownLayer(PanelType
: Word): Boolean;
219 function ObjectInRect(fX
, fY
: Integer; fWidth
, fHeight
: Word; ObjectType
: Byte; All
: Boolean): DWArray
;
220 function ObjectCollideLevel(fID
: DWORD
; ObjectType
: Byte; dX
, dY
: Integer): Boolean;
221 function ObjectCollide(ObjectType
: Byte; ID
: DWORD
; fX
, fY
: Integer; fWidth
, fHeight
: Word): Boolean;
222 function ObjectGetRect(ObjectType
: Byte; ID
: DWORD
): TRectWH
;
223 procedure MoveObject(ObjectType
: Byte; ID
: DWORD
; dX
, dY
: Integer);
224 function ResizeObject(ObjectType
: Byte; ID
: DWORD
; dWidth
, dHeight
: Integer; ResizeDir
: Byte): Boolean;
225 function ObjectSelected(ObjectType
: Byte; ID
: DWORD
): Boolean;
227 function GetPanelName(PanelType
: Word): String;
228 function GetPanelType(PanelName
: String): Word;
229 function GetTriggerName(TriggerType
: Byte): String;
230 function GetTriggerType(TriggerName
: String): Byte;
232 function IsSpecialTexture(TextureName
: String): Boolean;
233 function SpecialTextureID(TextureName
: String): DWORD
;
235 procedure ClearMap();
236 function SaveMap(Res
: String): Pointer;
237 function LoadMap(Res
: String): Boolean;
238 function LoadMapOld(_FileName
: String): Boolean;
240 procedure LoadData();
241 procedure FreeData();
243 procedure ShiftMapObjects(dx
, dy
: Integer);
248 BinEditor
, g_textures
, Dialogs
, SysUtils
, CONFIG
, f_main
,
249 Forms
, Math
, f_addresource_texture
, WADEDITOR
, g_language
, g_options
;
252 OLD_ITEM_MEDKIT_SMALL
= 1;
253 OLD_ITEM_MEDKIT_LARGE
= 2;
254 OLD_ITEM_ARMOR_GREEN
= 3;
255 OLD_ITEM_ARMOR_BLUE
= 4;
256 OLD_ITEM_SPHERE_BLUE
= 5;
257 OLD_ITEM_SPHERE_WHITE
= 6;
258 OLD_ITEM_WEAPON_SAW
= 7;
259 OLD_ITEM_WEAPON_SHOTGUN1
= 8;
260 OLD_ITEM_WEAPON_SHOTGUN2
= 9;
261 OLD_ITEM_WEAPON_CHAINGUN
= 10;
262 OLD_ITEM_WEAPON_ROCKETLAUNCHER
= 11;
263 OLD_ITEM_WEAPON_PLASMA
= 12;
264 OLD_ITEM_WEAPON_BFG
= 13;
265 OLD_ITEM_WEAPON_SUPERPULEMET
= 14;
266 OLD_ITEM_AMMO_BULLETS
= 15;
267 OLD_ITEM_AMMO_BULLETS_BOX
= 16;
268 OLD_ITEM_AMMO_SHELLS
= 17;
269 OLD_ITEM_AMMO_SHELLS_BOX
= 18;
270 OLD_ITEM_AMMO_ROCKET
= 19;
271 OLD_ITEM_AMMO_ROCKET_BOX
= 20;
272 OLD_ITEM_AMMO_CELL
= 21;
273 OLD_ITEM_AMMO_CELL_BIG
= 22;
274 OLD_ITEM_AMMO_BACKPACK
= 23;
275 OLD_ITEM_KEY_RED
= 24;
276 OLD_ITEM_KEY_GREEN
= 25;
277 OLD_ITEM_KEY_BLUE
= 26;
279 OLD_ITEM_OXYGEN
= 28;
280 OLD_ITEM_MEDKIT_BLACK
= 29;
283 ITEMSCONVERT
: Array [OLD_ITEM_MEDKIT_SMALL
..OLD_ITEM_INVUL
] of Integer =
284 ((ITEM_MEDKIT_SMALL
),
291 (ITEM_WEAPON_SHOTGUN1
),
292 (ITEM_WEAPON_SHOTGUN2
),
293 (ITEM_WEAPON_CHAINGUN
),
294 (ITEM_WEAPON_ROCKETLAUNCHER
),
295 (ITEM_WEAPON_PLASMA
),
297 (ITEM_WEAPON_SUPERPULEMET
),
299 (ITEM_AMMO_BULLETS_BOX
),
301 (ITEM_AMMO_SHELLS_BOX
),
303 (ITEM_AMMO_ROCKET_BOX
),
305 (ITEM_AMMO_CELL_BIG
),
306 (ITEM_AMMO_BACKPACK
),
315 OldItemSize
: Array [ITEM_MEDKIT_SMALL
..ITEM_KEY_BLUE
] of Array [0..1] of Byte =
316 (((14), (15)), // MEDKIT_SMALL
317 ((28), (19)), // MEDKIT_LARGE
318 ((28), (19)), // MEDKIT_BLACK - not in map generator
319 ((30), (16)), // ARMOR_GREEN
320 ((30), (16)), // ARMOR_BLUE
321 ((24), (24)), // SPHERE_BLUE
322 ((24), (24)), // SPHERE_WHITE
323 ((24), (46)), // SUIT
324 ((14), (27)), // OXYGEN
325 ((25), (25)), // INVUL - not in map generator
326 ((61), (23)), // WEAPON_SAW
327 ((62), (10)), // WEAPON_SHOTGUN1
328 ((52), (12)), // WEAPON_SHOTGUN2
329 ((53), (15)), // WEAPON_CHAINGUN
330 ((61), (15)), // WEAPON_ROCKETLAUNCHER
331 ((53), (14)), // WEAPON_PLASMA
332 ((61), (34)), // WEAPON_BFG
333 ((53), (16)), // WEAPON_SUPERPULEMET
334 (( 9), (10)), // AMMO_BULLETS
335 ((28), (16)), // AMMO_BULLETS_BOX
336 ((15), ( 7)), // AMMO_SHELLS
337 ((32), (12)), // AMMO_SHELLS_BOX
338 ((12), (26)), // AMMO_ROCKET
339 ((54), (21)), // AMMO_ROCKET_BOX
340 ((15), (12)), // AMMO_CELL
341 ((32), (21)), // AMMO_CELL_BIG
342 ((22), (29)), // AMMO_BACKPACK
343 ((16), (16)), // KEY_RED
344 ((16), (16)), // KEY_GREEN
345 ((16), (16))); // KEY_BLUE
347 OldAreaSize
: Array [0..1] of Byte = ((34), (56));
351 procedure LoadSky(Res
: String);
356 g_DeleteTexture(SKY_TEXTURE
);
361 g_ProcessResourceStr(Res
, @fn
, nil, nil);
365 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
369 fn
:= WadsDir
+ DirectorySeparator
+ Res
;
371 g_CreateTextureWAD(SKY_TEXTURE
, fn
);
374 function AddItem(Item
: TItem
): DWORD
;
383 if gItems
<> nil then
384 for a
:= 0 to High(gItems
) do
385 if gItems
[a
].ItemType
= ITEM_NONE
then
394 SetLength(gItems
, a
+ 128);
402 function AddPanel(Panel
: TPanel
): DWORD
;
412 if gPanels
<> nil then
413 for a
:= High(gPanels
) downto 0 do
414 if gPanels
[a
].PanelType
= PANEL_NONE
then
427 a
:= Length(gPanels
);
428 SetLength(gPanels
, a
+ 512);
436 function AddArea(Area
: TArea
): DWORD
;
445 if gAreas
<> nil then
446 for a
:= 0 to High(gAreas
) do
447 if gAreas
[a
].AreaType
= AREA_NONE
then
456 SetLength(gAreas
, a
+ 64);
464 function AddMonster(Monster
: TMonster
): DWORD
;
473 if gMonsters
<> nil then
474 for a
:= 0 to High(gMonsters
) do
475 if gMonsters
[a
].MonsterType
= MONSTER_NONE
then
483 a
:= Length(gMonsters
);
484 SetLength(gMonsters
, a
+ 128);
487 gMonsters
[a
] := Monster
;
492 function AddTrigger(Trigger
: TTrigger
): DWORD
;
501 if gTriggers
<> nil then
502 for a
:= 0 to High(gTriggers
) do
503 if gTriggers
[a
].TriggerType
= TRIGGER_NONE
then
511 a
:= Length(gTriggers
);
512 SetLength(gTriggers
, a
+ 64);
515 gTriggers
[a
] := Trigger
;
520 procedure RemoveObject(ID
: DWORD
; ObjectType
: Byte);
528 // Убираем ссылки триггеров на эту панель:
529 if gTriggers
<> nil then
530 for a
:= 0 to High(gTriggers
) do
531 if gTriggers
[a
].TriggerType
<> 0 then
533 if gTriggers
[a
].TexturePanel
= Integer(ID
) then
534 gTriggers
[a
].TexturePanel
:= -1;
536 if gTriggers
[a
].TriggerType
in [
537 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
538 TRIGGER_DOOR
, TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
,
539 TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
541 if gTriggers
[a
].Data
.PanelID
= Integer(ID
) then
542 gTriggers
[a
].Data
.PanelID
:= -1;
544 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
545 (gTriggers
[a
].Data
.ShotPanelID
= Integer(ID
)) then
546 gTriggers
[a
].Data
.ShotPanelID
:= -1;
549 gPanels
[ID
].PanelType
:= 0;
553 gItems
[ID
].ItemType
:= 0;
557 // Убираем ссылки триггеров на этого монстра:
558 if gTriggers
<> nil then
559 for a
:= 0 to High(gTriggers
) do
560 if gTriggers
[a
].TriggerType
<> 0 then
562 if gTriggers
[a
].TriggerType
in [TRIGGER_PRESS
,
563 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
564 if (gTriggers
[a
].Data
.MonsterID
-1 = Integer(ID
)) then
565 gTriggers
[a
].Data
.MonsterID
:= 0;
568 gMonsters
[ID
].MonsterType
:= 0;
572 gAreas
[ID
].AreaType
:= 0;
575 gTriggers
[ID
].TriggerType
:= 0;
579 function PanelInShownLayer(PanelType
: Word): Boolean;
583 Result
:= LayerEnabled
[LAYER_WALLS
];
586 Result
:= LayerEnabled
[LAYER_BACK
];
589 Result
:= LayerEnabled
[LAYER_FOREGROUND
];
592 Result
:= LayerEnabled
[LAYER_STEPS
];
594 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
595 PANEL_LIFTUP
, PANEL_LIFTDOWN
, PANEL_LIFTLEFT
, PANEL_LIFTRIGHT
,
596 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
,
598 Result
:= LayerEnabled
[LAYER_WATER
];
605 function ObjectInRect(fX
, fY
: Integer; fWidth
, fHeight
: Word; ObjectType
: Byte; All
: Boolean): DWArray
;
614 if gPanels
<> nil then
615 for a
:= High(gPanels
) downto 0 do
618 if not PanelInShownLayer(gPanels
[a
].PanelType
) then
621 if g_Collide(X
, Y
, Width
, Height
,
622 fX
, fY
, fWidth
, fHeight
) then
624 SetLength(Result
, Length(Result
)+1);
625 Result
[High(Result
)] := a
;
633 if LayerEnabled
[LAYER_ITEMS
] and (gItems
<> nil) then
634 for a
:= High(gItems
) downto 0 do
636 if (ItemType
<> ITEM_NONE
) and
637 g_Collide(X
, Y
, ItemSize
[ItemType
][0], ItemSize
[ItemType
][1],
638 fX
, fY
, fWidth
, fHeight
) then
640 SetLength(Result
, Length(Result
)+1);
641 Result
[High(Result
)] := a
;
648 if LayerEnabled
[LAYER_MONSTERS
] and (gMonsters
<> nil) then
649 for a
:= High(gMonsters
) downto 0 do
650 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
651 with MonsterSize
[gMonsters
[a
].MonsterType
] do
652 if (gMonsters
[a
].MonsterType
<> 0) and
653 g_Collide(gMonsters
[a
].X
, gMonsters
[a
].Y
, Width
, Height
,
654 fX
, fY
, fWidth
, fHeight
) then
656 SetLength(Result
, Length(Result
)+1);
657 Result
[High(Result
)] := a
;
664 if LayerEnabled
[LAYER_AREAS
] and (gAreas
<> nil) then
665 for a
:= High(gAreas
) downto 0 do
666 if gAreas
[a
].AreaType
<> AREA_NONE
then
667 with AreaSize
[gAreas
[a
].AreaType
] do
668 if (gAreas
[a
].AreaType
<> 0) and
669 g_Collide(gAreas
[a
].X
, gAreas
[a
].Y
, Width
, Height
,
670 fX
, fY
, fWidth
, fHeight
) then
672 SetLength(Result
, Length(Result
)+1);
673 Result
[High(Result
)] := a
;
680 if LayerEnabled
[LAYER_TRIGGERS
] and (gTriggers
<> nil) then
681 for a
:= High(gTriggers
) downto 0 do
682 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
685 if (TriggerType
<> 0) and
686 g_Collide(X
, Y
, Width
, Height
,
687 fX
, fY
, fWidth
, fHeight
) then
689 SetLength(Result
, Length(Result
)+1);
690 Result
[High(Result
)] := a
;
699 function ObjectCollideLevel(fID
: DWORD
; ObjectType
: Byte; dX
, dY
: Integer): Boolean;
705 PanelID
:= DWORD(-1);
710 Result
:= (PanelID
<> fID
) and
711 g_CollideLevel2(X
+dX
, Y
+dY
,
717 Result
:= g_CollideLevel(X
+dX
, Y
+dY
,
718 ItemSize
[ItemType
][0], ItemSize
[ItemType
][1]);
721 with MonsterSize
[gMonsters
[fID
].MonsterType
] do
722 Result
:= g_CollideLevel(gMonsters
[fID
].X
+dX
, gMonsters
[fID
].Y
+dY
,
726 with AreaSize
[gAreas
[fID
].AreaType
] do
727 Result
:= g_CollideLevel(gAreas
[fID
].X
+dX
, gAreas
[fID
].Y
+dY
,
731 with gTriggers
[fID
] do
732 Result
:= g_CollideLevel(X
+dX
, Y
+dY
,
737 function ObjectCollide(ObjectType
: Byte; ID
: DWORD
; fX
, fY
: Integer; fWidth
, fHeight
: Word): Boolean;
744 Result
:= g_Collide(X
, Y
, Width
, Height
,
745 fX
, fY
, fWidth
, fHeight
);
749 Result
:= g_Collide(X
, Y
, ItemSize
[ItemType
][0], ItemSize
[ItemType
][1],
750 fX
, fY
, fWidth
, fHeight
);
753 with MonsterSize
[gMonsters
[ID
].MonsterType
] do
754 Result
:= g_Collide(gMonsters
[ID
].X
, gMonsters
[ID
].Y
, Width
, Height
,
755 fX
, fY
, fWidth
, fHeight
);
758 with AreaSize
[gAreas
[ID
].AreaType
] do
759 Result
:= g_Collide(gAreas
[ID
].X
, gAreas
[ID
].Y
, Width
, Height
,
760 fX
, fY
, fWidth
, fHeight
);
763 with gTriggers
[ID
] do
764 Result
:= g_Collide(X
, Y
, Width
, Height
,
765 fX
, fY
, fWidth
, fHeight
);
769 function ObjectGetRect(ObjectType
: Byte; ID
: DWORD
): TRectWH
;
777 Result
.Width
:= Width
;
778 Result
.Height
:= Height
;
786 Result
.Width
:= ItemSize
[ItemType
][0];
787 Result
.Height
:= ItemSize
[ItemType
][1];
791 with MonsterSize
[gMonsters
[ID
].MonsterType
] do
793 Result
.X
:= gMonsters
[ID
].X
;
794 Result
.Y
:= gMonsters
[ID
].Y
;
795 Result
.Width
:= Width
;
796 Result
.Height
:= Height
;
800 with AreaSize
[gAreas
[ID
].AreaType
] do
802 Result
.X
:= gAreas
[ID
].X
;
803 Result
.Y
:= gAreas
[ID
].Y
;
804 Result
.Width
:= Width
;
805 Result
.Height
:= Height
;
809 with gTriggers
[ID
] do
813 Result
.Width
:= Width
;
814 Result
.Height
:= Height
;
827 procedure MoveObject(ObjectType
: Byte; ID
: DWORD
; dX
, dY
: Integer);
845 with gMonsters
[ID
] do
859 with gTriggers
[ID
] do
867 function ResizeObject(ObjectType
: Byte; ID
: DWORD
; dWidth
, dHeight
: Integer; ResizeDir
: Byte): Boolean;
874 if Width
>= -dWidth
then
875 Width
:= Width
+dWidth
883 if Height
>= -dHeight
then
884 Height
:= Height
+dHeight
898 OBJECT_ITEM
, OBJECT_MONSTER
, OBJECT_AREA
:
902 with gTriggers
[ID
] do
904 if Width
>= -dWidth
then
905 Width
:= Width
+dWidth
913 if Height
>= -dHeight
then
914 Height
:= Height
+dHeight
930 function ObjectSelected(ObjectType
: Byte; ID
: DWORD
): Boolean;
937 if SelectedObjects
<> nil then
938 for a
:= 0 to High(SelectedObjects
) do
939 if SelectedObjects
[a
].Live
and
940 (SelectedObjects
[a
].ObjectType
= ObjectType
) and
941 (SelectedObjects
[a
].ID
= ID
) then
948 function GetPanelName(PanelType
: Word): String;
953 PANEL_WALL
: Result
:= PANELNAMES
[0];
954 PANEL_BACK
: Result
:= PANELNAMES
[1];
955 PANEL_FORE
: Result
:= PANELNAMES
[2];
956 PANEL_OPENDOOR
: Result
:= PANELNAMES
[3];
957 PANEL_CLOSEDOOR
: Result
:= PANELNAMES
[4];
958 PANEL_STEP
: Result
:= PANELNAMES
[5];
959 PANEL_WATER
: Result
:= PANELNAMES
[6];
960 PANEL_ACID1
: Result
:= PANELNAMES
[7];
961 PANEL_ACID2
: Result
:= PANELNAMES
[8];
962 PANEL_LIFTUP
: Result
:= PANELNAMES
[9];
963 PANEL_LIFTDOWN
: Result
:= PANELNAMES
[10];
964 PANEL_LIFTLEFT
: Result
:= PANELNAMES
[11];
965 PANEL_LIFTRIGHT
: Result
:= PANELNAMES
[12];
966 PANEL_BLOCKMON
: Result
:= PANELNAMES
[13];
971 function GetPanelType(PanelName
: String): Word;
975 if PanelName
= PANELNAMES
[0] then
977 else if PanelName
= PANELNAMES
[1] then
979 else if PanelName
= PANELNAMES
[2] then
981 else if PanelName
= PANELNAMES
[3] then
982 Result
:= PANEL_OPENDOOR
983 else if PanelName
= PANELNAMES
[4] then
984 Result
:= PANEL_CLOSEDOOR
985 else if PanelName
= PANELNAMES
[5] then
987 else if PanelName
= PANELNAMES
[6] then
988 Result
:= PANEL_WATER
989 else if PanelName
= PANELNAMES
[7] then
990 Result
:= PANEL_ACID1
991 else if PanelName
= PANELNAMES
[8] then
992 Result
:= PANEL_ACID2
993 else if PanelName
= PANELNAMES
[9] then
994 Result
:= PANEL_LIFTUP
995 else if PanelName
= PANELNAMES
[10] then
996 Result
:= PANEL_LIFTDOWN
997 else if PanelName
= PANELNAMES
[11] then
998 Result
:= PANEL_LIFTLEFT
999 else if PanelName
= PANELNAMES
[12] then
1000 Result
:= PANEL_LIFTRIGHT
1001 else if PanelName
= PANELNAMES
[13] then
1002 Result
:= PANEL_BLOCKMON
;
1004 Assert(Result
<> 0);
1007 function GetTriggerName(TriggerType
: Byte): String;
1009 if TriggerType
in [TRIGGER_EXIT
..TRIGGER_MAX
] then
1010 Result
:= TriggerNames
[TriggerType
]
1015 function GetTriggerType(TriggerName
: String): Byte;
1020 Result
:= TRIGGER_NONE
;
1021 for i
:= TRIGGER_EXIT
to TRIGGER_MAX
do
1022 if TriggerNames
[i
] = TriggerName
then
1031 function IsSpecialTexture(TextureName
: string): Boolean;
1033 Result
:= (TextureName
= TEXTURE_NAME_WATER
) or
1034 (TextureName
= TEXTURE_NAME_ACID1
) or
1035 (TextureName
= TEXTURE_NAME_ACID2
);
1038 function SpecialTextureID(TextureName
: string): DWORD
;
1040 Assert(IsSpecialTexture(TextureName
));
1044 if TextureName
= TEXTURE_NAME_WATER
then
1045 Result
:= TEXTURE_SPECIAL_WATER
1047 if TextureName
= TEXTURE_NAME_ACID1
then
1048 Result
:= TEXTURE_SPECIAL_ACID1
1050 if TextureName
= TEXTURE_NAME_ACID2
then
1051 Result
:= TEXTURE_SPECIAL_ACID2
;
1054 function SaveMap(Res
: String): Pointer;
1057 MapWriter
: TMapWriter_1
;
1058 textures
: TTexturesRec1Array
;
1059 panels
: TPanelsRec1Array
;
1060 items
: TItemsRec1Array
;
1061 areas
: TAreasRec1Array
;
1062 monsters
: TMonsterRec1Array
;
1063 triggers
: TTriggersRec1Array
;
1064 header
: TMapHeaderRec_1
;
1067 PanelTable
: Array of Array [0..1] of Word;
1068 MonsterTable
: Array of Array [0..1] of Word;
1070 FileName
, SectionName
, ResName
: String;
1082 MonsterTable
:= nil;
1086 // Открываем WAD, если надо:
1089 WAD
:= TWADEditor_1
.Create();
1090 g_ProcessResourceStr(Res
, FileName
, SectionName
, ResName
);
1091 if not WAD
.ReadFile(FileName
) then
1097 MapWriter
:= TMapWriter_1
.Create();
1099 // Сохраняем заголовок:
1102 ZeroMemory(@header
, SizeOf(TMapHeaderRec_1
));
1104 s
:= utf2win(gMapInfo
.Name
);
1106 CopyMemory(@MapName
[0], @s
[1], Min(32, Length(s
)));
1108 s
:= utf2win(gMapInfo
.Description
);
1110 CopyMemory(@MapDescription
[0], @s
[1], Min(256, Length(s
)));
1112 s
:= utf2win(gMapInfo
.Author
);
1114 CopyMemory(@MapAuthor
[0], @s
[1], Min(32, Length(s
)));
1116 s
:= utf2win(gMapInfo
.MusicName
);
1118 CopyMemory(@MusicName
[0], @s
[1], Min(64, Length(s
)));
1120 s
:= utf2win(gMapInfo
.SkyName
);
1122 CopyMemory(@SkyName
[0], @s
[1], Min(64, Length(s
)));
1124 Width
:= gMapInfo
.Width
;
1125 Height
:= gMapInfo
.Height
;
1128 MapWriter
.AddHeader(header
);
1130 // Сохраняем названия текстур:
1131 if MainForm
.lbTextureList
.Items
.Count
> 0 then
1133 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1135 SetLength(textures
, Length(textures
)+1);
1136 s
:= utf2win(MainForm
.lbTextureList
.Items
[a
]);
1137 CopyMemory(@textures
[High(textures
)].Resource
[0], @s
[1], Min(64, Length(s
)));
1138 if g_GetTextureFlagByName(MainForm
.lbTextureList
.Items
[a
]) = 1 then
1139 textures
[High(textures
)].Anim
:= 1
1141 textures
[High(textures
)].Anim
:= 0;
1144 MapWriter
.AddTextures(textures
);
1147 // Сохраняем панели:
1148 if gPanels
<> nil then
1152 for a
:= 0 to High(gPanels
) do
1153 if gPanels
[a
].PanelType
<> 0 then
1155 SetLength(PanelTable
, Length(PanelTable
)+1);
1156 PanelTable
[High(PanelTable
)][0] := a
;
1157 PanelTable
[High(PanelTable
)][1] := c
;
1160 SetLength(panels
, Length(panels
)+1);
1162 with panels
[High(panels
)] do
1166 Width
:= gPanels
[a
].Width
;
1167 Height
:= gPanels
[a
].Height
;
1168 PanelType
:= gPanels
[a
].PanelType
;
1169 Alpha
:= gPanels
[a
].Alpha
;
1174 if WordBool(gPanels
[a
].PanelType
and
1175 (PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
)) then
1176 Flags
:= PANEL_FLAG_WATERTEXTURES
;
1178 // Может быть текстура:
1179 if not WordBool(gPanels
[a
].PanelType
and
1180 (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
or PANEL_BLOCKMON
)) then
1182 if gPanels
[a
].Blending
then
1183 Flags
:= Flags
or PANEL_FLAG_BLENDING
;
1184 if gPanels
[a
].TextureID
= TEXTURE_SPECIAL_NONE
then
1185 Flags
:= Flags
or PANEL_FLAG_HIDE
;
1187 // Номер текстуры в списке текстур:
1188 if gPanels
[a
].TextureID
<> TEXTURE_SPECIAL_NONE
then
1189 for b
:= 0 to High(textures
) do
1190 if utf2win(gPanels
[a
].TextureName
) = textures
[b
].Resource
then
1199 MapWriter
.AddPanels(panels
);
1202 // Сохраняем предметы:
1203 if gItems
<> nil then
1205 for a
:= 0 to High(gItems
) do
1206 if gItems
[a
].ItemType
<> 0 then
1208 SetLength(items
, Length(items
)+1);
1210 with items
[High(items
)] do
1214 ItemType
:= gItems
[a
].ItemType
;
1215 if gItems
[a
].OnlyDM
then
1216 Options
:= Options
or ITEM_OPTION_ONLYDM
;
1217 if gItems
[a
].Fall
then
1218 Options
:= Options
or ITEM_OPTION_FALL
;
1222 MapWriter
.AddItems(items
);
1225 // Сохраняем монстров:
1226 if gMonsters
<> nil then
1230 for a
:= 0 to High(gMonsters
) do
1231 if gMonsters
[a
].MonsterType
<> 0 then
1233 SetLength(MonsterTable
, Length(MonsterTable
)+1);
1234 MonsterTable
[High(MonsterTable
)][0] := a
;
1235 MonsterTable
[High(MonsterTable
)][1] := c
;
1238 SetLength(monsters
, Length(monsters
)+1);
1240 with monsters
[High(monsters
)] do
1242 X
:= gMonsters
[a
].X
;
1243 Y
:= gMonsters
[a
].Y
;
1244 MonsterType
:= gMonsters
[a
].MonsterType
;
1245 Direction
:= Ord(gMonsters
[a
].Direction
);
1249 MapWriter
.AddMonsters(monsters
);
1252 // Сохраняем области:
1253 if gAreas
<> nil then
1255 for a
:= 0 to High(gAreas
) do
1256 if gAreas
[a
].AreaType
<> 0 then
1258 SetLength(areas
, Length(areas
)+1);
1260 with areas
[High(areas
)] do
1264 AreaType
:= gAreas
[a
].AreaType
;
1265 Direction
:= Ord(gAreas
[a
].Direction
);
1269 MapWriter
.AddAreas(areas
);
1272 // Сохраняем триггеры:
1273 if gTriggers
<> nil then
1275 for a
:= 0 to High(gTriggers
) do
1276 if gTriggers
[a
].TriggerType
<> 0 then
1278 SetLength(triggers
, Length(triggers
)+1);
1280 with triggers
[High(triggers
)] do
1282 X
:= gTriggers
[a
].X
;
1283 Y
:= gTriggers
[a
].Y
;
1284 Width
:= gTriggers
[a
].Width
;
1285 Height
:= gTriggers
[a
].Height
;
1286 Enabled
:= Byte(gTriggers
[a
].Enabled
);
1288 TriggerType
:= gTriggers
[a
].TriggerType
;
1289 ActivateType
:= gTriggers
[a
].ActivateType
;
1290 Keys
:= gTriggers
[a
].Key
;
1291 DATA
:= gTriggers
[a
].Data
.Default
;
1293 if PanelTable
<> nil then
1295 // Ищем номер панели, которой этот триггер меняет текстуру:
1296 if gTriggers
[a
].TexturePanel
<> -1 then
1298 for c
:= 0 to High(PanelTable
) do
1299 if PanelTable
[c
][0] = gTriggers
[a
].TexturePanel
then
1300 TexturePanel
:= PanelTable
[c
][1];
1303 // Ищем номер панели, которую меняет этот триггер:
1304 if gTriggers
[a
].TriggerType
in [
1305 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
1306 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
1307 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
] then
1308 if TTriggerData(DATA
).PanelID
<> -1 then
1309 for c
:= 0 to High(PanelTable
) do
1310 if PanelTable
[c
][0] = TTriggerData(DATA
).PanelID
then
1312 TTriggerData(DATA
).PanelID
:= PanelTable
[c
][1];
1316 // Ищем номер панели индикации, которой этот триггер меняет текстуру:
1317 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
1318 (TTriggerData(DATA
).ShotPanelID
<> -1) then
1320 for c
:= 0 to High(PanelTable
) do
1321 if PanelTable
[c
][0] = TTriggerData(DATA
).ShotPanelID
then
1322 TTriggerData(DATA
).ShotPanelID
:= PanelTable
[c
][1];
1326 if MonsterTable
<> nil then
1328 // Ищем номер монстра - условие активации триггера:
1329 if gTriggers
[a
].TriggerType
in [
1330 TRIGGER_PRESS
, TRIGGER_ON
,
1331 TRIGGER_OFF
, TRIGGER_ONOFF
] then
1332 if TTriggerData(DATA
).MonsterID
<> 0 then
1333 for c
:= 0 to High(MonsterTable
) do
1334 if MonsterTable
[c
][0] = TTriggerData(DATA
).MonsterID
-1 then
1336 TTriggerData(DATA
).MonsterID
:= MonsterTable
[c
][1]+1;
1343 MapWriter
.AddTriggers(triggers
);
1346 // Сохраняем карту в память:
1347 Len
:= MapWriter
.SaveMap(Data
);
1351 // Записываем в WAD, если надо:
1354 s
:= utf2win(ResName
);
1355 WAD
.RemoveResource('', s
);
1356 WAD
.AddResource(Data
, Len
, s
, '');
1357 WAD
.SaveTo(FileName
);
1368 procedure AddTexture(res
: String; Error
: Boolean);
1372 with MainForm
.lbTextureList
do
1374 for a
:= 0 to Count
-1 do
1375 if Items
[a
] = res
then
1378 if Error
and (slInvalidTextures
.IndexOf(res
) = -1) then
1379 slInvalidTextures
.Add(res
);
1384 function LoadMap(Res
: String): Boolean;
1387 MapReader
: TMapReader_1
;
1388 Header
: TMapHeaderRec_1
;
1389 textures
: TTexturesRec1Array
;
1390 panels
: TPanelsRec1Array
;
1391 items
: TItemsRec1Array
;
1392 monsters
: TMonsterRec1Array
;
1393 areas
: TAreasRec1Array
;
1394 triggers
: TTriggersRec1Array
;
1402 Width
, Height
, m
: Word;
1403 FileName
, SectionName
, ResName
, _fn
: String;
1404 TextureRes
, ustr
: String;
1406 Len
, FrameLen
: Integer;
1422 MainForm
.pbLoad
.Position
:= 0;
1423 MainForm
.lLoad
.Caption
:= MsgLoadWad
;
1424 Application
.ProcessMessages();
1427 WAD
:= TWADEditor_1
.Create();
1428 g_ProcessResourceStr(Res
, FileName
, SectionName
, ResName
);
1430 if not WAD
.ReadFile(FileName
) then
1436 // Читаем ресурс карты:
1437 if not WAD
.GetResource('', utf2win(ResName
), pData
, Len
) then
1445 MapReader
:= TMapReader_1
.Create();
1447 MainForm
.lLoad
.Caption
:= MsgLoadMap
;
1448 Application
.ProcessMessages();
1450 MapReader
.LoadMap(pData
);
1452 // Загружаем текстуры:
1453 textures
:= MapReader
.GetTextures();
1455 if textures
<> nil then
1457 MainForm
.pbLoad
.Position
:= 0;
1458 MainForm
.pbLoad
.Max
:= Length(textures
);
1459 MainForm
.lLoad
.Caption
:= MsgLoadTextures
;
1461 for a
:= 0 to High(textures
) do
1463 MainForm
.pbLoad
.StepIt();
1464 Application
.ProcessMessages();
1465 ustr
:= win2utf(textures
[a
].Resource
);
1467 if IsSpecialTexture(ustr
) then
1469 AddTexture(ustr
, False);
1473 g_ProcessResourceStr(ustr
, @_fn
, nil, nil);
1476 TextureRes
:= FileName
+ ustr
1478 TextureRes
:= WadsDir
+ DirectorySeparator
+ ustr
;
1482 if not ByteBool(textures
[a
].Anim
) then
1483 begin // Обычная текстура
1484 if not g_CreateTextureWAD(ustr
, TextureRes
) then
1486 e_WriteLog(Format('g_CreateTextureWAD() error, res=%s',
1487 [ustr
]), MSG_WARNING
);
1491 AddTexture(ustr
, Error
);
1494 begin // Анимированная текстура
1495 if not GetFrame(TextureRes
, Data
, FrameLen
, Width
, Height
) then
1497 e_WriteLog(Format('GetFrame() error, res=%s',
1498 [ustr
]), MSG_WARNING
);
1502 if not g_CreateTextureMemorySize(Data
, FrameLen
, ustr
, 0, 0, Width
, Height
, 1) then
1503 begin // Сама текстура
1504 e_WriteLog(Format('g_CreateTextureMemorySize() error, res=%s',
1505 [ustr
]), MSG_WARNING
);
1509 AddTexture(ustr
, Error
);
1514 // Загружаем панели:
1515 panels
:= MapReader
.GetPanels();
1517 if panels
<> nil then
1519 MainForm
.pbLoad
.Position
:= 0;
1520 MainForm
.pbLoad
.Max
:= Length(panels
);
1521 MainForm
.lLoad
.Caption
:= MsgLoadPanels
;
1523 for a
:= 0 to High(panels
) do
1525 MainForm
.pbLoad
.StepIt();
1526 Application
.ProcessMessages();
1528 panel
.X
:= panels
[a
].X
;
1529 panel
.Y
:= panels
[a
].Y
;
1530 panel
.Height
:= panels
[a
].Height
;
1531 panel
.Width
:= panels
[a
].Width
;
1532 panel
.PanelType
:= panels
[a
].PanelType
;
1533 panel
.Alpha
:= panels
[a
].Alpha
;
1535 panel
.Blending
:= ByteBool(panels
[a
].Flags
and PANEL_FLAG_BLENDING
);
1537 panel
.TextureWidth
:= 0;
1538 panel
.TextureHeight
:= 0;
1539 panel
.TextureName
:= '';
1540 panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
1542 m
:= PANEL_WALL
or PANEL_BACK
or PANEL_FORE
or PANEL_STEP
or
1543 PANEL_OPENDOOR
or PANEL_CLOSEDOOR
;
1545 if ByteBool(panels
[a
].Flags
and PANEL_FLAG_WATERTEXTURES
) then
1546 m
:= m
or PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
;
1548 // Если панель видима:
1549 if WordBool(panel
.PanelType
and m
) and
1550 (not (ByteBool(panels
[a
].Flags
and PANEL_FLAG_HIDE
))) then
1552 ustr
:= win2utf(textures
[panels
[a
].TextureNum
].Resource
);
1553 if not IsSpecialTexture(ustr
) then
1555 if g_GetTexture(ustr
, panel
.TextureID
) then
1556 g_GetTextureSizeByID(panel
.TextureID
, panel
.TextureWidth
, panel
.TextureHeight
)
1558 panel
.TextureWidth
:= 1;
1559 panel
.TextureHeight
:= 1;
1560 if g_GetTexture('NOTEXTURE', NoTextureID
) then
1562 panel
.TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
1563 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
1564 panel
.TextureWidth
:= NW
;
1565 panel
.TextureHeight
:= NH
;
1569 else // Спец. текстура
1570 panel
.TextureID
:= SpecialTextureID(ustr
);
1572 panel
.TextureName
:= ustr
;
1575 // Жидкость без текстуры:
1576 if WordBool(panel
.PanelType
and (PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
)) and
1577 (not ByteBool(panels
[a
].Flags
and PANEL_FLAG_WATERTEXTURES
)) then
1579 case panel
.PanelType
of
1580 PANEL_WATER
: panel
.TextureName
:= TEXTURE_NAME_WATER
;
1581 PANEL_ACID1
: panel
.TextureName
:= TEXTURE_NAME_ACID1
;
1582 PANEL_ACID2
: panel
.TextureName
:= TEXTURE_NAME_ACID2
;
1585 panel
.TextureID
:= SpecialTextureID(panel
.TextureName
);
1586 AddTexture(panel
.TextureName
, False);
1593 // Загружаем предметы:
1594 items
:= MapReader
.GetItems();
1596 if items
<> nil then
1598 MainForm
.pbLoad
.Position
:= 0;
1599 MainForm
.pbLoad
.Max
:= Length(items
);
1600 MainForm
.lLoad
.Caption
:= MsgLoadItems
;
1602 for a
:= 0 to High(items
) do
1604 MainForm
.pbLoad
.StepIt();
1605 Application
.ProcessMessages();
1607 item
.X
:= items
[a
].X
;
1608 item
.Y
:= items
[a
].Y
;
1609 item
.ItemType
:= items
[a
].ItemType
;
1610 item
.OnlyDM
:= ByteBool(items
[a
].Options
and ITEM_OPTION_ONLYDM
);
1611 item
.Fall
:= ByteBool(items
[a
].Options
and ITEM_OPTION_FALL
);
1617 // Загружаем монстров:
1618 monsters
:= MapReader
.GetMonsters();
1620 if monsters
<> nil then
1622 MainForm
.pbLoad
.Position
:= 0;
1623 MainForm
.pbLoad
.Max
:= Length(monsters
);
1624 MainForm
.lLoad
.Caption
:= MsgLoadMonsters
;
1626 for a
:= 0 to High(monsters
) do
1628 MainForm
.pbLoad
.StepIt();
1629 Application
.ProcessMessages();
1631 monster
.X
:= monsters
[a
].X
;
1632 monster
.Y
:= monsters
[a
].Y
;
1633 monster
.MonsterType
:= monsters
[a
].MonsterType
;
1634 monster
.Direction
:= TDirection(monsters
[a
].Direction
);
1636 AddMonster(monster
);
1640 // Загружаем области:
1641 areas
:= MapReader
.GetAreas();
1643 if areas
<> nil then
1645 MainForm
.pbLoad
.Position
:= 0;
1646 MainForm
.pbLoad
.Max
:= Length(areas
);
1647 MainForm
.lLoad
.Caption
:= MsgLoadAreas
;
1649 for a
:= 0 to High(areas
) do
1651 MainForm
.pbLoad
.StepIt();
1652 Application
.ProcessMessages();
1654 area
.X
:= areas
[a
].X
;
1655 area
.Y
:= areas
[a
].Y
;
1656 area
.AreaType
:= areas
[a
].AreaType
;
1657 area
.Direction
:= TDirection(areas
[a
].Direction
);
1663 // Загружаем триггеры:
1664 triggers
:= MapReader
.GetTriggers();
1666 if triggers
<> nil then
1668 MainForm
.pbLoad
.Position
:= 0;
1669 MainForm
.pbLoad
.Max
:= Length(triggers
);
1670 MainForm
.lLoad
.Caption
:= MsgLoadTriggers
;
1672 for a
:= 0 to High(triggers
) do
1674 MainForm
.pbLoad
.StepIt();
1675 Application
.ProcessMessages();
1677 trigger
.X
:= triggers
[a
].X
;
1678 trigger
.Y
:= triggers
[a
].Y
;
1679 trigger
.Width
:= triggers
[a
].Width
;
1680 trigger
.Height
:= triggers
[a
].Height
;
1682 trigger
.Enabled
:= ByteBool(triggers
[a
].Enabled
);
1683 trigger
.TexturePanel
:= triggers
[a
].TexturePanel
;
1684 trigger
.TriggerType
:= triggers
[a
].TriggerType
;
1685 trigger
.ActivateType
:= triggers
[a
].ActivateType
;
1686 trigger
.Key
:= triggers
[a
].Keys
;
1687 trigger
.Data
.Default
:= triggers
[a
].DATA
;
1689 AddTrigger(trigger
);
1693 // Загружаем заголовок карты:
1694 Header
:= MapReader
.GetMapHeader();
1696 gMapInfo
.FileName
:= FileName
;
1701 Name
:= win2utf(Header
.MapName
);
1702 Description
:= win2utf(Header
.MapDescription
);
1703 Author
:= win2utf(Header
.MapAuthor
);
1704 MusicName
:= win2utf(Header
.MusicName
);
1705 SkyName
:= win2utf(Header
.SkyName
);
1706 Height
:= Header
.Height
;
1707 Width
:= Header
.Width
;
1710 LoadSky(gMapInfo
.SkyName
);
1724 function LoadMapOld(_FileName
: String): Boolean;
1726 TexturePrefix
= 'standart.wad:STDTEXTURES\';
1727 DefaultMusRes
= 'standart.wad:STDMUS\MUS1';
1728 DefaultSkyRes
= 'standart.wad:STDSKY\SKY0';
1741 if not FileExists(_FileName
) then
1745 MainForm
.pbLoad
.Position
:= 0;
1746 MainForm
.lLoad
.Caption
:= MsgLoadMap
;;
1747 Application
.ProcessMessages();
1749 map
:= TConfig
.CreateFile(_FileName
);
1752 i
:= map
.ReadInt('MapOptions', 'TextureCount', 0);
1754 MainForm
.pbLoad
.Max
:= i
;
1755 MainForm
.pbLoad
.Position
:= 0;
1756 MainForm
.lLoad
.Caption
:= MsgLoadTextures
;
1760 MainForm
.pbLoad
.StepIt();
1761 Application
.ProcessMessages();
1763 s
:= TexturePrefix
+ UpperCase(win2utf(map
.ReadStr('Textures', 'TextureName'+IntToStr(a
), '')));
1764 if s
= TexturePrefix
then
1767 // Нет такой текстуры - ищем в WAD карты:
1768 if not g_CreateTextureWAD(s
, WadsDir
+ DirectorySeparator
+ s
) then
1770 s
:= ExtractFileName(_FileName
);
1771 Delete(s
, Length(s
)-3, 4);
1772 s
:= UpperCase(s
) + '.WAD:TEXTURES\'+ UpperCase(win2utf(map
.ReadStr('Textures', 'TextureName'+IntToStr(a
), '')));
1774 if not g_CreateTextureWAD(s
, WadsDir
+ DirectorySeparator
+ s
) then
1778 MainForm
.lbTextureList
.Items
.Add(s
);
1782 i
:= map
.ReadInt('MapOptions', 'PanelCount', 0);
1784 MainForm
.pbLoad
.Max
:= i
;
1785 MainForm
.pbLoad
.Position
:= 0;
1786 MainForm
.lLoad
.Caption
:= MsgLoadPanels
;
1790 MainForm
.pbLoad
.StepIt();
1791 Application
.ProcessMessages();
1793 section
:= 'Panel' + IntToStr(a
);
1794 if not map
.SectionExists(section
) then
1797 panel
:= Default(TPanel
);
1798 panel
.X
:= map
.ReadInt(section
, 'X1', 0);
1799 panel
.Y
:= map
.ReadInt(section
, 'Y1', 0);
1800 panel
.Height
:= map
.ReadInt(section
, 'Height', 16);
1801 panel
.Width
:= map
.ReadInt(section
, 'Width', 16);
1803 case map
.ReadInt(section
, 'PanelType', 0) of
1804 0: panel
.PanelType
:= PANEL_WALL
;
1805 1: panel
.PanelType
:= PANEL_BACK
;
1806 2: panel
.PanelType
:= PANEL_FORE
;
1807 3: panel
.PanelType
:= PANEL_STEP
;
1808 4: panel
.PanelType
:= PANEL_WATER
;
1809 5: panel
.PanelType
:= PANEL_ACID1
;
1810 6: panel
.PanelType
:= PANEL_ACID2
;
1813 panel
.Alpha
:= map
.ReadInt(section
, 'Alpha', 0);
1814 panel
.Blending
:= false;
1817 if panel
.PanelType
in [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
, PANEL_STEP
] then
1819 s
:= TexturePrefix
+ UpperCase(win2utf(map
.ReadStr(section
, 'TextureName', '')));
1821 if g_GetTexture(s
, panel
.TextureID
) then
1823 g_GetTextureSizeByID(panel
.TextureID
, panel
.TextureWidth
, panel
.TextureHeight
);
1824 panel
.TextureName
:= s
;
1826 else // Нет такой текстуры - ищем в WAD карты:
1828 s
:= ExtractFileName(_FileName
);
1829 Delete(s
, Length(s
)-3, 4);
1830 s
:= UpperCase(s
) + '.WAD:TEXTURES\' + UpperCase(win2utf(map
.ReadStr(section
, 'TextureName', '')));
1832 if g_GetTexture(s
, panel
.TextureID
) then
1834 g_GetTextureSizeByID(panel
.TextureID
, panel
.TextureWidth
, panel
.TextureHeight
);
1835 panel
.TextureName
:= s
;
1841 else if panel
.PanelType
in [PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
] then
1843 case panel
.PanelType
of
1846 s
:= TEXTURE_NAME_WATER
;
1847 panel
.TextureID
:= TEXTURE_SPECIAL_WATER
;
1851 s
:= TEXTURE_NAME_ACID2
;
1852 panel
.TextureID
:= TEXTURE_SPECIAL_ACID2
;
1856 s
:= TEXTURE_NAME_ACID1
;
1857 panel
.TextureID
:= TEXTURE_SPECIAL_ACID1
;
1861 with MainForm
.lbTextureList
.Items
do
1862 if IndexOf(s
) = -1 then
1864 panel
.TextureName
:= s
;
1865 panel
.TextureWidth
:= 1;
1866 panel
.TextureHeight
:= 1;
1872 // Чтение предметов:
1873 i
:= map
.ReadInt('MapOptions', 'ItemCount', 0);
1875 MainForm
.pbLoad
.Max
:= i
;
1876 MainForm
.pbLoad
.Position
:= 0;
1877 MainForm
.lLoad
.Caption
:= MsgLoadItems
;
1881 MainForm
.pbLoad
.StepIt();
1882 Application
.ProcessMessages();
1884 section
:= 'Item' + IntToStr(a
);
1885 if not map
.SectionExists(section
) then
1888 item
:= Default(TItem
);
1889 item
.X
:= map
.ReadInt(section
, 'X', 0);
1890 item
.Y
:= map
.ReadInt(section
, 'Y', 0);
1891 item
.ItemType
:= ITEMSCONVERT
[map
.ReadInt(section
, 'Type', 0)];
1892 item
.OnlyDM
:= False;
1893 item
.Fall
:= item
.ItemType
in [ITEM_KEY_RED
, ITEM_KEY_GREEN
, ITEM_KEY_BLUE
];
1895 // Размер предметов теперь другой:
1896 item
.X
:= item
.X
+ OldItemSize
[item
.ItemType
][0] - ItemSize
[item
.ItemType
][0];
1897 item
.Y
:= item
.Y
+ OldItemSize
[item
.ItemType
][1] - ItemSize
[item
.ItemType
][1];
1903 i
:= map
.ReadInt('MapOptions', 'AreaCount', 0);
1905 MainForm
.pbLoad
.Max
:= i
;
1906 MainForm
.pbLoad
.Position
:= 0;
1907 MainForm
.lLoad
.Caption
:= MsgLoadAreas
;
1911 MainForm
.pbLoad
.StepIt();
1912 Application
.ProcessMessages();
1914 section
:= 'Area' + IntToStr(a
);
1915 if not map
.SectionExists(section
) then
1918 area
:= Default(TArea
);
1919 area
.X
:= map
.ReadInt(section
, 'X', 0);
1920 area
.Y
:= map
.ReadInt(section
, 'Y', 0);
1921 area
.AreaType
:= map
.ReadInt(section
, 'Type', 0);
1922 area
.Direction
:= D_RIGHT
;
1924 // Размер областей теперь другой:
1925 area
.X
:= area
.X
+ OldAreaSize
[0] - AreaSize
[area
.AreaType
].Width
;
1926 area
.Y
:= area
.Y
+ OldAreaSize
[1] - AreaSize
[area
.AreaType
].Height
;
1931 // Чтение параметров карты:
1932 gMapInfo
:= Default(TMapInfo
);
1935 Name
:= win2utf(map
.ReadStr('MapOptions', 'MapName', ''));
1936 Description
:= win2utf(map
.ReadStr('MapOptions', 'MapDescription', ''));
1938 MusicName
:= DefaultMusRes
;
1939 SkyName
:= DefaultSkyRes
;
1940 FileName
:= _FileName
;
1941 Height
:= map
.ReadInt('MapOptions', 'Height', 1600);
1942 Width
:= map
.ReadInt('MapOptions', 'Width', 1600);
1944 if Length(Name
) > 32 then
1945 SetLength(Name
, 32);
1946 if Length(Description
) > 256 then
1947 SetLength(Description
, 256);
1950 LoadSky(gMapInfo
.SkyName
);
1957 procedure ClearMap();
1962 if gPanels
<> nil then
1963 for a
:= 0 to High(gPanels
) do
1964 if gPanels
[a
].TextureName
<> '' then
1965 g_DeleteTexture(gPanels
[a
].TextureName
);
1967 SetLength(gPanels
, 0);
1969 SetLength(gItems
, 0);
1971 SetLength(gAreas
, 0);
1973 SetLength(gMonsters
, 0);
1975 SetLength(gTriggers
, 0);
1978 gMapInfo
:= Default(TMapInfo
);
1979 gMapInfo
.Width
:= 1600;
1980 gMapInfo
.Height
:= 1600;
1982 with MainForm
.lbTextureList
do
1984 if Items
.Count
> 0 then
1985 for a
:= Items
.Count
-1 downto 0 do
1986 if not IsSpecialTexture(Items
[a
]) then
1987 g_DeleteTexture(Items
[a
]);
1996 procedure DrawPanels(fPanelType
: Word);
1998 procedure DrawTexture(a
: Integer);
2009 TEXTURE_SPECIAL_NONE
:
2010 if PreviewMode
= 0 then
2011 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2012 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2015 TEXTURE_SPECIAL_NOTEXTURE
:
2016 if g_GetTexture('NOTEXTURE', NoTextureID
) then
2018 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
2019 e_DrawFill(NoTextureID
, X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2020 Width
div NW
, Height
div NH
, 0, False, False);
2023 TEXTURE_SPECIAL_WATER
:
2024 if PreviewMode
> 0 then
2025 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2026 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2027 0, 0, 255, 0, B_FILTER
)
2029 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2030 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2033 TEXTURE_SPECIAL_ACID1
:
2034 if PreviewMode
> 0 then
2035 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2036 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2037 0, 127, 0, 0, B_FILTER
)
2039 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2040 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2043 TEXTURE_SPECIAL_ACID2
:
2044 if PreviewMode
> 0 then
2045 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2046 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2047 127, 0, 0, 0, B_FILTER
)
2049 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2050 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2054 e_DrawFill(TextureID
, X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2055 Width
div TextureWidth
, Height
div TextureHeight
,
2056 Alpha
, True, Blending
);
2064 if gPanels
<> nil then
2065 for a
:= 0 to High(gPanels
) do
2066 if (gPanels
[a
].PanelType
<> 0) and
2067 WordBool(gPanels
[a
].PanelType
and fPanelType
) then
2070 if (TextureID
< TEXTURE_SPECIAL_NOTEXTURE
) and (TextureWidth
= 0) and (TextureWidth
= 0) then
2071 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
2073 PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
2074 PANEL_STEP
, PANEL_OPENDOOR
, PANEL_CLOSEDOOR
,
2075 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
:
2079 if PreviewMode
= 0 then
2080 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2081 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2084 if PreviewMode
= 0 then
2085 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2086 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2089 if PreviewMode
= 0 then
2090 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2091 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2094 if PreviewMode
= 0 then
2095 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2096 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2099 if PreviewMode
= 0 then
2100 e_DrawFillQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2101 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2107 procedure DrawContours (fPanelType
: Word);
2108 var i
, xx
, yy
, ww
, hh
: Integer;
2110 if gPanels
<> nil then
2111 for i
:= 0 to High(gPanels
) do
2112 if (gPanels
[i
].PanelType
<> 0) and WordBool(gPanels
[i
].PanelType
and fPanelType
) then
2114 xx
:= gPanels
[i
].X
+ MapOffset
.X
;
2115 yy
:= gPanels
[i
].Y
+ MapOffset
.Y
;
2116 ww
:= gPanels
[i
].X
+ MapOffset
.X
+ gPanels
[i
].Width
- 1;
2117 hh
:= gPanels
[i
].Y
+ MapOffset
.Y
+ gPanels
[i
].Height
- 1;
2118 case gPanels
[i
].PanelType
of
2120 PANEL_WALL
: e_DrawQuad(xx
, yy
, ww
, hh
, 208, 208, 208, 0);
2121 PANEL_BACK
: e_DrawQuad(xx
, yy
, ww
, hh
, 64, 64, 64, 0);
2122 PANEL_FORE
: e_DrawQuad(xx
, yy
, ww
, hh
, 128, 128, 128, 0);
2123 PANEL_WATER
: e_DrawQuad(xx
, yy
, ww
, hh
, 0, 0, 192, 0);
2124 PANEL_ACID1
: e_DrawQuad(xx
, yy
, ww
, hh
, 0, 176, 0, 0);
2125 PANEL_ACID2
: e_DrawQuad(xx
, yy
, ww
, hh
, 176, 0, 0, 0);
2126 PANEL_STEP
: e_DrawQuad(xx
, yy
, ww
, hh
, 128, 128, 128, 0);
2127 PANEL_LIFTUP
: e_DrawQuad(xx
, yy
, ww
, hh
, 116, 72, 36, 0);
2128 PANEL_LIFTDOWN
: e_DrawQuad(xx
, yy
, ww
, hh
, 116, 124, 96, 0);
2129 PANEL_OPENDOOR
: e_DrawQuad(xx
, yy
, ww
, hh
, 100, 220, 92, 0);
2130 PANEL_CLOSEDOOR
: e_DrawQuad(xx
, yy
, ww
, hh
, 212, 184, 64, 0);
2131 PANEL_BLOCKMON
: e_DrawQuad(xx
, yy
, ww
, hh
, 192, 0, 192, 0);
2132 PANEL_LIFTLEFT
: e_DrawQuad(xx
, yy
, ww
, hh
, 200, 80, 4, 0);
2133 PANEL_LIFTRIGHT
: e_DrawQuad(xx
, yy
, ww
, hh
, 252, 140, 56, 0);
2140 procedure DrawMap();
2144 xx
, yy
, dx
, dy
: Integer;
2151 // В режиме Превью рисуем небо:
2152 if PreviewMode
> 0 then
2154 w
:= Max(MainForm
.RenderPanel
.Width
, MainForm
.RenderPanel
.Height
);
2155 if MainForm
.RenderPanel
.Height
> MainForm
.RenderPanel
.Width
*3/4 then
2159 if g_GetTexture(SKY_TEXTURE
, ID
) then
2160 e_DrawSize(ID
, 0, 0, 0, False, False, w
, h
)
2162 e_DrawFillQuad(0, 0, w
-1, h
-1, 0, 0, 0, 0, B_NONE
);
2165 // Рисуем панели (если Превью или если включен слой):
2166 if LayerEnabled
[LAYER_BACK
] or (PreviewMode
= 1) then
2167 DrawPanels(PANEL_BACK
);
2168 if PreviewMode
> 0 then
2169 DrawPanels(PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)
2171 if LayerEnabled
[LAYER_WATER
] then
2172 DrawPanels(PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
or
2173 PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or PANEL_BLOCKMON
);
2174 if LayerEnabled
[LAYER_WALLS
] or (PreviewMode
= 1) then
2175 DrawPanels(PANEL_WALL
);
2176 if LayerEnabled
[LAYER_STEPS
] or (PreviewMode
= 1) then
2177 DrawPanels(PANEL_STEP
);
2180 if (LayerEnabled
[LAYER_ITEMS
] or (PreviewMode
= 1)) and
2181 (gItems
<> nil) then
2182 for a
:= 0 to High(gItems
) do
2183 if gItems
[a
].ItemType
<> ITEM_NONE
then
2190 ITEM_MEDKIT_SMALL
: g_GetTexture('ITEM_MEDKIT_SMALL', ID
);
2191 ITEM_MEDKIT_LARGE
: g_GetTexture('ITEM_MEDKIT_LARGE', ID
);
2192 ITEM_MEDKIT_BLACK
: g_GetTexture('ITEM_MEDKIT_BLACK', ID
);
2193 ITEM_ARMOR_GREEN
: g_GetTexture('ITEM_ARMORGREEN', ID
);
2194 ITEM_ARMOR_BLUE
: g_GetTexture('ITEM_ARMORBLUE', ID
);
2195 ITEM_SPHERE_BLUE
: g_GetTexture('ITEM_BLUESPHERE', ID
);
2196 ITEM_SPHERE_WHITE
: g_GetTexture('ITEM_WHITESPHERE', ID
);
2197 ITEM_SUIT
: g_GetTexture('ITEM_SUIT', ID
);
2198 ITEM_OXYGEN
: g_GetTexture('ITEM_OXYGEN', ID
);
2199 ITEM_INVUL
: g_GetTexture('ITEM_INVUL', ID
);
2200 ITEM_WEAPON_SAW
: g_GetTexture('ITEM_WEAPON_SAW', ID
);
2201 ITEM_WEAPON_SHOTGUN1
: g_GetTexture('ITEM_WEAPON_SHOTGUN1', ID
);
2202 ITEM_WEAPON_SHOTGUN2
: g_GetTexture('ITEM_WEAPON_SHOTGUN2', ID
);
2203 ITEM_WEAPON_CHAINGUN
: g_GetTexture('ITEM_WEAPON_CHAINGUN', ID
);
2204 ITEM_WEAPON_ROCKETLAUNCHER
: g_GetTexture('ITEM_WEAPON_ROCKETLAUNCHER', ID
);
2205 ITEM_WEAPON_PLASMA
: g_GetTexture('ITEM_WEAPON_PLASMA', ID
);
2206 ITEM_WEAPON_BFG
: g_GetTexture('ITEM_WEAPON_BFG', ID
);
2207 ITEM_WEAPON_SUPERPULEMET
: g_GetTexture('ITEM_WEAPON_SUPERPULEMET', ID
);
2208 ITEM_AMMO_BULLETS
: g_GetTexture('ITEM_AMMO_BULLETS', ID
);
2209 ITEM_AMMO_BULLETS_BOX
: g_GetTexture('ITEM_AMMO_BULLETS_BOX', ID
);
2210 ITEM_AMMO_SHELLS
: g_GetTexture('ITEM_AMMO_SHELLS', ID
);
2211 ITEM_AMMO_SHELLS_BOX
: g_GetTexture('ITEM_AMMO_SHELLS_BOX', ID
);
2212 ITEM_AMMO_ROCKET
: g_GetTexture('ITEM_AMMO_ROCKET', ID
);
2213 ITEM_AMMO_ROCKET_BOX
: g_GetTexture('ITEM_AMMO_ROCKET_BOX', ID
);
2214 ITEM_AMMO_CELL
: g_GetTexture('ITEM_AMMO_CELL', ID
);
2215 ITEM_AMMO_CELL_BIG
: g_GetTexture('ITEM_AMMO_CELL_BIG', ID
);
2216 ITEM_AMMO_BACKPACK
: g_GetTexture('ITEM_AMMO_BACKPACK', ID
);
2217 ITEM_KEY_RED
: g_GetTexture('ITEM_KEY_RED', ID
);
2218 ITEM_KEY_GREEN
: g_GetTexture('ITEM_KEY_GREEN', ID
);
2219 ITEM_KEY_BLUE
: g_GetTexture('ITEM_KEY_BLUE', ID
);
2220 ITEM_BOTTLE
: g_GetTexture('ITEM_BOTTLE', ID
);
2221 ITEM_HELMET
: g_GetTexture('ITEM_HELMET', ID
);
2222 ITEM_JETPACK
: g_GetTexture('ITEM_JETPACK', ID
);
2223 ITEM_INVIS
: g_GetTexture('ITEM_INVIS', ID
);
2224 ITEM_WEAPON_FLAMETHROWER
: g_GetTexture('ITEM_WEAPON_FLAMETHROWER', ID
);
2225 ITEM_AMMO_FUELCAN
: g_GetTexture('ITEM_AMMO_FUELCAN', ID
);
2228 if ID
<> DWORD(-1) then
2229 e_Draw(ID
, MapOffset
.X
+X
, MapOffset
.Y
+Y
, 0, True, False);
2233 if (LayerEnabled
[LAYER_MONSTERS
] or (PreviewMode
= 1)) and
2234 (gMonsters
<> nil) then
2235 for a
:= 0 to High(gMonsters
) do
2236 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
2237 with MonsterSize
[gMonsters
[a
].MonsterType
] do
2240 sel
:= ObjectSelected(OBJECT_MONSTER
, a
);
2242 case gMonsters
[a
].MonsterType
of
2244 MONSTER_DEMON
: g_GetTexture('MONSTER_DEMON', ID
);
2245 MONSTER_IMP
: g_GetTexture('MONSTER_IMP', ID
);
2246 MONSTER_ZOMBY
: g_GetTexture('MONSTER_ZOMBY', ID
);
2247 MONSTER_SERG
: g_GetTexture('MONSTER_SERG', ID
);
2248 MONSTER_CYBER
: g_GetTexture('MONSTER_CYBER', ID
);
2249 MONSTER_CGUN
: g_GetTexture('MONSTER_CGUN', ID
);
2250 MONSTER_BARON
: g_GetTexture('MONSTER_BARON', ID
);
2251 MONSTER_KNIGHT
: g_GetTexture('MONSTER_KNIGHT', ID
);
2252 MONSTER_CACO
: g_GetTexture('MONSTER_CACO', ID
);
2253 MONSTER_SOUL
: g_GetTexture('MONSTER_SOUL', ID
);
2254 MONSTER_PAIN
: g_GetTexture('MONSTER_PAIN', ID
);
2255 MONSTER_SPIDER
: g_GetTexture('MONSTER_SPIDER', ID
);
2256 MONSTER_BSP
: g_GetTexture('MONSTER_BSP', ID
);
2257 MONSTER_MANCUB
: g_GetTexture('MONSTER_MANCUB', ID
);
2258 MONSTER_SKEL
: g_GetTexture('MONSTER_SKEL', ID
);
2259 MONSTER_VILE
: g_GetTexture('MONSTER_VILE', ID
);
2260 MONSTER_FISH
: g_GetTexture('MONSTER_FISH', ID
);
2261 MONSTER_BARREL
: g_GetTexture('MONSTER_BARREL', ID
);
2262 MONSTER_ROBO
: g_GetTexture('MONSTER_ROBO', ID
);
2263 MONSTER_MAN
: g_GetTexture('MONSTER_MAN', ID
);
2266 if ID
<> DWORD(-1) then
2267 if gMonsters
[a
].Direction
= D_LEFT
then
2269 // Расстояние от края текстуры до края визуального положения объекта на текстуре:
2270 xx
:= (X
- MonsterSizeDelta
[gMonsters
[a
].MonsterType
].X
) + Width
;
2271 // Расстояние от края хит бокса до края визуального положения объекта на текстуре:
2272 xx
:= MonsterSizeDelta
[gMonsters
[a
].MonsterType
].Width
- xx
- X
;
2273 // Т.к. двигать текстуру нужно будет в противоположном направлении:
2274 xx
:= (gMonsters
[a
].X
- X
) - xx
;
2276 yy
:= (gMonsters
[a
].Y
- Y
) +
2277 MonsterSizeDelta
[gMonsters
[a
].MonsterType
].Y
;
2279 e_Draw(ID
, MapOffset
.X
+ xx
, MapOffset
.Y
+ yy
,
2280 0, True, False, M_HORIZONTAL
);
2284 // Левый верхний угол текстуры + смещение анимации:
2285 xx
:= (gMonsters
[a
].X
- X
) +
2286 MonsterSizeDelta
[gMonsters
[a
].MonsterType
].X
;
2287 yy
:= (gMonsters
[a
].Y
- Y
) +
2288 MonsterSizeDelta
[gMonsters
[a
].MonsterType
].Y
;
2290 e_Draw(ID
, MapOffset
.X
+ xx
, MapOffset
.Y
+ yy
,
2295 if PreviewMode
= 0 then
2297 e_DrawQuad(MapOffset
.X
+gMonsters
[a
].X
, MapOffset
.Y
+gMonsters
[a
].Y
,
2298 MapOffset
.X
+gMonsters
[a
].X
+Width
-1, MapOffset
.Y
+gMonsters
[a
].Y
+Height
-1,
2299 255, 255, 255, IfThen(sel
, 0, gAlphaMonsterRect
));
2303 // Рисуем закрытые двери после монстров:
2304 if ((PreviewMode
= 2) and LayerEnabled
[LAYER_WATER
])
2305 or (PreviewMode
= 1) then
2306 DrawPanels(PANEL_CLOSEDOOR
);
2309 if (LayerEnabled
[LAYER_AREAS
] or (PreviewMode
= 1)) and
2310 (gAreas
<> nil) then
2311 for a
:= 0 to High(gAreas
) do
2312 if gAreas
[a
].AreaType
<> AREA_NONE
then
2313 with AreaSize
[gAreas
[a
].AreaType
] do
2316 sel
:= ObjectSelected(OBJECT_AREA
, a
);
2318 case gAreas
[a
].AreaType
of
2319 AREA_PLAYERPOINT1
: g_GetTexture('AREA_PLAYERPOINT1', ID
);
2320 AREA_PLAYERPOINT2
: g_GetTexture('AREA_PLAYERPOINT2', ID
);
2321 AREA_DMPOINT
: g_GetTexture('AREA_DMPOINT', ID
);
2322 AREA_REDFLAG
: g_GetTexture('AREA_REDFLAG', ID
);
2323 AREA_BLUEFLAG
: g_GetTexture('AREA_BLUEFLAG', ID
);
2324 AREA_DOMFLAG
: g_GetTexture('AREA_DOMFLAG', ID
);
2325 AREA_REDTEAMPOINT
: g_GetTexture('AREA_REDPOINT', ID
);
2326 AREA_BLUETEAMPOINT
: g_GetTexture('AREA_BLUEPOINT', ID
);
2329 if (PreviewMode
= 0) or
2330 (gAreas
[a
].AreaType
= AREA_REDFLAG
) or
2331 (gAreas
[a
].AreaType
= AREA_BLUEFLAG
) or
2332 (gAreas
[a
].AreaType
= AREA_DOMFLAG
) then
2333 if ID
<> DWORD(-1) then
2334 if gAreas
[a
].Direction
= D_LEFT
then
2335 e_Draw(ID
, MapOffset
.X
+gAreas
[a
].X
-X
, MapOffset
.Y
+gAreas
[a
].Y
-Y
,
2336 0, True, False, M_HORIZONTAL
)
2338 e_Draw(ID
, MapOffset
.X
+gAreas
[a
].X
-X
, MapOffset
.Y
+gAreas
[a
].Y
-Y
,
2342 if PreviewMode
= 0 then
2344 e_DrawQuad(MapOffset
.X
+gAreas
[a
].X
, MapOffset
.Y
+gAreas
[a
].Y
,
2345 MapOffset
.X
+gAreas
[a
].X
+Width
-1, MapOffset
.Y
+gAreas
[a
].Y
+Height
-1,
2346 255, 255, 255, IfThen(sel
, 0, gAlphaAreaRect
));
2348 e_DrawPoint(2, MapOffset
.X
+gAreas
[a
].X
, MapOffset
.Y
+gAreas
[a
].Y
, 255, 0, 0);
2352 // Рисуем жидкости и передний план после областей:
2353 if LayerEnabled
[LAYER_WATER
] or (PreviewMode
= 1) then
2354 DrawPanels(PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
);
2355 if LayerEnabled
[LAYER_FOREGROUND
] or (PreviewMode
= 1) then
2356 DrawPanels(PANEL_FORE
);
2359 if LayerEnabled
[LAYER_TRIGGERS
] and
2360 (PreviewMode
= 0) and (gTriggers
<> nil) then
2361 for a
:= 0 to High(gTriggers
) do
2362 with gTriggers
[a
] do
2363 if TriggerType
<> TRIGGER_NONE
then
2365 // Если выбран - рисуем красным, иначе - белым:
2366 sel
:= ObjectSelected(OBJECT_TRIGGER
, a
);
2368 e_DrawFillQuad(MapOffset
.X
+X
, MapOffset
.Y
+Y
,
2369 MapOffset
.X
+X
+Width
-1, MapOffset
.Y
+Y
+Height
-1,
2372 if TexturePanel
<> -1 then
2374 with gPanels
[TexturePanel
] do
2382 e_DrawQuad(MapOffset
.X
+xx
, MapOffset
.Y
+yy
,
2383 MapOffset
.X
+xx
+ww
-1, MapOffset
.Y
+yy
+hh
-1,
2384 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2385 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2), MapOffset
.Y
+Y
+(Height
div 2),
2386 MapOffset
.X
+xx
, MapOffset
.Y
+yy
,
2387 0, 255, 0, IfThen(sel
, 0, gAlphaTriggerArea
));
2395 // Точка назначения Телепорта:
2396 if Data
.d2d_teleport
then
2397 e_DrawLine(2, MapOffset
.X
+Data
.TargetPoint
.X
-16,
2398 MapOffset
.Y
+Data
.TargetPoint
.Y
-1,
2399 MapOffset
.X
+Data
.TargetPoint
.X
+16, MapOffset
.Y
+Data
.TargetPoint
.Y
-1,
2400 0, 0, 255, IfThen(sel
, 0, gAlphaTriggerArea
))
2402 e_DrawQuad(MapOffset
.X
+Data
.TargetPoint
.X
,
2403 MapOffset
.Y
+Data
.TargetPoint
.Y
,
2404 MapOffset
.X
+Data
.TargetPoint
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
2405 MapOffset
.Y
+Data
.TargetPoint
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1,
2406 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2407 e_DrawPoint(2, MapOffset
.X
+Data
.TargetPoint
.X
,
2408 MapOffset
.Y
+Data
.TargetPoint
.Y
,
2410 // Линия к точке назначения Телепорта:
2411 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2412 MapOffset
.Y
+Y
+(Height
div 2),
2413 MapOffset
.X
+Data
.TargetPoint
.X
,
2414 MapOffset
.Y
+Data
.TargetPoint
.Y
,
2415 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2418 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
2419 TRIGGER_DOOR
, TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
,
2420 TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
2422 if Data
.PanelID
<> -1 then
2424 // Дверь/Ловушка/Лифт:
2425 e_DrawQuad(MapOffset
.X
+gPanels
[Data
.PanelID
].X
,
2426 MapOffset
.Y
+gPanels
[Data
.PanelID
].Y
,
2427 MapOffset
.X
+gPanels
[Data
.PanelID
].X
+gPanels
[Data
.PanelID
].Width
-1,
2428 MapOffset
.Y
+gPanels
[Data
.PanelID
].Y
+gPanels
[Data
.PanelID
].Height
-1,
2429 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2430 e_DrawPoint(2, MapOffset
.X
+gPanels
[Data
.PanelID
].X
,
2431 MapOffset
.Y
+gPanels
[Data
.PanelID
].Y
,
2433 // Линия к Двери/Ловушке/Лифту:
2434 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2435 MapOffset
.Y
+Y
+(Height
div 2),
2436 MapOffset
.X
+gPanels
[Data
.PanelID
].X
,
2437 MapOffset
.Y
+gPanels
[Data
.PanelID
].Y
,
2438 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2441 TRIGGER_PRESS
, TRIGGER_ON
,
2442 TRIGGER_OFF
, TRIGGER_ONOFF
:
2444 if (Data
.tWidth
> 0) and
2445 (Data
.tHeight
> 0) then
2447 // Область Расширителя:
2448 e_DrawQuad(MapOffset
.X
+Data
.tX
,
2449 MapOffset
.Y
+Data
.tY
,
2450 MapOffset
.X
+Data
.tX
+Data
.tWidth
-1,
2451 MapOffset
.Y
+Data
.tY
+Data
.tHeight
-1,
2452 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2453 e_DrawPoint(2, MapOffset
.X
+Data
.tX
,
2454 MapOffset
.Y
+Data
.tY
,
2456 // Линия к области Расширителя:
2457 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2458 MapOffset
.Y
+Y
+(Height
div 2),
2459 MapOffset
.X
+Data
.tX
,
2460 MapOffset
.Y
+Data
.tY
,
2461 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2464 if Data
.MonsterID
<> 0 then
2465 if (gMonsters
<> nil) and
2466 (gMonsters
[Data
.MonsterID
-1].MonsterType
<> MONSTER_NONE
) then
2468 // Рамка вокруг Монстра - условия активации:
2469 r
:= ObjectGetRect(OBJECT_MONSTER
, Data
.MonsterID
-1);
2470 e_DrawQuad(MapOffset
.X
+r
.X
,
2472 MapOffset
.X
+r
.X
+r
.Width
-1,
2473 MapOffset
.Y
+r
.Y
+r
.Height
-1,
2474 0, 255, 0, IfThen(sel
, 0, gAlphaTriggerArea
));
2475 // Линия к Монстру - условию активации:
2476 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2477 MapOffset
.Y
+Y
+(Height
div 2),
2480 0, 255, 0, IfThen(sel
, 0, gAlphaTriggerArea
));
2487 TRIGGER_SPAWNMONSTER
, TRIGGER_SPAWNITEM
:
2489 if TriggerType
= TRIGGER_SPAWNMONSTER
then
2491 xx
:= Data
.MonPos
.X
;
2492 yy
:= Data
.MonPos
.Y
;
2496 xx
:= Data
.ItemPos
.X
;
2497 yy
:= Data
.ItemPos
.Y
;
2499 // Точка появления Монстра/Предмета:
2500 e_DrawLine(2, MapOffset
.X
+xx
-16,
2504 0, 0, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2505 e_DrawPoint(2, MapOffset
.X
+xx
,
2508 // Линия к точке появления Монстра/Предмета:
2509 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2510 MapOffset
.Y
+Y
+(Height
div 2),
2513 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2514 // Предпросмотр создаваемого объекта:
2518 if TriggerType
= TRIGGER_SPAWNMONSTER
then
2520 if Data
.MonType
<> MONSTER_NONE
then
2521 with MonsterSize
[Data
.MonType
] do
2524 case Data
.MonType
of
2525 MONSTER_DEMON
: g_GetTexture('MONSTER_DEMON', ID
);
2526 MONSTER_IMP
: g_GetTexture('MONSTER_IMP', ID
);
2527 MONSTER_ZOMBY
: g_GetTexture('MONSTER_ZOMBY', ID
);
2528 MONSTER_SERG
: g_GetTexture('MONSTER_SERG', ID
);
2529 MONSTER_CYBER
: g_GetTexture('MONSTER_CYBER', ID
);
2530 MONSTER_CGUN
: g_GetTexture('MONSTER_CGUN', ID
);
2531 MONSTER_BARON
: g_GetTexture('MONSTER_BARON', ID
);
2532 MONSTER_KNIGHT
: g_GetTexture('MONSTER_KNIGHT', ID
);
2533 MONSTER_CACO
: g_GetTexture('MONSTER_CACO', ID
);
2534 MONSTER_SOUL
: g_GetTexture('MONSTER_SOUL', ID
);
2535 MONSTER_PAIN
: g_GetTexture('MONSTER_PAIN', ID
);
2536 MONSTER_SPIDER
: g_GetTexture('MONSTER_SPIDER', ID
);
2537 MONSTER_BSP
: g_GetTexture('MONSTER_BSP', ID
);
2538 MONSTER_MANCUB
: g_GetTexture('MONSTER_MANCUB', ID
);
2539 MONSTER_SKEL
: g_GetTexture('MONSTER_SKEL', ID
);
2540 MONSTER_VILE
: g_GetTexture('MONSTER_VILE', ID
);
2541 MONSTER_FISH
: g_GetTexture('MONSTER_FISH', ID
);
2542 MONSTER_BARREL
: g_GetTexture('MONSTER_BARREL', ID
);
2543 MONSTER_ROBO
: g_GetTexture('MONSTER_ROBO', ID
);
2544 MONSTER_MAN
: g_GetTexture('MONSTER_MAN', ID
);
2546 if ID
<> DWORD(-1) then
2548 if Data
.MonDir
= Byte(D_LEFT
) then
2550 xx
:= X
- MonsterSizeDelta
[Data
.MonType
].X
+ Width
;
2551 xx
:= MonsterSizeDelta
[Data
.MonType
].Width
- xx
- X
;
2552 xx
:= Data
.TargetPoint
.X
- X
- xx
- (Width
div 2);
2554 yy
:= Data
.TargetPoint
.Y
- Y
+
2555 MonsterSizeDelta
[Data
.MonType
].Y
-Height
;
2557 e_Draw(ID
, MapOffset
.X
+ xx
, MapOffset
.Y
+ yy
,
2558 128, True, False, M_HORIZONTAL
);
2562 xx
:= Data
.TargetPoint
.X
- X
+
2563 MonsterSizeDelta
[Data
.MonType
].X
-(Width
div 2);
2564 yy
:= Data
.TargetPoint
.Y
- Y
+
2565 MonsterSizeDelta
[Data
.MonType
].Y
-Height
;
2567 e_Draw(ID
, MapOffset
.X
+ xx
, MapOffset
.Y
+ yy
,
2571 e_DrawQuad(MapOffset
.X
+Data
.TargetPoint
.X
-(Width
div 2), MapOffset
.Y
+Data
.TargetPoint
.Y
-Height
,
2572 MapOffset
.X
+Data
.TargetPoint
.X
+(Width
div 2)-1, MapOffset
.Y
+Data
.TargetPoint
.Y
-1,
2580 if Data
.ItemType
<> ITEM_NONE
then
2583 case Data
.ItemType
of
2584 ITEM_MEDKIT_SMALL
: g_GetTexture('ITEM_MEDKIT_SMALL', ID
);
2585 ITEM_MEDKIT_LARGE
: g_GetTexture('ITEM_MEDKIT_LARGE', ID
);
2586 ITEM_MEDKIT_BLACK
: g_GetTexture('ITEM_MEDKIT_BLACK', ID
);
2587 ITEM_ARMOR_GREEN
: g_GetTexture('ITEM_ARMORGREEN', ID
);
2588 ITEM_ARMOR_BLUE
: g_GetTexture('ITEM_ARMORBLUE', ID
);
2589 ITEM_SPHERE_BLUE
: g_GetTexture('ITEM_BLUESPHERE', ID
);
2590 ITEM_SPHERE_WHITE
: g_GetTexture('ITEM_WHITESPHERE', ID
);
2591 ITEM_SUIT
: g_GetTexture('ITEM_SUIT', ID
);
2592 ITEM_OXYGEN
: g_GetTexture('ITEM_OXYGEN', ID
);
2593 ITEM_INVUL
: g_GetTexture('ITEM_INVUL', ID
);
2594 ITEM_WEAPON_SAW
: g_GetTexture('ITEM_WEAPON_SAW', ID
);
2595 ITEM_WEAPON_SHOTGUN1
: g_GetTexture('ITEM_WEAPON_SHOTGUN1', ID
);
2596 ITEM_WEAPON_SHOTGUN2
: g_GetTexture('ITEM_WEAPON_SHOTGUN2', ID
);
2597 ITEM_WEAPON_CHAINGUN
: g_GetTexture('ITEM_WEAPON_CHAINGUN', ID
);
2598 ITEM_WEAPON_ROCKETLAUNCHER
: g_GetTexture('ITEM_WEAPON_ROCKETLAUNCHER', ID
);
2599 ITEM_WEAPON_PLASMA
: g_GetTexture('ITEM_WEAPON_PLASMA', ID
);
2600 ITEM_WEAPON_BFG
: g_GetTexture('ITEM_WEAPON_BFG', ID
);
2601 ITEM_WEAPON_SUPERPULEMET
: g_GetTexture('ITEM_WEAPON_SUPERPULEMET', ID
);
2602 ITEM_AMMO_BULLETS
: g_GetTexture('ITEM_AMMO_BULLETS', ID
);
2603 ITEM_AMMO_BULLETS_BOX
: g_GetTexture('ITEM_AMMO_BULLETS_BOX', ID
);
2604 ITEM_AMMO_SHELLS
: g_GetTexture('ITEM_AMMO_SHELLS', ID
);
2605 ITEM_AMMO_SHELLS_BOX
: g_GetTexture('ITEM_AMMO_SHELLS_BOX', ID
);
2606 ITEM_AMMO_ROCKET
: g_GetTexture('ITEM_AMMO_ROCKET', ID
);
2607 ITEM_AMMO_ROCKET_BOX
: g_GetTexture('ITEM_AMMO_ROCKET_BOX', ID
);
2608 ITEM_AMMO_CELL
: g_GetTexture('ITEM_AMMO_CELL', ID
);
2609 ITEM_AMMO_CELL_BIG
: g_GetTexture('ITEM_AMMO_CELL_BIG', ID
);
2610 ITEM_AMMO_BACKPACK
: g_GetTexture('ITEM_AMMO_BACKPACK', ID
);
2611 ITEM_KEY_RED
: g_GetTexture('ITEM_KEY_RED', ID
);
2612 ITEM_KEY_GREEN
: g_GetTexture('ITEM_KEY_GREEN', ID
);
2613 ITEM_KEY_BLUE
: g_GetTexture('ITEM_KEY_BLUE', ID
);
2614 ITEM_BOTTLE
: g_GetTexture('ITEM_BOTTLE', ID
);
2615 ITEM_HELMET
: g_GetTexture('ITEM_HELMET', ID
);
2616 ITEM_JETPACK
: g_GetTexture('ITEM_JETPACK', ID
);
2617 ITEM_INVIS
: g_GetTexture('ITEM_INVIS', ID
);
2618 ITEM_WEAPON_FLAMETHROWER
: g_GetTexture('ITEM_WEAPON_FLAMETHROWER', ID
);
2619 ITEM_AMMO_FUELCAN
: g_GetTexture('ITEM_AMMO_FUELCAN', ID
);
2621 if ID
<> DWORD(-1) then
2622 e_Draw(ID
, MapOffset
.X
+Data
.ItemPos
.X
-(ItemSize
[Data
.ItemType
][0] div 2),
2623 MapOffset
.Y
+Data
.ItemPos
.Y
-ItemSize
[Data
.ItemType
][1],
2626 e_DrawQuad(MapOffset
.X
+Data
.ItemPos
.X
-(ItemSize
[Data
.ItemType
][0] div 2), MapOffset
.Y
+Data
.ItemPos
.Y
-ItemSize
[Data
.ItemType
][1],
2627 MapOffset
.X
+Data
.ItemPos
.X
+(ItemSize
[Data
.ItemType
][0] div 2)-1, MapOffset
.Y
+Data
.ItemPos
.Y
-1,
2636 // Линия направления и силы ускорения:
2637 xx
:= Round(Cos(-DegToRad(Data
.PushAngle
)) * Data
.PushForce
) + X
+(Width
div 2);
2638 yy
:= Round(Sin(-DegToRad(Data
.PushAngle
)) * Data
.PushForce
) + Y
+(Height
div 2);
2639 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2640 MapOffset
.Y
+Y
+(Height
div 2),
2643 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2648 xx
:= Data
.ShotPos
.X
;
2649 yy
:= Data
.ShotPos
.Y
;
2650 // Точка появления снаряда:
2651 e_DrawPoint(2, MapOffset
.X
+xx
,
2654 // Линия к точке появления снаряда:
2655 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2),
2656 MapOffset
.Y
+Y
+(Height
div 2),
2659 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2660 // Линия направления выстрела:
2661 dx
:= Round(Cos(-DegToRad(Data
.ShotAngle
)) * 24);
2662 dy
:= Round(Sin(-DegToRad(Data
.ShotAngle
)) * 24);
2663 e_DrawLine(1, MapOffset
.X
+xx
,
2667 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerLine
));
2669 if (Data
.ShotPanelID
<> -1) and
2670 (Data
.ShotPanelID
<= High(gPanels
)) then
2672 // Линия к панели индикации выстрела
2673 with gPanels
[Data
.ShotPanelID
] do
2681 e_DrawQuad(MapOffset
.X
+xx
, MapOffset
.Y
+yy
,
2682 MapOffset
.X
+xx
+ww
-1, MapOffset
.Y
+yy
+hh
-1,
2683 255, 255, 255, IfThen(sel
, 0, gAlphaTriggerArea
));
2684 e_DrawLine(1, MapOffset
.X
+X
+(Width
div 2), MapOffset
.Y
+Y
+(Height
div 2),
2685 MapOffset
.X
+xx
, MapOffset
.Y
+yy
,
2686 255, 255, 0, IfThen(sel
, 0, gAlphaTriggerArea
));
2692 // Draw panel contours
2694 if ContourEnabled
[LAYER_BACK
] then
2695 mask
:= mask
or PANEL_BACK
;
2696 if ContourEnabled
[LAYER_WALLS
] then
2697 mask
:= mask
or PANEL_WALL
;
2698 if ContourEnabled
[LAYER_FOREGROUND
] then
2699 mask
:= mask
or PANEL_FORE
;
2700 if ContourEnabled
[LAYER_STEPS
] then
2701 mask
:= mask
or PANEL_STEP
;
2702 if ContourEnabled
[LAYER_WATER
] then
2703 mask
:= mask
or PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
2704 or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or PANEL_BLOCKMON
2705 or PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
;
2708 if ContourEnabled
[LAYER_ITEMS
] and (gItems
<> nil) then
2709 for a
:= 0 to High(gItems
) do
2710 if gItems
[a
].ItemType
<> ITEM_NONE
then
2712 MapOffset
.X
+ gItems
[a
].X
,
2713 MapOffset
.Y
+ gItems
[a
].Y
,
2714 MapOffset
.X
+ gItems
[a
].X
+ ItemSize
[gItems
[a
].ItemType
, 0] - 1,
2715 MapOffset
.Y
+ gItems
[a
].Y
+ ItemSize
[gItems
[a
].ItemType
, 1] - 1,
2718 if ContourEnabled
[LAYER_MONSTERS
] and (gMonsters
<> nil) then
2719 for a
:= 0 to High(gMonsters
) do
2720 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
2722 MapOffset
.X
+ gMonsters
[a
].X
,
2723 MapOffset
.Y
+ gMonsters
[a
].Y
,
2724 MapOffset
.X
+ gMonsters
[a
].X
+ MonsterSize
[gMonsters
[a
].MonsterType
].Width
- 1,
2725 MapOffset
.Y
+ gMonsters
[a
].Y
+ MonsterSize
[gMonsters
[a
].MonsterType
].Height
- 1,
2728 if ContourEnabled
[LAYER_AREAS
] and (gAreas
<> nil) then
2729 for a
:= 0 to High(gAreas
) do
2730 if gAreas
[a
].AreaType
<> AREA_NONE
then
2732 MapOffset
.X
+ gAreas
[a
].X
,
2733 MapOffset
.Y
+ gAreas
[a
].Y
,
2734 MapOffset
.X
+ gAreas
[a
].X
+ AreaSize
[gAreas
[a
].AreaType
].Width
- 1,
2735 MapOffset
.Y
+ gAreas
[a
].Y
+ AreaSize
[gAreas
[a
].AreaType
].Height
- 1,
2738 if ContourEnabled
[LAYER_TRIGGERS
] and (gTriggers
<> nil) then
2739 for a
:= 0 to High(gTriggers
) do
2740 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
2742 MapOffset
.X
+ gTriggers
[a
].X
,
2743 MapOffset
.Y
+ gTriggers
[a
].Y
,
2744 MapOffset
.X
+ gTriggers
[a
].X
+ gTriggers
[a
].Width
- 1,
2745 MapOffset
.Y
+ gTriggers
[a
].Y
+ gTriggers
[a
].Height
- 1,
2750 if PreviewMode
= 0 then
2754 MainForm
.RenderPanel
.Width
,
2756 drEdge
[0], drEdge
[1], drEdge
[2], drEdge
[3], B_NONE
); // Top
2758 gMapInfo
.Height
+ MapOffset
.Y
,
2759 MainForm
.RenderPanel
.Width
,
2760 MainForm
.RenderPanel
.Height
,
2761 drEdge
[0], drEdge
[1], drEdge
[2], drEdge
[3], B_NONE
); // Bottom
2765 gMapInfo
.Height
+ MapOffset
.Y
- 1,
2766 drEdge
[0], drEdge
[1], drEdge
[2], drEdge
[3], B_NONE
); // Left
2767 e_DrawFillQuad(gMapInfo
.Width
+ MapOffset
.X
,
2769 MainForm
.RenderPanel
.Width
,
2770 gMapInfo
.Height
+ MapOffset
.Y
- 1,
2771 drEdge
[0], drEdge
[1], drEdge
[2], drEdge
[3], B_NONE
); // Right
2775 procedure ShiftMapObjects(dx
, dy
: Integer);
2779 if gPanels
<> nil then
2780 for i
:= 0 to High(gPanels
) do
2781 if gPanels
[i
].PanelType
<> 0 then
2783 Inc(gPanels
[i
].X
, dx
);
2784 Inc(gPanels
[i
].Y
, dy
);
2787 if gItems
<> nil then
2788 for i
:= 0 to High(gItems
) do
2789 if gItems
[i
].ItemType
<> 0 then
2791 Inc(gItems
[i
].X
, dx
);
2792 Inc(gItems
[i
].Y
, dy
);
2795 if gAreas
<> nil then
2796 for i
:= 0 to High(gAreas
) do
2797 if gAreas
[i
].AreaType
<> 0 then
2799 Inc(gAreas
[i
].X
, dx
);
2800 Inc(gAreas
[i
].Y
, dy
);
2803 if gMonsters
<> nil then
2804 for i
:= 0 to High(gMonsters
) do
2805 if gMonsters
[i
].MonsterType
<> 0 then
2807 Inc(gMonsters
[i
].X
, dx
);
2808 Inc(gMonsters
[i
].Y
, dy
);
2811 if gTriggers
<> nil then
2812 for i
:= 0 to High(gTriggers
) do
2813 if gTriggers
[i
].TriggerType
<> 0 then
2815 Inc(gTriggers
[i
].X
, dx
);
2816 Inc(gTriggers
[i
].Y
, dy
);
2818 case gTriggers
[i
].TriggerType
of
2821 Inc(gTriggers
[i
].Data
.TargetPoint
.X
, dx
);
2822 Inc(gTriggers
[i
].Data
.TargetPoint
.Y
, dy
);
2825 TRIGGER_PRESS
, TRIGGER_ON
,
2826 TRIGGER_OFF
, TRIGGER_ONOFF
:
2828 Inc(gTriggers
[i
].Data
.tX
, dx
);
2829 Inc(gTriggers
[i
].Data
.tY
, dy
);
2832 TRIGGER_SPAWNMONSTER
:
2834 Inc(gTriggers
[i
].Data
.MonPos
.X
, dx
);
2835 Inc(gTriggers
[i
].Data
.MonPos
.Y
, dy
);
2840 Inc(gTriggers
[i
].Data
.ItemPos
.X
, dx
);
2841 Inc(gTriggers
[i
].Data
.ItemPos
.Y
, dy
);
2846 Inc(gTriggers
[i
].Data
.ShotPos
.X
, dx
);
2847 Inc(gTriggers
[i
].Data
.ShotPos
.Y
, dy
);
2853 procedure LoadData();
2855 g_CreateTextureWAD('PREVIEW', EditorWad
+ ':TEXTURES\CHECKERS');
2856 g_CreateTextureWAD('NOTEXTURE', GameWad
+ ':TEXTURES\NOTEXTURE');
2858 g_CreateTextureWADSize('AREA_REDFLAG', GameWad
+ ':TEXTURES\FLAGRED', 0, 0, 64, 64);
2859 g_CreateTextureWADSize('AREA_BLUEFLAG', GameWad
+ ':TEXTURES\FLAGBLUE', 0, 0, 64, 64);
2860 g_CreateTextureWADSize('AREA_DOMFLAG', GameWad
+ ':TEXTURES\FLAGDOM', 0, 0, 64, 64);
2862 g_CreateTextureWADSize('MONSTER_DEMON', GameWad
+ ':MTEXTURES\DEMON_SLEEP', 0, 0, 64, 64);
2863 g_CreateTextureWADSize('MONSTER_IMP', GameWad
+ ':MTEXTURES\IMP_SLEEP', 0, 0, 64, 64);
2864 g_CreateTextureWADSize('MONSTER_ZOMBY', GameWad
+ ':MTEXTURES\ZOMBY_SLEEP', 0, 0, 64, 64);
2865 g_CreateTextureWADSize('MONSTER_SERG', GameWad
+ ':MTEXTURES\SERG_SLEEP', 0, 0, 64, 64);
2866 g_CreateTextureWADSize('MONSTER_CYBER', GameWad
+ ':MTEXTURES\CYBER_SLEEP', 0, 0, 128, 128);
2867 g_CreateTextureWADSize('MONSTER_CGUN', GameWad
+ ':MTEXTURES\CGUN_SLEEP', 0, 0, 64, 64);
2868 g_CreateTextureWADSize('MONSTER_BARON', GameWad
+ ':MTEXTURES\BARON_SLEEP', 0, 0, 128, 128);
2869 g_CreateTextureWADSize('MONSTER_KNIGHT', GameWad
+ ':MTEXTURES\KNIGHT_SLEEP', 0, 0, 128, 128);
2870 g_CreateTextureWADSize('MONSTER_CACO', GameWad
+ ':MTEXTURES\CACO_SLEEP', 0, 0, 128, 128);
2871 g_CreateTextureWADSize('MONSTER_SOUL', GameWad
+ ':MTEXTURES\SOUL_SLEEP', 0, 0, 64, 64);
2872 g_CreateTextureWADSize('MONSTER_PAIN', GameWad
+ ':MTEXTURES\PAIN_SLEEP', 0, 0, 128, 128);
2873 g_CreateTextureWADSize('MONSTER_SPIDER', GameWad
+ ':MTEXTURES\SPIDER_SLEEP', 0, 0, 256, 128);
2874 g_CreateTextureWADSize('MONSTER_BSP', GameWad
+ ':MTEXTURES\BSP_SLEEP', 0, 0, 128, 64);
2875 g_CreateTextureWADSize('MONSTER_MANCUB', GameWad
+ ':MTEXTURES\MANCUB_SLEEP', 0, 0, 128, 128);
2876 g_CreateTextureWADSize('MONSTER_SKEL', GameWad
+ ':MTEXTURES\SKEL_SLEEP', 0, 0, 128, 128);
2877 g_CreateTextureWADSize('MONSTER_VILE', GameWad
+ ':MTEXTURES\VILE_SLEEP', 0, 0, 128, 128);
2878 g_CreateTextureWADSize('MONSTER_FISH', GameWad
+ ':MTEXTURES\FISH_SLEEP', 0, 0, 32, 32);
2879 g_CreateTextureWADSize('MONSTER_BARREL', GameWad
+ ':MTEXTURES\BARREL_SLEEP', 0, 0, 64, 64);
2880 g_CreateTextureWADSize('MONSTER_ROBO', GameWad
+ ':MTEXTURES\ROBO_SLEEP', 0, 0, 128, 128);
2881 g_CreateTextureWADSize('MONSTER_MAN', GameWad
+ ':MTEXTURES\MAN_SLEEP', 0, 0, 64, 64);
2883 g_CreateTextureWADSize('ITEM_BLUESPHERE', GameWad
+ ':TEXTURES\SBLUE', 0, 0, 32, 32);
2884 g_CreateTextureWADSize('ITEM_WHITESPHERE', GameWad
+ ':TEXTURES\SWHITE', 0, 0, 32, 32);
2885 g_CreateTextureWADSize('ITEM_ARMORGREEN', GameWad
+ ':TEXTURES\ARMORGREEN', 0, 0, 32, 16);
2886 g_CreateTextureWADSize('ITEM_ARMORBLUE', GameWad
+ ':TEXTURES\ARMORBLUE', 0, 0, 32, 16);
2887 g_CreateTextureWADSize('ITEM_INVUL', GameWad
+ ':TEXTURES\INVUL', 0, 0, 32, 32);
2888 g_CreateTextureWADSize('ITEM_BOTTLE', GameWad
+ ':TEXTURES\BOTTLE', 0, 0, 16, 32);
2889 g_CreateTextureWADSize('ITEM_HELMET', GameWad
+ ':TEXTURES\HELMET', 0, 0, 16, 16);
2890 g_CreateTextureWADSize('ITEM_JETPACK', GameWad
+ ':TEXTURES\JETPACK', 0, 0, 32, 32);
2891 g_CreateTextureWADSize('ITEM_INVIS', GameWad
+ ':TEXTURES\INVIS', 0, 0, 32, 32);
2892 g_CreateTextureWADSize('ITEM_WEAPON_FLAMETHROWER', GameWad
+ ':TEXTURES\FLAMETHROWER', 0, 0, 64, 32);
2893 g_CreateTextureWADSize('ITEM_AMMO_FUELCAN', GameWad
+ ':TEXTURES\FUELCAN', 0, 0, 16, 32);
2895 g_CreateTextureWAD('ITEM_MEDKIT_SMALL', GameWad
+ ':TEXTURES\MED1');
2896 g_CreateTextureWAD('ITEM_MEDKIT_LARGE', GameWad
+ ':TEXTURES\MED2');
2897 g_CreateTextureWAD('ITEM_WEAPON_SAW', GameWad
+ ':TEXTURES\SAW');
2898 g_CreateTextureWAD('ITEM_WEAPON_PISTOL', GameWad
+ ':TEXTURES\PISTOL');
2899 g_CreateTextureWAD('ITEM_WEAPON_KASTET', GameWad
+ ':TEXTURES\KASTET');
2900 g_CreateTextureWAD('ITEM_WEAPON_SHOTGUN1', GameWad
+ ':TEXTURES\SHOTGUN1');
2901 g_CreateTextureWAD('ITEM_WEAPON_SHOTGUN2', GameWad
+ ':TEXTURES\SHOTGUN2');
2902 g_CreateTextureWAD('ITEM_WEAPON_CHAINGUN', GameWad
+ ':TEXTURES\MGUN');
2903 g_CreateTextureWAD('ITEM_WEAPON_ROCKETLAUNCHER', GameWad
+ ':TEXTURES\RLAUNCHER');
2904 g_CreateTextureWAD('ITEM_WEAPON_PLASMA', GameWad
+ ':TEXTURES\PGUN');
2905 g_CreateTextureWAD('ITEM_WEAPON_BFG', GameWad
+ ':TEXTURES\BFG');
2906 g_CreateTextureWAD('ITEM_WEAPON_SUPERPULEMET', GameWad
+ ':TEXTURES\SPULEMET');
2907 g_CreateTextureWAD('ITEM_AMMO_BULLETS', GameWad
+ ':TEXTURES\CLIP');
2908 g_CreateTextureWAD('ITEM_AMMO_BULLETS_BOX', GameWad
+ ':TEXTURES\AMMO');
2909 g_CreateTextureWAD('ITEM_AMMO_SHELLS', GameWad
+ ':TEXTURES\SHELL1');
2910 g_CreateTextureWAD('ITEM_AMMO_SHELLS_BOX', GameWad
+ ':TEXTURES\SHELL2');
2911 g_CreateTextureWAD('ITEM_AMMO_ROCKET', GameWad
+ ':TEXTURES\ROCKET');
2912 g_CreateTextureWAD('ITEM_AMMO_ROCKET_BOX', GameWad
+ ':TEXTURES\ROCKETS');
2913 g_CreateTextureWAD('ITEM_AMMO_CELL', GameWad
+ ':TEXTURES\CELL');
2914 g_CreateTextureWAD('ITEM_AMMO_CELL_BIG', GameWad
+ ':TEXTURES\CELL2');
2915 g_CreateTextureWAD('ITEM_AMMO_BACKPACK', GameWad
+ ':TEXTURES\BPACK');
2916 g_CreateTextureWAD('ITEM_KEY_RED', GameWad
+ ':TEXTURES\KEYR');
2917 g_CreateTextureWAD('ITEM_KEY_GREEN', GameWad
+ ':TEXTURES\KEYG');
2918 g_CreateTextureWAD('ITEM_KEY_BLUE', GameWad
+ ':TEXTURES\KEYB');
2919 g_CreateTextureWAD('ITEM_OXYGEN', GameWad
+ ':TEXTURES\OXYGEN');
2920 g_CreateTextureWAD('ITEM_SUIT', GameWad
+ ':TEXTURES\SUIT');
2921 g_CreateTextureWAD('ITEM_MEDKIT_BLACK', GameWad
+ ':TEXTURES\BMED');
2923 g_CreateTextureWAD('AREA_PLAYERPOINT1', EditorWad
+ ':TEXTURES\P1POINT');
2924 g_CreateTextureWAD('AREA_PLAYERPOINT2', EditorWad
+ ':TEXTURES\P2POINT');
2925 g_CreateTextureWAD('AREA_DMPOINT', EditorWad
+ ':TEXTURES\DMPOINT');
2926 g_CreateTextureWAD('AREA_REDPOINT', EditorWad
+ ':TEXTURES\REDPOINT');
2927 g_CreateTextureWAD('AREA_BLUEPOINT', EditorWad
+ ':TEXTURES\BLUEPOINT');
2930 procedure FreeData();
2932 g_DeleteTexture('NOTEXTURE');
2934 g_DeleteTexture('ITEM_BLUESPHERE');
2935 g_DeleteTexture('ITEM_WHITESPHERE');
2936 g_DeleteTexture('ITEM_ARMORGREEN');
2937 g_DeleteTexture('ITEM_ARMORBLUE');
2938 g_DeleteTexture('ITEM_INVUL');
2939 g_DeleteTexture('ITEM_BOTTLE');
2940 g_DeleteTexture('ITEM_HELMET');
2941 g_DeleteTexture('AREA_REDFLAG');
2942 g_DeleteTexture('AREA_BLUEFLAG');
2943 g_DeleteTexture('AREA_DOMFLAG');
2945 g_DeleteTexture('MONSTER_DEMON');
2946 g_DeleteTexture('MONSTER_IMP');
2947 g_DeleteTexture('MONSTER_ZOMBY');
2948 g_DeleteTexture('MONSTER_SERG');
2949 g_DeleteTexture('MONSTER_CGUN');
2950 g_DeleteTexture('MONSTER_BARREL');
2951 g_DeleteTexture('MONSTER_MAN');
2953 g_DeleteTexture('MONSTER_DEMON');
2954 g_DeleteTexture('MONSTER_IMP');
2955 g_DeleteTexture('MONSTER_ZOMBY');
2956 g_DeleteTexture('MONSTER_SERG');
2957 g_DeleteTexture('MONSTER_CYBER');
2958 g_DeleteTexture('MONSTER_CGUN');
2959 g_DeleteTexture('MONSTER_BARON');
2960 g_DeleteTexture('MONSTER_KNIGHT');
2961 g_DeleteTexture('MONSTER_CACO');
2962 g_DeleteTexture('MONSTER_SOUL');
2963 g_DeleteTexture('MONSTER_PAIN');
2964 g_DeleteTexture('MONSTER_SPIDER');
2965 g_DeleteTexture('MONSTER_BSP');
2966 g_DeleteTexture('MONSTER_MANCUB');
2967 g_DeleteTexture('MONSTER_SKEL');
2968 g_DeleteTexture('MONSTER_VILE');
2969 g_DeleteTexture('MONSTER_FISH');
2970 g_DeleteTexture('MONSTER_BARREL');
2971 g_DeleteTexture('MONSTER_ROBO');
2972 g_DeleteTexture('MONSTER_MAN');
2974 g_DeleteTexture('ITEM_MEDKIT_SMALL');
2975 g_DeleteTexture('ITEM_MEDKIT_LARGE');
2976 g_DeleteTexture('ITEM_WEAPON_SAW');
2977 g_DeleteTexture('ITEM_WEAPON_PISTOL');
2978 g_DeleteTexture('ITEM_WEAPON_KASTET');
2979 g_DeleteTexture('ITEM_WEAPON_SHOTGUN1');
2980 g_DeleteTexture('ITEM_WEAPON_SHOTGUN2');
2981 g_DeleteTexture('ITEM_WEAPON_CHAINGUN');
2982 g_DeleteTexture('ITEM_WEAPON_ROCKETLAUNCHER');
2983 g_DeleteTexture('ITEM_WEAPON_PLASMA');
2984 g_DeleteTexture('ITEM_WEAPON_BFG');
2985 g_DeleteTexture('ITEM_WEAPON_SUPERPULEMET');
2986 g_DeleteTexture('ITEM_AMMO_BULLETS');
2987 g_DeleteTexture('ITEM_AMMO_BULLETS_BOX');
2988 g_DeleteTexture('ITEM_AMMO_SHELLS');
2989 g_DeleteTexture('ITEM_AMMO_SHELLS_BOX');
2990 g_DeleteTexture('ITEM_AMMO_ROCKET');
2991 g_DeleteTexture('ITEM_AMMO_ROCKET_BOX');
2992 g_DeleteTexture('ITEM_AMMO_CELL');
2993 g_DeleteTexture('ITEM_AMMO_CELL_BIG');
2994 g_DeleteTexture('ITEM_AMMO_BACKPACK');
2995 g_DeleteTexture('ITEM_KEY_RED');
2996 g_DeleteTexture('ITEM_KEY_GREEN');
2997 g_DeleteTexture('ITEM_KEY_BLUE');
2998 g_DeleteTexture('ITEM_OXYGEN');
2999 g_DeleteTexture('ITEM_SUIT');
3000 g_DeleteTexture('ITEM_MEDKIT_BLACK');
3001 g_DeleteTexture('ITEM_JETPACK');
3002 g_DeleteTexture('ITEM_INVIS');
3003 g_DeleteTexture('ITEM_WEAPON_FLAMETHROWER');
3004 g_DeleteTexture('ITEM_AMMO_FUELCAN');
3006 g_DeleteTexture('AREA_PLAYERPOINT1');
3007 g_DeleteTexture('AREA_PLAYERPOINT2');
3008 g_DeleteTexture('AREA_DMPOINT');
3009 g_DeleteTexture('AREA_REDPOINT');
3010 g_DeleteTexture('AREA_BLUEPOINT');