1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 MAPSTRUCT
, e_graphics
, MAPDEF
, g_basic
, g_sound
,
39 TexturePanel
: Integer;
40 TexturePanelType
: Word;
44 Activators
: array of TActivator
;
45 PlayerCollide
: Boolean;
49 SoundPlayCount
: Integer;
50 Sound
: TPlayableSound
;
52 SpawnCooldown
: Integer;
53 SpawnedCount
: Integer;
55 ShotPanelTime
: Integer;
56 ShotSightTime
: Integer;
57 ShotSightTimeout
: Integer;
58 ShotSightTarget
: Word;
59 ShotSightTargetN
: Word;
61 ShotReloadTime
: Integer;
66 function g_Triggers_Create(Trigger
: TTrigger
): DWORD
;
67 procedure g_Triggers_Update();
68 procedure g_Triggers_Press(ID
: DWORD
; ActivateType
: Byte; ActivateUID
: Word = 0);
69 function g_Triggers_PressR(X
, Y
: Integer; Width
, Height
: Word; UID
: Word;
70 ActivateType
: Byte; IgnoreList
: DWArray
= nil): DWArray
;
71 procedure g_Triggers_PressL(X1
, Y1
, X2
, Y2
: Integer; UID
: DWORD
; ActivateType
: Byte);
72 procedure g_Triggers_PressC(CX
, CY
: Integer; Radius
: Word; UID
: Word; ActivateType
: Byte; IgnoreTrigger
: Integer = -1);
73 procedure g_Triggers_OpenAll();
74 procedure g_Triggers_DecreaseSpawner(ID
: DWORD
);
75 procedure g_Triggers_Free();
76 procedure g_Triggers_SaveState(var Mem
: TBinMemoryWriter
);
77 procedure g_Triggers_LoadState(var Mem
: TBinMemoryReader
);
79 function tr_Message(MKind
: Integer; MText
: string; MSendTo
: Integer; MTime
: Integer; ActivateUID
: Integer): Boolean;
81 function tr_CloseDoor(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
82 function tr_OpenDoor(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
83 procedure tr_CloseTrap(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean);
84 function tr_SetLift(PanelID
: Integer; d
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
86 function tr_Teleport(ActivateUID
: Integer; TX
, TY
: Integer; TDir
: Integer; Silent
: Boolean; D2D
: Boolean): Boolean;
87 function tr_Push(ActivateUID
: Integer; VX
, VY
: Integer; ResetVel
: Boolean): Boolean;
89 procedure tr_MakeEffect(X
, Y
, VX
, VY
: Integer; T
, ST
, CR
, CG
, CB
: Byte; Silent
, Send
: Boolean);
90 function tr_SpawnShot(ShotType
: Integer; wx
, wy
, dx
, dy
: Integer; ShotSound
: Boolean; ShotTarget
: Word): Integer;
93 gTriggerClientID
: Integer = 0;
94 gTriggers
: array of TTrigger
;
95 gSecretsCount
: Integer = 0;
96 gMonstersSpawned
: array of LongInt = nil;
101 g_player
, g_map
, Math
, g_gfx
, g_game
, g_textures
,
102 g_console
, g_monsters
, g_items
, g_phys
, g_weapons
,
103 wadreader
, g_main
, SysUtils
, e_log
, g_language
,
104 g_options
, g_net
, g_netmsg
, g_scripts
;
107 TRIGGER_SIGNATURE
= $52475254; // 'TRGR'
110 function FindTrigger(): DWORD
;
114 if gTriggers
<> nil then
115 for i
:= 0 to High(gTriggers
) do
116 if gTriggers
[i
].TriggerType
= TRIGGER_NONE
then
122 if gTriggers
= nil then
124 SetLength(gTriggers
, 8);
129 Result
:= High(gTriggers
) + 1;
130 SetLength(gTriggers
, Length(gTriggers
) + 8);
134 function tr_CloseDoor(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
140 if PanelID
= -1 then Exit
;
144 with gWalls
[PanelID
] do
146 if g_CollidePlayer(X
, Y
, Width
, Height
) or
147 g_CollideMonster(X
, Y
, Width
, Height
) then Exit
;
153 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
154 if g_Game_IsServer
and g_Game_IsNet
then
155 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
157 g_Map_EnableWall(PanelID
);
164 if gDoorMap
= nil then Exit
;
167 for a
:= 0 to High(gDoorMap
) do
169 for b
:= 0 to High(gDoorMap
[a
]) do
170 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
176 if c
<> -1 then Break
;
180 for b
:= 0 to High(gDoorMap
[c
]) do
181 with gWalls
[gDoorMap
[c
, b
]] do
183 if g_CollidePlayer(X
, Y
, Width
, Height
) or
184 g_CollideMonster(X
, Y
, Width
, Height
) then Exit
;
188 for b
:= 0 to High(gDoorMap
[c
]) do
189 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
191 with gWalls
[PanelID
] do
193 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
194 if g_Game_IsServer
and g_Game_IsNet
then
195 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
200 for b
:= 0 to High(gDoorMap
[c
]) do
201 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
203 g_Map_EnableWall(gDoorMap
[c
, b
]);
209 procedure tr_CloseTrap(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean);
213 if PanelID
= -1 then Exit
;
217 with gWalls
[PanelID
] do
218 if (not NoSound
) and (not Enabled
) then
220 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
221 if g_Game_IsServer
and g_Game_IsNet
then
222 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
225 with gWalls
[PanelID
] do
227 if gPlayers
<> nil then
228 for a
:= 0 to High(gPlayers
) do
229 if (gPlayers
[a
] <> nil) and gPlayers
[a
].Live
and
230 gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
231 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
233 if gMonsters
<> nil then
234 for a
:= 0 to High(gMonsters
) do
235 if (gMonsters
[a
] <> nil) and gMonsters
[a
].Live
and
236 g_Obj_Collide(X
, Y
, Width
, Height
, @gMonsters
[a
].Obj
) then
237 gMonsters
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
239 if not Enabled
then g_Map_EnableWall(PanelID
);
244 if gDoorMap
= nil then Exit
;
247 for a
:= 0 to High(gDoorMap
) do
249 for b
:= 0 to High(gDoorMap
[a
]) do
250 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
256 if c
<> -1 then Break
;
261 for b
:= 0 to High(gDoorMap
[c
]) do
262 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
264 with gWalls
[PanelID
] do
266 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
267 if g_Game_IsServer
and g_Game_IsNet
then
268 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
273 for b
:= 0 to High(gDoorMap
[c
]) do
274 with gWalls
[gDoorMap
[c
, b
]] do
276 if gPlayers
<> nil then
277 for a
:= 0 to High(gPlayers
) do
278 if (gPlayers
[a
] <> nil) and gPlayers
[a
].Live
and
279 gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
280 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
282 if gMonsters
<> nil then
283 for a
:= 0 to High(gMonsters
) do
284 if (gMonsters
[a
] <> nil) and gMonsters
[a
].Live
and
285 g_Obj_Collide(X
, Y
, Width
, Height
, @gMonsters
[a
].Obj
) then
286 gMonsters
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
288 if not Enabled
then g_Map_EnableWall(gDoorMap
[c
, b
]);
293 function tr_OpenDoor(PanelID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
299 if PanelID
= -1 then Exit
;
303 with gWalls
[PanelID
] do
308 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
309 if g_Game_IsServer
and g_Game_IsNet
then
310 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
312 g_Map_DisableWall(PanelID
);
318 if gDoorMap
= nil then Exit
;
321 for a
:= 0 to High(gDoorMap
) do
323 for b
:= 0 to High(gDoorMap
[a
]) do
324 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
330 if c
<> -1 then Break
;
335 for b
:= 0 to High(gDoorMap
[c
]) do
336 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
338 with gWalls
[PanelID
] do
340 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
341 if g_Game_IsServer
and g_Game_IsNet
then
342 MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
347 for b
:= 0 to High(gDoorMap
[c
]) do
348 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
350 g_Map_DisableWall(gDoorMap
[c
, b
]);
356 function tr_SetLift(PanelID
: Integer; d
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
363 if PanelID
= -1 then Exit
;
365 if (gLifts
[PanelID
].PanelType
= PANEL_LIFTUP
) or
366 (gLifts
[PanelID
].PanelType
= PANEL_LIFTDOWN
) then
370 else t
:= IfThen(gLifts
[PanelID
].LiftType
= 1, 0, 1);
372 else if (gLifts
[PanelID
].PanelType
= PANEL_LIFTLEFT
) or
373 (gLifts
[PanelID
].PanelType
= PANEL_LIFTRIGHT
) then
377 else t
:= IfThen(gLifts
[PanelID
].LiftType
= 2, 3, 2);
382 with gLifts
[PanelID
] do
383 if LiftType
<> t
then
385 g_Map_SetLift(PanelID
, t
);
388 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);}
394 if gLiftMap
= nil then Exit
;
397 for a
:= 0 to High(gLiftMap
) do
399 for b
:= 0 to High(gLiftMap
[a
]) do
400 if gLiftMap
[a
, b
] = DWORD(PanelID
) then
406 if c
<> -1 then Break
;
411 for b := 0 to High(gLiftMap[c]) do
412 if gLifts[gLiftMap[c, b]].LiftType <> t then
414 with gLifts[PanelID] do
415 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
419 for b
:= 0 to High(gLiftMap
[c
]) do
420 with gLifts
[gLiftMap
[c
, b
]] do
421 if LiftType
<> t
then
423 g_Map_SetLift(gLiftMap
[c
, b
], t
);
430 function tr_SpawnShot(ShotType
: Integer; wx
, wy
, dx
, dy
: Integer; ShotSound
: Boolean; ShotTarget
: Word): Integer;
438 TextureID
:= DWORD(-1);
439 snd
:= 'SOUND_WEAPON_FIREROCKET';
444 g_Weapon_pistol(wx
, wy
, dx
, dy
, 0, True);
445 snd
:= 'SOUND_WEAPON_FIREPISTOL';
449 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
451 MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
457 g_Weapon_mgun(wx
, wy
, dx
, dy
, 0, True);
458 if gSoundEffectsDF
then snd
:= 'SOUND_WEAPON_FIRECGUN'
459 else snd
:= 'SOUND_WEAPON_FIREPISTOL';
463 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
465 MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
469 TRIGGER_SHOT_SHOTGUN
:
471 g_Weapon_Shotgun(wx
, wy
, dx
, dy
, 0, True);
472 snd
:= 'SOUND_WEAPON_FIRESHOTGUN';
476 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
478 MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL2
);
484 g_Weapon_DShotgun(wx
, wy
, dx
, dy
, 0, True);
485 snd
:= 'SOUND_WEAPON_FIRESHOTGUN2';
489 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
490 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
492 MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL3
);
498 g_Weapon_ball1(wx
, wy
, dx
, dy
, 0, -1, True);
499 snd
:= 'SOUND_WEAPON_FIREBALL';
504 g_Weapon_Plasma(wx
, wy
, dx
, dy
, 0, -1, True);
505 snd
:= 'SOUND_WEAPON_FIREPLASMA';
510 g_Weapon_aplasma(wx
, wy
, dx
, dy
, 0, -1, True);
511 snd
:= 'SOUND_WEAPON_FIREPLASMA';
516 g_Weapon_ball2(wx
, wy
, dx
, dy
, 0, -1, True);
517 snd
:= 'SOUND_WEAPON_FIREBALL';
522 g_Weapon_ball7(wx
, wy
, dx
, dy
, 0, -1, True);
523 snd
:= 'SOUND_WEAPON_FIREBALL';
528 g_Weapon_manfire(wx
, wy
, dx
, dy
, 0, -1, True);
529 snd
:= 'SOUND_WEAPON_FIREBALL';
534 g_Weapon_revf(wx
, wy
, dx
, dy
, 0, ShotTarget
, -1, True);
535 snd
:= 'SOUND_WEAPON_FIREREV';
540 g_Weapon_Rocket(wx
, wy
, dx
, dy
, 0, -1, True);
541 snd
:= 'SOUND_WEAPON_FIREROCKET';
546 g_Weapon_BFGShot(wx
, wy
, dx
, dy
, 0, -1, True);
547 snd
:= 'SOUND_WEAPON_FIREBFG';
552 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_ROCKET') then
554 Anim
:= TAnimation
.Create(TextureID
, False, 6);
555 Anim
.Blending
:= False;
556 g_GFX_OnceAnim(wx
-64, wy
-64, Anim
);
560 g_Weapon_Explode(wx
, wy
, 60, 0);
561 snd
:= 'SOUND_WEAPON_EXPLODEROCKET';
564 TRIGGER_SHOT_BFGEXPL
:
566 if g_Frames_Get(TextureID
, 'FRAMES_EXPLODE_BFG') then
568 Anim
:= TAnimation
.Create(TextureID
, False, 6);
569 Anim
.Blending
:= False;
570 g_GFX_OnceAnim(wx
-64, wy
-64, Anim
);
574 g_Weapon_BFG9000(wx
, wy
, 0);
575 snd
:= 'SOUND_WEAPON_EXPLODEBFG';
581 if g_Game_IsNet
and g_Game_IsServer
then
584 MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_EXPLODE
);
585 TRIGGER_SHOT_BFGEXPL
:
586 MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_BFGEXPL
);
590 MH_SEND_CreateShot(LastShotID
);
592 MH_SEND_Sound(wx
, wy
, snd
);
597 g_Sound_PlayExAt(snd
, wx
, wy
);
600 Result
:= LastShotID
;
603 procedure MakeShot(var Trigger
: TTrigger
; wx
, wy
, dx
, dy
: Integer; TargetUID
: Word);
606 if (Data
.ShotAmmo
= 0) or
607 ((Data
.ShotAmmo
> 0) and (ShotAmmoCount
> 0)) then
609 if (Data
.ShotPanelID
<> -1) and (ShotPanelTime
= 0) then
611 g_Map_SwitchTexture(ShotPanelType
, Data
.ShotPanelID
);
612 ShotPanelTime
:= 4; // òèêîâ íà âñïûøêó âûñòðåëà
615 if Data
.ShotIntSight
> 0 then
616 ShotSightTimeout
:= 180; // ~= 5 ñåêóíä
618 if ShotAmmoCount
> 0 then Dec(ShotAmmoCount
);
620 dx
:= dx
+ Random(Data
.ShotAccuracy
) - Random(Data
.ShotAccuracy
);
621 dy
:= dy
+ Random(Data
.ShotAccuracy
) - Random(Data
.ShotAccuracy
);
623 tr_SpawnShot(Data
.ShotType
, wx
, wy
, dx
, dy
, Data
.ShotSound
, TargetUID
);
626 if (Data
.ShotIntReload
> 0) and (ShotReloadTime
= 0) then
627 ShotReloadTime
:= Data
.ShotIntReload
; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
630 procedure tr_MakeEffect(X
, Y
, VX
, VY
: Integer; T
, ST
, CR
, CG
, CB
: Byte; Silent
, Send
: Boolean);
635 if T
= TRIGGER_EFFECT_PARTICLE
then
637 TRIGGER_EFFECT_SLIQUID
:
639 if (CR
= 255) and (CG
= 0) and (CB
= 0) then
640 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 1, 0, 0, 0)
641 else if (CR
= 0) and (CG
= 255) and (CB
= 0) then
642 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 2, 0, 0, 0)
643 else if (CR
= 0) and (CG
= 0) and (CB
= 255) then
644 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 3, 0, 0, 0)
646 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 0, 0, 0, 0);
648 TRIGGER_EFFECT_LLIQUID
:
649 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 4, CR
, CG
, CB
);
650 TRIGGER_EFFECT_DLIQUID
:
651 g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 5, CR
, CG
, CB
);
652 TRIGGER_EFFECT_BLOOD
:
653 g_GFX_Blood(X
, Y
, 1, VX
, VY
, 0, 0, CR
, CG
, CB
);
654 TRIGGER_EFFECT_SPARK
:
655 g_GFX_Spark(X
, Y
, 1, GetAngle2(VX
, VY
), 0, 0);
656 TRIGGER_EFFECT_BUBBLE
:
657 g_GFX_Bubbles(X
, Y
, 1, 0, 0);
659 if T
= TRIGGER_EFFECT_ANIMATION
then
661 EFFECT_TELEPORT
: begin
662 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
664 Anim
:= TAnimation
.Create(FramesID
, False, 3);
666 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X
, Y
);
667 g_GFX_OnceAnim(X
-32, Y
-32, Anim
);
670 if Send
and g_Game_IsServer
and g_Game_IsNet
then
671 MH_SEND_Effect(X
, Y
, Byte(not Silent
), NET_GFX_TELE
);
673 EFFECT_RESPAWN
: begin
674 if g_Frames_Get(FramesID
, 'FRAMES_ITEM_RESPAWN') then
676 Anim
:= TAnimation
.Create(FramesID
, False, 4);
678 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X
, Y
);
679 g_GFX_OnceAnim(X
-16, Y
-16, Anim
);
682 if Send
and g_Game_IsServer
and g_Game_IsNet
then
683 MH_SEND_Effect(X
-16, Y
-16, Byte(not Silent
), NET_GFX_RESPAWN
);
686 if g_Frames_Get(FramesID
, 'FRAMES_FIRE') then
688 Anim
:= TAnimation
.Create(FramesID
, False, 4);
690 g_Sound_PlayExAt('SOUND_FIRE', X
, Y
);
691 g_GFX_OnceAnim(X
-32, Y
-128, Anim
);
694 if Send
and g_Game_IsServer
and g_Game_IsNet
then
695 MH_SEND_Effect(X
-32, Y
-128, Byte(not Silent
), NET_GFX_FIRE
);
700 function tr_Teleport(ActivateUID
: Integer; TX
, TY
: Integer; TDir
: Integer; Silent
: Boolean; D2D
: Boolean): Boolean;
706 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
707 case g_GetUIDType(ActivateUID
) of
710 p
:= g_Player_Get(ActivateUID
);
716 if p
.TeleportTo(TX
-(p
.Obj
.Rect
.Width
div 2),
717 TY
-p
.Obj
.Rect
.Height
,
723 if p
.TeleportTo(TX
, TY
, Silent
, TDir
) then
729 m
:= g_Monsters_Get(ActivateUID
);
735 if m
.TeleportTo(TX
-(m
.Obj
.Rect
.Width
div 2),
736 TY
-m
.Obj
.Rect
.Height
,
742 if m
.TeleportTo(TX
, TY
, Silent
, TDir
) then
748 function tr_Push(ActivateUID
: Integer; VX
, VY
: Integer; ResetVel
: Boolean): Boolean;
754 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
755 case g_GetUIDType(ActivateUID
) of
758 p
:= g_Player_Get(ActivateUID
);
775 m
:= g_Monsters_Get(ActivateUID
);
792 function tr_Message(MKind
: Integer; MText
: string; MSendTo
: Integer; MTime
: Integer; ActivateUID
: Integer): Boolean;
799 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
800 msg
:= b_Text_Format(MText
);
804 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
806 if g_Game_IsWatchedPlayer(ActivateUID
) then
809 g_Console_Add(msg
, True)
810 else if MKind
= 1 then
811 g_Game_Message(msg
, MTime
);
815 p
:= g_Player_Get(ActivateUID
);
816 if g_Game_IsNet
and (p
.FClientID
>= 0) then
818 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, p
.FClientID
)
819 else if MKind
= 1 then
820 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, p
.FClientID
);
825 1: // activator's team
827 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
829 p
:= g_Player_Get(ActivateUID
);
830 if g_Game_IsWatchedTeam(p
.Team
) then
832 g_Console_Add(msg
, True)
833 else if MKind
= 1 then
834 g_Game_Message(msg
, MTime
);
838 for i
:= Low(gPlayers
) to High(gPlayers
) do
839 if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
841 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
842 else if MKind
= 1 then
843 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
848 2: // activator's enemy team
850 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
852 p
:= g_Player_Get(ActivateUID
);
853 if g_Game_IsWatchedTeam(p
.Team
) then
855 g_Console_Add(msg
, True)
856 else if MKind
= 1 then
857 g_Game_Message(msg
, MTime
);
861 for i
:= Low(gPlayers
) to High(gPlayers
) do
862 if (gPlayers
[i
].Team
<> p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
864 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
865 else if MKind
= 1 then
866 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
873 if g_Game_IsWatchedTeam(TEAM_RED
) then
875 g_Console_Add(msg
, True)
876 else if MKind
= 1 then
877 g_Game_Message(msg
, MTime
);
881 for i
:= Low(gPlayers
) to High(gPlayers
) do
882 if (gPlayers
[i
].Team
= TEAM_RED
) and (gPlayers
[i
].FClientID
>= 0) then
884 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
885 else if MKind
= 1 then
886 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
892 if g_Game_IsWatchedTeam(TEAM_BLUE
) then
894 g_Console_Add(msg
, True)
895 else if MKind
= 1 then
896 g_Game_Message(msg
, MTime
);
900 for i
:= Low(gPlayers
) to High(gPlayers
) do
901 if (gPlayers
[i
].Team
= TEAM_BLUE
) and (gPlayers
[i
].FClientID
>= 0) then
903 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
904 else if MKind
= 1 then
905 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
912 g_Console_Add(msg
, True)
913 else if MKind
= 1 then
914 g_Game_Message(msg
, MTime
);
919 MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
)
920 else if MKind
= 1 then
921 MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
);
927 function tr_ShotAimCheck(var Trigger
: TTrigger
; Obj
: PObj
): Boolean;
931 if TriggerType
<> TRIGGER_SHOT
then
933 Result
:= (Data
.ShotAim
and TRIGGER_SHOT_AIM_ALLMAP
> 0)
934 or g_Obj_Collide(X
, Y
, Width
, Height
, Obj
);
935 if Result
and (Data
.ShotAim
and TRIGGER_SHOT_AIM_TRACE
> 0) then
936 Result
:= g_TraceVector(Data
.ShotPos
.X
,
938 Obj
^.X
+ Obj
^.Rect
.X
+ (Obj
^.Rect
.Width
div 2),
939 Obj
^.Y
+ Obj
^.Rect
.Y
+ (Obj
^.Rect
.Height
div 2));
943 function ActivateTrigger(var Trigger
: TTrigger
; actType
: Byte): Boolean;
948 i
, k
, wx
, wy
, xd
, yd
: Integer;
958 if g_Game_IsClient
then
961 if not Trigger
.Enabled
then
963 if (Trigger
.TimeOut
<> 0) and (actType
<> ACTIVATE_CUSTOM
) then
965 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
970 coolDown
:= (actType
<> 0);
977 g_Sound_PlayEx('SOUND_GAME_SWITCH0');
978 if g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH0');
979 gExitByTrigger
:= True;
980 g_Game_ExitLevel(Data
.MapName
);
989 Result
:= tr_Teleport(ActivateUID
,
990 Data
.TargetPoint
.X
, Data
.TargetPoint
.Y
,
991 Data
.TlpDir
, Data
.silent_teleport
,
998 Result
:= tr_OpenDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
1004 Result
:= tr_CloseDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
1008 TRIGGER_DOOR
, TRIGGER_DOOR5
:
1010 if Data
.PanelID
<> -1 then
1012 if gWalls
[Data
.PanelID
].Enabled
then
1014 Result
:= tr_OpenDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
1016 if TriggerType
= TRIGGER_DOOR5
then
1020 Result
:= tr_CloseDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
1027 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1029 tr_CloseTrap(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
1031 if TriggerType
= TRIGGER_TRAP
then
1045 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
1047 PressCount
:= PressCount
+ 1;
1049 if PressTime
= -1 then
1050 PressTime
:= Data
.Wait
;
1060 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1064 if gLMSRespawn
= LMS_RESPAWN_NONE
then
1066 g_Player_Get(ActivateUID
).GetSecret();
1067 Inc(gCoopSecretsFound
);
1068 if g_Game_IsNet
then MH_SEND_GameStats();
1074 Result
:= tr_SetLift(Data
.PanelID
, 0, Data
.NoSound
, Data
.d2d_doors
);
1077 if (not Data
.NoSound
) and Result
then begin
1078 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1080 Y
+ (Height
div 2));
1081 if g_Game_IsServer
and g_Game_IsNet
then
1082 MH_SEND_Sound(X
+ (Width
div 2),
1084 'SOUND_GAME_SWITCH0');
1090 Result
:= tr_SetLift(Data
.PanelID
, 1, Data
.NoSound
, Data
.d2d_doors
);
1093 if (not Data
.NoSound
) and Result
then begin
1094 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1096 Y
+ (Height
div 2));
1097 if g_Game_IsServer
and g_Game_IsNet
then
1098 MH_SEND_Sound(X
+ (Width
div 2),
1100 'SOUND_GAME_SWITCH0');
1106 Result
:= tr_SetLift(Data
.PanelID
, 3, Data
.NoSound
, Data
.d2d_doors
);
1112 if (not Data
.NoSound
) and Result
then begin
1113 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1115 Y
+ (Height
div 2));
1116 if g_Game_IsServer
and g_Game_IsNet
then
1117 MH_SEND_Sound(X
+ (Width
div 2),
1119 'SOUND_GAME_SWITCH0');
1126 if ByteBool(Data
.ActivateOnce
) then
1129 TriggerType
:= TRIGGER_NONE
;
1137 animonce
:= Data
.AnimOnce
;
1143 if Sound
<> nil then
1145 if Data
.SoundSwitch
and Sound
.IsPlaying() then
1146 begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
1148 SoundPlayCount
:= 0;
1151 else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
1152 if (Data
.PlayCount
> 0) or (not Sound
.IsPlaying()) then
1154 if Data
.PlayCount
> 0 then
1155 SoundPlayCount
:= Data
.PlayCount
1156 else // 0 - èãðàåì áåñêîíå÷íî
1157 SoundPlayCount
:= 1;
1160 if g_Game_IsNet
then MH_SEND_TriggerSound(Trigger
);
1164 TRIGGER_SPAWNMONSTER
:
1165 if (Data
.MonType
in [MONSTER_DEMON
..MONSTER_MAN
]) then
1168 if (Data
.MonDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1170 AutoSpawn
:= not AutoSpawn
;
1172 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1176 if ((Data
.MonDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1177 or ((Data
.MonDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1178 for k
:= 1 to Data
.MonCount
do
1180 if (actType
= ACTIVATE_CUSTOM
) and (Data
.MonDelay
> 0) then
1181 SpawnCooldown
:= Data
.MonDelay
;
1182 if (Data
.MonMax
> 0) and (SpawnedCount
>= Data
.MonMax
) then
1185 i
:= g_Monsters_Create(Data
.MonType
,
1186 Data
.MonPos
.X
, Data
.MonPos
.Y
,
1187 TDirection(Data
.MonDir
), True);
1192 if (Data
.MonHealth
> 0) then
1193 gMonsters
[i
].SetHealth(Data
.MonHealth
);
1194 // Óñòàíàâëèâàåì ïîâåäåíèå:
1195 gMonsters
[i
].MonsterBehaviour
:= Data
.MonBehav
;
1196 gMonsters
[i
].FNoRespawn
:= True;
1197 if g_Game_IsNet
then
1198 MH_SEND_MonsterSpawn(gMonsters
[i
].UID
);
1199 // Èäåì èñêàòü öåëü, åñëè íàäî:
1200 if Data
.MonActive
then
1201 gMonsters
[i
].WakeUp();
1203 if Data
.MonType
<> MONSTER_BARREL
then Inc(gTotalMonsters
);
1205 if g_Game_IsNet
then
1207 SetLength(gMonstersSpawned
, Length(gMonstersSpawned
)+1);
1208 gMonstersSpawned
[High(gMonstersSpawned
)] := gMonsters
[i
].UID
;
1211 if Data
.MonMax
> 0 then
1213 gMonsters
[i
].SpawnTrigger
:= ID
;
1217 case Data
.MonEffect
of
1218 EFFECT_TELEPORT
: begin
1219 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
1221 Anim
:= TAnimation
.Create(FramesID
, False, 3);
1222 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data
.MonPos
.X
, Data
.MonPos
.Y
);
1223 g_GFX_OnceAnim(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-32,
1224 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+(gMonsters
[i
].Obj
.Rect
.Height
div 2)-32, Anim
);
1227 if g_Game_IsServer
and g_Game_IsNet
then
1228 MH_SEND_Effect(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-32,
1229 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+(gMonsters
[i
].Obj
.Rect
.Height
div 2)-32, 1,
1232 EFFECT_RESPAWN
: begin
1233 if g_Frames_Get(FramesID
, 'FRAMES_ITEM_RESPAWN') then
1235 Anim
:= TAnimation
.Create(FramesID
, False, 4);
1236 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data
.MonPos
.X
, Data
.MonPos
.Y
);
1237 g_GFX_OnceAnim(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-16,
1238 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+(gMonsters
[i
].Obj
.Rect
.Height
div 2)-16, Anim
);
1241 if g_Game_IsServer
and g_Game_IsNet
then
1242 MH_SEND_Effect(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-16,
1243 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+(gMonsters
[i
].Obj
.Rect
.Height
div 2)-16, 1,
1247 if g_Frames_Get(FramesID
, 'FRAMES_FIRE') then
1249 Anim
:= TAnimation
.Create(FramesID
, False, 4);
1250 g_Sound_PlayExAt('SOUND_FIRE', Data
.MonPos
.X
, Data
.MonPos
.Y
);
1251 g_GFX_OnceAnim(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-32,
1252 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+gMonsters
[i
].Obj
.Rect
.Height
-128, Anim
);
1255 if g_Game_IsServer
and g_Game_IsNet
then
1256 MH_SEND_Effect(gMonsters
[i
].Obj
.X
+gMonsters
[i
].Obj
.Rect
.X
+(gMonsters
[i
].Obj
.Rect
.Width
div 2)-32,
1257 gMonsters
[i
].Obj
.Y
+gMonsters
[i
].Obj
.Rect
.Y
+gMonsters
[i
].Obj
.Rect
.Height
-128, 1,
1262 if g_Game_IsNet
then
1264 MH_SEND_GameStats();
1265 MH_SEND_CoopStats();
1272 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1273 if actType
= ACTIVATE_CUSTOM
then
1278 if (Data
.ItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
]) then
1281 if (Data
.ItemDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1283 AutoSpawn
:= not AutoSpawn
;
1285 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1289 if ((Data
.ItemDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1290 or ((Data
.ItemDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1291 if (not Data
.ItemOnlyDM
) or
1292 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1293 for k
:= 1 to Data
.ItemCount
do
1295 if (actType
= ACTIVATE_CUSTOM
) and (Data
.ItemDelay
> 0) then
1296 SpawnCooldown
:= Data
.ItemDelay
;
1297 if (Data
.ItemMax
> 0) and (SpawnedCount
>= Data
.ItemMax
) then
1300 iid
:= g_Items_Create(Data
.ItemPos
.X
, Data
.ItemPos
.Y
,
1301 Data
.ItemType
, Data
.ItemFalls
, False, True);
1305 if Data
.ItemMax
> 0 then
1307 gItems
[iid
].SpawnTrigger
:= ID
;
1311 case Data
.ItemEffect
of
1312 EFFECT_TELEPORT
: begin
1313 if g_Frames_Get(FramesID
, 'FRAMES_TELEPORT') then
1315 Anim
:= TAnimation
.Create(FramesID
, False, 3);
1316 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data
.ItemPos
.X
, Data
.ItemPos
.Y
);
1317 g_GFX_OnceAnim(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-32,
1318 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+(gItems
[iid
].Obj
.Rect
.Height
div 2)-32, Anim
);
1321 if g_Game_IsServer
and g_Game_IsNet
then
1322 MH_SEND_Effect(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-32,
1323 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+(gItems
[iid
].Obj
.Rect
.Height
div 2)-32, 1,
1326 EFFECT_RESPAWN
: begin
1327 if g_Frames_Get(FramesID
, 'FRAMES_ITEM_RESPAWN') then
1329 Anim
:= TAnimation
.Create(FramesID
, False, 4);
1330 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data
.ItemPos
.X
, Data
.ItemPos
.Y
);
1331 g_GFX_OnceAnim(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-16,
1332 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+(gItems
[iid
].Obj
.Rect
.Height
div 2)-16, Anim
);
1335 if g_Game_IsServer
and g_Game_IsNet
then
1336 MH_SEND_Effect(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-16,
1337 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+(gItems
[iid
].Obj
.Rect
.Height
div 2)-16, 1,
1341 if g_Frames_Get(FramesID
, 'FRAMES_FIRE') then
1343 Anim
:= TAnimation
.Create(FramesID
, False, 4);
1344 g_Sound_PlayExAt('SOUND_FIRE', Data
.ItemPos
.X
, Data
.ItemPos
.Y
);
1345 g_GFX_OnceAnim(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-32,
1346 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+gItems
[iid
].Obj
.Rect
.Height
-128, Anim
);
1349 if g_Game_IsServer
and g_Game_IsNet
then
1350 MH_SEND_Effect(gItems
[iid
].Obj
.X
+gItems
[iid
].Obj
.Rect
.X
+(gItems
[iid
].Obj
.Rect
.Width
div 2)-32,
1351 gItems
[iid
].Obj
.Y
+gItems
[iid
].Obj
.Rect
.Y
+gItems
[iid
].Obj
.Rect
.Height
-128, 1,
1356 if g_Game_IsNet
then
1357 MH_SEND_ItemSpawn(True, iid
);
1364 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1365 if actType
= ACTIVATE_CUSTOM
then
1371 // Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
1372 if (Trigger
.Data
.MusicName
<> '') then
1374 gMusic
.SetByName(Trigger
.Data
.MusicName
);
1375 gMusic
.SpecPause
:= True;
1379 if Trigger
.Data
.MusicAction
= 1 then
1381 if gMusic
.SpecPause
then // Áûëà íà ïàóçå => èãðàòü
1382 gMusic
.SpecPause
:= False
1383 else // Èãðàëà => ñíà÷àëà
1384 gMusic
.SetPosition(0);
1389 gMusic
.SpecPause
:= True;
1397 if g_Game_IsNet
then MH_SEND_TriggerMusic
;
1402 pAngle
:= -DegToRad(Data
.PushAngle
);
1403 Result
:= tr_Push(ActivateUID
,
1404 Floor(Cos(pAngle
)*Data
.PushForce
),
1405 Floor(Sin(pAngle
)*Data
.PushForce
),
1413 // Ïðèáàâèòü èëè îòíÿòü î÷êî
1414 if (Data
.ScoreAction
in [0..1]) and (Data
.ScoreCount
> 0) then
1416 // Ñâîåé èëè ÷óæîé êîìàíäå
1417 if (Data
.ScoreTeam
in [0..1]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1419 p
:= g_Player_Get(ActivateUID
);
1420 if ((Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_RED
))
1421 or ((Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_BLUE
)) then
1423 Inc(gTeamStat
[TEAM_RED
].Goals
, Data
.ScoreCount
); // Red Scores
1425 if Data
.ScoreCon
then
1426 if Data
.ScoreTeam
= 0 then
1428 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1429 if g_Game_IsServer
and g_Game_IsNet
then
1430 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '+r');
1433 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1434 if g_Game_IsServer
and g_Game_IsNet
then
1435 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '+re');
1438 if Data
.ScoreMsg
then
1440 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1441 if g_Game_IsServer
and g_Game_IsNet
then
1442 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1445 if ((Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_RED
))
1446 or ((Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_BLUE
)) then
1448 Dec(gTeamStat
[TEAM_RED
].Goals
, Data
.ScoreCount
); // Red Fouls
1450 if Data
.ScoreCon
then
1451 if Data
.ScoreTeam
= 0 then
1453 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1454 if g_Game_IsServer
and g_Game_IsNet
then
1455 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '-r');
1458 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1459 if g_Game_IsServer
and g_Game_IsNet
then
1460 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '-re');
1463 if Data
.ScoreMsg
then
1465 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1466 if g_Game_IsServer
and g_Game_IsNet
then
1467 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1470 if ((Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_BLUE
))
1471 or ((Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_RED
)) then
1473 Inc(gTeamStat
[TEAM_BLUE
].Goals
, Data
.ScoreCount
); // Blue Scores
1475 if Data
.ScoreCon
then
1476 if Data
.ScoreTeam
= 0 then
1478 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1479 if g_Game_IsServer
and g_Game_IsNet
then
1480 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '+b');
1483 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1484 if g_Game_IsServer
and g_Game_IsNet
then
1485 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '+be');
1488 if Data
.ScoreMsg
then
1490 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1491 if g_Game_IsServer
and g_Game_IsNet
then
1492 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1495 if ((Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_BLUE
))
1496 or ((Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_RED
)) then
1498 Dec(gTeamStat
[TEAM_BLUE
].Goals
, Data
.ScoreCount
); // Blue Fouls
1500 if Data
.ScoreCon
then
1501 if Data
.ScoreTeam
= 0 then
1503 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1504 if g_Game_IsServer
and g_Game_IsNet
then
1505 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '-b');
1508 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, Data
.ScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1509 if g_Game_IsServer
and g_Game_IsNet
then
1510 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (Data
.ScoreCount
shl 16), '-be');
1513 if Data
.ScoreMsg
then
1515 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1516 if g_Game_IsServer
and g_Game_IsNet
then
1517 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1520 Result
:= (p
.Team
= TEAM_RED
) or (p
.Team
= TEAM_BLUE
);
1522 // Êàêîé-òî êîíêðåòíîé êîìàíäå
1523 if Data
.ScoreTeam
in [2..3] then
1525 if (Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 2) then
1527 Inc(gTeamStat
[TEAM_RED
].Goals
, Data
.ScoreCount
); // Red Scores
1529 if Data
.ScoreCon
then
1531 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], Data
.ScoreCount
]), True);
1532 if g_Game_IsServer
and g_Game_IsNet
then
1533 MH_SEND_GameEvent(NET_EV_SCORE
, Data
.ScoreCount
shl 16, '+tr');
1536 if Data
.ScoreMsg
then
1538 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1539 if g_Game_IsServer
and g_Game_IsNet
then
1540 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1543 if (Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 2) then
1545 Dec(gTeamStat
[TEAM_RED
].Goals
, Data
.ScoreCount
); // Red Fouls
1547 if Data
.ScoreCon
then
1549 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], Data
.ScoreCount
]), True);
1550 if g_Game_IsServer
and g_Game_IsNet
then
1551 MH_SEND_GameEvent(NET_EV_SCORE
, Data
.ScoreCount
shl 16, '-tr');
1554 if Data
.ScoreMsg
then
1556 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1557 if g_Game_IsServer
and g_Game_IsNet
then
1558 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1561 if (Data
.ScoreAction
= 0) and (Data
.ScoreTeam
= 3) then
1563 Inc(gTeamStat
[TEAM_BLUE
].Goals
, Data
.ScoreCount
); // Blue Scores
1565 if Data
.ScoreCon
then
1567 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], Data
.ScoreCount
]), True);
1568 if g_Game_IsServer
and g_Game_IsNet
then
1569 MH_SEND_GameEvent(NET_EV_SCORE
, Data
.ScoreCount
shl 16, '+tb');
1572 if Data
.ScoreMsg
then
1574 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1575 if g_Game_IsServer
and g_Game_IsNet
then
1576 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1579 if (Data
.ScoreAction
= 1) and (Data
.ScoreTeam
= 3) then
1581 Dec(gTeamStat
[TEAM_BLUE
].Goals
, Data
.ScoreCount
); // Blue Fouls
1583 if Data
.ScoreCon
then
1585 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], Data
.ScoreCount
]), True);
1586 if g_Game_IsServer
and g_Game_IsNet
then
1587 MH_SEND_GameEvent(NET_EV_SCORE
, Data
.ScoreCount
shl 16, '-tb');
1590 if Data
.ScoreMsg
then
1592 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1593 if g_Game_IsServer
and g_Game_IsNet
then
1594 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1601 if (Data
.ScoreAction
= 2) and (gGameSettings
.GoalLimit
> 0) then
1603 // Ñâîåé èëè ÷óæîé êîìàíäû
1604 if (Data
.ScoreTeam
in [0..1]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1606 p
:= g_Player_Get(ActivateUID
);
1607 if ((Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_RED
)) // Red Wins
1608 or ((Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_BLUE
)) then
1609 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1611 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1613 if Data
.ScoreCon
then
1614 if Data
.ScoreTeam
= 0 then
1616 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1617 if g_Game_IsServer
and g_Game_IsNet
then
1618 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1621 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1622 if g_Game_IsServer
and g_Game_IsNet
then
1623 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1628 if ((Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_BLUE
)) // Blue Wins
1629 or ((Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_RED
)) then
1630 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1632 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1634 if Data
.ScoreCon
then
1635 if Data
.ScoreTeam
= 0 then
1637 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1638 if g_Game_IsServer
and g_Game_IsNet
then
1639 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
1642 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1643 if g_Game_IsServer
and g_Game_IsNet
then
1644 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
1650 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1651 if Data
.ScoreTeam
in [2..3] then
1653 if Data
.ScoreTeam
= 2 then // Red Wins
1654 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1656 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1659 if Data
.ScoreTeam
= 3 then // Blue Wins
1660 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1662 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1668 if (Data
.ScoreAction
= 3) and (gGameSettings
.GoalLimit
> 0) then
1670 // Ñâîåé èëè ÷óæîé êîìàíäû
1671 if (Data
.ScoreTeam
in [0..1]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1673 p
:= g_Player_Get(ActivateUID
);
1674 if ((Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_BLUE
)) // Red Wins
1675 or ((Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_RED
)) then
1676 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1678 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1680 if Data
.ScoreCon
then
1681 if Data
.ScoreTeam
= 0 then
1683 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1684 if g_Game_IsServer
and g_Game_IsNet
then
1685 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1688 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1689 if g_Game_IsServer
and g_Game_IsNet
then
1690 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1695 if ((Data
.ScoreTeam
= 0) and (p
.Team
= TEAM_RED
)) // Blue Wins
1696 or ((Data
.ScoreTeam
= 1) and (p
.Team
= TEAM_BLUE
)) then
1697 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1699 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1701 if Data
.ScoreCon
then
1702 if Data
.ScoreTeam
= 0 then
1704 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1705 if g_Game_IsServer
and g_Game_IsNet
then
1706 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
1709 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1710 if g_Game_IsServer
and g_Game_IsNet
then
1711 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
1717 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1718 if Data
.ScoreTeam
in [2..3] then
1720 if Data
.ScoreTeam
= 3 then // Red Wins
1721 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1723 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1726 if Data
.ScoreTeam
= 2 then // Blue Wins
1727 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1729 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1734 if Result
then begin
1739 if g_Game_IsServer
and g_Game_IsNet
then
1746 Result
:= tr_Message(Data
.MessageKind
, Data
.MessageText
,
1747 Data
.MessageSendTo
, Data
.MessageTime
,
1752 TRIGGER_DAMAGE
, TRIGGER_HEALTH
:
1755 UIDType
:= g_GetUIDType(ActivateUID
);
1756 if (UIDType
= UID_PLAYER
) or (UIDType
= UID_MONSTER
) then
1762 // Âñïîìèíàåì, àêòèâèðîâàë ëè îí ìåíÿ ðàíüøå
1763 for i
:= 0 to High(Activators
) do
1764 if Activators
[i
].UID
= ActivateUID
then
1770 begin // Âèäèì åãî âïåðâûå
1772 SetLength(Activators
, Length(Activators
) + 1);
1773 k
:= High(Activators
);
1774 Activators
[k
].UID
:= ActivateUID
;
1776 begin // Óæå âèäåëè åãî
1777 // Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
1778 if (Data
.DamageInterval
= 0) and (Activators
[k
].TimeOut
> 0) then
1779 Activators
[k
].TimeOut
:= 65535;
1780 // Òàéìàóò ïðîø¸ë - ðàáîòàåì
1781 Result
:= Activators
[k
].TimeOut
= 0;
1790 p
:= g_Player_Get(ActivateUID
);
1794 // Íàíîñèì óðîí èãðîêó
1795 if (TriggerType
= TRIGGER_DAMAGE
) and (Data
.DamageValue
> 0) then
1796 p
.Damage(Data
.DamageValue
, 0, 0, 0, HIT_SOME
);
1799 if (TriggerType
= TRIGGER_HEALTH
) and (Data
.HealValue
> 0) then
1800 if p
.Heal(Data
.HealValue
, not Data
.HealMax
) and (not Data
.HealSilent
) then
1802 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p
.Obj
.X
, p
.Obj
.Y
);
1803 if g_Game_IsServer
and g_Game_IsNet
then
1804 MH_SEND_Sound(p
.Obj
.X
, p
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
1810 m
:= g_Monsters_Get(ActivateUID
);
1814 // Íàíîñèì óðîí ìîíñòðó
1815 if (TriggerType
= TRIGGER_DAMAGE
) and (Data
.DamageValue
> 0) then
1816 m
.Damage(Data
.DamageValue
, 0, 0, 0, HIT_SOME
);
1819 if (TriggerType
= TRIGGER_HEALTH
) and (Data
.HealValue
> 0) then
1820 if m
.Heal(Data
.HealValue
) and (not Data
.HealSilent
) then
1822 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m
.Obj
.X
, m
.Obj
.Y
);
1823 if g_Game_IsServer
and g_Game_IsNet
then
1824 MH_SEND_Sound(m
.Obj
.X
, m
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
1828 // Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
1829 if TriggerType
= TRIGGER_DAMAGE
then
1830 i
:= Data
.DamageInterval
1832 i
:= Data
.HealInterval
;
1835 Activators
[k
].TimeOut
:= i
1837 Activators
[k
].TimeOut
:= 65535;
1845 if ShotSightTime
> 0 then
1848 // put this at the beginning so it doesn't trigger itself
1849 TimeOut
:= Data
.ShotWait
+ 1;
1851 wx
:= Data
.ShotPos
.X
;
1852 wy
:= Data
.ShotPos
.Y
;
1853 pAngle
:= -DegToRad(Data
.ShotAngle
);
1854 xd
:= wx
+ Round(Cos(pAngle
) * 32.0);
1855 yd
:= wy
+ Round(Sin(pAngle
) * 32.0);
1858 case Data
.ShotTarget
of
1859 TRIGGER_SHOT_TARGET_MON
: // monsters
1860 if gMonsters
<> nil then
1861 for i
:= Low(gMonsters
) to High(gMonsters
) do
1862 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and
1863 tr_ShotAimCheck(Trigger
, @(gMonsters
[i
].Obj
)) then
1865 xd
:= gMonsters
[i
].GameX
+ gMonsters
[i
].Obj
.Rect
.Width
div 2;
1866 yd
:= gMonsters
[i
].GameY
+ gMonsters
[i
].Obj
.Rect
.Height
div 2;
1867 TargetUID
:= gMonsters
[i
].UID
;
1871 TRIGGER_SHOT_TARGET_PLR
: // players
1872 if gPlayers
<> nil then
1873 for i
:= Low(gPlayers
) to High(gPlayers
) do
1874 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and
1875 tr_ShotAimCheck(Trigger
, @(gPlayers
[i
].Obj
)) then
1877 xd
:= gPlayers
[i
].GameX
+ PLAYER_RECT_CX
;
1878 yd
:= gPlayers
[i
].GameY
+ PLAYER_RECT_CY
;
1879 TargetUID
:= gPlayers
[i
].UID
;
1883 TRIGGER_SHOT_TARGET_RED
: // red team
1884 if gPlayers
<> nil then
1885 for i
:= Low(gPlayers
) to High(gPlayers
) do
1886 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and
1887 (gPlayers
[i
].Team
= TEAM_RED
) and
1888 tr_ShotAimCheck(Trigger
, @(gPlayers
[i
].Obj
)) then
1890 xd
:= gPlayers
[i
].GameX
+ PLAYER_RECT_CX
;
1891 yd
:= gPlayers
[i
].GameY
+ PLAYER_RECT_CY
;
1892 TargetUID
:= gPlayers
[i
].UID
;
1896 TRIGGER_SHOT_TARGET_BLUE
: // blue team
1897 if gPlayers
<> nil then
1898 for i
:= Low(gPlayers
) to High(gPlayers
) do
1899 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and
1900 (gPlayers
[i
].Team
= TEAM_BLUE
) and
1901 tr_ShotAimCheck(Trigger
, @(gPlayers
[i
].Obj
)) then
1903 xd
:= gPlayers
[i
].GameX
+ PLAYER_RECT_CX
;
1904 yd
:= gPlayers
[i
].GameY
+ PLAYER_RECT_CY
;
1905 TargetUID
:= gPlayers
[i
].UID
;
1909 TRIGGER_SHOT_TARGET_MONPLR
: // monsters then players
1911 if gMonsters
<> nil then
1912 for i
:= Low(gMonsters
) to High(gMonsters
) do
1913 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and
1914 tr_ShotAimCheck(Trigger
, @(gMonsters
[i
].Obj
)) then
1916 xd
:= gMonsters
[i
].GameX
+ gMonsters
[i
].Obj
.Rect
.Width
div 2;
1917 yd
:= gMonsters
[i
].GameY
+ gMonsters
[i
].Obj
.Rect
.Height
div 2;
1918 TargetUID
:= gMonsters
[i
].UID
;
1921 if (TargetUID
= 0) and (gPlayers
<> nil) then
1922 for i
:= Low(gPlayers
) to High(gPlayers
) do
1923 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and
1924 tr_ShotAimCheck(Trigger
, @(gPlayers
[i
].Obj
)) then
1926 xd
:= gPlayers
[i
].GameX
+ PLAYER_RECT_CX
;
1927 yd
:= gPlayers
[i
].GameY
+ PLAYER_RECT_CY
;
1928 TargetUID
:= gPlayers
[i
].UID
;
1933 TRIGGER_SHOT_TARGET_PLRMON
: // players then monsters
1935 if gPlayers
<> nil then
1936 for i
:= Low(gPlayers
) to High(gPlayers
) do
1937 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
and
1938 tr_ShotAimCheck(Trigger
, @(gPlayers
[i
].Obj
)) then
1940 xd
:= gPlayers
[i
].GameX
+ PLAYER_RECT_CX
;
1941 yd
:= gPlayers
[i
].GameY
+ PLAYER_RECT_CY
;
1942 TargetUID
:= gPlayers
[i
].UID
;
1945 if (TargetUID
= 0) and (gMonsters
<> nil) then
1946 for i
:= Low(gMonsters
) to High(gMonsters
) do
1947 if (gMonsters
[i
] <> nil) and gMonsters
[i
].Live
and
1948 tr_ShotAimCheck(Trigger
, @(gMonsters
[i
].Obj
)) then
1950 xd
:= gMonsters
[i
].GameX
+ gMonsters
[i
].Obj
.Rect
.Width
div 2;
1951 yd
:= gMonsters
[i
].GameY
+ gMonsters
[i
].Obj
.Rect
.Height
div 2;
1952 TargetUID
:= gMonsters
[i
].UID
;
1958 if (Data
.ShotTarget
<> TRIGGER_SHOT_TARGET_NONE
) or
1959 (Data
.ShotType
<> TRIGGER_SHOT_REV
) then
1960 TargetUID
:= ActivateUID
;
1964 if (Data
.ShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or (TargetUID
> 0) or
1965 ((Data
.ShotTarget
> TRIGGER_SHOT_TARGET_NONE
) and (TargetUID
= 0)) then
1968 if (Data
.ShotIntSight
= 0) or
1969 (Data
.ShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or
1970 (TargetUID
= ShotSightTarget
) then
1971 MakeShot(Trigger
, wx
, wy
, xd
, yd
, TargetUID
)
1974 ShotSightTime
:= Data
.ShotIntSight
;
1975 ShotSightTargetN
:= TargetUID
;
1976 if Data
.ShotType
= TRIGGER_SHOT_BFG
then
1978 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx
, wy
);
1979 if g_Game_IsNet
and g_Game_IsServer
then
1980 MH_SEND_Sound(wx
, wy
, 'SOUND_WEAPON_STARTFIREBFG');
1993 TRIGGER_EFFECT_POS_CENTER
:
1995 wx
:= X
+ Width
div 2;
1996 wy
:= Y
+ Height
div 2;
1998 TRIGGER_EFFECT_POS_AREA
:
2000 wx
:= X
+ Random(Width
);
2001 wy
:= Y
+ Random(Height
);
2004 wx
:= X
+ Width
div 2;
2005 wy
:= Y
+ Height
div 2;
2010 if Data
.FXSpreadL
> 0 then xd
:= xd
- Random(Data
.FXSpreadL
+ 1);
2011 if Data
.FXSpreadR
> 0 then xd
:= xd
+ Random(Data
.FXSpreadR
+ 1);
2012 if Data
.FXSpreadU
> 0 then yd
:= yd
- Random(Data
.FXSpreadU
+ 1);
2013 if Data
.FXSpreadD
> 0 then yd
:= yd
+ Random(Data
.FXSpreadD
+ 1);
2014 tr_MakeEffect(wx
, wy
, xd
, yd
,
2015 Data
.FXType
, Data
.FXSubType
,
2016 Data
.FXColorR
, Data
.FXColorG
, Data
.FXColorB
, True, False);
2019 TimeOut
:= Data
.FXWait
;
2024 g_Scripts_ProcExec(Data
.SCRProc
, [ID
, ActivateUID
, actType
, Data
.SCRArg
], 'map');
2031 if Result
and (Trigger
.TexturePanel
<> -1) then
2032 g_Map_SwitchTexture(Trigger
.TexturePanelType
, Trigger
.TexturePanel
, IfThen(animonce
, 2, 1));
2035 function g_Triggers_Create(Trigger
: TTrigger
): DWORD
;
2040 // Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà:
2041 if (Trigger
.TriggerType
= TRIGGER_EXIT
) and
2042 (not LongBool(gGameSettings
.Options
and GAME_OPTION_ALLOWEXIT
)) then
2043 Trigger
.TriggerType
:= TRIGGER_NONE
;
2045 // Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð:
2046 if (Trigger
.TriggerType
= TRIGGER_SPAWNMONSTER
) and
2047 (not LongBool(gGameSettings
.Options
and GAME_OPTION_MONSTERS
)) and
2048 (gGameSettings
.GameType
<> GT_SINGLE
) then
2049 Trigger
.TriggerType
:= TRIGGER_NONE
;
2051 // Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå:
2052 if Trigger
.TriggerType
= TRIGGER_SECRET
then
2053 gSecretsCount
:= gSecretsCount
+ 1;
2055 find_id
:= FindTrigger();
2056 gTriggers
[find_id
] := Trigger
;
2058 with gTriggers
[find_id
] do
2061 // if this type of trigger exists both on the client and on the server
2062 // use an uniform numeration
2063 if Trigger
.TriggerType
= TRIGGER_SOUND
then
2065 Inc(gTriggerClientID
);
2066 ClientID
:= gTriggerClientID
;
2072 PlayerCollide
:= False;
2076 SoundPlayCount
:= 0;
2083 // Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê":
2084 if (Trigger
.TriggerType
= TRIGGER_SOUND
) and
2085 (Trigger
.Data
.SoundName
<> '') then
2087 // Åùå íåò òàêîãî çâóêà:
2088 if not g_Sound_Exists(Trigger
.Data
.SoundName
) then
2090 fn
:= g_ExtractWadName(Trigger
.Data
.SoundName
);
2093 begin // Çâóê â ôàéëå ñ êàðòîé
2094 mapw
:= g_ExtractWadName(gMapInfo
.Map
);
2095 fn
:= mapw
+':'+g_ExtractFilePathName(Trigger
.Data
.SoundName
);
2097 else // Çâóê â îòäåëüíîì ôàéëå
2098 fn
:= GameDir
+ '/wads/' + Trigger
.Data
.SoundName
;
2100 if not g_Sound_CreateWADEx(Trigger
.Data
.SoundName
, fn
) then
2101 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, Trigger
.Data
.SoundName
]));
2104 // Ñîçäàåì îáúåêò çâóêà:
2105 with gTriggers
[find_id
] do
2107 Sound
:= TPlayableSound
.Create();
2108 if not Sound
.SetByName(Trigger
.Data
.SoundName
) then
2116 // Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà":
2117 if (Trigger
.TriggerType
= TRIGGER_MUSIC
) and
2118 (Trigger
.Data
.MusicName
<> '') then
2120 // Åùå íåò òàêîé ìóçûêè:
2121 if not g_Sound_Exists(Trigger
.Data
.MusicName
) then
2123 fn
:= g_ExtractWadName(Trigger
.Data
.MusicName
);
2126 begin // Ìóçûêà â ôàéëå ñ êàðòîé
2127 mapw
:= g_ExtractWadName(gMapInfo
.Map
);
2128 fn
:= mapw
+':'+g_ExtractFilePathName(Trigger
.Data
.MusicName
);
2130 else // Ìóçûêà â ôàéëå ñ êàðòîé
2131 fn
:= GameDir
+'/wads/'+Trigger
.Data
.MusicName
;
2133 if not g_Sound_CreateWADEx(Trigger
.Data
.MusicName
, fn
, True) then
2134 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, Trigger
.Data
.MusicName
]));
2138 // Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü":
2139 if Trigger
.TriggerType
= TRIGGER_SHOT
then
2140 with gTriggers
[find_id
] do
2144 ShotSightTimeout
:= 0;
2145 ShotSightTarget
:= 0;
2146 ShotSightTargetN
:= 0;
2147 ShotAmmoCount
:= Trigger
.Data
.ShotAmmo
;
2148 ShotReloadTime
:= 0;
2154 procedure g_Triggers_Update();
2157 Affected
: array of Integer;
2159 if gTriggers
= nil then
2161 SetLength(Affected
, 0);
2163 for a
:= 0 to High(gTriggers
) do
2164 with gTriggers
[a
] do
2166 if TriggerType
<> TRIGGER_NONE
then
2168 // Óìåíüøàåì âðåìÿ äî çàêðûòèÿ äâåðè (îòêðûòèÿ ëîâóøêè):
2169 if DoorTime
> 0 then
2170 DoorTime
:= DoorTime
- 1;
2171 // Óìåíüøàåì âðåìÿ îæèäàíèÿ ïîñëå íàæàòèÿ:
2172 if PressTime
> 0 then
2173 PressTime
:= PressTime
- 1;
2174 // Ïðîâåðÿåì èãðîêîâ è ìîíñòðîâ, êîòîðûõ ðàíåå çàïîìíèëè:
2175 if (TriggerType
= TRIGGER_DAMAGE
) or (TriggerType
= TRIGGER_HEALTH
) then
2176 for b
:= 0 to High(Activators
) do
2178 // Óìåíüøàåì âðåìÿ äî ïîâòîðíîãî âîçäåéñòâèÿ:
2179 if Activators
[b
].TimeOut
> 0 then
2180 Dec(Activators
[b
].TimeOut
)
2183 // Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
2184 if (Data
.DamageInterval
= 0) and (Activators
[b
].TimeOut
< 65530) then
2185 Activators
[b
].TimeOut
:= 0;
2188 // Îáðàáàòûâàåì ñïàâíåðû:
2189 if Enabled
and AutoSpawn
then
2190 if SpawnCooldown
= 0 then
2192 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà:
2193 if (TriggerType
= TRIGGER_SPAWNMONSTER
) and (Data
.MonDelay
> 0) then
2196 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2198 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò:
2199 if (TriggerType
= TRIGGER_SPAWNITEM
) and (Data
.ItemDelay
> 0) then
2202 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2204 end else // Óìåíüøàåì âðåìÿ îæèäàíèÿ:
2207 // Îáðàáàòûâàåì ñîáûòèÿ òðèããåðà "Òóðåëü":
2208 if TriggerType
= TRIGGER_SHOT
then
2210 if ShotPanelTime
> 0 then
2213 if ShotPanelTime
= 0 then
2214 g_Map_SwitchTexture(ShotPanelType
, Data
.ShotPanelID
);
2216 if ShotSightTime
> 0 then
2219 if ShotSightTime
= 0 then
2220 ShotSightTarget
:= ShotSightTargetN
;
2222 if ShotSightTimeout
> 0 then
2224 Dec(ShotSightTimeout
);
2225 if ShotSightTimeout
= 0 then
2226 ShotSightTarget
:= 0;
2228 if ShotReloadTime
> 0 then
2230 Dec(ShotReloadTime
);
2231 if ShotReloadTime
= 0 then
2232 ShotAmmoCount
:= Data
.ShotAmmo
;
2236 // Òðèããåð "Çâóê" óæå îòûãðàë, åñëè íóæíî åùå - ïåðåçàïóñêàåì:
2237 if Enabled
and (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) then
2238 if (SoundPlayCount
> 0) and (not Sound
.IsPlaying()) then
2240 if Data
.PlayCount
> 0 then // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
2241 SoundPlayCount
:= SoundPlayCount
- 1;
2243 Sound
.PlayVolumeAt(X
+(Width
div 2), Y
+(Height
div 2), Data
.Volume
/255.0)
2245 Sound
.PlayPanVolume((Data
.Pan
-127.0)/128.0, Data
.Volume
/255.0);
2246 if Sound
.IsPlaying() and g_Game_IsNet
and g_Game_IsServer
then
2247 MH_SEND_TriggerSound(gTriggers
[a
]);
2250 // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü:
2251 if (TriggerType
= TRIGGER_TRAP
) and (DoorTime
= 0) and (Data
.PanelID
<> -1) then
2253 tr_OpenDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
);
2257 // Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü:
2258 if (TriggerType
= TRIGGER_DOOR5
) and (DoorTime
= 0) and (Data
.PanelID
<> -1) then
2261 if gWalls
[Data
.PanelID
].Enabled
then
2263 else // Ïîêà îòêðûòà - çàêðûâàåì
2264 if tr_CloseDoor(Data
.PanelID
, Data
.NoSound
, Data
.d2d_doors
) then
2268 // Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
2269 if (TriggerType
in [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) and
2270 (PressTime
= 0) and (PressCount
>= Data
.Count
) then
2272 // Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
2274 // Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
2275 if Data
.Count
> 0 then
2276 PressCount
:= PressCount
- Data
.Count
2280 // Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
2281 for b
:= 0 to High(gTriggers
) do
2282 if g_Collide(Data
.tX
, Data
.tY
, Data
.tWidth
, Data
.tHeight
, gTriggers
[b
].X
, gTriggers
[b
].Y
,
2283 gTriggers
[b
].Width
, gTriggers
[b
].Height
) and
2284 ((b
<> a
) or (Data
.Wait
> 0)) then
2285 begin // Can be self-activated, if there is Data.Wait
2286 if (not Data
.ExtRandom
) or gTriggers
[b
].Enabled
then
2288 SetLength(Affected
, Length(Affected
) + 1);
2289 Affected
[High(Affected
)] := b
;
2292 // Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
2293 if (TriggerType
= TRIGGER_PRESS
) and Data
.ExtRandom
then
2295 if (Length(Affected
) > 0) then
2297 b
:= Affected
[Random(Length(Affected
))];
2298 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2299 ActivateTrigger(gTriggers
[b
], 0);
2302 else //  ïðîòèâíîì ñëó÷àå ðàáîòàåì êàê îáû÷íî:
2303 for i
:= 0 to High(Affected
) do
2309 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2310 ActivateTrigger(gTriggers
[b
], 0);
2314 gTriggers
[b
].Enabled
:= True;
2318 gTriggers
[b
].Enabled
:= False;
2319 gTriggers
[b
].TimeOut
:= 0;
2320 if gTriggers
[b
].AutoSpawn
then
2322 gTriggers
[b
].AutoSpawn
:= False;
2323 gTriggers
[b
].SpawnCooldown
:= 0;
2328 gTriggers
[b
].Enabled
:= not gTriggers
[b
].Enabled
;
2329 if not gTriggers
[b
].Enabled
then
2331 gTriggers
[b
].TimeOut
:= 0;
2332 if gTriggers
[b
].AutoSpawn
then
2334 gTriggers
[b
].AutoSpawn
:= False;
2335 gTriggers
[b
].SpawnCooldown
:= 0;
2341 SetLength(Affected
, 0);
2344 // Óìåíüøàåì âðåìÿ äî âîçìîæíîñòè ïîâòîðíîé àêòèâàöèè:
2347 TimeOut
:= TimeOut
- 1;
2348 Continue
; // ×òîáû íå ïîòåðÿòü 1 åäèíèöó çàäåðæêè
2351 // Íèæå èäóò òèïû àêòèâàöèè, åñëè òðèããåð îòêëþ÷¸í - èä¸ì äàëüøå
2356 if ByteBool(ActivateType
and ACTIVATE_PLAYERCOLLIDE
) and
2358 if gPlayers
<> nil then
2359 for b
:= 0 to High(gPlayers
) do
2360 if gPlayers
[b
] <> nil then
2362 // Æèâ, åñòü íóæíûå êëþ÷è è îí ðÿäîì:
2363 if Live
and ((gTriggers
[a
].Keys
and GetKeys
) = gTriggers
[a
].Keys
) and
2364 Collide(X
, Y
, Width
, Height
) then
2366 gTriggers
[a
].ActivateUID
:= UID
;
2368 if (gTriggers
[a
].TriggerType
in [TRIGGER_SOUND
, TRIGGER_MUSIC
]) and
2370 { Don't activate sound/music again if player is here }
2372 ActivateTrigger(gTriggers
[a
], ACTIVATE_PLAYERCOLLIDE
);
2375 { TODO 5 : àêòèâàöèÿ ìîíñòðàìè òðèããåðîâ ñ êëþ÷àìè }
2377 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2378 ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2379 (TimeOut
= 0) and (Keys
= 0) then
2381 // Åñëè "Ìîíñòð áëèçêî" è "Ìîíñòðîâ íåò",
2382 // çàïóñêàåì òðèããåð íà ñòàðòå êàðòû è ñíèìàåì îáà ôëàãà
2383 ActivateType
:= ActivateType
and not (ACTIVATE_MONSTERCOLLIDE
or ACTIVATE_NOMONSTER
);
2384 gTriggers
[a
].ActivateUID
:= 0;
2385 ActivateTrigger(gTriggers
[a
], 0);
2389 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2390 (TimeOut
= 0) and (Keys
= 0) then // Åñëè íå íóæíû êëþ÷è
2391 if gMonsters
<> nil then
2392 for b
:= 0 to High(gMonsters
) do
2393 if (gMonsters
[b
] <> nil) then
2394 with gMonsters
[b
] do
2395 if Collide(X
, Y
, Width
, Height
) then
2397 gTriggers
[a
].ActivateUID
:= UID
;
2398 ActivateTrigger(gTriggers
[a
], ACTIVATE_MONSTERCOLLIDE
);
2402 if ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2403 (TimeOut
= 0) and (Keys
= 0) then
2404 if not g_CollideMonster(X
, Y
, Width
, Height
) then
2406 gTriggers
[a
].ActivateUID
:= 0;
2407 ActivateTrigger(gTriggers
[a
], ACTIVATE_NOMONSTER
);
2411 PlayerCollide
:= g_CollidePlayer(X
, Y
, Width
, Height
);
2415 procedure g_Triggers_Press(ID
: DWORD
; ActivateType
: Byte; ActivateUID
: Word = 0);
2417 gTriggers
[ID
].ActivateUID
:= ActivateUID
;
2418 ActivateTrigger(gTriggers
[ID
], ActivateType
);
2421 function g_Triggers_PressR(X
, Y
: Integer; Width
, Height
: Word; UID
: Word;
2422 ActivateType
: Byte; IgnoreList
: DWArray
= nil): DWArray
;
2430 if gTriggers
= nil then Exit
;
2432 case g_GetUIDType(UID
) of
2436 p
:= g_Player_Get(UID
);
2445 for a
:= 0 to High(gTriggers
) do
2446 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2447 (gTriggers
[a
].TimeOut
= 0) and
2448 (not InDWArray(a
, IgnoreList
)) and
2449 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2450 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2451 if g_Collide(X
, Y
, Width
, Height
,
2452 gTriggers
[a
].X
, gTriggers
[a
].Y
,
2453 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2455 gTriggers
[a
].ActivateUID
:= UID
;
2456 if ActivateTrigger(gTriggers
[a
], ActivateType
) then
2458 SetLength(Result
, Length(Result
)+1);
2459 Result
[High(Result
)] := a
;
2464 procedure g_Triggers_PressL(X1
, Y1
, X2
, Y2
: Integer; UID
: DWORD
; ActivateType
: Byte);
2470 if gTriggers
= nil then Exit
;
2472 case g_GetUIDType(UID
) of
2476 p
:= g_Player_Get(UID
);
2485 for a
:= 0 to High(gTriggers
) do
2486 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2487 (gTriggers
[a
].TimeOut
= 0) and
2488 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2489 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2490 if g_CollideLine(x1
, y1
, x2
, y2
, gTriggers
[a
].X
, gTriggers
[a
].Y
,
2491 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2493 gTriggers
[a
].ActivateUID
:= UID
;
2494 ActivateTrigger(gTriggers
[a
], ActivateType
);
2498 procedure g_Triggers_PressC(CX
, CY
: Integer; Radius
: Word; UID
: Word; ActivateType
: Byte; IgnoreTrigger
: Integer = -1);
2505 if gTriggers
= nil then
2508 case g_GetUIDType(UID
) of
2512 p
:= g_Player_Get(UID
);
2521 rsq
:= Radius
* Radius
;
2523 for a
:= 0 to High(gTriggers
) do
2524 if (gTriggers
[a
].ID
<> DWORD(IgnoreTrigger
)) and
2525 (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2526 (gTriggers
[a
].TimeOut
= 0) and
2527 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2528 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2529 with gTriggers
[a
] do
2530 if g_Collide(CX
-Radius
, CY
-Radius
, 2*Radius
, 2*Radius
,
2531 X
, Y
, Width
, Height
) then
2532 if ((Sqr(CX
-X
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ëåâîìó óãëó
2533 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ïðàâîìó óãëó
2534 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ïðàâîìó óãëó
2535 ((Sqr(CX
-X
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ëåâîìó óãëó
2536 ( (CX
> (X
-Radius
)) and (CX
< (X
+Width
+Radius
)) and
2537 (CY
> Y
) and (CY
< (Y
+Height
)) ) or // Öåíòð êðóãà íåäàëåêî îò âåðòèêàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
2538 ( (CY
> (Y
-Radius
)) and (CY
< (Y
+Height
+Radius
)) and
2539 (CX
> X
) and (CX
< (X
+Width
)) ) then // Öåíòð êðóãà íåäàëåêî îò ãîðèçîíòàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
2542 ActivateTrigger(gTriggers
[a
], ActivateType
);
2546 procedure g_Triggers_OpenAll();
2551 if gTriggers
= nil then Exit
;
2554 for a
:= 0 to High(gTriggers
) do
2555 with gTriggers
[a
] do
2556 if (TriggerType
= TRIGGER_OPENDOOR
) or
2557 (TriggerType
= TRIGGER_DOOR5
) or
2558 (TriggerType
= TRIGGER_DOOR
) then
2560 tr_OpenDoor(Data
.PanelID
, True, Data
.d2d_doors
);
2561 if TriggerType
= TRIGGER_DOOR5
then DoorTime
:= 180;
2565 if b
then g_Sound_PlayEx('SOUND_GAME_DOOROPEN');
2568 procedure g_Triggers_DecreaseSpawner(ID
: DWORD
);
2570 if (gTriggers
<> nil) then
2571 if gTriggers
[ID
].SpawnedCount
> 0 then
2572 Dec(gTriggers
[ID
].SpawnedCount
);
2575 procedure g_Triggers_Free();
2579 if gTriggers
<> nil then
2580 for a
:= 0 to High(gTriggers
) do
2582 if gTriggers
[a
].TriggerType
= TRIGGER_SOUND
then
2584 if g_Sound_Exists(gTriggers
[a
].Data
.SoundName
) then
2585 g_Sound_Delete(gTriggers
[a
].Data
.SoundName
);
2587 gTriggers
[a
].Sound
.Free();
2589 if gTriggers
[a
].Activators
<> nil then
2590 SetLength(gTriggers
[a
].Activators
, 0);
2595 SetLength(gMonstersSpawned
, 0);
2598 procedure g_Triggers_SaveState(var Mem
: TBinMemoryWriter
);
2600 count
, act_count
, i
, j
: Integer;
2606 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ:
2608 if gTriggers
<> nil then
2609 for i
:= 0 to High(gTriggers
) do
2612 Mem
:= TBinMemoryWriter
.Create((count
+1) * 200);
2614 // Êîëè÷åñòâî òðèããåðîâ:
2615 Mem
.WriteInt(count
);
2620 for i
:= 0 to High(gTriggers
) do
2622 // Ñèãíàòóðà òðèããåðà:
2623 dw
:= TRIGGER_SIGNATURE
; // 'TRGR'
2626 Mem
.WriteByte(gTriggers
[i
].TriggerType
);
2627 // Ñïåöèàëüíûå äàííûå òðèããåðà:
2628 p
:= @gTriggers
[i
].Data
;
2629 Mem
.WriteMemory(p
, SizeOf(TTriggerData
));
2630 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
2631 Mem
.WriteInt(gTriggers
[i
].X
);
2632 Mem
.WriteInt(gTriggers
[i
].Y
);
2634 Mem
.WriteWord(gTriggers
[i
].Width
);
2635 Mem
.WriteWord(gTriggers
[i
].Height
);
2636 // Âêëþ÷åí ëè òðèããåð:
2637 Mem
.WriteBoolean(gTriggers
[i
].Enabled
);
2638 // Òèï àêòèâàöèè òðèããåðà:
2639 Mem
.WriteByte(gTriggers
[i
].ActivateType
);
2640 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè:
2641 Mem
.WriteByte(gTriggers
[i
].Keys
);
2642 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ:
2643 Mem
.WriteInt(gTriggers
[i
].TexturePanel
);
2645 Mem
.WriteWord(gTriggers
[i
].TexturePanelType
);
2646 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
2647 Mem
.WriteWord(gTriggers
[i
].TimeOut
);
2648 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
2649 Mem
.WriteWord(gTriggers
[i
].ActivateUID
);
2650 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
2651 act_count
:= Length(gTriggers
[i
].Activators
);
2652 Mem
.WriteInt(act_count
);
2653 for j
:= 0 to act_count
-1 do
2656 Mem
.WriteWord(gTriggers
[i
].Activators
[j
].UID
);
2658 Mem
.WriteWord(gTriggers
[i
].Activators
[j
].TimeOut
);
2660 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà:
2661 Mem
.WriteBoolean(gTriggers
[i
].PlayerCollide
);
2662 // Âðåìÿ äî çàêðûòèÿ äâåðè:
2663 Mem
.WriteInt(gTriggers
[i
].DoorTime
);
2664 // Çàäåðæêà àêòèâàöèè:
2665 Mem
.WriteInt(gTriggers
[i
].PressTime
);
2667 Mem
.WriteInt(gTriggers
[i
].PressCount
);
2669 Mem
.WriteBoolean(gTriggers
[i
].AutoSpawn
);
2670 // Çàäåðæêà ñïàâíåðà:
2671 Mem
.WriteInt(gTriggers
[i
].SpawnCooldown
);
2672 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ:
2673 Mem
.WriteInt(gTriggers
[i
].SpawnedCount
);
2674 // Ñêîëüêî ðàç ïðîèãðàí çâóê:
2675 Mem
.WriteInt(gTriggers
[i
].SoundPlayCount
);
2676 // Ïðîèãðûâàåòñÿ ëè çâóê?
2677 if gTriggers
[i
].Sound
<> nil then
2678 b
:= gTriggers
[i
].Sound
.IsPlaying()
2681 Mem
.WriteBoolean(b
);
2684 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà:
2685 dw
:= gTriggers
[i
].Sound
.GetPosition();
2688 sg
:= gTriggers
[i
].Sound
.GetVolume();
2689 sg
:= sg
/ (gSoundLevel
/255.0);
2690 Mem
.WriteSingle(sg
);
2691 // Ñòåðåî ñìåùåíèå çâóêà:
2692 sg
:= gTriggers
[i
].Sound
.GetPan();
2693 Mem
.WriteSingle(sg
);
2698 procedure g_Triggers_LoadState(var Mem
: TBinMemoryReader
);
2700 count
, act_count
, i
, j
, a
: Integer;
2712 // Êîëè÷åñòâî òðèããåðîâ:
2718 for a
:= 0 to count
-1 do
2720 // Ñèãíàòóðà òðèããåðà:
2722 if dw
<> TRIGGER_SIGNATURE
then // 'TRGR'
2724 raise EBinSizeError
.Create('g_Triggers_LoadState: Wrong Trigger Signature');
2727 Mem
.ReadByte(Trig
.TriggerType
);
2728 // Ñïåöèàëüíûå äàííûå òðèããåðà:
2729 Mem
.ReadMemory(p
, dw
);
2730 if dw
<> SizeOf(TTriggerData
) then
2732 raise EBinSizeError
.Create('g_Triggers_LoadState: Wrong TriggerData Size');
2734 Trig
.Data
:= TTriggerData(p
^);
2736 i
:= g_Triggers_Create(Trig
);
2737 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
2738 Mem
.ReadInt(gTriggers
[i
].X
);
2739 Mem
.ReadInt(gTriggers
[i
].Y
);
2741 Mem
.ReadWord(gTriggers
[i
].Width
);
2742 Mem
.ReadWord(gTriggers
[i
].Height
);
2743 // Âêëþ÷åí ëè òðèããåð:
2744 Mem
.ReadBoolean(gTriggers
[i
].Enabled
);
2745 // Òèï àêòèâàöèè òðèããåðà:
2746 Mem
.ReadByte(gTriggers
[i
].ActivateType
);
2747 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè:
2748 Mem
.ReadByte(gTriggers
[i
].Keys
);
2749 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ:
2750 Mem
.ReadInt(gTriggers
[i
].TexturePanel
);
2752 Mem
.ReadWord(gTriggers
[i
].TexturePanelType
);
2753 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
2754 Mem
.ReadWord(gTriggers
[i
].TimeOut
);
2755 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
2756 Mem
.ReadWord(gTriggers
[i
].ActivateUID
);
2757 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
2758 Mem
.ReadInt(act_count
);
2759 if act_count
> 0 then
2761 SetLength(gTriggers
[i
].Activators
, act_count
);
2762 for j
:= 0 to act_count
-1 do
2765 Mem
.ReadWord(gTriggers
[i
].Activators
[j
].UID
);
2767 Mem
.ReadWord(gTriggers
[i
].Activators
[j
].TimeOut
);
2770 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà:
2771 Mem
.ReadBoolean(gTriggers
[i
].PlayerCollide
);
2772 // Âðåìÿ äî çàêðûòèÿ äâåðè:
2773 Mem
.ReadInt(gTriggers
[i
].DoorTime
);
2774 // Çàäåðæêà àêòèâàöèè:
2775 Mem
.ReadInt(gTriggers
[i
].PressTime
);
2777 Mem
.ReadInt(gTriggers
[i
].PressCount
);
2779 Mem
.ReadBoolean(gTriggers
[i
].AutoSpawn
);
2780 // Çàäåðæêà ñïàâíåðà:
2781 Mem
.ReadInt(gTriggers
[i
].SpawnCooldown
);
2782 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ:
2783 Mem
.ReadInt(gTriggers
[i
].SpawnedCount
);
2784 // Ñêîëüêî ðàç ïðîèãðàí çâóê:
2785 Mem
.ReadInt(gTriggers
[i
].SoundPlayCount
);
2786 // Ïðîèãðûâàåòñÿ ëè çâóê?
2790 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà:
2793 Mem
.ReadSingle(vol
);
2794 // Ñòåðåî ñìåùåíèå çâóêà:
2795 Mem
.ReadSingle(pan
);
2796 // Çàïóñêàåì çâóê, åñëè åñòü:
2797 if gTriggers
[i
].Sound
<> nil then
2799 gTriggers
[i
].Sound
.PlayPanVolume(pan
, vol
);
2800 gTriggers
[i
].Sound
.Pause(True);
2801 gTriggers
[i
].Sound
.SetPosition(dw
);