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, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
21 SysUtils
, Variants
, Classes
,
22 MAPDEF
, g_basic
, g_sound
,
23 xdynrec
, hashtable
, exoma
;
42 TexturePanelGUID
: Integer;
43 //TexturePanelType: Word;
47 Activators
: array of TActivator
;
48 PlayerCollide
: Boolean;
52 SoundPlayCount
: Integer;
53 Sound
: TPlayableSound
;
55 SpawnCooldown
: Integer;
56 SpawnedCount
: Integer;
57 //ShotPanelType: Word;
58 ShotPanelTime
: Integer;
59 ShotSightTime
: Integer;
60 ShotSightTimeout
: Integer;
61 ShotSightTarget
: Word;
62 ShotSightTargetN
: Word;
64 ShotReloadTime
: Integer;
66 mapId
: AnsiString; // trigger id, from map
67 mapIndex
: Integer; // index in fields['trigger'], used in save/load
68 trigPanelGUID
: Integer;
70 trigDataRec
: TDynRecord
; // triggerdata; owned by trigger (cloned)
71 exoInit
, exoThink
, exoCheck
, exoAction
: TExprBase
;
73 userVars
: THashStrVariant
;
75 {$INCLUDE ../shared/mapdef_tgc_def.inc}
78 function trigCenter (): TDFPoint
; inline;
81 function g_Triggers_Create (aTrigger
: TTrigger
; trec
: TDynRecord
; forceInternalIndex
: Integer=-1): DWORD
;
82 procedure g_Triggers_Update();
83 procedure g_Triggers_Press(ID
: DWORD
; ActivateType
: Byte; ActivateUID
: Word = 0);
84 function g_Triggers_PressR(X
, Y
: Integer; Width
, Height
: Word; UID
: Word;
85 ActivateType
: Byte; IgnoreList
: DWArray
= nil): DWArray
;
86 procedure g_Triggers_PressL(X1
, Y1
, X2
, Y2
: Integer; UID
: DWORD
; ActivateType
: Byte);
87 procedure g_Triggers_PressC(CX
, CY
: Integer; Radius
: Word; UID
: Word; ActivateType
: Byte; IgnoreTrigger
: Integer = -1);
88 procedure g_Triggers_OpenAll();
89 procedure g_Triggers_DecreaseSpawner(ID
: DWORD
);
90 procedure g_Triggers_Free();
91 procedure g_Triggers_SaveState (st
: TStream
);
92 procedure g_Triggers_LoadState (st
: TStream
);
96 gTriggerClientID
: Integer = 0;
97 gTriggers
: array of TTrigger
;
98 gSecretsCount
: Integer = 0;
99 gMonstersSpawned
: array of LongInt = nil;
108 {$IFDEF ENABLE_SHELLS}
112 g_player
, g_map
, g_panel
, g_game
,
113 g_console
, g_monsters
, g_items
, g_phys
, g_weapons
,
114 wadreader
, e_log
, g_language
, e_res
,
115 g_options
, g_net
, g_netmsg
, utils
, xparser
, xstreams
119 TRIGGER_SIGNATURE
= $58475254; // 'TRGX'
122 {$INCLUDE ../shared/mapdef_tgc_impl.inc}
125 // ////////////////////////////////////////////////////////////////////////// //
127 TTrigScope
= class(TExprScope
)
130 monsprops
: TPropHash
;
131 platprops
: TPropHash
;
137 constructor Create ();
138 destructor Destroy (); override;
140 function getObj (const aname
: AnsiString): TObject
; override;
141 function getField (obj
: TObject
; const afldname
: AnsiString): Variant; override;
142 procedure setField (obj
: TObject
; const afldname
: AnsiString; var aval
: Variant); override;
146 // ////////////////////////////////////////////////////////////////////////// //
148 TMyConstList
= class(TExprConstList
)
150 function valid (const cname
: AnsiString): Boolean; override;
151 function get (const cname
: AnsiString; out v
: Variant): Boolean; override;
155 // ////////////////////////////////////////////////////////////////////////// //
156 function TMyConstList
.valid (const cname
: AnsiString): Boolean;
158 //writeln('CHECK: ''', cname, '''');
160 (cname
= 'player') or
165 function TMyConstList
.get (const cname
: AnsiString; out v
: Variant): Boolean;
170 //if (cname = 'answer') then begin v := LongInt(42); result := true; exit; end;
172 if (gCurrentMap
= nil) then exit
;
173 for eidx
:= 0 to gCurrentMap
.mapdef
.ebsTypeCount
-1 do
175 ebs
:= gCurrentMap
.mapdef
.ebsTypeAt
[eidx
];
176 if ebs
.has
[cname
] then
178 //writeln('FOUND: ''', cname, '''');
187 // ////////////////////////////////////////////////////////////////////////// //
188 constructor TTrigScope
.Create ();
190 plrprops
:= TPropHash
.Create(TPlayer
, 'e');
191 monsprops
:= TPropHash
.Create(TMonster
, 'e');
192 platprops
:= TPropHash
.Create(TPanel
, 'e');
197 destructor TTrigScope
.Destroy ();
206 function TTrigScope
.getObj (const aname
: AnsiString): TObject
;
208 if (aname
= 'player') then result
:= gPlayers
[0] //FIXME
209 else if (aname
= 'self') or (aname
= 'this') then result
:= TObject(Pointer(PtrUInt(1)))
210 else result
:= inherited getObj(aname
);
214 function TTrigScope
.getField (obj
: TObject
; const afldname
: AnsiString): Variant;
216 if (obj
= gPlayers
[0]) then
218 if plrprops
.get(obj
, afldname
, result
) then exit
;
220 else if (obj
= TObject(Pointer(PtrUInt(1)))) then
222 if (me
<> nil) and (me
.userVars
<> nil) then
224 if me
.userVars
.get(afldname
, result
) then exit
;
227 result
:= inherited getField(obj
, afldname
);
231 procedure TTrigScope
.setField (obj
: TObject
; const afldname
: AnsiString; var aval
: Variant);
233 if (obj
= gPlayers
[0]) then
235 if plrprops
.put(obj
, afldname
, aval
) then exit
;
237 else if (obj
= TObject(Pointer(PtrUInt(1)))) then
241 if (Length(afldname
) > 4) and (afldname
[1] = 'u') and (afldname
[2] = 's') and
242 (afldname
[3] = 'e') and (afldname
[4] = 'r') then
244 if (me
.userVars
= nil) then me
.userVars
:= THashStrVariant
.Create();
245 me
.userVars
.put(afldname
, aval
);
250 inherited setField(obj
, afldname
, aval
);
254 // ////////////////////////////////////////////////////////////////////////// //
256 tgscope
: TTrigScope
= nil;
257 tgclist
: TMyConstList
= nil;
260 // ////////////////////////////////////////////////////////////////////////// //
261 function TTrigger
.trigCenter (): TDFPoint
; inline;
263 result
:= TDFPoint
.Create(x
+width
div 2, y
+height
div 2);
267 function FindTrigger (): DWORD
;
271 olen
:= Length(gTriggers
);
273 for i
:= 0 to olen
-1 do
275 if gTriggers
[i
].TriggerType
= TRIGGER_NONE
then begin result
:= i
; exit
; end;
278 SetLength(gTriggers
, olen
+8);
281 for i
:= result
to High(gTriggers
) do
283 gTriggers
[i
].TriggerType
:= TRIGGER_NONE
;
284 gTriggers
[i
].trigDataRec
:= nil;
285 gTriggers
[i
].exoInit
:= nil;
286 gTriggers
[i
].exoThink
:= nil;
287 gTriggers
[i
].exoCheck
:= nil;
288 gTriggers
[i
].exoAction
:= nil;
289 gTriggers
[i
].userVars
:= nil;
294 function tr_CloseDoor (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
301 pan
:= g_Map_PanelByGUID(PanelGUID
);
302 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
303 PanelID
:= pan
.arrIdx
;
307 with gWalls
[PanelID
] do
309 if g_CollidePlayer(X
, Y
, Width
, Height
) or g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then Exit
;
314 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
315 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
317 g_Map_EnableWallGUID(PanelGUID
);
324 if (gDoorMap
= nil) then exit
;
327 for a
:= 0 to High(gDoorMap
) do
329 for b
:= 0 to High(gDoorMap
[a
]) do
331 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
337 if (c
<> -1) then break
;
339 if (c
= -1) then exit
;
341 for b
:= 0 to High(gDoorMap
[c
]) do
343 with gWalls
[gDoorMap
[c
, b
]] do
345 if g_CollidePlayer(X
, Y
, Width
, Height
) or g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then exit
;
351 for b
:= 0 to High(gDoorMap
[c
]) do
353 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
355 with gWalls
[PanelID
] do
357 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
358 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
365 for b
:= 0 to High(gDoorMap
[c
]) do
367 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
369 g_Map_EnableWall_XXX(gDoorMap
[c
, b
]);
377 procedure tr_CloseTrap (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean);
380 wx
, wy
, wh
, ww
: Integer;
384 function monsDamage (mon
: TMonster
): Boolean;
386 result
:= false; // don't stop
387 if g_Obj_Collide(wx
, wy
, ww
, wh
, @mon
.Obj
) then mon
.Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
391 pan
:= g_Map_PanelByGUID(PanelGUID
);
395 e_LogWritefln('tr_CloseTrap: pguid=%s; NO PANEL!', [PanelGUID], MSG_WARNING);
399 e_LogWritefln('tr_CloseTrap: pguid=%s; isGWall=%s; arrIdx=%s', [PanelGUID, pan.isGWall, pan.arrIdx]);
402 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
403 PanelID
:= pan
.arrIdx
;
407 with gWalls
[PanelID
] do
409 if (not NoSound
) and (not Enabled
) then
411 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
412 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
416 wx
:= gWalls
[PanelID
].X
;
417 wy
:= gWalls
[PanelID
].Y
;
418 ww
:= gWalls
[PanelID
].Width
;
419 wh
:= gWalls
[PanelID
].Height
;
421 with gWalls
[PanelID
] do
423 if gPlayers
<> nil then
425 for a
:= 0 to High(gPlayers
) do
427 if (gPlayers
[a
] <> nil) and gPlayers
[a
].alive
and gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
429 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
434 //g_Mons_ForEach(monsDamage);
435 g_Mons_ForEachAliveAt(wx
, wy
, ww
, wh
, monsDamage
);
437 if not Enabled
then g_Map_EnableWallGUID(PanelGUID
);
442 if (gDoorMap
= nil) then exit
;
445 for a
:= 0 to High(gDoorMap
) do
447 for b
:= 0 to High(gDoorMap
[a
]) do
449 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
455 if (c
<> -1) then break
;
457 if (c
= -1) then exit
;
461 for b
:= 0 to High(gDoorMap
[c
]) do
463 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
465 with gWalls
[PanelID
] do
467 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
468 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
475 for b
:= 0 to High(gDoorMap
[c
]) do
477 wx
:= gWalls
[gDoorMap
[c
, b
]].X
;
478 wy
:= gWalls
[gDoorMap
[c
, b
]].Y
;
479 ww
:= gWalls
[gDoorMap
[c
, b
]].Width
;
480 wh
:= gWalls
[gDoorMap
[c
, b
]].Height
;
482 with gWalls
[gDoorMap
[c
, b
]] do
484 if gPlayers
<> nil then
486 for a
:= 0 to High(gPlayers
) do
488 if (gPlayers
[a
] <> nil) and gPlayers
[a
].alive
and gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
490 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
495 //g_Mons_ForEach(monsDamage);
496 g_Mons_ForEachAliveAt(wx
, wy
, ww
, wh
, monsDamage
);
498 if gMonsters <> nil then
499 for a := 0 to High(gMonsters) do
500 if (gMonsters[a] <> nil) and gMonsters[a].alive and
501 g_Obj_Collide(X, Y, Width, Height, @gMonsters[a].Obj) then
502 gMonsters[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
505 if not Enabled
then g_Map_EnableWall_XXX(gDoorMap
[c
, b
]);
512 function tr_OpenDoor (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
519 pan
:= g_Map_PanelByGUID(PanelGUID
);
520 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
521 PanelID
:= pan
.arrIdx
;
525 with gWalls
[PanelID
] do
531 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
532 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
534 g_Map_DisableWallGUID(PanelGUID
);
541 if (gDoorMap
= nil) then exit
;
544 for a
:= 0 to High(gDoorMap
) do
546 for b
:= 0 to High(gDoorMap
[a
]) do
548 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
554 if (c
<> -1) then break
;
556 if (c
= -1) then exit
;
560 for b
:= 0 to High(gDoorMap
[c
]) do
562 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
564 with gWalls
[PanelID
] do
566 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
567 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
574 for b
:= 0 to High(gDoorMap
[c
]) do
576 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
578 g_Map_DisableWall_XXX(gDoorMap
[c
, b
]);
586 function tr_SetLift (PanelGUID
: Integer; d
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
594 pan
:= g_Map_PanelByGUID(PanelGUID
);
595 if (pan
= nil) or not pan
.isGLift
then exit
; //!FIXME!TRIGANY!
596 PanelID
:= pan
.arrIdx
;
598 if (gLifts
[PanelID
].PanelType
= PANEL_LIFTUP
) or (gLifts
[PanelID
].PanelType
= PANEL_LIFTDOWN
) then
602 1: t
:= LIFTTYPE_DOWN
;
603 else t
:= IfThen(gLifts
[PanelID
].LiftType
= LIFTTYPE_DOWN
, LIFTTYPE_UP
, LIFTTYPE_DOWN
);
606 else if (gLifts
[PanelID
].PanelType
= PANEL_LIFTLEFT
) or (gLifts
[PanelID
].PanelType
= PANEL_LIFTRIGHT
) then
609 0: t
:= LIFTTYPE_LEFT
;
610 1: t
:= LIFTTYPE_RIGHT
;
611 else t
:= IfThen(gLifts
[PanelID
].LiftType
= LIFTTYPE_LEFT
, LIFTTYPE_RIGHT
, LIFTTYPE_LEFT
);
617 with gLifts
[PanelID
] do
619 if (LiftType
<> t
) then
621 g_Map_SetLiftGUID(PanelGUID
, t
); //???
622 //if not NoSound then g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
629 if (gLiftMap
= nil) then exit
;
632 for a
:= 0 to High(gLiftMap
) do
634 for b
:= 0 to High(gLiftMap
[a
]) do
636 if (gLiftMap
[a
, b
] = DWORD(PanelID
)) then
642 if (c
<> -1) then break
;
644 if (c
= -1) then exit
;
647 for b := 0 to High(gLiftMap[c]) do
648 if gLifts[gLiftMap[c, b]].LiftType <> t then
650 with gLifts[PanelID] do
651 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
655 for b
:= 0 to High(gLiftMap
[c
]) do
657 with gLifts
[gLiftMap
[c
, b
]] do
659 if (LiftType
<> t
) then
661 g_Map_SetLift_XXX(gLiftMap
[c
, b
], t
);
670 function tr_SpawnShot (ShotType
: Integer; wx
, wy
, dx
, dy
: Integer; ShotSound
: Boolean; ShotTarget
: Word): Integer;
676 snd
:= 'SOUND_WEAPON_FIREROCKET';
682 g_Weapon_pistol(wx
, wy
, dx
, dy
, 0, True);
683 snd
:= 'SOUND_WEAPON_FIREPISTOL';
687 {$IFDEF ENABLE_SHELLS}
688 g_Shells_Create(wx
, wy
, 0, -2, SHELL_BULLET
);
690 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
696 g_Weapon_mgun(wx
, wy
, dx
, dy
, 0, True);
697 if gSoundEffectsDF
then snd
:= 'SOUND_WEAPON_FIRECGUN'
698 else snd
:= 'SOUND_WEAPON_FIREPISTOL';
702 {$IFDEF ENABLE_SHELLS}
703 g_Shells_Create(wx
, wy
, 0, -2, SHELL_BULLET
);
705 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
709 TRIGGER_SHOT_SHOTGUN
:
711 g_Weapon_Shotgun(wx
, wy
, dx
, dy
, 0, True);
712 snd
:= 'SOUND_WEAPON_FIRESHOTGUN';
716 {$IFDEF ENABLE_SHELLS}
717 g_Shells_Create(wx
, wy
, 0, -2, SHELL_SHELL
);
719 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL2
);
725 g_Weapon_DShotgun(wx
, wy
, dx
, dy
, 0, True);
726 snd
:= 'SOUND_WEAPON_FIRESHOTGUN2';
730 {$IFDEF ENABLE_SHELLS}
731 g_Shells_Create(wx
, wy
, 0, -2, SHELL_SHELL
);
732 g_Shells_Create(wx
, wy
, 0, -2, SHELL_SHELL
);
734 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL3
);
740 g_Weapon_ball1(wx
, wy
, dx
, dy
, 0, -1, True);
741 snd
:= 'SOUND_WEAPON_FIREBALL';
746 g_Weapon_Plasma(wx
, wy
, dx
, dy
, 0, -1, True);
747 snd
:= 'SOUND_WEAPON_FIREPLASMA';
752 g_Weapon_aplasma(wx
, wy
, dx
, dy
, 0, -1, True);
753 snd
:= 'SOUND_WEAPON_FIREPLASMA';
758 g_Weapon_ball2(wx
, wy
, dx
, dy
, 0, -1, True);
759 snd
:= 'SOUND_WEAPON_FIREBALL';
764 g_Weapon_ball7(wx
, wy
, dx
, dy
, 0, -1, True);
765 snd
:= 'SOUND_WEAPON_FIREBALL';
770 g_Weapon_manfire(wx
, wy
, dx
, dy
, 0, -1, True);
771 snd
:= 'SOUND_WEAPON_FIREBALL';
776 g_Weapon_revf(wx
, wy
, dx
, dy
, 0, ShotTarget
, -1, True);
777 snd
:= 'SOUND_WEAPON_FIREREV';
782 g_Weapon_Rocket(wx
, wy
, dx
, dy
, 0, -1, True);
783 snd
:= 'SOUND_WEAPON_FIREROCKET';
788 g_Weapon_BFGShot(wx
, wy
, dx
, dy
, 0, -1, True);
789 snd
:= 'SOUND_WEAPON_FIREBFG';
795 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, wx
- 64, wy
- 64);
798 g_Weapon_Explode(wx
, wy
, 60, 0);
799 snd
:= 'SOUND_WEAPON_EXPLODEROCKET';
802 TRIGGER_SHOT_BFGEXPL
:
805 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, wx
- 64, wy
- 64);
808 g_Weapon_BFG9000(wx
, wy
, 0);
809 snd
:= 'SOUND_WEAPON_EXPLODEBFG';
814 g_Weapon_flame(wx
, wy
, dx
, dy
, 0, -1, True);
815 snd
:= 'SOUND_GAME_BURNING';
821 if g_Game_IsNet
and g_Game_IsServer
then
824 TRIGGER_SHOT_EXPL
: MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_EXPLODE
);
825 TRIGGER_SHOT_BFGEXPL
: MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_BFGEXPL
);
828 if Projectile
then MH_SEND_CreateShot(LastShotID
);
829 if ShotSound
then MH_SEND_Sound(wx
, wy
, snd
);
834 if ShotSound
then g_Sound_PlayExAt(snd
, wx
, wy
);
836 if Projectile
then Result
:= LastShotID
;
840 procedure MakeShot (var Trigger
: TTrigger
; wx
, wy
, dx
, dy
: Integer; TargetUID
: Word);
844 if (tgcAmmo
= 0) or ((tgcAmmo
> 0) and (ShotAmmoCount
> 0)) then
846 if (trigPanelGUID
<> -1) and (ShotPanelTime
= 0) then
848 g_Map_SwitchTextureGUID({ShotPanelType,} trigPanelGUID
);
849 ShotPanelTime
:= 4; // òèêîâ íà âñïûøêó âûñòðåëà
852 if (tgcSight
> 0) then ShotSightTimeout
:= 180; // ~= 5 ñåêóíä
854 if (ShotAmmoCount
> 0) then Dec(ShotAmmoCount
);
856 dx
+= Random(tgcAccuracy
)-Random(tgcAccuracy
);
857 dy
+= Random(tgcAccuracy
)-Random(tgcAccuracy
);
859 tr_SpawnShot(tgcShotType
, wx
, wy
, dx
, dy
, tgcShotSound
, TargetUID
);
863 if (tgcReload
> 0) and (ShotReloadTime
= 0) then
865 ShotReloadTime
:= tgcReload
; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
872 procedure tr_MakeEffect (X
, Y
, VX
, VY
: Integer; T
, ST
, CR
, CG
, CB
: Byte; Silent
, Send
: Boolean);
875 if T
= TRIGGER_EFFECT_PARTICLE
then
878 TRIGGER_EFFECT_SLIQUID
:
880 if (CR
= 255) and (CG
= 0) and (CB
= 0) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 1, 0, 0, 0)
881 else if (CR
= 0) and (CG
= 255) and (CB
= 0) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 2, 0, 0, 0)
882 else if (CR
= 0) and (CG
= 0) and (CB
= 255) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 3, 0, 0, 0)
883 else g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 0, 0, 0, 0);
885 TRIGGER_EFFECT_LLIQUID
: g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 4, CR
, CG
, CB
);
886 TRIGGER_EFFECT_DLIQUID
: g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 5, CR
, CG
, CB
);
887 TRIGGER_EFFECT_BLOOD
: g_GFX_Blood(X
, Y
, 1, VX
, VY
, 0, 0, CR
, CG
, CB
);
888 TRIGGER_EFFECT_SPARK
: g_GFX_Spark(X
, Y
, 1, GetAngle2(VX
, VY
), 0, 0);
889 TRIGGER_EFFECT_BUBBLE
: g_GFX_Bubbles(X
, Y
, 1, 0, 0);
894 if T
= TRIGGER_EFFECT_ANIMATION
then
897 EFFECT_TELEPORT
: begin
898 if not Silent
then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X
, Y
);
900 g_GFX_QueueEffect(R_GFX_TELEPORT_FAST
, X
- 32, Y
- 32);
902 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
, Y
, Byte(not Silent
), NET_GFX_TELE
);
904 EFFECT_RESPAWN
: begin
905 if not Silent
then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X
, Y
);
907 g_GFX_QueueEffect(R_GFX_ITEM_RESPAWN
, X
- 16, Y
- 16);
909 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
-16, Y
-16, Byte(not Silent
), NET_GFX_RESPAWN
);
912 if not Silent
then g_Sound_PlayExAt('SOUND_FIRE', X
, Y
);
914 g_GFX_QueueEffect(R_GFX_FIRE
, X
- 32, Y
- 128);
916 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
-32, Y
-128, Byte(not Silent
), NET_GFX_FIRE
);
923 function tr_Teleport (ActivateUID
: Integer; TX
, TY
: Integer; TDir
: Integer; Silent
: Boolean; D2D
: Boolean): Boolean;
929 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
930 case g_GetUIDType(ActivateUID
) of
933 p
:= g_Player_Get(ActivateUID
);
934 if p
= nil then Exit
;
937 if p
.TeleportTo(TX
-(p
.Obj
.Rect
.Width
div 2), TY
-p
.Obj
.Rect
.Height
, Silent
, TDir
) then result
:= true;
941 if p
.TeleportTo(TX
, TY
, Silent
, TDir
) then result
:= true;
946 m
:= g_Monsters_ByUID(ActivateUID
);
947 if m
= nil then Exit
;
950 if m
.TeleportTo(TX
-(m
.Obj
.Rect
.Width
div 2), TY
-m
.Obj
.Rect
.Height
, Silent
, TDir
) then result
:= true;
954 if m
.TeleportTo(TX
, TY
, Silent
, TDir
) then result
:= true;
961 function tr_Push (ActivateUID
: Integer; VX
, VY
: Integer; ResetVel
: Boolean): Boolean;
967 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then exit
;
968 case g_GetUIDType(ActivateUID
) of
971 p
:= g_Player_Get(ActivateUID
);
972 if p
= nil then Exit
;
987 m
:= g_Monsters_ByUID(ActivateUID
);
988 if m
= nil then Exit
;
1004 function tr_Message (MKind
: Integer; MText
: string; MSendTo
: Integer; MTime
: Integer; ActivateUID
: Integer): Boolean;
1011 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
1012 msg
:= b_Text_Format(MText
);
1014 TRIGGER_MESSAGE_DEST_ME
: // activator
1016 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1018 if g_Game_IsWatchedPlayer(ActivateUID
) then
1020 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1021 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1025 p
:= g_Player_Get(ActivateUID
);
1026 if g_Game_IsNet
and (p
.FClientID
>= 0) then
1028 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, p
.FClientID
)
1029 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, p
.FClientID
);
1035 TRIGGER_MESSAGE_DEST_MY_TEAM
: // activator's team
1037 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1039 p
:= g_Player_Get(ActivateUID
);
1040 if g_Game_IsWatchedTeam(p
.Team
) then
1042 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1043 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1046 if g_Game_IsNet
then
1048 for i
:= Low(gPlayers
) to High(gPlayers
) do
1050 if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
1052 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1053 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1060 TRIGGER_MESSAGE_DEST_ENEMY_TEAM
: // activator's enemy team
1062 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1064 p
:= g_Player_Get(ActivateUID
);
1065 if g_Game_IsWatchedTeam(p
.Team
) then
1067 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1068 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1071 if g_Game_IsNet
then
1073 for i
:= Low(gPlayers
) to High(gPlayers
) do
1075 if (gPlayers
[i
].Team
<> p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
1077 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1078 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1085 TRIGGER_MESSAGE_DEST_RED_TEAM
: // red team
1087 if g_Game_IsWatchedTeam(TEAM_RED
) then
1089 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1090 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1093 if g_Game_IsNet
then
1095 for i
:= Low(gPlayers
) to High(gPlayers
) do
1097 if (gPlayers
[i
].Team
= TEAM_RED
) and (gPlayers
[i
].FClientID
>= 0) then
1099 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1100 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1106 TRIGGER_MESSAGE_DEST_BLUE_TEAM
: // blue team
1108 if g_Game_IsWatchedTeam(TEAM_BLUE
) then
1110 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1111 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1114 if g_Game_IsNet
then
1116 for i
:= Low(gPlayers
) to High(gPlayers
) do
1118 if (gPlayers
[i
].Team
= TEAM_BLUE
) and (gPlayers
[i
].FClientID
>= 0) then
1120 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1121 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1127 TRIGGER_MESSAGE_DEST_EVERYONE
: // everyone
1129 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1130 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1132 if g_Game_IsNet
then
1134 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
)
1135 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
);
1142 function tr_ShotAimCheck (var Trigger
: TTrigger
; Obj
: PObj
): Boolean;
1147 if TriggerType
<> TRIGGER_SHOT
then Exit
;
1148 result
:= (tgcAim
and TRIGGER_SHOT_AIM_ALLMAP
> 0)
1149 or g_Obj_Collide(X
, Y
, Width
, Height
, Obj
);
1150 if result
and (tgcAim
and TRIGGER_SHOT_AIM_TRACE
> 0) then
1152 result
:= g_TraceVector(tgcTX
, tgcTY
,
1153 Obj
^.X
+ Obj
^.Rect
.X
+ (Obj
^.Rect
.Width
div 2),
1154 Obj
^.Y
+ Obj
^.Rect
.Y
+ (Obj
^.Rect
.Height
div 2));
1160 function ActivateTrigger (var Trigger
: TTrigger
; actType
: Byte): Boolean;
1166 idx
, k
, wx
, wy
, xd
, yd
: Integer;
1175 function monsShotTarget (mon
: TMonster
): Boolean;
1177 result
:= false; // don't stop
1178 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1180 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1181 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1182 TargetUID
:= mon
.UID
;
1183 result
:= true; // stop
1187 function monsShotTargetMonPlr (mon
: TMonster
): Boolean;
1189 result
:= false; // don't stop
1190 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1192 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1193 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1194 TargetUID
:= mon
.UID
;
1195 result
:= true; // stop
1199 function monShotTargetPlrMon (mon
: TMonster
): Boolean;
1201 result
:= false; // don't stop
1202 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1204 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1205 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1206 TargetUID
:= mon
.UID
;
1207 result
:= true; // stop
1215 if g_Game_IsClient
then exit
;
1217 if not Trigger
.Enabled
then exit
;
1218 if (Trigger
.TimeOut
<> 0) and (actType
<> ACTIVATE_CUSTOM
) then exit
;
1219 if (gLMSRespawn
> LMS_RESPAWN_NONE
) then exit
;
1221 if (Trigger
.exoCheck
<> nil) then
1223 //conwritefln('exocheck: [%s]', [Trigger.exoCheck.toString()]);
1225 tgscope
.me
:= @Trigger
;
1226 tvval
:= Trigger
.exoCheck
.value(tgscope
);
1228 if not Boolean(tvval
) then exit
;
1229 except on e
: Exception
do
1232 conwritefln('trigger exocheck error: %s [%s]', [e
.message, Trigger
.exoCheck
.toString()]);
1240 coolDown
:= (actType
<> 0);
1242 if (Trigger
.exoAction
<> nil) then
1244 //conwritefln('exoactivate: [%s]', [Trigger.exoAction.toString()]);
1246 tgscope
.me
:= @Trigger
;
1247 Trigger
.exoAction
.value(tgscope
);
1249 except on e
: Exception
do
1252 conwritefln('trigger exoactivate error: %s [%s]', [e
.message, Trigger
.exoAction
.toString()]);
1263 g_Sound_PlayEx('SOUND_GAME_SWITCH0');
1264 if g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH0');
1265 gExitByTrigger
:= True;
1266 g_Game_ExitLevel(tgcMap
);
1275 Result
:= tr_Teleport(ActivateUID
,
1276 tgcTarget
.X
, tgcTarget
.Y
,
1277 tgcDirection
, tgcSilent
,
1284 Result
:= tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1290 Result
:= tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1294 TRIGGER_DOOR
, TRIGGER_DOOR5
:
1296 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
1297 if (pan
<> nil) and pan
.isGWall
then
1299 if gWalls
[{trigPanelID}pan
.arrIdx
].Enabled
then
1301 result
:= tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1302 if (TriggerType
= TRIGGER_DOOR5
) then DoorTime
:= 180;
1306 result
:= tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1309 if result
then TimeOut
:= 18;
1313 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1315 tr_CloseTrap(trigPanelGUID
, tgcSilent
, tgcD2d
);
1317 if TriggerType
= TRIGGER_TRAP
then
1331 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
1334 if PressTime
= -1 then PressTime
:= tgcWait
;
1335 if coolDown
then TimeOut
:= 18 else TimeOut
:= 0;
1340 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1344 p
:= g_Player_Get(ActivateUID
);
1346 Inc(gCoopSecretsFound
);
1347 if g_Game_IsNet
then
1349 MH_SEND_GameStats();
1350 MH_SEND_GameEvent(NET_EV_SECRET
, p
.UID
, '');
1356 Result
:= tr_SetLift(trigPanelGUID
, 0, tgcSilent
, tgcD2d
);
1359 if (not tgcSilent
) and Result
then begin
1360 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1362 Y
+ (Height
div 2));
1363 if g_Game_IsServer
and g_Game_IsNet
then
1364 MH_SEND_Sound(X
+ (Width
div 2),
1366 'SOUND_GAME_SWITCH0');
1372 Result
:= tr_SetLift(trigPanelGUID
, 1, tgcSilent
, tgcD2d
);
1375 if (not tgcSilent
) and Result
then begin
1376 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1378 Y
+ (Height
div 2));
1379 if g_Game_IsServer
and g_Game_IsNet
then
1380 MH_SEND_Sound(X
+ (Width
div 2),
1382 'SOUND_GAME_SWITCH0');
1388 Result
:= tr_SetLift(trigPanelGUID
, 3, tgcSilent
, tgcD2d
);
1394 if (not tgcSilent
) and Result
then begin
1395 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1397 Y
+ (Height
div 2));
1398 if g_Game_IsServer
and g_Game_IsNet
then
1399 MH_SEND_Sound(X
+ (Width
div 2),
1401 'SOUND_GAME_SWITCH0');
1408 if tgcActivateOnce
then
1411 TriggerType
:= TRIGGER_NONE
;
1419 animonce
:= tgcAnimateOnce
;
1425 if Sound
<> nil then
1427 if tgcSoundSwitch
and Sound
.IsPlaying() then
1428 begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
1430 SoundPlayCount
:= 0;
1433 else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
1434 if (tgcPlayCount
> 0) or (not Sound
.IsPlaying()) then
1436 if tgcPlayCount
> 0 then
1437 SoundPlayCount
:= tgcPlayCount
1438 else // 0 - èãðàåì áåñêîíå÷íî
1439 SoundPlayCount
:= 1;
1442 if g_Game_IsNet
then MH_SEND_TriggerSound(Trigger
);
1446 TRIGGER_SPAWNMONSTER
:
1447 if (tgcSpawnMonsType
in [MONSTER_DEMON
..MONSTER_MAN
]) then
1450 if (tgcDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1452 AutoSpawn
:= not AutoSpawn
;
1454 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1458 if ((tgcDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1459 or ((tgcDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1460 for k
:= 1 to tgcMonsCount
do
1462 if (actType
= ACTIVATE_CUSTOM
) and (tgcDelay
> 0) then
1463 SpawnCooldown
:= -1; // Çàäåðæêà âûñòàâèòñÿ ìîíñòðîì ïðè óíè÷òîæåíèè
1464 if (tgcMax
> 0) and (SpawnedCount
>= tgcMax
) then
1467 mon
:= g_Monsters_Create(tgcSpawnMonsType
,
1469 TDirection(tgcDirection
), True);
1474 if (tgcHealth
> 0) then
1475 mon
.SetHealth(tgcHealth
);
1476 // Óñòàíàâëèâàåì ïîâåäåíèå:
1477 mon
.MonsterBehaviour
:= tgcBehaviour
;
1478 mon
.FNoRespawn
:= True;
1479 if g_Game_IsNet
then
1480 MH_SEND_MonsterSpawn(mon
.UID
);
1481 // Èäåì èñêàòü öåëü, åñëè íàäî:
1485 if tgcSpawnMonsType
<> MONSTER_BARREL
then Inc(gTotalMonsters
);
1487 if g_Game_IsNet
then
1489 SetLength(gMonstersSpawned
, Length(gMonstersSpawned
)+1);
1490 gMonstersSpawned
[High(gMonstersSpawned
)] := mon
.UID
;
1493 mon
.SpawnTrigger
:= ID
;
1494 if tgcMax
> 0 then Inc(SpawnedCount
);
1499 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX
, tgcTY
);
1502 R_GFX_TELEPORT_FAST
,
1503 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1504 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-32
1507 if g_Game_IsServer
and g_Game_IsNet
then
1508 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1509 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-32, 1,
1514 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX
, tgcTY
);
1518 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-16,
1519 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-16
1522 if g_Game_IsServer
and g_Game_IsNet
then
1523 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-16,
1524 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-16, 1,
1529 g_Sound_PlayExAt('SOUND_FIRE', tgcTX
, tgcTY
);
1533 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1534 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+mon
.Obj
.Rect
.Height
-128
1537 if g_Game_IsServer
and g_Game_IsNet
then
1538 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1539 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+mon
.Obj
.Rect
.Height
-128, 1,
1544 if g_Game_IsNet
then
1546 MH_SEND_GameStats();
1547 MH_SEND_CoopStats();
1554 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1555 if actType
= ACTIVATE_CUSTOM
then
1560 if (tgcSpawnItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
]) then
1563 if (tgcDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1565 AutoSpawn
:= not AutoSpawn
;
1567 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1571 if ((tgcDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1572 or ((tgcDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1573 if (not tgcDmonly
) or
1574 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1575 for k
:= 1 to tgcItemCount
do
1577 if (actType
= ACTIVATE_CUSTOM
) and (tgcDelay
> 0) then
1578 SpawnCooldown
:= -1; // Çàäåðæêà âûñòàâèòñÿ èòåìîì ïðè óíè÷òîæåíèè
1579 if (tgcMax
> 0) and (SpawnedCount
>= tgcMax
) then
1582 iid
:= g_Items_Create(tgcTX
, tgcTY
,
1583 tgcSpawnItemType
, tgcGravity
, False, True);
1587 it
:= g_Items_ByIdx(iid
);
1588 it
.SpawnTrigger
:= ID
;
1589 if tgcMax
> 0 then Inc(SpawnedCount
);
1594 it
:= g_Items_ByIdx(iid
);
1595 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX
, tgcTY
);
1598 R_GFX_TELEPORT_FAST
,
1599 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1600 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-32
1603 if g_Game_IsServer
and g_Game_IsNet
then
1604 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1605 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-32, 1,
1610 it
:= g_Items_ByIdx(iid
);
1611 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX
, tgcTY
);
1615 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-16,
1616 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-16
1619 if g_Game_IsServer
and g_Game_IsNet
then
1620 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-16,
1621 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-16, 1,
1626 it
:= g_Items_ByIdx(iid
);
1627 g_Sound_PlayExAt('SOUND_FIRE', tgcTX
, tgcTY
);
1631 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1632 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+it
.Obj
.Rect
.Height
-128
1635 if g_Game_IsServer
and g_Game_IsNet
then
1636 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1637 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+it
.Obj
.Rect
.Height
-128, 1,
1642 if g_Game_IsNet
then
1643 MH_SEND_ItemSpawn(True, iid
);
1650 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1651 if actType
= ACTIVATE_CUSTOM
then
1657 // Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
1658 if (Trigger
.tgcMusicName
<> '') then
1660 gMusic
.SetByName(Trigger
.tgcMusicName
);
1661 gMusic
.SpecPause
:= True;
1665 case Trigger
.tgcMusicAction
of
1666 TRIGGER_MUSIC_ACTION_STOP
: // Âûêëþ÷èòü
1667 gMusic
.SpecPause
:= True; // Ïàóçà
1668 TRIGGER_MUSIC_ACTION_PLAY
: // Âêëþ÷èòü
1669 if gMusic
.SpecPause
then // Áûëà íà ïàóçå => èãðàòü
1670 gMusic
.SpecPause
:= False
1671 else // Èãðàëà => ñíà÷àëà
1672 gMusic
.SetPosition(0);
1680 if g_Game_IsNet
then MH_SEND_TriggerMusic
;
1685 pAngle
:= -DegToRad(tgcAngle
);
1686 Result
:= tr_Push(ActivateUID
,
1687 Floor(Cos(pAngle
)*tgcForce
),
1688 Floor(Sin(pAngle
)*tgcForce
),
1696 // Ïðèáàâèòü èëè îòíÿòü î÷êî
1697 if (tgcScoreAction
in [TRIGGER_SCORE_ACTION_ADD
, TRIGGER_SCORE_ACTION_SUB
]) and (tgcScoreCount
> 0) then
1699 // Ñâîåé èëè ÷óæîé êîìàíäå
1700 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1702 p
:= g_Player_Get(ActivateUID
);
1703 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
))
1704 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1706 Inc(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Scores
1710 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1712 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1713 if g_Game_IsServer
and g_Game_IsNet
then
1714 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+r');
1717 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1718 if g_Game_IsServer
and g_Game_IsNet
then
1719 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+re');
1725 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1726 if g_Game_IsServer
and g_Game_IsNet
then
1727 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1730 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
))
1731 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1733 Dec(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Fouls
1737 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1739 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1740 if g_Game_IsServer
and g_Game_IsNet
then
1741 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-r');
1744 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1745 if g_Game_IsServer
and g_Game_IsNet
then
1746 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-re');
1752 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1753 if g_Game_IsServer
and g_Game_IsNet
then
1754 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1757 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
))
1758 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1760 Inc(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Scores
1764 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1766 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1767 if g_Game_IsServer
and g_Game_IsNet
then
1768 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+b');
1771 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1772 if g_Game_IsServer
and g_Game_IsNet
then
1773 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+be');
1779 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1780 if g_Game_IsServer
and g_Game_IsNet
then
1781 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1784 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
))
1785 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1787 Dec(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Fouls
1791 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1793 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1794 if g_Game_IsServer
and g_Game_IsNet
then
1795 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-b');
1798 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1799 if g_Game_IsServer
and g_Game_IsNet
then
1800 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-be');
1806 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1807 if g_Game_IsServer
and g_Game_IsNet
then
1808 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1811 Result
:= (p
.Team
= TEAM_RED
) or (p
.Team
= TEAM_BLUE
);
1813 // Êàêîé-òî êîíêðåòíîé êîìàíäå
1814 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_RED
, TRIGGER_SCORE_TEAM_FORCE_BLUE
] then
1816 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then
1818 Inc(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Scores
1822 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], tgcScoreCount
]), True);
1823 if g_Game_IsServer
and g_Game_IsNet
then
1824 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '+tr');
1829 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1830 if g_Game_IsServer
and g_Game_IsNet
then
1831 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1834 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then
1836 Dec(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Fouls
1840 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], tgcScoreCount
]), True);
1841 if g_Game_IsServer
and g_Game_IsNet
then
1842 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '-tr');
1847 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1848 if g_Game_IsServer
and g_Game_IsNet
then
1849 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1852 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then
1854 Inc(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Scores
1858 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], tgcScoreCount
]), True);
1859 if g_Game_IsServer
and g_Game_IsNet
then
1860 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '+tb');
1865 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1866 if g_Game_IsServer
and g_Game_IsNet
then
1867 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1870 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then
1872 Dec(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Fouls
1876 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], tgcScoreCount
]), True);
1877 if g_Game_IsServer
and g_Game_IsNet
then
1878 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '-tb');
1883 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1884 if g_Game_IsServer
and g_Game_IsNet
then
1885 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1892 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_WIN
) and (gGameSettings
.GoalLimit
> 0) then
1894 // Ñâîåé èëè ÷óæîé êîìàíäû
1895 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1897 p
:= g_Player_Get(ActivateUID
);
1898 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
)) // Red Wins
1899 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1901 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1903 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1907 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1909 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1910 if g_Game_IsServer
and g_Game_IsNet
then
1911 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1914 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1915 if g_Game_IsServer
and g_Game_IsNet
then
1916 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1923 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
)) // Blue Wins
1924 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1926 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1928 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1932 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1934 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1935 if g_Game_IsServer
and g_Game_IsNet
then
1936 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
1939 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1940 if g_Game_IsServer
and g_Game_IsNet
then
1941 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
1949 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1950 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_RED
, TRIGGER_SCORE_TEAM_FORCE_BLUE
] then
1952 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then // Red Wins
1954 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1956 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1960 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then // Blue Wins
1962 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1964 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1971 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_LOOSE
) and (gGameSettings
.GoalLimit
> 0) then
1973 // Ñâîåé èëè ÷óæîé êîìàíäû
1974 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1976 p
:= g_Player_Get(ActivateUID
);
1977 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
)) // Red Wins
1978 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1979 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1981 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1984 if tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
then
1986 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1987 if g_Game_IsServer
and g_Game_IsNet
then
1988 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1991 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1992 if g_Game_IsServer
and g_Game_IsNet
then
1993 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1998 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
)) // Blue Wins
1999 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
2000 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
2002 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
2005 if tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
then
2007 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
2008 if g_Game_IsServer
and g_Game_IsNet
then
2009 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
2012 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
2013 if g_Game_IsServer
and g_Game_IsNet
then
2014 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
2020 // Êàêîé-òî êîíêðåòíîé êîìàíäû
2021 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_BLUE
, TRIGGER_SCORE_TEAM_FORCE_RED
] then
2023 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then // Red Wins
2025 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
2027 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
2031 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then // Blue Wins
2033 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
2035 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
2041 if Result
then begin
2046 if g_Game_IsServer
and g_Game_IsNet
then
2053 Result
:= tr_Message(tgcKind
, tgcText
,
2054 tgcMsgDest
, tgcMsgTime
,
2059 TRIGGER_DAMAGE
, TRIGGER_HEALTH
:
2062 UIDType
:= g_GetUIDType(ActivateUID
);
2063 if (UIDType
= UID_PLAYER
) or (UIDType
= UID_MONSTER
) then
2069 // Âñïîìèíàåì, àêòèâèðîâàë ëè îí ìåíÿ ðàíüøå
2070 for idx
:= 0 to High(Activators
) do
2071 if Activators
[idx
].UID
= ActivateUID
then
2077 begin // Âèäèì åãî âïåðâûå
2079 SetLength(Activators
, Length(Activators
) + 1);
2080 k
:= High(Activators
);
2081 Activators
[k
].UID
:= ActivateUID
;
2083 begin // Óæå âèäåëè åãî
2084 // Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
2085 if (tgcInterval
= 0) and (Activators
[k
].TimeOut
> 0) then
2086 Activators
[k
].TimeOut
:= 65535;
2087 // Òàéìàóò ïðîø¸ë - ðàáîòàåì
2088 Result
:= Activators
[k
].TimeOut
= 0;
2097 p
:= g_Player_Get(ActivateUID
);
2101 // Íàíîñèì óðîí èãðîêó
2102 if (TriggerType
= TRIGGER_DAMAGE
) and (tgcAmount
> 0) then
2104 // Êèñëîòíûé óðîí íå íàíîñèòñÿ êîãäà åñòü êîñòþì
2105 // "Âîäÿíîé" óðîí íå íàíîñèòñÿ êîãäà åñòü êèñëîðîä
2106 if not (((tgcKind
= HIT_ACID
) and (p
.FMegaRulez
[MR_SUIT
] > gTime
)) or
2107 ((tgcKind
= HIT_WATER
) and (p
.Air
> 0))) then
2108 p
.Damage(tgcAmount
, 0, 0, 0, tgcKind
);
2109 if (tgcKind
= HIT_FLAME
) then p
.CatchFire(0);
2113 if (TriggerType
= TRIGGER_HEALTH
) and (tgcAmount
> 0) then
2114 if p
.Heal(tgcAmount
, not tgcHealMax
) and (not tgcSilent
) then
2116 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p
.Obj
.X
, p
.Obj
.Y
);
2117 if g_Game_IsServer
and g_Game_IsNet
then
2118 MH_SEND_Sound(p
.Obj
.X
, p
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
2124 m
:= g_Monsters_ByUID(ActivateUID
);
2128 // Íàíîñèì óðîí ìîíñòðó
2129 if (TriggerType
= TRIGGER_DAMAGE
) and (tgcAmount
> 0) then
2131 m
.Damage(tgcAmount
, 0, 0, 0, tgcKind
);
2132 if (tgcKind
= HIT_FLAME
) then m
.CatchFire(0);
2136 if (TriggerType
= TRIGGER_HEALTH
) and (tgcAmount
> 0) then
2137 if m
.Heal(tgcAmount
) and (not tgcSilent
) then
2139 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m
.Obj
.X
, m
.Obj
.Y
);
2140 if g_Game_IsServer
and g_Game_IsNet
then
2141 MH_SEND_Sound(m
.Obj
.X
, m
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
2145 // Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
2149 Activators
[k
].TimeOut
:= idx
2151 Activators
[k
].TimeOut
:= 65535;
2159 if ShotSightTime
> 0 then
2162 // put this at the beginning so it doesn't trigger itself
2163 TimeOut
:= tgcWait
+ 1;
2167 pAngle
:= -DegToRad(tgcAngle
);
2168 xd
:= wx
+ Round(Cos(pAngle
) * 32.0);
2169 yd
:= wy
+ Round(Sin(pAngle
) * 32.0);
2172 case tgcShotTarget
of
2173 TRIGGER_SHOT_TARGET_MON
: // monsters
2174 //TODO: accelerate this!
2175 g_Mons_ForEachAlive(monsShotTarget
);
2177 TRIGGER_SHOT_TARGET_PLR
: // players
2178 if gPlayers
<> nil then
2179 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2180 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2181 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2183 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2184 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2185 TargetUID
:= gPlayers
[idx
].UID
;
2189 TRIGGER_SHOT_TARGET_RED
: // red team
2190 if gPlayers
<> nil then
2191 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2192 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2193 (gPlayers
[idx
].Team
= TEAM_RED
) and
2194 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2196 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2197 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2198 TargetUID
:= gPlayers
[idx
].UID
;
2202 TRIGGER_SHOT_TARGET_BLUE
: // blue team
2203 if gPlayers
<> nil then
2204 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2205 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2206 (gPlayers
[idx
].Team
= TEAM_BLUE
) and
2207 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2209 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2210 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2211 TargetUID
:= gPlayers
[idx
].UID
;
2215 TRIGGER_SHOT_TARGET_MONPLR
: // monsters then players
2217 //TODO: accelerate this!
2218 g_Mons_ForEachAlive(monsShotTargetMonPlr
);
2220 if (TargetUID
= 0) and (gPlayers
<> nil) then
2221 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2222 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2223 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2225 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2226 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2227 TargetUID
:= gPlayers
[idx
].UID
;
2232 TRIGGER_SHOT_TARGET_PLRMON
: // players then monsters
2234 if gPlayers
<> nil then
2235 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2236 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2237 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2239 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2240 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2241 TargetUID
:= gPlayers
[idx
].UID
;
2244 if TargetUID
= 0 then
2246 //TODO: accelerate this!
2247 g_Mons_ForEachAlive(monShotTargetPlrMon
);
2252 if (tgcShotTarget
<> TRIGGER_SHOT_TARGET_NONE
) or
2253 (tgcShotType
<> TRIGGER_SHOT_REV
) then
2254 TargetUID
:= ActivateUID
;
2258 if (tgcShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or (TargetUID
> 0) or
2259 ((tgcShotTarget
> TRIGGER_SHOT_TARGET_NONE
) and (TargetUID
= 0)) then
2262 if (tgcSight
= 0) or
2263 (tgcShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or
2264 (TargetUID
= ShotSightTarget
) then
2265 MakeShot(Trigger
, wx
, wy
, xd
, yd
, TargetUID
)
2268 ShotSightTime
:= tgcSight
;
2269 ShotSightTargetN
:= TargetUID
;
2270 if tgcShotType
= TRIGGER_SHOT_BFG
then
2272 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx
, wy
);
2273 if g_Game_IsNet
and g_Game_IsServer
then
2274 MH_SEND_Sound(wx
, wy
, 'SOUND_WEAPON_STARTFIREBFG');
2287 TRIGGER_EFFECT_POS_CENTER
:
2289 wx
:= X
+ Width
div 2;
2290 wy
:= Y
+ Height
div 2;
2292 TRIGGER_EFFECT_POS_AREA
:
2294 wx
:= X
+ Random(Width
);
2295 wy
:= Y
+ Random(Height
);
2298 wx
:= X
+ Width
div 2;
2299 wy
:= Y
+ Height
div 2;
2304 if tgcSpreadL
> 0 then xd
-= Random(tgcSpreadL
+1);
2305 if tgcSpreadR
> 0 then xd
+= Random(tgcSpreadR
+1);
2306 if tgcSpreadU
> 0 then yd
-= Random(tgcSpreadU
+1);
2307 if tgcSpreadD
> 0 then yd
+= Random(tgcSpreadD
+1);
2308 tr_MakeEffect(wx
, wy
, xd
, yd
,
2309 tgcFXType
, tgcFXSubType
,
2310 tgcFXRed
, tgcFXGreen
, tgcFXBlue
, True, False);
2319 if Result
{and (Trigger.TexturePanel <> -1)} then
2321 g_Map_SwitchTextureGUID({Trigger.TexturePanelType,} Trigger
.TexturePanelGUID
, IfThen(animonce
, 2, 1));
2326 function g_Triggers_CreateWithMapIndex (aTrigger
: TTrigger
; arridx
, mapidx
: Integer): DWORD
;
2328 triggers
: TDynField
;
2330 triggers
:= gCurrentMap
['trigger'];
2331 if (triggers
= nil) then raise Exception
.Create('LOAD: map has no triggers');
2332 if (mapidx
< 0) or (mapidx
>= triggers
.count
) then raise Exception
.Create('LOAD: invalid map trigger index');
2333 aTrigger
.mapIndex
:= mapidx
;
2334 result
:= g_Triggers_Create(aTrigger
, triggers
.itemAt
[mapidx
], arridx
);
2338 function g_Triggers_Create (aTrigger
: TTrigger
; trec
: TDynRecord
; forceInternalIndex
: Integer=-1): DWORD
;
2345 if (tgscope
= nil) then tgscope
:= TTrigScope
.Create();
2346 if (tgclist
= nil) then tgclist
:= TMyConstList
.Create();
2348 // Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà
2349 if (aTrigger
.TriggerType
= TRIGGER_EXIT
) and
2350 (not LongBool(gGameSettings
.Options
and GAME_OPTION_ALLOWEXIT
)) then
2352 aTrigger
.TriggerType
:= TRIGGER_NONE
;
2355 // Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð
2356 if (aTrigger
.TriggerType
= TRIGGER_SPAWNMONSTER
) and
2357 (not LongBool(gGameSettings
.Options
and GAME_OPTION_MONSTERS
)) and
2358 (gGameSettings
.GameType
<> GT_SINGLE
) then
2360 aTrigger
.TriggerType
:= TRIGGER_NONE
;
2363 // Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå
2364 if (aTrigger
.TriggerType
= TRIGGER_SECRET
) then gSecretsCount
+= 1;
2366 if (forceInternalIndex
< 0) then
2368 find_id
:= FindTrigger();
2372 olen
:= Length(gTriggers
);
2373 if (forceInternalIndex
>= olen
) then
2375 SetLength(gTriggers
, forceInternalIndex
+1);
2376 for f
:= olen
to High(gTriggers
) do
2378 gTriggers
[f
].TriggerType
:= TRIGGER_NONE
;
2379 gTriggers
[f
].trigDataRec
:= nil;
2380 gTriggers
[f
].exoInit
:= nil;
2381 gTriggers
[f
].exoThink
:= nil;
2382 gTriggers
[f
].exoCheck
:= nil;
2383 gTriggers
[f
].exoAction
:= nil;
2384 gTriggers
[f
].userVars
:= nil;
2387 f
:= forceInternalIndex
;
2388 gTriggers
[f
].trigDataRec
.Free();
2389 gTriggers
[f
].exoInit
.Free();
2390 gTriggers
[f
].exoThink
.Free();
2391 gTriggers
[f
].exoCheck
.Free();
2392 gTriggers
[f
].exoAction
.Free();
2393 gTriggers
[f
].userVars
.Free();
2394 gTriggers
[f
].trigDataRec
:= nil;
2395 gTriggers
[f
].exoInit
:= nil;
2396 gTriggers
[f
].exoThink
:= nil;
2397 gTriggers
[f
].exoCheck
:= nil;
2398 gTriggers
[f
].exoAction
:= nil;
2399 gTriggers
[f
].userVars
:= nil;
2400 find_id
:= DWORD(forceInternalIndex
);
2402 gTriggers
[find_id
] := aTrigger
;
2403 ptg
:= @gTriggers
[find_id
];
2405 ptg
.mapId
:= trec
.id
;
2406 // clone trigger data
2407 if (trec
.trigRec
= nil) then
2409 ptg
.trigDataRec
:= nil;
2411 if (ptg
.TriggerType
<> TRIGGER_SECRET
) then
2413 e_LogWritefln('trigger of type %s has no triggerdata; wtf?!', [ptg
.TriggerType
], TMsgType
.Warning
);
2418 ptg
.trigDataRec
:= trec
.trigRec
.clone(nil);
2424 // if this type of trigger exists both on the client and on the server
2425 // use an uniform numeration
2427 if (ptg
.TriggerType
= TRIGGER_SOUND
) then
2429 Inc(gTriggerClientID
);
2430 ClientID
:= gTriggerClientID
;
2434 PlayerCollide
:= False;
2438 SoundPlayCount
:= 0;
2445 // update cached trigger variables
2446 trigUpdateCacheData(ptg
^, ptg
.trigDataRec
);
2448 ptg
.userVars
:= nil;
2451 ptg
.exoThink
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_think']));
2453 on e
: TExomaParseException
do
2455 conwritefln('*** ERROR parsing exoma_think (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_think'])]);
2456 ptg
.exoThink
:= nil;
2462 ptg
.exoCheck
:= TExprBase
.parse(tgclist
, VarToStr(trec
.user
['exoma_check']));
2464 on e
: TExomaParseException
do
2466 conwritefln('*** ERROR parsing exoma_check (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_check'])]);
2467 ptg
.exoCheck
:= nil;
2473 ptg
.exoAction
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_action']));
2475 on e
: TExomaParseException
do
2477 conwritefln('*** ERROR parsing exoma_action (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_action'])]);
2478 ptg
.exoAction
:= nil;
2484 ptg
.exoInit
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_init']));
2486 on e
: TExomaParseException
do
2488 conwritefln('*** ERROR parsing exoma_init (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_init'])]);
2495 if (forceInternalIndex
< 0) and (ptg
.exoInit
<> nil) then
2497 //conwritefln('executing trigger init: [%s]', [gTriggers[find_id].exoInit.toString()]);
2500 ptg
.exoInit
.value(tgscope
);
2504 conwritefln('*** trigger exoactivate error: %s', [ptg
.exoInit
.toString()]);
2509 // Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê"
2510 if (ptg
.TriggerType
= TRIGGER_SOUND
) and (ptg
.tgcSoundName
<> '') then
2512 // Åùå íåò òàêîãî çâóêà
2513 if not g_Sound_Exists(ptg
.tgcSoundName
) then
2515 fn
:= e_GetResourcePath(WadDirs
, ptg
.tgcSoundName
, g_ExtractWadName(gMapInfo
.Map
));
2516 //e_LogWritefln('loading trigger sound ''%s''', [fn]);
2517 if not g_Sound_CreateWADEx(ptg
.tgcSoundName
, fn
) then
2519 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, ptg
.tgcSoundName
]));
2523 // Ñîçäàåì îáúåêò çâóêà
2526 Sound
:= TPlayableSound
.Create();
2527 if not Sound
.SetByName(ptg
.tgcSoundName
) then
2535 // Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà"
2536 if (ptg
.TriggerType
= TRIGGER_MUSIC
) and (ptg
.tgcMusicName
<> '') then
2538 // Åùå íåò òàêîé ìóçûêè
2539 if not g_Sound_Exists(ptg
.tgcMusicName
) then
2541 fn
:= e_GetResourcePath(WadDirs
, ptg
.tgcMusicName
, g_ExtractWadName(gMapInfo
.Map
));
2542 if not g_Sound_CreateWADEx(ptg
.tgcMusicName
, fn
, True) then
2544 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, ptg
.tgcMusicName
]));
2549 // Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü"
2550 if (ptg
.TriggerType
= TRIGGER_SHOT
) then
2556 ShotSightTimeout
:= 0;
2557 ShotSightTarget
:= 0;
2558 ShotSightTargetN
:= 0;
2559 ShotAmmoCount
:= ptg
.tgcAmmo
;
2560 ShotReloadTime
:= 0;
2568 // sorry; grid doesn't support recursive queries, so we have to do this
2570 TSimpleMonsterList
= specialize TSimpleList
<TMonster
>;
2573 tgMonsList
: TSimpleMonsterList
= nil;
2575 procedure g_Triggers_Update();
2578 Affected
: array of Integer;
2580 function monsNear (mon
: TMonster
): Boolean;
2582 result
:= false; // don't stop
2584 gTriggers[a].ActivateUID := mon.UID;
2585 ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
2587 tgMonsList
.append(mon
);
2594 if (tgMonsList
= nil) then tgMonsList
:= TSimpleMonsterList
.Create();
2596 if gTriggers
= nil then Exit
;
2597 if gLMSRespawn
> LMS_RESPAWN_NONE
then Exit
; // don't update triggers at all
2599 SetLength(Affected
, 0);
2601 for a
:= 0 to High(gTriggers
) do
2602 with gTriggers
[a
] do
2604 if TriggerType
<> TRIGGER_NONE
then
2606 // Óìåíüøàåì âðåìÿ äî çàêðûòèÿ äâåðè (îòêðûòèÿ ëîâóøêè)
2607 if DoorTime
> 0 then DoorTime
:= DoorTime
- 1;
2608 // Óìåíüøàåì âðåìÿ îæèäàíèÿ ïîñëå íàæàòèÿ
2609 if PressTime
> 0 then PressTime
:= PressTime
- 1;
2610 // Ïðîâåðÿåì èãðîêîâ è ìîíñòðîâ, êîòîðûõ ðàíåå çàïîìíèëè:
2611 if (TriggerType
= TRIGGER_DAMAGE
) or (TriggerType
= TRIGGER_HEALTH
) then
2613 for b
:= 0 to High(Activators
) do
2615 // Óìåíüøàåì âðåìÿ äî ïîâòîðíîãî âîçäåéñòâèÿ:
2616 if Activators
[b
].TimeOut
> 0 then
2618 Dec(Activators
[b
].TimeOut
);
2624 // Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
2625 if (tgcInterval
= 0) and (Activators
[b
].TimeOut
< 65530) then Activators
[b
].TimeOut
:= 0;
2629 // Îáðàáàòûâàåì ñïàâíåðû
2630 if Enabled
and AutoSpawn
then
2632 if SpawnCooldown
= 0 then
2634 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà
2635 if (TriggerType
= TRIGGER_SPAWNMONSTER
) and (tgcDelay
> 0) then
2638 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2640 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò
2641 if (TriggerType
= TRIGGER_SPAWNITEM
) and (tgcDelay
> 0) then
2644 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2649 // Óìåíüøàåì âðåìÿ îæèäàíèÿ
2654 // Îáðàáàòûâàåì ñîáûòèÿ òðèããåðà "Òóðåëü"
2655 if TriggerType
= TRIGGER_SHOT
then
2657 if ShotPanelTime
> 0 then
2660 if ShotPanelTime
= 0 then g_Map_SwitchTextureGUID({ShotPanelType,} trigPanelGUID
);
2662 if ShotSightTime
> 0 then
2665 if ShotSightTime
= 0 then ShotSightTarget
:= ShotSightTargetN
;
2667 if ShotSightTimeout
> 0 then
2669 Dec(ShotSightTimeout
);
2670 if ShotSightTimeout
= 0 then ShotSightTarget
:= 0;
2672 if ShotReloadTime
> 0 then
2674 Dec(ShotReloadTime
);
2675 if ShotReloadTime
= 0 then ShotAmmoCount
:= tgcAmmo
;
2679 // Òðèããåð "Çâóê" óæå îòûãðàë, åñëè íóæíî åùå - ïåðåçàïóñêàåì
2680 if Enabled
and (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) then
2682 if (SoundPlayCount
> 0) and (not Sound
.IsPlaying()) then
2684 if tgcPlayCount
> 0 then Dec(SoundPlayCount
); (* looped sound if zero *)
2686 Sound
.PlayVolumeAtRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
2688 Sound
.PlayPanVolume((tgcPan
- 127.0) / 128.0, tgcVolume
/ 255.0);
2689 if Sound
.IsPlaying() and g_Game_IsNet
and g_Game_IsServer
then
2690 MH_SEND_TriggerSound(gTriggers
[a
])
2694 // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü
2695 if (TriggerType
= TRIGGER_TRAP
) and (DoorTime
= 0) and (g_Map_PanelByGUID(trigPanelGUID
) <> nil) then
2697 tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
2701 // Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü
2702 if (TriggerType
= TRIGGER_DOOR5
) and (DoorTime
= 0) and (g_Map_PanelByGUID(trigPanelGUID
) <> nil) then
2704 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
2705 if (pan
<> nil) and pan
.isGWall
then
2708 if {gWalls[trigPanelID].Enabled} pan
.Enabled
then
2714 // Ïîêà îòêðûòà - çàêðûâàåì
2715 if tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
) then DoorTime
:= -1;
2720 // Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
2721 if (TriggerType
in [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) and
2722 (PressTime
= 0) and (PressCount
>= tgcPressCount
) then
2724 // Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
2726 // Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
2727 if tgcPressCount
> 0 then PressCount
-= tgcPressCount
else PressCount
:= 0;
2729 // Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
2730 for b
:= 0 to High(gTriggers
) do
2732 if g_Collide(tgcTX
, tgcTY
, tgcTWidth
, tgcTHeight
, gTriggers
[b
].X
, gTriggers
[b
].Y
,
2733 gTriggers
[b
].Width
, gTriggers
[b
].Height
) and
2734 ((b
<> a
) or (tgcWait
> 0)) then
2735 begin // Can be self-activated, if there is Data.Wait
2736 if (not tgcExtRandom
) or gTriggers
[b
].Enabled
then
2738 SetLength(Affected
, Length(Affected
) + 1);
2739 Affected
[High(Affected
)] := b
;
2745 // if we have panelid, assume that it will switch the moving platform
2746 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
2747 if (pan
<> nil) then
2750 TRIGGER_PRESS
: pan
.movingActive
:= true; // what to do here?
2751 TRIGGER_ON
: pan
.movingActive
:= true;
2752 TRIGGER_OFF
: pan
.movingActive
:= false;
2753 TRIGGER_ONOFF
: pan
.movingActive
:= not pan
.movingActive
;
2755 if not tgcSilent
and (Length(tgcSound
) > 0) then
2757 g_Sound_PlayExAt(tgcSound
, X
, Y
);
2758 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, tgcSound
);
2762 // Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
2763 if (TriggerType
= TRIGGER_PRESS
) and tgcExtRandom
then
2765 if (Length(Affected
) > 0) then
2767 b
:= Affected
[Random(Length(Affected
))];
2768 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2769 ActivateTrigger(gTriggers
[b
], 0);
2772 else //  ïðîòèâíîì ñëó÷àå ðàáîòàåì êàê îáû÷íî:
2774 for i
:= 0 to High(Affected
) do
2780 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2781 ActivateTrigger(gTriggers
[b
], 0);
2785 gTriggers
[b
].Enabled
:= True;
2789 gTriggers
[b
].Enabled
:= False;
2790 gTriggers
[b
].TimeOut
:= 0;
2791 if gTriggers
[b
].AutoSpawn
then
2793 gTriggers
[b
].AutoSpawn
:= False;
2794 gTriggers
[b
].SpawnCooldown
:= 0;
2799 gTriggers
[b
].Enabled
:= not gTriggers
[b
].Enabled
;
2800 if not gTriggers
[b
].Enabled
then
2802 gTriggers
[b
].TimeOut
:= 0;
2803 if gTriggers
[b
].AutoSpawn
then
2805 gTriggers
[b
].AutoSpawn
:= False;
2806 gTriggers
[b
].SpawnCooldown
:= 0;
2813 SetLength(Affected
, 0);
2816 // Óìåíüøàåì âðåìÿ äî âîçìîæíîñòè ïîâòîðíîé àêòèâàöèè:
2819 TimeOut
:= TimeOut
- 1;
2820 Continue
; // ×òîáû íå ïîòåðÿòü 1 åäèíèöó çàäåðæêè
2823 // Íèæå èäóò òèïû àêòèâàöèè, åñëè òðèããåð îòêëþ÷¸í - èä¸ì äàëüøå
2828 if ByteBool(ActivateType
and ACTIVATE_PLAYERCOLLIDE
) and
2830 if gPlayers
<> nil then
2831 for b
:= 0 to High(gPlayers
) do
2832 if gPlayers
[b
] <> nil then
2834 // Æèâ, åñòü íóæíûå êëþ÷è è îí ðÿäîì:
2835 if alive
and ((gTriggers
[a
].Keys
and GetKeys
) = gTriggers
[a
].Keys
) and
2836 Collide(X
, Y
, Width
, Height
) then
2838 gTriggers
[a
].ActivateUID
:= UID
;
2840 if (gTriggers
[a
].TriggerType
in [TRIGGER_SOUND
, TRIGGER_MUSIC
]) and
2842 { Don't activate sound/music again if player is here }
2844 ActivateTrigger(gTriggers
[a
], ACTIVATE_PLAYERCOLLIDE
);
2847 { TODO 5 : àêòèâàöèÿ ìîíñòðàìè òðèããåðîâ ñ êëþ÷àìè }
2849 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2850 ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2851 (TimeOut
= 0) and (Keys
= 0) then
2853 // Åñëè "Ìîíñòð áëèçêî" è "Ìîíñòðîâ íåò",
2854 // çàïóñêàåì òðèããåð íà ñòàðòå êàðòû è ñíèìàåì îáà ôëàãà
2855 ActivateType
:= ActivateType
and not (ACTIVATE_MONSTERCOLLIDE
or ACTIVATE_NOMONSTER
);
2856 gTriggers
[a
].ActivateUID
:= 0;
2857 ActivateTrigger(gTriggers
[a
], 0);
2861 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2862 (TimeOut
= 0) and (Keys
= 0) then // Åñëè íå íóæíû êëþ÷è
2864 //g_Mons_ForEach(monsNear);
2867 g_Mons_ForEachAt(gTriggers
[a
].X
, gTriggers
[a
].Y
, gTriggers
[a
].Width
, gTriggers
[a
].Height
, monsNear
);
2868 for mon
in tgMonsList
do
2870 gTriggers
[a
].ActivateUID
:= mon
.UID
;
2871 ActivateTrigger(gTriggers
[a
], ACTIVATE_MONSTERCOLLIDE
);
2873 tgMonsList
.reset(); // just in case
2877 if ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2878 (TimeOut
= 0) and (Keys
= 0) then
2879 if not g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then
2881 gTriggers
[a
].ActivateUID
:= 0;
2882 ActivateTrigger(gTriggers
[a
], ACTIVATE_NOMONSTER
);
2886 PlayerCollide
:= g_CollidePlayer(X
, Y
, Width
, Height
);
2890 procedure g_Triggers_Press(ID
: DWORD
; ActivateType
: Byte; ActivateUID
: Word = 0);
2892 if (ID
>= Length(gTriggers
)) then exit
;
2893 gTriggers
[ID
].ActivateUID
:= ActivateUID
;
2894 ActivateTrigger(gTriggers
[ID
], ActivateType
);
2897 function g_Triggers_PressR(X
, Y
: Integer; Width
, Height
: Word; UID
: Word;
2898 ActivateType
: Byte; IgnoreList
: DWArray
= nil): DWArray
;
2906 if gTriggers
= nil then Exit
;
2908 case g_GetUIDType(UID
) of
2912 p
:= g_Player_Get(UID
);
2921 for a
:= 0 to High(gTriggers
) do
2922 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2923 (gTriggers
[a
].TimeOut
= 0) and
2924 (not InDWArray(a
, IgnoreList
)) and
2925 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2926 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2927 if g_Collide(X
, Y
, Width
, Height
,
2928 gTriggers
[a
].X
, gTriggers
[a
].Y
,
2929 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2931 gTriggers
[a
].ActivateUID
:= UID
;
2932 if ActivateTrigger(gTriggers
[a
], ActivateType
) then
2934 SetLength(Result
, Length(Result
)+1);
2935 Result
[High(Result
)] := a
;
2940 procedure g_Triggers_PressL(X1
, Y1
, X2
, Y2
: Integer; UID
: DWORD
; ActivateType
: Byte);
2946 if gTriggers
= nil then Exit
;
2948 case g_GetUIDType(UID
) of
2952 p
:= g_Player_Get(UID
);
2961 for a
:= 0 to High(gTriggers
) do
2962 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2963 (gTriggers
[a
].TimeOut
= 0) and
2964 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2965 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2966 if g_CollideLine(x1
, y1
, x2
, y2
, gTriggers
[a
].X
, gTriggers
[a
].Y
,
2967 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2969 gTriggers
[a
].ActivateUID
:= UID
;
2970 ActivateTrigger(gTriggers
[a
], ActivateType
);
2974 procedure g_Triggers_PressC(CX
, CY
: Integer; Radius
: Word; UID
: Word; ActivateType
: Byte; IgnoreTrigger
: Integer = -1);
2981 if gTriggers
= nil then
2984 case g_GetUIDType(UID
) of
2988 p
:= g_Player_Get(UID
);
2997 rsq
:= Radius
* Radius
;
2999 for a
:= 0 to High(gTriggers
) do
3000 if (gTriggers
[a
].ID
<> DWORD(IgnoreTrigger
)) and
3001 (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
3002 (gTriggers
[a
].TimeOut
= 0) and
3003 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
3004 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
3005 with gTriggers
[a
] do
3006 if g_Collide(CX
-Radius
, CY
-Radius
, 2*Radius
, 2*Radius
,
3007 X
, Y
, Width
, Height
) then
3008 if ((Sqr(CX
-X
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ëåâîìó óãëó
3009 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ïðàâîìó óãëó
3010 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ïðàâîìó óãëó
3011 ((Sqr(CX
-X
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ëåâîìó óãëó
3012 ( (CX
> (X
-Radius
)) and (CX
< (X
+Width
+Radius
)) and
3013 (CY
> Y
) and (CY
< (Y
+Height
)) ) or // Öåíòð êðóãà íåäàëåêî îò âåðòèêàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
3014 ( (CY
> (Y
-Radius
)) and (CY
< (Y
+Height
+Radius
)) and
3015 (CX
> X
) and (CX
< (X
+Width
)) ) then // Öåíòð êðóãà íåäàëåêî îò ãîðèçîíòàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
3018 ActivateTrigger(gTriggers
[a
], ActivateType
);
3022 procedure g_Triggers_OpenAll();
3027 if gTriggers
= nil then Exit
;
3030 for a
:= 0 to High(gTriggers
) do
3032 with gTriggers
[a
] do
3034 if (TriggerType
= TRIGGER_OPENDOOR
) or
3035 (TriggerType
= TRIGGER_DOOR5
) or
3036 (TriggerType
= TRIGGER_DOOR
) then
3038 tr_OpenDoor(trigPanelGUID
, True, tgcD2d
);
3039 if TriggerType
= TRIGGER_DOOR5
then DoorTime
:= 180;
3045 if b
then g_Sound_PlayEx('SOUND_GAME_DOOROPEN');
3048 procedure g_Triggers_DecreaseSpawner(ID
: DWORD
);
3050 if (gTriggers
<> nil) then
3052 if gTriggers
[ID
].tgcMax
> 0 then
3054 if gTriggers
[ID
].SpawnedCount
> 0 then
3055 Dec(gTriggers
[ID
].SpawnedCount
);
3057 if gTriggers
[ID
].tgcDelay
> 0 then
3059 if gTriggers
[ID
].SpawnCooldown
< 0 then
3060 gTriggers
[ID
].SpawnCooldown
:= gTriggers
[ID
].tgcDelay
;
3065 procedure g_Triggers_Free ();
3069 for a
:= 0 to High(gTriggers
) do
3071 if (gTriggers
[a
].TriggerType
= TRIGGER_SOUND
) then
3073 if g_Sound_Exists(gTriggers
[a
].tgcSoundName
) then
3075 g_Sound_Delete(gTriggers
[a
].tgcSoundName
);
3077 gTriggers
[a
].Sound
.Free();
3079 if (gTriggers
[a
].Activators
<> nil) then
3081 SetLength(gTriggers
[a
].Activators
, 0);
3083 gTriggers
[a
].trigDataRec
.Free();
3085 gTriggers
[a
].exoThink
.Free();
3086 gTriggers
[a
].exoCheck
.Free();
3087 gTriggers
[a
].exoAction
.Free();
3088 gTriggers
[a
].userVars
.Free();
3093 SetLength(gMonstersSpawned
, 0);
3097 procedure g_Triggers_SaveState (st
: TStream
);
3099 count
, actCount
, i
, j
: Integer;
3102 kv
: THashStrVariant
.PEntry
;
3105 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ
3106 count
:= Length(gTriggers
);
3108 // Êîëè÷åñòâî òðèããåðîâ
3109 utils
.writeInt(st
, LongInt(count
));
3110 if (count
= 0) then exit
;
3112 for i
:= 0 to High(gTriggers
) do
3114 // Ñèãíàòóðà òðèããåðà
3115 utils
.writeSign(st
, 'TRGX');
3116 utils
.writeInt(st
, Byte(0));
3118 utils
.writeInt(st
, Byte(gTriggers
[i
].TriggerType
));
3119 if (gTriggers
[i
].TriggerType
= TRIGGER_NONE
) then continue
; // empty one
3120 // Ñïåöèàëüíûå äàííûå òðèããåðà: ïîòîì èç êàðòû îïÿòü âûòàùèì; ñîõðàíèì òîëüêî èíäåêñ
3121 utils
.writeInt(st
, LongInt(gTriggers
[i
].mapIndex
));
3122 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà
3123 utils
.writeInt(st
, LongInt(gTriggers
[i
].X
));
3124 utils
.writeInt(st
, LongInt(gTriggers
[i
].Y
));
3126 utils
.writeInt(st
, Word(gTriggers
[i
].Width
));
3127 utils
.writeInt(st
, Word(gTriggers
[i
].Height
));
3128 // Âêëþ÷åí ëè òðèããåð
3129 utils
.writeBool(st
, gTriggers
[i
].Enabled
);
3130 // Òèï àêòèâàöèè òðèããåðà
3131 utils
.writeInt(st
, Byte(gTriggers
[i
].ActivateType
));
3132 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè
3133 utils
.writeInt(st
, Byte(gTriggers
[i
].Keys
));
3134 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ
3135 utils
.writeInt(st
, LongInt(gTriggers
[i
].TexturePanelGUID
));
3137 //Mem.WriteWord(gTriggers[i].TexturePanelType);
3138 // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
3139 utils
.writeInt(st
, LongInt(gTriggers
[i
].trigPanelGUID
));
3140 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè
3141 utils
.writeInt(st
, Word(gTriggers
[i
].TimeOut
));
3142 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð
3143 utils
.writeInt(st
, Word(gTriggers
[i
].ActivateUID
));
3144 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì
3145 actCount
:= Length(gTriggers
[i
].Activators
);
3146 utils
.writeInt(st
, LongInt(actCount
));
3147 for j
:= 0 to actCount
-1 do
3150 utils
.writeInt(st
, Word(gTriggers
[i
].Activators
[j
].UID
));
3152 utils
.writeInt(st
, Word(gTriggers
[i
].Activators
[j
].TimeOut
));
3154 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà
3155 utils
.writeBool(st
, gTriggers
[i
].PlayerCollide
);
3156 // Âðåìÿ äî çàêðûòèÿ äâåðè
3157 utils
.writeInt(st
, LongInt(gTriggers
[i
].DoorTime
));
3158 // Çàäåðæêà àêòèâàöèè
3159 utils
.writeInt(st
, LongInt(gTriggers
[i
].PressTime
));
3161 utils
.writeInt(st
, LongInt(gTriggers
[i
].PressCount
));
3163 utils
.writeBool(st
, gTriggers
[i
].AutoSpawn
);
3164 // Çàäåðæêà ñïàâíåðà
3165 utils
.writeInt(st
, LongInt(gTriggers
[i
].SpawnCooldown
));
3166 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ
3167 utils
.writeInt(st
, LongInt(gTriggers
[i
].SpawnedCount
));
3168 // Ñêîëüêî ðàç ïðîèãðàí çâóê
3169 utils
.writeInt(st
, LongInt(gTriggers
[i
].SoundPlayCount
));
3170 // Ïðîèãðûâàåòñÿ ëè çâóê?
3171 if (gTriggers
[i
].Sound
<> nil) then b
:= gTriggers
[i
].Sound
.IsPlaying() else b
:= false;
3172 utils
.writeBool(st
, b
);
3175 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà
3176 utils
.writeInt(st
, LongWord(gTriggers
[i
].Sound
.GetPosition()));
3178 sg
:= gTriggers
[i
].Sound
.GetVolume();
3179 sg
:= sg
/(gSoundLevel
/255.0);
3180 //Mem.WriteSingle(sg);
3181 st
.WriteBuffer(sg
, sizeof(sg
)); // sorry
3182 // Ñòåðåî ñìåùåíèå çâóêà
3183 sg
:= gTriggers
[i
].Sound
.GetPan();
3184 //Mem.WriteSingle(sg);
3185 st
.WriteBuffer(sg
, sizeof(sg
)); // sorry
3188 if (gTriggers
[i
].userVars
= nil) then
3190 utils
.writeInt(st
, LongInt(0));
3194 utils
.writeInt(st
, LongInt(gTriggers
[i
].userVars
.count
)); //FIXME: check for overflow
3195 for kv
in gTriggers
[i
].userVars
.byKeyValue
do
3197 //writeln('<', kv.key, '>:<', VarToStr(kv.value), '>');
3198 utils
.writeStr(st
, kv
.key
);
3199 t
:= LongInt(varType(kv
.value
));
3200 utils
.writeInt(st
, LongInt(t
));
3202 varString
: utils
.writeStr(st
, AnsiString(kv
.value
));
3203 varBoolean
: utils
.writeBool(st
, Boolean(kv
.value
));
3204 varShortInt
: utils
.writeInt(st
, LongInt(kv
.value
));
3205 varSmallint
: utils
.writeInt(st
, LongInt(kv
.value
));
3206 varInteger
: utils
.writeInt(st
, LongInt(kv
.value
));
3207 //varInt64: Mem.WriteInt(Integer(kv.value));
3208 varByte
: utils
.writeInt(st
, LongInt(kv
.value
));
3209 varWord
: utils
.writeInt(st
, LongInt(kv
.value
));
3210 varLongWord
: utils
.writeInt(st
, LongInt(kv
.value
));
3212 else raise Exception
.CreateFmt('cannot save uservar ''%s''', [kv
.key
]);
3220 procedure g_Triggers_LoadState (st
: TStream
);
3222 count
, actCount
, i
, j
, a
: Integer;
3231 uvname
: AnsiString = '';
3232 ustr
: AnsiString = '';
3240 // Êîëè÷åñòâî òðèããåðîâ
3241 count
:= utils
.readLongInt(st
);
3242 if (count
= 0) then exit
;
3243 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid trigger count');
3245 for a
:= 0 to count
-1 do
3247 // Ñèãíàòóðà òðèããåðà
3248 if not utils
.checkSign(st
, 'TRGX') then raise XStreamError
.Create('invalid trigger signature');
3249 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid trigger version');
3251 Trig
.TriggerType
:= utils
.readByte(st
);
3252 if (Trig
.TriggerType
= TRIGGER_NONE
) then continue
; // empty one
3253 // Ñïåöèàëüíûå äàííûå òðèããåðà: èíäåêñ â gCurrentMap.field['triggers']
3254 mapIndex
:= utils
.readLongInt(st
);
3255 i
:= g_Triggers_CreateWithMapIndex(Trig
, a
, mapIndex
);
3256 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà
3257 gTriggers
[i
].X
:= utils
.readLongInt(st
);
3258 gTriggers
[i
].Y
:= utils
.readLongInt(st
);
3260 gTriggers
[i
].Width
:= utils
.readWord(st
);
3261 gTriggers
[i
].Height
:= utils
.readWord(st
);
3262 // Âêëþ÷åí ëè òðèããåð
3263 gTriggers
[i
].Enabled
:= utils
.readBool(st
);
3264 // Òèï àêòèâàöèè òðèããåðà
3265 gTriggers
[i
].ActivateType
:= utils
.readByte(st
);
3266 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè
3267 gTriggers
[i
].Keys
:= utils
.readByte(st
);
3268 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ
3269 gTriggers
[i
].TexturePanelGUID
:= utils
.readLongInt(st
);
3271 //Mem.ReadWord(gTriggers[i].TexturePanelType);
3272 // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
3273 gTriggers
[i
].trigPanelGUID
:= utils
.readLongInt(st
);
3274 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè
3275 gTriggers
[i
].TimeOut
:= utils
.readWord(st
);
3276 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð
3277 gTriggers
[i
].ActivateUID
:= utils
.readWord(st
);
3278 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì
3279 actCount
:= utils
.readLongInt(st
);
3280 if (actCount
< 0) or (actCount
> 1024*1024) then raise XStreamError
.Create('invalid activated object count');
3281 if (actCount
> 0) then
3283 SetLength(gTriggers
[i
].Activators
, actCount
);
3284 for j
:= 0 to actCount
-1 do
3287 gTriggers
[i
].Activators
[j
].UID
:= utils
.readWord(st
);
3289 gTriggers
[i
].Activators
[j
].TimeOut
:= utils
.readWord(st
);
3292 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà
3293 gTriggers
[i
].PlayerCollide
:= utils
.readBool(st
);
3294 // Âðåìÿ äî çàêðûòèÿ äâåðè
3295 gTriggers
[i
].DoorTime
:= utils
.readLongInt(st
);
3296 // Çàäåðæêà àêòèâàöèè
3297 gTriggers
[i
].PressTime
:= utils
.readLongInt(st
);
3299 gTriggers
[i
].PressCount
:= utils
.readLongInt(st
);
3301 gTriggers
[i
].AutoSpawn
:= utils
.readBool(st
);
3302 // Çàäåðæêà ñïàâíåðà
3303 gTriggers
[i
].SpawnCooldown
:= utils
.readLongInt(st
);
3304 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ
3305 gTriggers
[i
].SpawnedCount
:= utils
.readLongInt(st
);
3306 // Ñêîëüêî ðàç ïðîèãðàí çâóê
3307 gTriggers
[i
].SoundPlayCount
:= utils
.readLongInt(st
);
3308 // Ïðîèãðûâàåòñÿ ëè çâóê?
3309 b
:= utils
.readBool(st
);
3312 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà
3313 dw
:= utils
.readLongWord(st
);
3315 //Mem.ReadSingle(vol);
3316 st
.ReadBuffer(vol
, sizeof(vol
)); // sorry
3317 // Ñòåðåî ñìåùåíèå çâóêà
3318 //Mem.ReadSingle(pan);
3319 st
.ReadBuffer(pan
, sizeof(pan
)); // sorry
3320 // Çàïóñêàåì çâóê, åñëè åñòü
3321 if (gTriggers
[i
].Sound
<> nil) then
3323 gTriggers
[i
].Sound
.PlayPanVolume(pan
, vol
);
3324 gTriggers
[i
].Sound
.Pause(True);
3325 gTriggers
[i
].Sound
.SetPosition(dw
);
3329 gTriggers
[i
].userVars
.Free();
3330 gTriggers
[i
].userVars
:= nil;
3331 uvcount
:= utils
.readLongInt(st
);
3332 if (uvcount
< 0) or (uvcount
> 1024*1024) then raise XStreamError
.Create('invalid number of user vars in trigger');
3333 if (uvcount
> 0) then
3335 gTriggers
[i
].userVars
:= THashStrVariant
.Create();
3337 while (uvcount
> 0) do
3340 uvname
:= utils
.readStr(st
);
3341 vt
:= utils
.readLongInt(st
);
3343 varString
: begin ustr
:= utils
.readStr(st
); vv
:= ustr
; end;
3344 varBoolean
: begin ubool
:= utils
.readBool(st
); vv
:= ubool
; end;
3345 varShortInt
: begin uint
:= utils
.readLongInt(st
); vv
:= ShortInt(uint
); end;
3346 varSmallint
: begin uint
:= utils
.readLongInt(st
); vv
:= SmallInt(uint
); end;
3347 varInteger
: begin uint
:= utils
.readLongInt(st
); vv
:= LongInt(uint
); end;
3348 varByte
: begin uint
:= utils
.readLongInt(st
); vv
:= Byte(uint
); end;
3349 varWord
: begin uint
:= utils
.readLongInt(st
); vv
:= Word(uint
); end;
3350 varLongWord
: begin uint
:= utils
.readLongInt(st
); vv
:= LongWord(uint
); end;
3351 else raise Exception
.CreateFmt('cannot load uservar ''%s''', [uvname
]);
3353 gTriggers
[i
].userVars
.put(uvname
, vv
);