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;
109 g_player
, g_map
, g_panel
, g_game
,
110 g_console
, g_monsters
, g_items
, g_phys
, g_weapons
,
111 wadreader
, e_log
, g_language
, e_res
,
112 g_options
, g_net
, g_netmsg
, utils
, xparser
, xstreams
116 TRIGGER_SIGNATURE
= $58475254; // 'TRGX'
119 {$INCLUDE ../shared/mapdef_tgc_impl.inc}
122 // ////////////////////////////////////////////////////////////////////////// //
124 TTrigScope
= class(TExprScope
)
127 monsprops
: TPropHash
;
128 platprops
: TPropHash
;
134 constructor Create ();
135 destructor Destroy (); override;
137 function getObj (const aname
: AnsiString): TObject
; override;
138 function getField (obj
: TObject
; const afldname
: AnsiString): Variant; override;
139 procedure setField (obj
: TObject
; const afldname
: AnsiString; var aval
: Variant); override;
143 // ////////////////////////////////////////////////////////////////////////// //
145 TMyConstList
= class(TExprConstList
)
147 function valid (const cname
: AnsiString): Boolean; override;
148 function get (const cname
: AnsiString; out v
: Variant): Boolean; override;
152 // ////////////////////////////////////////////////////////////////////////// //
153 function TMyConstList
.valid (const cname
: AnsiString): Boolean;
155 //writeln('CHECK: ''', cname, '''');
157 (cname
= 'player') or
162 function TMyConstList
.get (const cname
: AnsiString; out v
: Variant): Boolean;
167 //if (cname = 'answer') then begin v := LongInt(42); result := true; exit; end;
169 if (gCurrentMap
= nil) then exit
;
170 for eidx
:= 0 to gCurrentMap
.mapdef
.ebsTypeCount
-1 do
172 ebs
:= gCurrentMap
.mapdef
.ebsTypeAt
[eidx
];
173 if ebs
.has
[cname
] then
175 //writeln('FOUND: ''', cname, '''');
184 // ////////////////////////////////////////////////////////////////////////// //
185 constructor TTrigScope
.Create ();
187 plrprops
:= TPropHash
.Create(TPlayer
, 'e');
188 monsprops
:= TPropHash
.Create(TMonster
, 'e');
189 platprops
:= TPropHash
.Create(TPanel
, 'e');
194 destructor TTrigScope
.Destroy ();
203 function TTrigScope
.getObj (const aname
: AnsiString): TObject
;
205 if (aname
= 'player') then result
:= gPlayers
[0] //FIXME
206 else if (aname
= 'self') or (aname
= 'this') then result
:= TObject(Pointer(PtrUInt(1)))
207 else result
:= inherited getObj(aname
);
211 function TTrigScope
.getField (obj
: TObject
; const afldname
: AnsiString): Variant;
213 if (obj
= gPlayers
[0]) then
215 if plrprops
.get(obj
, afldname
, result
) then exit
;
217 else if (obj
= TObject(Pointer(PtrUInt(1)))) then
219 if (me
<> nil) and (me
.userVars
<> nil) then
221 if me
.userVars
.get(afldname
, result
) then exit
;
224 result
:= inherited getField(obj
, afldname
);
228 procedure TTrigScope
.setField (obj
: TObject
; const afldname
: AnsiString; var aval
: Variant);
230 if (obj
= gPlayers
[0]) then
232 if plrprops
.put(obj
, afldname
, aval
) then exit
;
234 else if (obj
= TObject(Pointer(PtrUInt(1)))) then
238 if (Length(afldname
) > 4) and (afldname
[1] = 'u') and (afldname
[2] = 's') and
239 (afldname
[3] = 'e') and (afldname
[4] = 'r') then
241 if (me
.userVars
= nil) then me
.userVars
:= THashStrVariant
.Create();
242 me
.userVars
.put(afldname
, aval
);
247 inherited setField(obj
, afldname
, aval
);
251 // ////////////////////////////////////////////////////////////////////////// //
253 tgscope
: TTrigScope
= nil;
254 tgclist
: TMyConstList
= nil;
257 // ////////////////////////////////////////////////////////////////////////// //
258 function TTrigger
.trigCenter (): TDFPoint
; inline;
260 result
:= TDFPoint
.Create(x
+width
div 2, y
+height
div 2);
264 function FindTrigger (): DWORD
;
268 olen
:= Length(gTriggers
);
270 for i
:= 0 to olen
-1 do
272 if gTriggers
[i
].TriggerType
= TRIGGER_NONE
then begin result
:= i
; exit
; end;
275 SetLength(gTriggers
, olen
+8);
278 for i
:= result
to High(gTriggers
) do
280 gTriggers
[i
].TriggerType
:= TRIGGER_NONE
;
281 gTriggers
[i
].trigDataRec
:= nil;
282 gTriggers
[i
].exoInit
:= nil;
283 gTriggers
[i
].exoThink
:= nil;
284 gTriggers
[i
].exoCheck
:= nil;
285 gTriggers
[i
].exoAction
:= nil;
286 gTriggers
[i
].userVars
:= nil;
291 function tr_CloseDoor (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
298 pan
:= g_Map_PanelByGUID(PanelGUID
);
299 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
300 PanelID
:= pan
.arrIdx
;
304 with gWalls
[PanelID
] do
306 if g_CollidePlayer(X
, Y
, Width
, Height
) or g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then Exit
;
311 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
312 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
314 g_Map_EnableWallGUID(PanelGUID
);
321 if (gDoorMap
= nil) then exit
;
324 for a
:= 0 to High(gDoorMap
) do
326 for b
:= 0 to High(gDoorMap
[a
]) do
328 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
334 if (c
<> -1) then break
;
336 if (c
= -1) then exit
;
338 for b
:= 0 to High(gDoorMap
[c
]) do
340 with gWalls
[gDoorMap
[c
, b
]] do
342 if g_CollidePlayer(X
, Y
, Width
, Height
) or g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then exit
;
348 for b
:= 0 to High(gDoorMap
[c
]) do
350 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
352 with gWalls
[PanelID
] do
354 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X
, Y
);
355 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOORCLOSE');
362 for b
:= 0 to High(gDoorMap
[c
]) do
364 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
366 g_Map_EnableWall_XXX(gDoorMap
[c
, b
]);
374 procedure tr_CloseTrap (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean);
377 wx
, wy
, wh
, ww
: Integer;
381 function monsDamage (mon
: TMonster
): Boolean;
383 result
:= false; // don't stop
384 if g_Obj_Collide(wx
, wy
, ww
, wh
, @mon
.Obj
) then mon
.Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
388 pan
:= g_Map_PanelByGUID(PanelGUID
);
392 e_LogWritefln('tr_CloseTrap: pguid=%s; NO PANEL!', [PanelGUID], MSG_WARNING);
396 e_LogWritefln('tr_CloseTrap: pguid=%s; isGWall=%s; arrIdx=%s', [PanelGUID, pan.isGWall, pan.arrIdx]);
399 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
400 PanelID
:= pan
.arrIdx
;
404 with gWalls
[PanelID
] do
406 if (not NoSound
) and (not Enabled
) then
408 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
409 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
413 wx
:= gWalls
[PanelID
].X
;
414 wy
:= gWalls
[PanelID
].Y
;
415 ww
:= gWalls
[PanelID
].Width
;
416 wh
:= gWalls
[PanelID
].Height
;
418 with gWalls
[PanelID
] do
420 if gPlayers
<> nil then
422 for a
:= 0 to High(gPlayers
) do
424 if (gPlayers
[a
] <> nil) and gPlayers
[a
].alive
and gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
426 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
431 //g_Mons_ForEach(monsDamage);
432 g_Mons_ForEachAliveAt(wx
, wy
, ww
, wh
, monsDamage
);
434 if not Enabled
then g_Map_EnableWallGUID(PanelGUID
);
439 if (gDoorMap
= nil) then exit
;
442 for a
:= 0 to High(gDoorMap
) do
444 for b
:= 0 to High(gDoorMap
[a
]) do
446 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
452 if (c
<> -1) then break
;
454 if (c
= -1) then exit
;
458 for b
:= 0 to High(gDoorMap
[c
]) do
460 if not gWalls
[gDoorMap
[c
, b
]].Enabled
then
462 with gWalls
[PanelID
] do
464 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X
, Y
);
465 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH1');
472 for b
:= 0 to High(gDoorMap
[c
]) do
474 wx
:= gWalls
[gDoorMap
[c
, b
]].X
;
475 wy
:= gWalls
[gDoorMap
[c
, b
]].Y
;
476 ww
:= gWalls
[gDoorMap
[c
, b
]].Width
;
477 wh
:= gWalls
[gDoorMap
[c
, b
]].Height
;
479 with gWalls
[gDoorMap
[c
, b
]] do
481 if gPlayers
<> nil then
483 for a
:= 0 to High(gPlayers
) do
485 if (gPlayers
[a
] <> nil) and gPlayers
[a
].alive
and gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
487 gPlayers
[a
].Damage(TRAP_DAMAGE
, 0, 0, 0, HIT_TRAP
);
492 //g_Mons_ForEach(monsDamage);
493 g_Mons_ForEachAliveAt(wx
, wy
, ww
, wh
, monsDamage
);
495 if gMonsters <> nil then
496 for a := 0 to High(gMonsters) do
497 if (gMonsters[a] <> nil) and gMonsters[a].alive and
498 g_Obj_Collide(X, Y, Width, Height, @gMonsters[a].Obj) then
499 gMonsters[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
502 if not Enabled
then g_Map_EnableWall_XXX(gDoorMap
[c
, b
]);
509 function tr_OpenDoor (PanelGUID
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
516 pan
:= g_Map_PanelByGUID(PanelGUID
);
517 if (pan
= nil) or not pan
.isGWall
then exit
; //!FIXME!TRIGANY!
518 PanelID
:= pan
.arrIdx
;
522 with gWalls
[PanelID
] do
528 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
529 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
531 g_Map_DisableWallGUID(PanelGUID
);
538 if (gDoorMap
= nil) then exit
;
541 for a
:= 0 to High(gDoorMap
) do
543 for b
:= 0 to High(gDoorMap
[a
]) do
545 if gDoorMap
[a
, b
] = DWORD(PanelID
) then
551 if (c
<> -1) then break
;
553 if (c
= -1) then exit
;
557 for b
:= 0 to High(gDoorMap
[c
]) do
559 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
561 with gWalls
[PanelID
] do
563 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X
, Y
);
564 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_DOOROPEN');
571 for b
:= 0 to High(gDoorMap
[c
]) do
573 if gWalls
[gDoorMap
[c
, b
]].Enabled
then
575 g_Map_DisableWall_XXX(gDoorMap
[c
, b
]);
583 function tr_SetLift (PanelGUID
: Integer; d
: Integer; NoSound
: Boolean; d2d
: Boolean): Boolean;
591 pan
:= g_Map_PanelByGUID(PanelGUID
);
592 if (pan
= nil) or not pan
.isGLift
then exit
; //!FIXME!TRIGANY!
593 PanelID
:= pan
.arrIdx
;
595 if (gLifts
[PanelID
].PanelType
= PANEL_LIFTUP
) or (gLifts
[PanelID
].PanelType
= PANEL_LIFTDOWN
) then
599 1: t
:= LIFTTYPE_DOWN
;
600 else t
:= IfThen(gLifts
[PanelID
].LiftType
= LIFTTYPE_DOWN
, LIFTTYPE_UP
, LIFTTYPE_DOWN
);
603 else if (gLifts
[PanelID
].PanelType
= PANEL_LIFTLEFT
) or (gLifts
[PanelID
].PanelType
= PANEL_LIFTRIGHT
) then
606 0: t
:= LIFTTYPE_LEFT
;
607 1: t
:= LIFTTYPE_RIGHT
;
608 else t
:= IfThen(gLifts
[PanelID
].LiftType
= LIFTTYPE_LEFT
, LIFTTYPE_RIGHT
, LIFTTYPE_LEFT
);
614 with gLifts
[PanelID
] do
616 if (LiftType
<> t
) then
618 g_Map_SetLiftGUID(PanelGUID
, t
); //???
619 //if not NoSound then g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
626 if (gLiftMap
= nil) then exit
;
629 for a
:= 0 to High(gLiftMap
) do
631 for b
:= 0 to High(gLiftMap
[a
]) do
633 if (gLiftMap
[a
, b
] = DWORD(PanelID
)) then
639 if (c
<> -1) then break
;
641 if (c
= -1) then exit
;
644 for b := 0 to High(gLiftMap[c]) do
645 if gLifts[gLiftMap[c, b]].LiftType <> t then
647 with gLifts[PanelID] do
648 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
652 for b
:= 0 to High(gLiftMap
[c
]) do
654 with gLifts
[gLiftMap
[c
, b
]] do
656 if (LiftType
<> t
) then
658 g_Map_SetLift_XXX(gLiftMap
[c
, b
], t
);
667 function tr_SpawnShot (ShotType
: Integer; wx
, wy
, dx
, dy
: Integer; ShotSound
: Boolean; ShotTarget
: Word): Integer;
673 snd
:= 'SOUND_WEAPON_FIREROCKET';
679 g_Weapon_pistol(wx
, wy
, dx
, dy
, 0, True);
680 snd
:= 'SOUND_WEAPON_FIREPISTOL';
684 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
685 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
691 g_Weapon_mgun(wx
, wy
, dx
, dy
, 0, True);
692 if gSoundEffectsDF
then snd
:= 'SOUND_WEAPON_FIRECGUN'
693 else snd
:= 'SOUND_WEAPON_FIREPISTOL';
697 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_BULLET
);
698 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL1
);
702 TRIGGER_SHOT_SHOTGUN
:
704 g_Weapon_Shotgun(wx
, wy
, dx
, dy
, 0, True);
705 snd
:= 'SOUND_WEAPON_FIRESHOTGUN';
709 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
710 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL2
);
716 g_Weapon_DShotgun(wx
, wy
, dx
, dy
, 0, True);
717 snd
:= 'SOUND_WEAPON_FIRESHOTGUN2';
721 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
722 g_Player_CreateShell(wx
, wy
, 0, -2, SHELL_SHELL
);
723 if g_Game_IsNet
then MH_SEND_Effect(wx
, wy
, 0, NET_GFX_SHELL3
);
729 g_Weapon_ball1(wx
, wy
, dx
, dy
, 0, -1, True);
730 snd
:= 'SOUND_WEAPON_FIREBALL';
735 g_Weapon_Plasma(wx
, wy
, dx
, dy
, 0, -1, True);
736 snd
:= 'SOUND_WEAPON_FIREPLASMA';
741 g_Weapon_aplasma(wx
, wy
, dx
, dy
, 0, -1, True);
742 snd
:= 'SOUND_WEAPON_FIREPLASMA';
747 g_Weapon_ball2(wx
, wy
, dx
, dy
, 0, -1, True);
748 snd
:= 'SOUND_WEAPON_FIREBALL';
753 g_Weapon_ball7(wx
, wy
, dx
, dy
, 0, -1, True);
754 snd
:= 'SOUND_WEAPON_FIREBALL';
759 g_Weapon_manfire(wx
, wy
, dx
, dy
, 0, -1, True);
760 snd
:= 'SOUND_WEAPON_FIREBALL';
765 g_Weapon_revf(wx
, wy
, dx
, dy
, 0, ShotTarget
, -1, True);
766 snd
:= 'SOUND_WEAPON_FIREREV';
771 g_Weapon_Rocket(wx
, wy
, dx
, dy
, 0, -1, True);
772 snd
:= 'SOUND_WEAPON_FIREROCKET';
777 g_Weapon_BFGShot(wx
, wy
, dx
, dy
, 0, -1, True);
778 snd
:= 'SOUND_WEAPON_FIREBFG';
784 g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET
, wx
- 64, wy
- 64);
787 g_Weapon_Explode(wx
, wy
, 60, 0);
788 snd
:= 'SOUND_WEAPON_EXPLODEROCKET';
791 TRIGGER_SHOT_BFGEXPL
:
794 g_GFX_QueueEffect(R_GFX_EXPLODE_BFG
, wx
- 64, wy
- 64);
797 g_Weapon_BFG9000(wx
, wy
, 0);
798 snd
:= 'SOUND_WEAPON_EXPLODEBFG';
803 g_Weapon_flame(wx
, wy
, dx
, dy
, 0, -1, True);
804 snd
:= 'SOUND_GAME_BURNING';
810 if g_Game_IsNet
and g_Game_IsServer
then
813 TRIGGER_SHOT_EXPL
: MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_EXPLODE
);
814 TRIGGER_SHOT_BFGEXPL
: MH_SEND_Effect(wx
, wy
, Byte(ShotSound
), NET_GFX_BFGEXPL
);
817 if Projectile
then MH_SEND_CreateShot(LastShotID
);
818 if ShotSound
then MH_SEND_Sound(wx
, wy
, snd
);
823 if ShotSound
then g_Sound_PlayExAt(snd
, wx
, wy
);
825 if Projectile
then Result
:= LastShotID
;
829 procedure MakeShot (var Trigger
: TTrigger
; wx
, wy
, dx
, dy
: Integer; TargetUID
: Word);
833 if (tgcAmmo
= 0) or ((tgcAmmo
> 0) and (ShotAmmoCount
> 0)) then
835 if (trigPanelGUID
<> -1) and (ShotPanelTime
= 0) then
837 g_Map_SwitchTextureGUID({ShotPanelType,} trigPanelGUID
);
838 ShotPanelTime
:= 4; // òèêîâ íà âñïûøêó âûñòðåëà
841 if (tgcSight
> 0) then ShotSightTimeout
:= 180; // ~= 5 ñåêóíä
843 if (ShotAmmoCount
> 0) then Dec(ShotAmmoCount
);
845 dx
+= Random(tgcAccuracy
)-Random(tgcAccuracy
);
846 dy
+= Random(tgcAccuracy
)-Random(tgcAccuracy
);
848 tr_SpawnShot(tgcShotType
, wx
, wy
, dx
, dy
, tgcShotSound
, TargetUID
);
852 if (tgcReload
> 0) and (ShotReloadTime
= 0) then
854 ShotReloadTime
:= tgcReload
; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
861 procedure tr_MakeEffect (X
, Y
, VX
, VY
: Integer; T
, ST
, CR
, CG
, CB
: Byte; Silent
, Send
: Boolean);
864 if T
= TRIGGER_EFFECT_PARTICLE
then
867 TRIGGER_EFFECT_SLIQUID
:
869 if (CR
= 255) and (CG
= 0) and (CB
= 0) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 1, 0, 0, 0)
870 else if (CR
= 0) and (CG
= 255) and (CB
= 0) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 2, 0, 0, 0)
871 else if (CR
= 0) and (CG
= 0) and (CB
= 255) then g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 3, 0, 0, 0)
872 else g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 0, 0, 0, 0);
874 TRIGGER_EFFECT_LLIQUID
: g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 4, CR
, CG
, CB
);
875 TRIGGER_EFFECT_DLIQUID
: g_GFX_SimpleWater(X
, Y
, 1, VX
, VY
, 5, CR
, CG
, CB
);
876 TRIGGER_EFFECT_BLOOD
: g_GFX_Blood(X
, Y
, 1, VX
, VY
, 0, 0, CR
, CG
, CB
);
877 TRIGGER_EFFECT_SPARK
: g_GFX_Spark(X
, Y
, 1, GetAngle2(VX
, VY
), 0, 0);
878 TRIGGER_EFFECT_BUBBLE
: g_GFX_Bubbles(X
, Y
, 1, 0, 0);
883 if T
= TRIGGER_EFFECT_ANIMATION
then
886 EFFECT_TELEPORT
: begin
887 if not Silent
then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X
, Y
);
889 g_GFX_QueueEffect(R_GFX_TELEPORT_FAST
, X
- 32, Y
- 32);
891 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
, Y
, Byte(not Silent
), NET_GFX_TELE
);
893 EFFECT_RESPAWN
: begin
894 if not Silent
then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X
, Y
);
896 g_GFX_QueueEffect(R_GFX_ITEM_RESPAWN
, X
- 16, Y
- 16);
898 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
-16, Y
-16, Byte(not Silent
), NET_GFX_RESPAWN
);
901 if not Silent
then g_Sound_PlayExAt('SOUND_FIRE', X
, Y
);
903 g_GFX_QueueEffect(R_GFX_FIRE
, X
- 32, Y
- 128);
905 if Send
and g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Effect(X
-32, Y
-128, Byte(not Silent
), NET_GFX_FIRE
);
912 function tr_Teleport (ActivateUID
: Integer; TX
, TY
: Integer; TDir
: Integer; Silent
: Boolean; D2D
: Boolean): Boolean;
918 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
919 case g_GetUIDType(ActivateUID
) of
922 p
:= g_Player_Get(ActivateUID
);
923 if p
= nil then Exit
;
926 if p
.TeleportTo(TX
-(p
.Obj
.Rect
.Width
div 2), TY
-p
.Obj
.Rect
.Height
, Silent
, TDir
) then result
:= true;
930 if p
.TeleportTo(TX
, TY
, Silent
, TDir
) then result
:= true;
935 m
:= g_Monsters_ByUID(ActivateUID
);
936 if m
= nil then Exit
;
939 if m
.TeleportTo(TX
-(m
.Obj
.Rect
.Width
div 2), TY
-m
.Obj
.Rect
.Height
, Silent
, TDir
) then result
:= true;
943 if m
.TeleportTo(TX
, TY
, Silent
, TDir
) then result
:= true;
950 function tr_Push (ActivateUID
: Integer; VX
, VY
: Integer; ResetVel
: Boolean): Boolean;
956 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then exit
;
957 case g_GetUIDType(ActivateUID
) of
960 p
:= g_Player_Get(ActivateUID
);
961 if p
= nil then Exit
;
976 m
:= g_Monsters_ByUID(ActivateUID
);
977 if m
= nil then Exit
;
993 function tr_Message (MKind
: Integer; MText
: string; MSendTo
: Integer; MTime
: Integer; ActivateUID
: Integer): Boolean;
1000 if (ActivateUID
< 0) or (ActivateUID
> $FFFF) then Exit
;
1001 msg
:= b_Text_Format(MText
);
1003 TRIGGER_MESSAGE_DEST_ME
: // activator
1005 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1007 if g_Game_IsWatchedPlayer(ActivateUID
) then
1009 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1010 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1014 p
:= g_Player_Get(ActivateUID
);
1015 if g_Game_IsNet
and (p
.FClientID
>= 0) then
1017 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, p
.FClientID
)
1018 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, p
.FClientID
);
1024 TRIGGER_MESSAGE_DEST_MY_TEAM
: // activator's team
1026 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1028 p
:= g_Player_Get(ActivateUID
);
1029 if g_Game_IsWatchedTeam(p
.Team
) then
1031 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1032 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1035 if g_Game_IsNet
then
1037 for i
:= Low(gPlayers
) to High(gPlayers
) do
1039 if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
1041 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1042 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1049 TRIGGER_MESSAGE_DEST_ENEMY_TEAM
: // activator's enemy team
1051 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1053 p
:= g_Player_Get(ActivateUID
);
1054 if g_Game_IsWatchedTeam(p
.Team
) then
1056 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1057 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1060 if g_Game_IsNet
then
1062 for i
:= Low(gPlayers
) to High(gPlayers
) do
1064 if (gPlayers
[i
].Team
<> p
.Team
) and (gPlayers
[i
].FClientID
>= 0) then
1066 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1067 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1074 TRIGGER_MESSAGE_DEST_RED_TEAM
: // red team
1076 if g_Game_IsWatchedTeam(TEAM_RED
) then
1078 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1079 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1082 if g_Game_IsNet
then
1084 for i
:= Low(gPlayers
) to High(gPlayers
) do
1086 if (gPlayers
[i
].Team
= TEAM_RED
) and (gPlayers
[i
].FClientID
>= 0) then
1088 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1089 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1095 TRIGGER_MESSAGE_DEST_BLUE_TEAM
: // blue team
1097 if g_Game_IsWatchedTeam(TEAM_BLUE
) then
1099 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1100 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1103 if g_Game_IsNet
then
1105 for i
:= Low(gPlayers
) to High(gPlayers
) do
1107 if (gPlayers
[i
].Team
= TEAM_BLUE
) and (gPlayers
[i
].FClientID
>= 0) then
1109 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
, gPlayers
[i
].FClientID
)
1110 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
, gPlayers
[i
].FClientID
);
1116 TRIGGER_MESSAGE_DEST_EVERYONE
: // everyone
1118 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then g_Console_Add(msg
, True)
1119 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then g_Game_Message(msg
, MTime
);
1121 if g_Game_IsNet
then
1123 if MKind
= TRIGGER_MESSAGE_KIND_CHAT
then MH_SEND_Chat(msg
, NET_CHAT_SYSTEM
)
1124 else if MKind
= TRIGGER_MESSAGE_KIND_GAME
then MH_SEND_GameEvent(NET_EV_BIGTEXT
, MTime
, msg
);
1131 function tr_ShotAimCheck (var Trigger
: TTrigger
; Obj
: PObj
): Boolean;
1136 if TriggerType
<> TRIGGER_SHOT
then Exit
;
1137 result
:= (tgcAim
and TRIGGER_SHOT_AIM_ALLMAP
> 0)
1138 or g_Obj_Collide(X
, Y
, Width
, Height
, Obj
);
1139 if result
and (tgcAim
and TRIGGER_SHOT_AIM_TRACE
> 0) then
1141 result
:= g_TraceVector(tgcTX
, tgcTY
,
1142 Obj
^.X
+ Obj
^.Rect
.X
+ (Obj
^.Rect
.Width
div 2),
1143 Obj
^.Y
+ Obj
^.Rect
.Y
+ (Obj
^.Rect
.Height
div 2));
1149 function ActivateTrigger (var Trigger
: TTrigger
; actType
: Byte): Boolean;
1155 idx
, k
, wx
, wy
, xd
, yd
: Integer;
1164 function monsShotTarget (mon
: TMonster
): Boolean;
1166 result
:= false; // don't stop
1167 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1169 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1170 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1171 TargetUID
:= mon
.UID
;
1172 result
:= true; // stop
1176 function monsShotTargetMonPlr (mon
: TMonster
): Boolean;
1178 result
:= false; // don't stop
1179 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1181 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1182 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1183 TargetUID
:= mon
.UID
;
1184 result
:= true; // stop
1188 function monShotTargetPlrMon (mon
: TMonster
): Boolean;
1190 result
:= false; // don't stop
1191 if mon
.alive
and tr_ShotAimCheck(Trigger
, @(mon
.Obj
)) then
1193 xd
:= mon
.GameX
+ mon
.Obj
.Rect
.Width
div 2;
1194 yd
:= mon
.GameY
+ mon
.Obj
.Rect
.Height
div 2;
1195 TargetUID
:= mon
.UID
;
1196 result
:= true; // stop
1204 if g_Game_IsClient
then exit
;
1206 if not Trigger
.Enabled
then exit
;
1207 if (Trigger
.TimeOut
<> 0) and (actType
<> ACTIVATE_CUSTOM
) then exit
;
1208 if (gLMSRespawn
> LMS_RESPAWN_NONE
) then exit
;
1210 if (Trigger
.exoCheck
<> nil) then
1212 //conwritefln('exocheck: [%s]', [Trigger.exoCheck.toString()]);
1214 tgscope
.me
:= @Trigger
;
1215 tvval
:= Trigger
.exoCheck
.value(tgscope
);
1217 if not Boolean(tvval
) then exit
;
1218 except on e
: Exception
do
1221 conwritefln('trigger exocheck error: %s [%s]', [e
.message, Trigger
.exoCheck
.toString()]);
1229 coolDown
:= (actType
<> 0);
1231 if (Trigger
.exoAction
<> nil) then
1233 //conwritefln('exoactivate: [%s]', [Trigger.exoAction.toString()]);
1235 tgscope
.me
:= @Trigger
;
1236 Trigger
.exoAction
.value(tgscope
);
1238 except on e
: Exception
do
1241 conwritefln('trigger exoactivate error: %s [%s]', [e
.message, Trigger
.exoAction
.toString()]);
1252 g_Sound_PlayEx('SOUND_GAME_SWITCH0');
1253 if g_Game_IsNet
then MH_SEND_Sound(X
, Y
, 'SOUND_GAME_SWITCH0');
1254 gExitByTrigger
:= True;
1255 g_Game_ExitLevel(tgcMap
);
1264 Result
:= tr_Teleport(ActivateUID
,
1265 tgcTarget
.X
, tgcTarget
.Y
,
1266 tgcDirection
, tgcSilent
,
1273 Result
:= tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1279 Result
:= tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1283 TRIGGER_DOOR
, TRIGGER_DOOR5
:
1285 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
1286 if (pan
<> nil) and pan
.isGWall
then
1288 if gWalls
[{trigPanelID}pan
.arrIdx
].Enabled
then
1290 result
:= tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1291 if (TriggerType
= TRIGGER_DOOR5
) then DoorTime
:= 180;
1295 result
:= tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
1298 if result
then TimeOut
:= 18;
1302 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1304 tr_CloseTrap(trigPanelGUID
, tgcSilent
, tgcD2d
);
1306 if TriggerType
= TRIGGER_TRAP
then
1320 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
1323 if PressTime
= -1 then PressTime
:= tgcWait
;
1324 if coolDown
then TimeOut
:= 18 else TimeOut
:= 0;
1329 if g_GetUIDType(ActivateUID
) = UID_PLAYER
then
1333 p
:= g_Player_Get(ActivateUID
);
1335 Inc(gCoopSecretsFound
);
1336 if g_Game_IsNet
then
1338 MH_SEND_GameStats();
1339 MH_SEND_GameEvent(NET_EV_SECRET
, p
.UID
, '');
1345 Result
:= tr_SetLift(trigPanelGUID
, 0, tgcSilent
, tgcD2d
);
1348 if (not tgcSilent
) and Result
then begin
1349 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1351 Y
+ (Height
div 2));
1352 if g_Game_IsServer
and g_Game_IsNet
then
1353 MH_SEND_Sound(X
+ (Width
div 2),
1355 'SOUND_GAME_SWITCH0');
1361 Result
:= tr_SetLift(trigPanelGUID
, 1, tgcSilent
, tgcD2d
);
1364 if (not tgcSilent
) and Result
then begin
1365 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1367 Y
+ (Height
div 2));
1368 if g_Game_IsServer
and g_Game_IsNet
then
1369 MH_SEND_Sound(X
+ (Width
div 2),
1371 'SOUND_GAME_SWITCH0');
1377 Result
:= tr_SetLift(trigPanelGUID
, 3, tgcSilent
, tgcD2d
);
1383 if (not tgcSilent
) and Result
then begin
1384 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1386 Y
+ (Height
div 2));
1387 if g_Game_IsServer
and g_Game_IsNet
then
1388 MH_SEND_Sound(X
+ (Width
div 2),
1390 'SOUND_GAME_SWITCH0');
1397 if tgcActivateOnce
then
1400 TriggerType
:= TRIGGER_NONE
;
1408 animonce
:= tgcAnimateOnce
;
1414 if Sound
<> nil then
1416 if tgcSoundSwitch
and Sound
.IsPlaying() then
1417 begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
1419 SoundPlayCount
:= 0;
1422 else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
1423 if (tgcPlayCount
> 0) or (not Sound
.IsPlaying()) then
1425 if tgcPlayCount
> 0 then
1426 SoundPlayCount
:= tgcPlayCount
1427 else // 0 - èãðàåì áåñêîíå÷íî
1428 SoundPlayCount
:= 1;
1431 if g_Game_IsNet
then MH_SEND_TriggerSound(Trigger
);
1435 TRIGGER_SPAWNMONSTER
:
1436 if (tgcSpawnMonsType
in [MONSTER_DEMON
..MONSTER_MAN
]) then
1439 if (tgcDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1441 AutoSpawn
:= not AutoSpawn
;
1443 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1447 if ((tgcDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1448 or ((tgcDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1449 for k
:= 1 to tgcMonsCount
do
1451 if (actType
= ACTIVATE_CUSTOM
) and (tgcDelay
> 0) then
1452 SpawnCooldown
:= -1; // Çàäåðæêà âûñòàâèòñÿ ìîíñòðîì ïðè óíè÷òîæåíèè
1453 if (tgcMax
> 0) and (SpawnedCount
>= tgcMax
) then
1456 mon
:= g_Monsters_Create(tgcSpawnMonsType
,
1458 TDirection(tgcDirection
), True);
1463 if (tgcHealth
> 0) then
1464 mon
.SetHealth(tgcHealth
);
1465 // Óñòàíàâëèâàåì ïîâåäåíèå:
1466 mon
.MonsterBehaviour
:= tgcBehaviour
;
1467 mon
.FNoRespawn
:= True;
1468 if g_Game_IsNet
then
1469 MH_SEND_MonsterSpawn(mon
.UID
);
1470 // Èäåì èñêàòü öåëü, åñëè íàäî:
1474 if tgcSpawnMonsType
<> MONSTER_BARREL
then Inc(gTotalMonsters
);
1476 if g_Game_IsNet
then
1478 SetLength(gMonstersSpawned
, Length(gMonstersSpawned
)+1);
1479 gMonstersSpawned
[High(gMonstersSpawned
)] := mon
.UID
;
1482 mon
.SpawnTrigger
:= ID
;
1483 if tgcMax
> 0 then Inc(SpawnedCount
);
1488 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX
, tgcTY
);
1491 R_GFX_TELEPORT_FAST
,
1492 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1493 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-32
1496 if g_Game_IsServer
and g_Game_IsNet
then
1497 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1498 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-32, 1,
1503 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX
, tgcTY
);
1507 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-16,
1508 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-16
1511 if g_Game_IsServer
and g_Game_IsNet
then
1512 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-16,
1513 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2)-16, 1,
1518 g_Sound_PlayExAt('SOUND_FIRE', tgcTX
, tgcTY
);
1522 mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1523 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+mon
.Obj
.Rect
.Height
-128
1526 if g_Game_IsServer
and g_Game_IsNet
then
1527 MH_SEND_Effect(mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2)-32,
1528 mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+mon
.Obj
.Rect
.Height
-128, 1,
1533 if g_Game_IsNet
then
1535 MH_SEND_GameStats();
1536 MH_SEND_CoopStats();
1543 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1544 if actType
= ACTIVATE_CUSTOM
then
1549 if (tgcSpawnItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
]) then
1552 if (tgcDelay
> 0) and (actType
<> ACTIVATE_CUSTOM
) then
1554 AutoSpawn
:= not AutoSpawn
;
1556 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1560 if ((tgcDelay
= 0) and (actType
<> ACTIVATE_CUSTOM
))
1561 or ((tgcDelay
> 0) and (actType
= ACTIVATE_CUSTOM
)) then
1562 if (not tgcDmonly
) or
1563 (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
1564 for k
:= 1 to tgcItemCount
do
1566 if (actType
= ACTIVATE_CUSTOM
) and (tgcDelay
> 0) then
1567 SpawnCooldown
:= -1; // Çàäåðæêà âûñòàâèòñÿ èòåìîì ïðè óíè÷òîæåíèè
1568 if (tgcMax
> 0) and (SpawnedCount
>= tgcMax
) then
1571 iid
:= g_Items_Create(tgcTX
, tgcTY
,
1572 tgcSpawnItemType
, tgcGravity
, False, True);
1576 it
:= g_Items_ByIdx(iid
);
1577 it
.SpawnTrigger
:= ID
;
1578 if tgcMax
> 0 then Inc(SpawnedCount
);
1583 it
:= g_Items_ByIdx(iid
);
1584 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX
, tgcTY
);
1587 R_GFX_TELEPORT_FAST
,
1588 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1589 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-32
1592 if g_Game_IsServer
and g_Game_IsNet
then
1593 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1594 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-32, 1,
1599 it
:= g_Items_ByIdx(iid
);
1600 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX
, tgcTY
);
1604 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-16,
1605 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-16
1608 if g_Game_IsServer
and g_Game_IsNet
then
1609 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-16,
1610 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+(it
.Obj
.Rect
.Height
div 2)-16, 1,
1615 it
:= g_Items_ByIdx(iid
);
1616 g_Sound_PlayExAt('SOUND_FIRE', tgcTX
, tgcTY
);
1620 it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1621 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+it
.Obj
.Rect
.Height
-128
1624 if g_Game_IsServer
and g_Game_IsNet
then
1625 MH_SEND_Effect(it
.Obj
.X
+it
.Obj
.Rect
.X
+(it
.Obj
.Rect
.Width
div 2)-32,
1626 it
.Obj
.Y
+it
.Obj
.Rect
.Y
+it
.Obj
.Rect
.Height
-128, 1,
1631 if g_Game_IsNet
then
1632 MH_SEND_ItemSpawn(True, iid
);
1639 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1640 if actType
= ACTIVATE_CUSTOM
then
1646 // Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
1647 if (Trigger
.tgcMusicName
<> '') then
1649 gMusic
.SetByName(Trigger
.tgcMusicName
);
1650 gMusic
.SpecPause
:= True;
1654 case Trigger
.tgcMusicAction
of
1655 TRIGGER_MUSIC_ACTION_STOP
: // Âûêëþ÷èòü
1656 gMusic
.SpecPause
:= True; // Ïàóçà
1657 TRIGGER_MUSIC_ACTION_PLAY
: // Âêëþ÷èòü
1658 if gMusic
.SpecPause
then // Áûëà íà ïàóçå => èãðàòü
1659 gMusic
.SpecPause
:= False
1660 else // Èãðàëà => ñíà÷àëà
1661 gMusic
.SetPosition(0);
1669 if g_Game_IsNet
then MH_SEND_TriggerMusic
;
1674 pAngle
:= -DegToRad(tgcAngle
);
1675 Result
:= tr_Push(ActivateUID
,
1676 Floor(Cos(pAngle
)*tgcForce
),
1677 Floor(Sin(pAngle
)*tgcForce
),
1685 // Ïðèáàâèòü èëè îòíÿòü î÷êî
1686 if (tgcScoreAction
in [TRIGGER_SCORE_ACTION_ADD
, TRIGGER_SCORE_ACTION_SUB
]) and (tgcScoreCount
> 0) then
1688 // Ñâîåé èëè ÷óæîé êîìàíäå
1689 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1691 p
:= g_Player_Get(ActivateUID
);
1692 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
))
1693 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1695 Inc(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Scores
1699 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1701 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1702 if g_Game_IsServer
and g_Game_IsNet
then
1703 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+r');
1706 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1707 if g_Game_IsServer
and g_Game_IsNet
then
1708 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+re');
1714 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1715 if g_Game_IsServer
and g_Game_IsNet
then
1716 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1719 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
))
1720 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1722 Dec(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Fouls
1726 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1728 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1729 if g_Game_IsServer
and g_Game_IsNet
then
1730 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-r');
1733 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1734 if g_Game_IsServer
and g_Game_IsNet
then
1735 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-re');
1741 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1742 if g_Game_IsServer
and g_Game_IsNet
then
1743 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1746 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
))
1747 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1749 Inc(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Scores
1753 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1755 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1756 if g_Game_IsServer
and g_Game_IsNet
then
1757 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+b');
1760 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1761 if g_Game_IsServer
and g_Game_IsNet
then
1762 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '+be');
1768 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1769 if g_Game_IsServer
and g_Game_IsNet
then
1770 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1773 if ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
))
1774 or ((tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1776 Dec(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Fouls
1780 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1782 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_OWN
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1783 if g_Game_IsServer
and g_Game_IsNet
then
1784 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-b');
1787 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_ENEMY
], [p
.Name
, tgcScoreCount
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1788 if g_Game_IsServer
and g_Game_IsNet
then
1789 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
or (tgcScoreCount
shl 16), '-be');
1795 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1796 if g_Game_IsServer
and g_Game_IsNet
then
1797 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1800 Result
:= (p
.Team
= TEAM_RED
) or (p
.Team
= TEAM_BLUE
);
1802 // Êàêîé-òî êîíêðåòíîé êîìàíäå
1803 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_RED
, TRIGGER_SCORE_TEAM_FORCE_BLUE
] then
1805 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then
1807 Inc(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Scores
1811 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], tgcScoreCount
]), True);
1812 if g_Game_IsServer
and g_Game_IsNet
then
1813 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '+tr');
1818 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1819 if g_Game_IsServer
and g_Game_IsNet
then
1820 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_RED
);
1823 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then
1825 Dec(gTeamStat
[TEAM_RED
].Goals
, tgcScoreCount
); // Red Fouls
1829 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_RED
], tgcScoreCount
]), True);
1830 if g_Game_IsServer
and g_Game_IsNet
then
1831 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '-tr');
1836 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 108);
1837 if g_Game_IsServer
and g_Game_IsNet
then
1838 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_RED
);
1841 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_ADD
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then
1843 Inc(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Scores
1847 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_ADD_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], tgcScoreCount
]), True);
1848 if g_Game_IsServer
and g_Game_IsNet
then
1849 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '+tb');
1854 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_ADD
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1855 if g_Game_IsServer
and g_Game_IsNet
then
1856 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, TEAM_BLUE
);
1859 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_SUB
) and (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then
1861 Dec(gTeamStat
[TEAM_BLUE
].Goals
, tgcScoreCount
); // Blue Fouls
1865 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_SUB_TEAM
], [_lc
[I_PLAYER_SCORE_BLUE
], tgcScoreCount
]), True);
1866 if g_Game_IsServer
and g_Game_IsNet
then
1867 MH_SEND_GameEvent(NET_EV_SCORE
, tgcScoreCount
shl 16, '-tb');
1872 g_Game_Message(Format(_lc
[I_MESSAGE_SCORE_SUB
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 108);
1873 if g_Game_IsServer
and g_Game_IsNet
then
1874 MH_SEND_GameEvent(NET_EV_SCORE_MSG
, -TEAM_BLUE
);
1881 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_WIN
) and (gGameSettings
.GoalLimit
> 0) then
1883 // Ñâîåé èëè ÷óæîé êîìàíäû
1884 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1886 p
:= g_Player_Get(ActivateUID
);
1887 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
)) // Red Wins
1888 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1890 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1892 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1896 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1898 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1899 if g_Game_IsServer
and g_Game_IsNet
then
1900 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1903 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1904 if g_Game_IsServer
and g_Game_IsNet
then
1905 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1912 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
)) // Blue Wins
1913 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1915 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1917 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1921 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) then
1923 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1924 if g_Game_IsServer
and g_Game_IsNet
then
1925 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
1928 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1929 if g_Game_IsServer
and g_Game_IsNet
then
1930 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
1938 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1939 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_RED
, TRIGGER_SCORE_TEAM_FORCE_BLUE
] then
1941 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then // Red Wins
1943 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1945 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1949 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then // Blue Wins
1951 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1953 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1960 if (tgcScoreAction
= TRIGGER_SCORE_ACTION_LOOSE
) and (gGameSettings
.GoalLimit
> 0) then
1962 // Ñâîåé èëè ÷óæîé êîìàíäû
1963 if (tgcScoreTeam
in [TRIGGER_SCORE_TEAM_MINE_RED
, TRIGGER_SCORE_TEAM_MINE_BLUE
]) and (g_GetUIDType(ActivateUID
) = UID_PLAYER
) then
1965 p
:= g_Player_Get(ActivateUID
);
1966 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_BLUE
)) // Red Wins
1967 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_RED
)) then
1968 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1970 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
1973 if tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
then
1975 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1976 if g_Game_IsServer
and g_Game_IsNet
then
1977 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wre');
1980 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_RED
]]), True);
1981 if g_Game_IsServer
and g_Game_IsNet
then
1982 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wr');
1987 if ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
) and (p
.Team
= TEAM_RED
)) // Blue Wins
1988 or ((tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_BLUE
) and (p
.Team
= TEAM_BLUE
)) then
1989 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
1991 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
1994 if tgcScoreTeam
= TRIGGER_SCORE_TEAM_MINE_RED
then
1996 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_ENEMY
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
1997 if g_Game_IsServer
and g_Game_IsNet
then
1998 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wbe');
2001 g_Console_Add(Format(_lc
[I_PLAYER_SCORE_WIN_OWN
], [p
.Name
, _lc
[I_PLAYER_SCORE_TO_BLUE
]]), True);
2002 if g_Game_IsServer
and g_Game_IsNet
then
2003 MH_SEND_GameEvent(NET_EV_SCORE
, p
.UID
, 'wb');
2009 // Êàêîé-òî êîíêðåòíîé êîìàíäû
2010 if tgcScoreTeam
in [TRIGGER_SCORE_TEAM_FORCE_BLUE
, TRIGGER_SCORE_TEAM_FORCE_RED
] then
2012 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_BLUE
) then // Red Wins
2014 if gTeamStat
[TEAM_RED
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
2016 gTeamStat
[TEAM_RED
].Goals
:= gGameSettings
.GoalLimit
;
2020 if (tgcScoreTeam
= TRIGGER_SCORE_TEAM_FORCE_RED
) then // Blue Wins
2022 if gTeamStat
[TEAM_BLUE
].Goals
< SmallInt(gGameSettings
.GoalLimit
) then
2024 gTeamStat
[TEAM_BLUE
].Goals
:= gGameSettings
.GoalLimit
;
2030 if Result
then begin
2035 if g_Game_IsServer
and g_Game_IsNet
then
2042 Result
:= tr_Message(tgcKind
, tgcText
,
2043 tgcMsgDest
, tgcMsgTime
,
2048 TRIGGER_DAMAGE
, TRIGGER_HEALTH
:
2051 UIDType
:= g_GetUIDType(ActivateUID
);
2052 if (UIDType
= UID_PLAYER
) or (UIDType
= UID_MONSTER
) then
2058 // Âñïîìèíàåì, àêòèâèðîâàë ëè îí ìåíÿ ðàíüøå
2059 for idx
:= 0 to High(Activators
) do
2060 if Activators
[idx
].UID
= ActivateUID
then
2066 begin // Âèäèì åãî âïåðâûå
2068 SetLength(Activators
, Length(Activators
) + 1);
2069 k
:= High(Activators
);
2070 Activators
[k
].UID
:= ActivateUID
;
2072 begin // Óæå âèäåëè åãî
2073 // Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
2074 if (tgcInterval
= 0) and (Activators
[k
].TimeOut
> 0) then
2075 Activators
[k
].TimeOut
:= 65535;
2076 // Òàéìàóò ïðîø¸ë - ðàáîòàåì
2077 Result
:= Activators
[k
].TimeOut
= 0;
2086 p
:= g_Player_Get(ActivateUID
);
2090 // Íàíîñèì óðîí èãðîêó
2091 if (TriggerType
= TRIGGER_DAMAGE
) and (tgcAmount
> 0) then
2093 // Êèñëîòíûé óðîí íå íàíîñèòñÿ êîãäà åñòü êîñòþì
2094 // "Âîäÿíîé" óðîí íå íàíîñèòñÿ êîãäà åñòü êèñëîðîä
2095 if not (((tgcKind
= HIT_ACID
) and (p
.FMegaRulez
[MR_SUIT
] > gTime
)) or
2096 ((tgcKind
= HIT_WATER
) and (p
.Air
> 0))) then
2097 p
.Damage(tgcAmount
, 0, 0, 0, tgcKind
);
2098 if (tgcKind
= HIT_FLAME
) then p
.CatchFire(0);
2102 if (TriggerType
= TRIGGER_HEALTH
) and (tgcAmount
> 0) then
2103 if p
.Heal(tgcAmount
, not tgcHealMax
) and (not tgcSilent
) then
2105 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p
.Obj
.X
, p
.Obj
.Y
);
2106 if g_Game_IsServer
and g_Game_IsNet
then
2107 MH_SEND_Sound(p
.Obj
.X
, p
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
2113 m
:= g_Monsters_ByUID(ActivateUID
);
2117 // Íàíîñèì óðîí ìîíñòðó
2118 if (TriggerType
= TRIGGER_DAMAGE
) and (tgcAmount
> 0) then
2120 m
.Damage(tgcAmount
, 0, 0, 0, tgcKind
);
2121 if (tgcKind
= HIT_FLAME
) then m
.CatchFire(0);
2125 if (TriggerType
= TRIGGER_HEALTH
) and (tgcAmount
> 0) then
2126 if m
.Heal(tgcAmount
) and (not tgcSilent
) then
2128 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m
.Obj
.X
, m
.Obj
.Y
);
2129 if g_Game_IsServer
and g_Game_IsNet
then
2130 MH_SEND_Sound(m
.Obj
.X
, m
.Obj
.Y
, 'SOUND_ITEM_GETITEM');
2134 // Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
2138 Activators
[k
].TimeOut
:= idx
2140 Activators
[k
].TimeOut
:= 65535;
2148 if ShotSightTime
> 0 then
2151 // put this at the beginning so it doesn't trigger itself
2152 TimeOut
:= tgcWait
+ 1;
2156 pAngle
:= -DegToRad(tgcAngle
);
2157 xd
:= wx
+ Round(Cos(pAngle
) * 32.0);
2158 yd
:= wy
+ Round(Sin(pAngle
) * 32.0);
2161 case tgcShotTarget
of
2162 TRIGGER_SHOT_TARGET_MON
: // monsters
2163 //TODO: accelerate this!
2164 g_Mons_ForEachAlive(monsShotTarget
);
2166 TRIGGER_SHOT_TARGET_PLR
: // players
2167 if gPlayers
<> nil then
2168 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2169 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2170 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2172 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2173 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2174 TargetUID
:= gPlayers
[idx
].UID
;
2178 TRIGGER_SHOT_TARGET_RED
: // red team
2179 if gPlayers
<> nil then
2180 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2181 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2182 (gPlayers
[idx
].Team
= TEAM_RED
) and
2183 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2185 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2186 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2187 TargetUID
:= gPlayers
[idx
].UID
;
2191 TRIGGER_SHOT_TARGET_BLUE
: // blue team
2192 if gPlayers
<> nil then
2193 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2194 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2195 (gPlayers
[idx
].Team
= TEAM_BLUE
) and
2196 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2198 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2199 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2200 TargetUID
:= gPlayers
[idx
].UID
;
2204 TRIGGER_SHOT_TARGET_MONPLR
: // monsters then players
2206 //TODO: accelerate this!
2207 g_Mons_ForEachAlive(monsShotTargetMonPlr
);
2209 if (TargetUID
= 0) and (gPlayers
<> nil) then
2210 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2211 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2212 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2214 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2215 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2216 TargetUID
:= gPlayers
[idx
].UID
;
2221 TRIGGER_SHOT_TARGET_PLRMON
: // players then monsters
2223 if gPlayers
<> nil then
2224 for idx
:= Low(gPlayers
) to High(gPlayers
) do
2225 if (gPlayers
[idx
] <> nil) and gPlayers
[idx
].alive
and
2226 tr_ShotAimCheck(Trigger
, @(gPlayers
[idx
].Obj
)) then
2228 xd
:= gPlayers
[idx
].GameX
+ PLAYER_RECT_CX
;
2229 yd
:= gPlayers
[idx
].GameY
+ PLAYER_RECT_CY
;
2230 TargetUID
:= gPlayers
[idx
].UID
;
2233 if TargetUID
= 0 then
2235 //TODO: accelerate this!
2236 g_Mons_ForEachAlive(monShotTargetPlrMon
);
2241 if (tgcShotTarget
<> TRIGGER_SHOT_TARGET_NONE
) or
2242 (tgcShotType
<> TRIGGER_SHOT_REV
) then
2243 TargetUID
:= ActivateUID
;
2247 if (tgcShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or (TargetUID
> 0) or
2248 ((tgcShotTarget
> TRIGGER_SHOT_TARGET_NONE
) and (TargetUID
= 0)) then
2251 if (tgcSight
= 0) or
2252 (tgcShotTarget
= TRIGGER_SHOT_TARGET_NONE
) or
2253 (TargetUID
= ShotSightTarget
) then
2254 MakeShot(Trigger
, wx
, wy
, xd
, yd
, TargetUID
)
2257 ShotSightTime
:= tgcSight
;
2258 ShotSightTargetN
:= TargetUID
;
2259 if tgcShotType
= TRIGGER_SHOT_BFG
then
2261 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx
, wy
);
2262 if g_Game_IsNet
and g_Game_IsServer
then
2263 MH_SEND_Sound(wx
, wy
, 'SOUND_WEAPON_STARTFIREBFG');
2276 TRIGGER_EFFECT_POS_CENTER
:
2278 wx
:= X
+ Width
div 2;
2279 wy
:= Y
+ Height
div 2;
2281 TRIGGER_EFFECT_POS_AREA
:
2283 wx
:= X
+ Random(Width
);
2284 wy
:= Y
+ Random(Height
);
2287 wx
:= X
+ Width
div 2;
2288 wy
:= Y
+ Height
div 2;
2293 if tgcSpreadL
> 0 then xd
-= Random(tgcSpreadL
+1);
2294 if tgcSpreadR
> 0 then xd
+= Random(tgcSpreadR
+1);
2295 if tgcSpreadU
> 0 then yd
-= Random(tgcSpreadU
+1);
2296 if tgcSpreadD
> 0 then yd
+= Random(tgcSpreadD
+1);
2297 tr_MakeEffect(wx
, wy
, xd
, yd
,
2298 tgcFXType
, tgcFXSubType
,
2299 tgcFXRed
, tgcFXGreen
, tgcFXBlue
, True, False);
2308 if Result
{and (Trigger.TexturePanel <> -1)} then
2310 g_Map_SwitchTextureGUID({Trigger.TexturePanelType,} Trigger
.TexturePanelGUID
, IfThen(animonce
, 2, 1));
2315 function g_Triggers_CreateWithMapIndex (aTrigger
: TTrigger
; arridx
, mapidx
: Integer): DWORD
;
2317 triggers
: TDynField
;
2319 triggers
:= gCurrentMap
['trigger'];
2320 if (triggers
= nil) then raise Exception
.Create('LOAD: map has no triggers');
2321 if (mapidx
< 0) or (mapidx
>= triggers
.count
) then raise Exception
.Create('LOAD: invalid map trigger index');
2322 aTrigger
.mapIndex
:= mapidx
;
2323 result
:= g_Triggers_Create(aTrigger
, triggers
.itemAt
[mapidx
], arridx
);
2327 function g_Triggers_Create (aTrigger
: TTrigger
; trec
: TDynRecord
; forceInternalIndex
: Integer=-1): DWORD
;
2334 if (tgscope
= nil) then tgscope
:= TTrigScope
.Create();
2335 if (tgclist
= nil) then tgclist
:= TMyConstList
.Create();
2337 // Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà
2338 if (aTrigger
.TriggerType
= TRIGGER_EXIT
) and
2339 (not LongBool(gGameSettings
.Options
and GAME_OPTION_ALLOWEXIT
)) then
2341 aTrigger
.TriggerType
:= TRIGGER_NONE
;
2344 // Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð
2345 if (aTrigger
.TriggerType
= TRIGGER_SPAWNMONSTER
) and
2346 (not LongBool(gGameSettings
.Options
and GAME_OPTION_MONSTERS
)) and
2347 (gGameSettings
.GameType
<> GT_SINGLE
) then
2349 aTrigger
.TriggerType
:= TRIGGER_NONE
;
2352 // Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå
2353 if (aTrigger
.TriggerType
= TRIGGER_SECRET
) then gSecretsCount
+= 1;
2355 if (forceInternalIndex
< 0) then
2357 find_id
:= FindTrigger();
2361 olen
:= Length(gTriggers
);
2362 if (forceInternalIndex
>= olen
) then
2364 SetLength(gTriggers
, forceInternalIndex
+1);
2365 for f
:= olen
to High(gTriggers
) do
2367 gTriggers
[f
].TriggerType
:= TRIGGER_NONE
;
2368 gTriggers
[f
].trigDataRec
:= nil;
2369 gTriggers
[f
].exoInit
:= nil;
2370 gTriggers
[f
].exoThink
:= nil;
2371 gTriggers
[f
].exoCheck
:= nil;
2372 gTriggers
[f
].exoAction
:= nil;
2373 gTriggers
[f
].userVars
:= nil;
2376 f
:= forceInternalIndex
;
2377 gTriggers
[f
].trigDataRec
.Free();
2378 gTriggers
[f
].exoInit
.Free();
2379 gTriggers
[f
].exoThink
.Free();
2380 gTriggers
[f
].exoCheck
.Free();
2381 gTriggers
[f
].exoAction
.Free();
2382 gTriggers
[f
].userVars
.Free();
2383 gTriggers
[f
].trigDataRec
:= nil;
2384 gTriggers
[f
].exoInit
:= nil;
2385 gTriggers
[f
].exoThink
:= nil;
2386 gTriggers
[f
].exoCheck
:= nil;
2387 gTriggers
[f
].exoAction
:= nil;
2388 gTriggers
[f
].userVars
:= nil;
2389 find_id
:= DWORD(forceInternalIndex
);
2391 gTriggers
[find_id
] := aTrigger
;
2392 ptg
:= @gTriggers
[find_id
];
2394 ptg
.mapId
:= trec
.id
;
2395 // clone trigger data
2396 if (trec
.trigRec
= nil) then
2398 ptg
.trigDataRec
:= nil;
2400 if (ptg
.TriggerType
<> TRIGGER_SECRET
) then
2402 e_LogWritefln('trigger of type %s has no triggerdata; wtf?!', [ptg
.TriggerType
], TMsgType
.Warning
);
2407 ptg
.trigDataRec
:= trec
.trigRec
.clone(nil);
2413 // if this type of trigger exists both on the client and on the server
2414 // use an uniform numeration
2416 if (ptg
.TriggerType
= TRIGGER_SOUND
) then
2418 Inc(gTriggerClientID
);
2419 ClientID
:= gTriggerClientID
;
2423 PlayerCollide
:= False;
2427 SoundPlayCount
:= 0;
2434 // update cached trigger variables
2435 trigUpdateCacheData(ptg
^, ptg
.trigDataRec
);
2437 ptg
.userVars
:= nil;
2440 ptg
.exoThink
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_think']));
2442 on e
: TExomaParseException
do
2444 conwritefln('*** ERROR parsing exoma_think (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_think'])]);
2445 ptg
.exoThink
:= nil;
2451 ptg
.exoCheck
:= TExprBase
.parse(tgclist
, VarToStr(trec
.user
['exoma_check']));
2453 on e
: TExomaParseException
do
2455 conwritefln('*** ERROR parsing exoma_check (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_check'])]);
2456 ptg
.exoCheck
:= nil;
2462 ptg
.exoAction
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_action']));
2464 on e
: TExomaParseException
do
2466 conwritefln('*** ERROR parsing exoma_action (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_action'])]);
2467 ptg
.exoAction
:= nil;
2473 ptg
.exoInit
:= TExprBase
.parseStatList(tgclist
, VarToStr(trec
.user
['exoma_init']));
2475 on e
: TExomaParseException
do
2477 conwritefln('*** ERROR parsing exoma_init (%s,%s): %s [%s]', [e
.tokLine
, e
.tokCol
, e
.message, VarToStr(trec
.user
['exoma_init'])]);
2484 if (forceInternalIndex
< 0) and (ptg
.exoInit
<> nil) then
2486 //conwritefln('executing trigger init: [%s]', [gTriggers[find_id].exoInit.toString()]);
2489 ptg
.exoInit
.value(tgscope
);
2493 conwritefln('*** trigger exoactivate error: %s', [ptg
.exoInit
.toString()]);
2498 // Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê"
2499 if (ptg
.TriggerType
= TRIGGER_SOUND
) and (ptg
.tgcSoundName
<> '') then
2501 // Åùå íåò òàêîãî çâóêà
2502 if not g_Sound_Exists(ptg
.tgcSoundName
) then
2504 fn
:= e_GetResourcePath(WadDirs
, ptg
.tgcSoundName
, g_ExtractWadName(gMapInfo
.Map
));
2505 //e_LogWritefln('loading trigger sound ''%s''', [fn]);
2506 if not g_Sound_CreateWADEx(ptg
.tgcSoundName
, fn
) then
2508 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, ptg
.tgcSoundName
]));
2512 // Ñîçäàåì îáúåêò çâóêà
2515 Sound
:= TPlayableSound
.Create();
2516 if not Sound
.SetByName(ptg
.tgcSoundName
) then
2524 // Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà"
2525 if (ptg
.TriggerType
= TRIGGER_MUSIC
) and (ptg
.tgcMusicName
<> '') then
2527 // Åùå íåò òàêîé ìóçûêè
2528 if not g_Sound_Exists(ptg
.tgcMusicName
) then
2530 fn
:= e_GetResourcePath(WadDirs
, ptg
.tgcMusicName
, g_ExtractWadName(gMapInfo
.Map
));
2531 if not g_Sound_CreateWADEx(ptg
.tgcMusicName
, fn
, True) then
2533 g_FatalError(Format(_lc
[I_GAME_ERROR_TR_SOUND
], [fn
, ptg
.tgcMusicName
]));
2538 // Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü"
2539 if (ptg
.TriggerType
= TRIGGER_SHOT
) then
2545 ShotSightTimeout
:= 0;
2546 ShotSightTarget
:= 0;
2547 ShotSightTargetN
:= 0;
2548 ShotAmmoCount
:= ptg
.tgcAmmo
;
2549 ShotReloadTime
:= 0;
2557 // sorry; grid doesn't support recursive queries, so we have to do this
2559 TSimpleMonsterList
= specialize TSimpleList
<TMonster
>;
2562 tgMonsList
: TSimpleMonsterList
= nil;
2564 procedure g_Triggers_Update();
2567 Affected
: array of Integer;
2569 function monsNear (mon
: TMonster
): Boolean;
2571 result
:= false; // don't stop
2573 gTriggers[a].ActivateUID := mon.UID;
2574 ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
2576 tgMonsList
.append(mon
);
2583 if (tgMonsList
= nil) then tgMonsList
:= TSimpleMonsterList
.Create();
2585 if gTriggers
= nil then Exit
;
2586 if gLMSRespawn
> LMS_RESPAWN_NONE
then Exit
; // don't update triggers at all
2588 SetLength(Affected
, 0);
2590 for a
:= 0 to High(gTriggers
) do
2591 with gTriggers
[a
] do
2593 if TriggerType
<> TRIGGER_NONE
then
2595 // Óìåíüøàåì âðåìÿ äî çàêðûòèÿ äâåðè (îòêðûòèÿ ëîâóøêè)
2596 if DoorTime
> 0 then DoorTime
:= DoorTime
- 1;
2597 // Óìåíüøàåì âðåìÿ îæèäàíèÿ ïîñëå íàæàòèÿ
2598 if PressTime
> 0 then PressTime
:= PressTime
- 1;
2599 // Ïðîâåðÿåì èãðîêîâ è ìîíñòðîâ, êîòîðûõ ðàíåå çàïîìíèëè:
2600 if (TriggerType
= TRIGGER_DAMAGE
) or (TriggerType
= TRIGGER_HEALTH
) then
2602 for b
:= 0 to High(Activators
) do
2604 // Óìåíüøàåì âðåìÿ äî ïîâòîðíîãî âîçäåéñòâèÿ:
2605 if Activators
[b
].TimeOut
> 0 then
2607 Dec(Activators
[b
].TimeOut
);
2613 // Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
2614 if (tgcInterval
= 0) and (Activators
[b
].TimeOut
< 65530) then Activators
[b
].TimeOut
:= 0;
2618 // Îáðàáàòûâàåì ñïàâíåðû
2619 if Enabled
and AutoSpawn
then
2621 if SpawnCooldown
= 0 then
2623 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà
2624 if (TriggerType
= TRIGGER_SPAWNMONSTER
) and (tgcDelay
> 0) then
2627 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2629 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò
2630 if (TriggerType
= TRIGGER_SPAWNITEM
) and (tgcDelay
> 0) then
2633 ActivateTrigger(gTriggers
[a
], ACTIVATE_CUSTOM
);
2638 // Óìåíüøàåì âðåìÿ îæèäàíèÿ
2643 // Îáðàáàòûâàåì ñîáûòèÿ òðèããåðà "Òóðåëü"
2644 if TriggerType
= TRIGGER_SHOT
then
2646 if ShotPanelTime
> 0 then
2649 if ShotPanelTime
= 0 then g_Map_SwitchTextureGUID({ShotPanelType,} trigPanelGUID
);
2651 if ShotSightTime
> 0 then
2654 if ShotSightTime
= 0 then ShotSightTarget
:= ShotSightTargetN
;
2656 if ShotSightTimeout
> 0 then
2658 Dec(ShotSightTimeout
);
2659 if ShotSightTimeout
= 0 then ShotSightTarget
:= 0;
2661 if ShotReloadTime
> 0 then
2663 Dec(ShotReloadTime
);
2664 if ShotReloadTime
= 0 then ShotAmmoCount
:= tgcAmmo
;
2668 // Òðèããåð "Çâóê" óæå îòûãðàë, åñëè íóæíî åùå - ïåðåçàïóñêàåì
2669 if Enabled
and (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) then
2671 if (SoundPlayCount
> 0) and (not Sound
.IsPlaying()) then
2673 if tgcPlayCount
> 0 then Dec(SoundPlayCount
); (* looped sound if zero *)
2675 Sound
.PlayVolumeAtRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
2677 Sound
.PlayPanVolume((tgcPan
- 127.0) / 128.0, tgcVolume
/ 255.0);
2678 if Sound
.IsPlaying() and g_Game_IsNet
and g_Game_IsServer
then
2679 MH_SEND_TriggerSound(gTriggers
[a
])
2683 // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü
2684 if (TriggerType
= TRIGGER_TRAP
) and (DoorTime
= 0) and (g_Map_PanelByGUID(trigPanelGUID
) <> nil) then
2686 tr_OpenDoor(trigPanelGUID
, tgcSilent
, tgcD2d
);
2690 // Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü
2691 if (TriggerType
= TRIGGER_DOOR5
) and (DoorTime
= 0) and (g_Map_PanelByGUID(trigPanelGUID
) <> nil) then
2693 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
2694 if (pan
<> nil) and pan
.isGWall
then
2697 if {gWalls[trigPanelID].Enabled} pan
.Enabled
then
2703 // Ïîêà îòêðûòà - çàêðûâàåì
2704 if tr_CloseDoor(trigPanelGUID
, tgcSilent
, tgcD2d
) then DoorTime
:= -1;
2709 // Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
2710 if (TriggerType
in [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) and
2711 (PressTime
= 0) and (PressCount
>= tgcPressCount
) then
2713 // Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
2715 // Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
2716 if tgcPressCount
> 0 then PressCount
-= tgcPressCount
else PressCount
:= 0;
2718 // Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
2719 for b
:= 0 to High(gTriggers
) do
2721 if g_Collide(tgcTX
, tgcTY
, tgcTWidth
, tgcTHeight
, gTriggers
[b
].X
, gTriggers
[b
].Y
,
2722 gTriggers
[b
].Width
, gTriggers
[b
].Height
) and
2723 ((b
<> a
) or (tgcWait
> 0)) then
2724 begin // Can be self-activated, if there is Data.Wait
2725 if (not tgcExtRandom
) or gTriggers
[b
].Enabled
then
2727 SetLength(Affected
, Length(Affected
) + 1);
2728 Affected
[High(Affected
)] := b
;
2734 // if we have panelid, assume that it will switch the moving platform
2735 pan
:= g_Map_PanelByGUID(trigPanelGUID
);
2736 if (pan
<> nil) then
2739 TRIGGER_PRESS
: pan
.movingActive
:= true; // what to do here?
2740 TRIGGER_ON
: pan
.movingActive
:= true;
2741 TRIGGER_OFF
: pan
.movingActive
:= false;
2742 TRIGGER_ONOFF
: pan
.movingActive
:= not pan
.movingActive
;
2744 if not tgcSilent
and (Length(tgcSound
) > 0) then
2746 g_Sound_PlayExAt(tgcSound
, X
, Y
);
2747 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_Sound(X
, Y
, tgcSound
);
2751 // Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
2752 if (TriggerType
= TRIGGER_PRESS
) and tgcExtRandom
then
2754 if (Length(Affected
) > 0) then
2756 b
:= Affected
[Random(Length(Affected
))];
2757 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2758 ActivateTrigger(gTriggers
[b
], 0);
2761 else //  ïðîòèâíîì ñëó÷àå ðàáîòàåì êàê îáû÷íî:
2763 for i
:= 0 to High(Affected
) do
2769 gTriggers
[b
].ActivateUID
:= gTriggers
[a
].ActivateUID
;
2770 ActivateTrigger(gTriggers
[b
], 0);
2774 gTriggers
[b
].Enabled
:= True;
2778 gTriggers
[b
].Enabled
:= False;
2779 gTriggers
[b
].TimeOut
:= 0;
2780 if gTriggers
[b
].AutoSpawn
then
2782 gTriggers
[b
].AutoSpawn
:= False;
2783 gTriggers
[b
].SpawnCooldown
:= 0;
2788 gTriggers
[b
].Enabled
:= not gTriggers
[b
].Enabled
;
2789 if not gTriggers
[b
].Enabled
then
2791 gTriggers
[b
].TimeOut
:= 0;
2792 if gTriggers
[b
].AutoSpawn
then
2794 gTriggers
[b
].AutoSpawn
:= False;
2795 gTriggers
[b
].SpawnCooldown
:= 0;
2802 SetLength(Affected
, 0);
2805 // Óìåíüøàåì âðåìÿ äî âîçìîæíîñòè ïîâòîðíîé àêòèâàöèè:
2808 TimeOut
:= TimeOut
- 1;
2809 Continue
; // ×òîáû íå ïîòåðÿòü 1 åäèíèöó çàäåðæêè
2812 // Íèæå èäóò òèïû àêòèâàöèè, åñëè òðèããåð îòêëþ÷¸í - èä¸ì äàëüøå
2817 if ByteBool(ActivateType
and ACTIVATE_PLAYERCOLLIDE
) and
2819 if gPlayers
<> nil then
2820 for b
:= 0 to High(gPlayers
) do
2821 if gPlayers
[b
] <> nil then
2823 // Æèâ, åñòü íóæíûå êëþ÷è è îí ðÿäîì:
2824 if alive
and ((gTriggers
[a
].Keys
and GetKeys
) = gTriggers
[a
].Keys
) and
2825 Collide(X
, Y
, Width
, Height
) then
2827 gTriggers
[a
].ActivateUID
:= UID
;
2829 if (gTriggers
[a
].TriggerType
in [TRIGGER_SOUND
, TRIGGER_MUSIC
]) and
2831 { Don't activate sound/music again if player is here }
2833 ActivateTrigger(gTriggers
[a
], ACTIVATE_PLAYERCOLLIDE
);
2836 { TODO 5 : àêòèâàöèÿ ìîíñòðàìè òðèããåðîâ ñ êëþ÷àìè }
2838 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2839 ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2840 (TimeOut
= 0) and (Keys
= 0) then
2842 // Åñëè "Ìîíñòð áëèçêî" è "Ìîíñòðîâ íåò",
2843 // çàïóñêàåì òðèããåð íà ñòàðòå êàðòû è ñíèìàåì îáà ôëàãà
2844 ActivateType
:= ActivateType
and not (ACTIVATE_MONSTERCOLLIDE
or ACTIVATE_NOMONSTER
);
2845 gTriggers
[a
].ActivateUID
:= 0;
2846 ActivateTrigger(gTriggers
[a
], 0);
2850 if ByteBool(ActivateType
and ACTIVATE_MONSTERCOLLIDE
) and
2851 (TimeOut
= 0) and (Keys
= 0) then // Åñëè íå íóæíû êëþ÷è
2853 //g_Mons_ForEach(monsNear);
2856 g_Mons_ForEachAt(gTriggers
[a
].X
, gTriggers
[a
].Y
, gTriggers
[a
].Width
, gTriggers
[a
].Height
, monsNear
);
2857 for mon
in tgMonsList
do
2859 gTriggers
[a
].ActivateUID
:= mon
.UID
;
2860 ActivateTrigger(gTriggers
[a
], ACTIVATE_MONSTERCOLLIDE
);
2862 tgMonsList
.reset(); // just in case
2866 if ByteBool(ActivateType
and ACTIVATE_NOMONSTER
) and
2867 (TimeOut
= 0) and (Keys
= 0) then
2868 if not g_Mons_IsAnyAliveAt(X
, Y
, Width
, Height
) then
2870 gTriggers
[a
].ActivateUID
:= 0;
2871 ActivateTrigger(gTriggers
[a
], ACTIVATE_NOMONSTER
);
2875 PlayerCollide
:= g_CollidePlayer(X
, Y
, Width
, Height
);
2879 procedure g_Triggers_Press(ID
: DWORD
; ActivateType
: Byte; ActivateUID
: Word = 0);
2881 if (ID
>= Length(gTriggers
)) then exit
;
2882 gTriggers
[ID
].ActivateUID
:= ActivateUID
;
2883 ActivateTrigger(gTriggers
[ID
], ActivateType
);
2886 function g_Triggers_PressR(X
, Y
: Integer; Width
, Height
: Word; UID
: Word;
2887 ActivateType
: Byte; IgnoreList
: DWArray
= nil): DWArray
;
2895 if gTriggers
= nil then Exit
;
2897 case g_GetUIDType(UID
) of
2901 p
:= g_Player_Get(UID
);
2910 for a
:= 0 to High(gTriggers
) do
2911 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2912 (gTriggers
[a
].TimeOut
= 0) and
2913 (not InDWArray(a
, IgnoreList
)) and
2914 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2915 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2916 if g_Collide(X
, Y
, Width
, Height
,
2917 gTriggers
[a
].X
, gTriggers
[a
].Y
,
2918 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2920 gTriggers
[a
].ActivateUID
:= UID
;
2921 if ActivateTrigger(gTriggers
[a
], ActivateType
) then
2923 SetLength(Result
, Length(Result
)+1);
2924 Result
[High(Result
)] := a
;
2929 procedure g_Triggers_PressL(X1
, Y1
, X2
, Y2
: Integer; UID
: DWORD
; ActivateType
: Byte);
2935 if gTriggers
= nil then Exit
;
2937 case g_GetUIDType(UID
) of
2941 p
:= g_Player_Get(UID
);
2950 for a
:= 0 to High(gTriggers
) do
2951 if (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2952 (gTriggers
[a
].TimeOut
= 0) and
2953 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2954 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2955 if g_CollideLine(x1
, y1
, x2
, y2
, gTriggers
[a
].X
, gTriggers
[a
].Y
,
2956 gTriggers
[a
].Width
, gTriggers
[a
].Height
) then
2958 gTriggers
[a
].ActivateUID
:= UID
;
2959 ActivateTrigger(gTriggers
[a
], ActivateType
);
2963 procedure g_Triggers_PressC(CX
, CY
: Integer; Radius
: Word; UID
: Word; ActivateType
: Byte; IgnoreTrigger
: Integer = -1);
2970 if gTriggers
= nil then
2973 case g_GetUIDType(UID
) of
2977 p
:= g_Player_Get(UID
);
2986 rsq
:= Radius
* Radius
;
2988 for a
:= 0 to High(gTriggers
) do
2989 if (gTriggers
[a
].ID
<> DWORD(IgnoreTrigger
)) and
2990 (gTriggers
[a
].TriggerType
<> TRIGGER_NONE
) and
2991 (gTriggers
[a
].TimeOut
= 0) and
2992 ((gTriggers
[a
].Keys
and k
) = gTriggers
[a
].Keys
) and
2993 ByteBool(gTriggers
[a
].ActivateType
and ActivateType
) then
2994 with gTriggers
[a
] do
2995 if g_Collide(CX
-Radius
, CY
-Radius
, 2*Radius
, 2*Radius
,
2996 X
, Y
, Width
, Height
) then
2997 if ((Sqr(CX
-X
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ëåâîìó óãëó
2998 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ïðàâîìó óãëó
2999 ((Sqr(CX
-X
-Width
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ïðàâîìó óãëó
3000 ((Sqr(CX
-X
)+Sqr(CY
-Y
-Height
)) < rsq
) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ëåâîìó óãëó
3001 ( (CX
> (X
-Radius
)) and (CX
< (X
+Width
+Radius
)) and
3002 (CY
> Y
) and (CY
< (Y
+Height
)) ) or // Öåíòð êðóãà íåäàëåêî îò âåðòèêàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
3003 ( (CY
> (Y
-Radius
)) and (CY
< (Y
+Height
+Radius
)) and
3004 (CX
> X
) and (CX
< (X
+Width
)) ) then // Öåíòð êðóãà íåäàëåêî îò ãîðèçîíòàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
3007 ActivateTrigger(gTriggers
[a
], ActivateType
);
3011 procedure g_Triggers_OpenAll();
3016 if gTriggers
= nil then Exit
;
3019 for a
:= 0 to High(gTriggers
) do
3021 with gTriggers
[a
] do
3023 if (TriggerType
= TRIGGER_OPENDOOR
) or
3024 (TriggerType
= TRIGGER_DOOR5
) or
3025 (TriggerType
= TRIGGER_DOOR
) then
3027 tr_OpenDoor(trigPanelGUID
, True, tgcD2d
);
3028 if TriggerType
= TRIGGER_DOOR5
then DoorTime
:= 180;
3034 if b
then g_Sound_PlayEx('SOUND_GAME_DOOROPEN');
3037 procedure g_Triggers_DecreaseSpawner(ID
: DWORD
);
3039 if (gTriggers
<> nil) then
3041 if gTriggers
[ID
].tgcMax
> 0 then
3043 if gTriggers
[ID
].SpawnedCount
> 0 then
3044 Dec(gTriggers
[ID
].SpawnedCount
);
3046 if gTriggers
[ID
].tgcDelay
> 0 then
3048 if gTriggers
[ID
].SpawnCooldown
< 0 then
3049 gTriggers
[ID
].SpawnCooldown
:= gTriggers
[ID
].tgcDelay
;
3054 procedure g_Triggers_Free ();
3058 for a
:= 0 to High(gTriggers
) do
3060 if (gTriggers
[a
].TriggerType
= TRIGGER_SOUND
) then
3062 if g_Sound_Exists(gTriggers
[a
].tgcSoundName
) then
3064 g_Sound_Delete(gTriggers
[a
].tgcSoundName
);
3066 gTriggers
[a
].Sound
.Free();
3068 if (gTriggers
[a
].Activators
<> nil) then
3070 SetLength(gTriggers
[a
].Activators
, 0);
3072 gTriggers
[a
].trigDataRec
.Free();
3074 gTriggers
[a
].exoThink
.Free();
3075 gTriggers
[a
].exoCheck
.Free();
3076 gTriggers
[a
].exoAction
.Free();
3077 gTriggers
[a
].userVars
.Free();
3082 SetLength(gMonstersSpawned
, 0);
3086 procedure g_Triggers_SaveState (st
: TStream
);
3088 count
, actCount
, i
, j
: Integer;
3091 kv
: THashStrVariant
.PEntry
;
3094 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ
3095 count
:= Length(gTriggers
);
3097 // Êîëè÷åñòâî òðèããåðîâ
3098 utils
.writeInt(st
, LongInt(count
));
3099 if (count
= 0) then exit
;
3101 for i
:= 0 to High(gTriggers
) do
3103 // Ñèãíàòóðà òðèããåðà
3104 utils
.writeSign(st
, 'TRGX');
3105 utils
.writeInt(st
, Byte(0));
3107 utils
.writeInt(st
, Byte(gTriggers
[i
].TriggerType
));
3108 if (gTriggers
[i
].TriggerType
= TRIGGER_NONE
) then continue
; // empty one
3109 // Ñïåöèàëüíûå äàííûå òðèããåðà: ïîòîì èç êàðòû îïÿòü âûòàùèì; ñîõðàíèì òîëüêî èíäåêñ
3110 utils
.writeInt(st
, LongInt(gTriggers
[i
].mapIndex
));
3111 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà
3112 utils
.writeInt(st
, LongInt(gTriggers
[i
].X
));
3113 utils
.writeInt(st
, LongInt(gTriggers
[i
].Y
));
3115 utils
.writeInt(st
, Word(gTriggers
[i
].Width
));
3116 utils
.writeInt(st
, Word(gTriggers
[i
].Height
));
3117 // Âêëþ÷åí ëè òðèããåð
3118 utils
.writeBool(st
, gTriggers
[i
].Enabled
);
3119 // Òèï àêòèâàöèè òðèããåðà
3120 utils
.writeInt(st
, Byte(gTriggers
[i
].ActivateType
));
3121 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè
3122 utils
.writeInt(st
, Byte(gTriggers
[i
].Keys
));
3123 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ
3124 utils
.writeInt(st
, LongInt(gTriggers
[i
].TexturePanelGUID
));
3126 //Mem.WriteWord(gTriggers[i].TexturePanelType);
3127 // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
3128 utils
.writeInt(st
, LongInt(gTriggers
[i
].trigPanelGUID
));
3129 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè
3130 utils
.writeInt(st
, Word(gTriggers
[i
].TimeOut
));
3131 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð
3132 utils
.writeInt(st
, Word(gTriggers
[i
].ActivateUID
));
3133 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì
3134 actCount
:= Length(gTriggers
[i
].Activators
);
3135 utils
.writeInt(st
, LongInt(actCount
));
3136 for j
:= 0 to actCount
-1 do
3139 utils
.writeInt(st
, Word(gTriggers
[i
].Activators
[j
].UID
));
3141 utils
.writeInt(st
, Word(gTriggers
[i
].Activators
[j
].TimeOut
));
3143 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà
3144 utils
.writeBool(st
, gTriggers
[i
].PlayerCollide
);
3145 // Âðåìÿ äî çàêðûòèÿ äâåðè
3146 utils
.writeInt(st
, LongInt(gTriggers
[i
].DoorTime
));
3147 // Çàäåðæêà àêòèâàöèè
3148 utils
.writeInt(st
, LongInt(gTriggers
[i
].PressTime
));
3150 utils
.writeInt(st
, LongInt(gTriggers
[i
].PressCount
));
3152 utils
.writeBool(st
, gTriggers
[i
].AutoSpawn
);
3153 // Çàäåðæêà ñïàâíåðà
3154 utils
.writeInt(st
, LongInt(gTriggers
[i
].SpawnCooldown
));
3155 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ
3156 utils
.writeInt(st
, LongInt(gTriggers
[i
].SpawnedCount
));
3157 // Ñêîëüêî ðàç ïðîèãðàí çâóê
3158 utils
.writeInt(st
, LongInt(gTriggers
[i
].SoundPlayCount
));
3159 // Ïðîèãðûâàåòñÿ ëè çâóê?
3160 if (gTriggers
[i
].Sound
<> nil) then b
:= gTriggers
[i
].Sound
.IsPlaying() else b
:= false;
3161 utils
.writeBool(st
, b
);
3164 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà
3165 utils
.writeInt(st
, LongWord(gTriggers
[i
].Sound
.GetPosition()));
3167 sg
:= gTriggers
[i
].Sound
.GetVolume();
3168 sg
:= sg
/(gSoundLevel
/255.0);
3169 //Mem.WriteSingle(sg);
3170 st
.WriteBuffer(sg
, sizeof(sg
)); // sorry
3171 // Ñòåðåî ñìåùåíèå çâóêà
3172 sg
:= gTriggers
[i
].Sound
.GetPan();
3173 //Mem.WriteSingle(sg);
3174 st
.WriteBuffer(sg
, sizeof(sg
)); // sorry
3177 if (gTriggers
[i
].userVars
= nil) then
3179 utils
.writeInt(st
, LongInt(0));
3183 utils
.writeInt(st
, LongInt(gTriggers
[i
].userVars
.count
)); //FIXME: check for overflow
3184 for kv
in gTriggers
[i
].userVars
.byKeyValue
do
3186 //writeln('<', kv.key, '>:<', VarToStr(kv.value), '>');
3187 utils
.writeStr(st
, kv
.key
);
3188 t
:= LongInt(varType(kv
.value
));
3189 utils
.writeInt(st
, LongInt(t
));
3191 varString
: utils
.writeStr(st
, AnsiString(kv
.value
));
3192 varBoolean
: utils
.writeBool(st
, Boolean(kv
.value
));
3193 varShortInt
: utils
.writeInt(st
, LongInt(kv
.value
));
3194 varSmallint
: utils
.writeInt(st
, LongInt(kv
.value
));
3195 varInteger
: utils
.writeInt(st
, LongInt(kv
.value
));
3196 //varInt64: Mem.WriteInt(Integer(kv.value));
3197 varByte
: utils
.writeInt(st
, LongInt(kv
.value
));
3198 varWord
: utils
.writeInt(st
, LongInt(kv
.value
));
3199 varLongWord
: utils
.writeInt(st
, LongInt(kv
.value
));
3201 else raise Exception
.CreateFmt('cannot save uservar ''%s''', [kv
.key
]);
3209 procedure g_Triggers_LoadState (st
: TStream
);
3211 count
, actCount
, i
, j
, a
: Integer;
3220 uvname
: AnsiString = '';
3221 ustr
: AnsiString = '';
3229 // Êîëè÷åñòâî òðèããåðîâ
3230 count
:= utils
.readLongInt(st
);
3231 if (count
= 0) then exit
;
3232 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid trigger count');
3234 for a
:= 0 to count
-1 do
3236 // Ñèãíàòóðà òðèããåðà
3237 if not utils
.checkSign(st
, 'TRGX') then raise XStreamError
.Create('invalid trigger signature');
3238 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid trigger version');
3240 Trig
.TriggerType
:= utils
.readByte(st
);
3241 if (Trig
.TriggerType
= TRIGGER_NONE
) then continue
; // empty one
3242 // Ñïåöèàëüíûå äàííûå òðèããåðà: èíäåêñ â gCurrentMap.field['triggers']
3243 mapIndex
:= utils
.readLongInt(st
);
3244 i
:= g_Triggers_CreateWithMapIndex(Trig
, a
, mapIndex
);
3245 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà
3246 gTriggers
[i
].X
:= utils
.readLongInt(st
);
3247 gTriggers
[i
].Y
:= utils
.readLongInt(st
);
3249 gTriggers
[i
].Width
:= utils
.readWord(st
);
3250 gTriggers
[i
].Height
:= utils
.readWord(st
);
3251 // Âêëþ÷åí ëè òðèããåð
3252 gTriggers
[i
].Enabled
:= utils
.readBool(st
);
3253 // Òèï àêòèâàöèè òðèããåðà
3254 gTriggers
[i
].ActivateType
:= utils
.readByte(st
);
3255 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè
3256 gTriggers
[i
].Keys
:= utils
.readByte(st
);
3257 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ
3258 gTriggers
[i
].TexturePanelGUID
:= utils
.readLongInt(st
);
3260 //Mem.ReadWord(gTriggers[i].TexturePanelType);
3261 // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
3262 gTriggers
[i
].trigPanelGUID
:= utils
.readLongInt(st
);
3263 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè
3264 gTriggers
[i
].TimeOut
:= utils
.readWord(st
);
3265 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð
3266 gTriggers
[i
].ActivateUID
:= utils
.readWord(st
);
3267 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì
3268 actCount
:= utils
.readLongInt(st
);
3269 if (actCount
< 0) or (actCount
> 1024*1024) then raise XStreamError
.Create('invalid activated object count');
3270 if (actCount
> 0) then
3272 SetLength(gTriggers
[i
].Activators
, actCount
);
3273 for j
:= 0 to actCount
-1 do
3276 gTriggers
[i
].Activators
[j
].UID
:= utils
.readWord(st
);
3278 gTriggers
[i
].Activators
[j
].TimeOut
:= utils
.readWord(st
);
3281 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà
3282 gTriggers
[i
].PlayerCollide
:= utils
.readBool(st
);
3283 // Âðåìÿ äî çàêðûòèÿ äâåðè
3284 gTriggers
[i
].DoorTime
:= utils
.readLongInt(st
);
3285 // Çàäåðæêà àêòèâàöèè
3286 gTriggers
[i
].PressTime
:= utils
.readLongInt(st
);
3288 gTriggers
[i
].PressCount
:= utils
.readLongInt(st
);
3290 gTriggers
[i
].AutoSpawn
:= utils
.readBool(st
);
3291 // Çàäåðæêà ñïàâíåðà
3292 gTriggers
[i
].SpawnCooldown
:= utils
.readLongInt(st
);
3293 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ
3294 gTriggers
[i
].SpawnedCount
:= utils
.readLongInt(st
);
3295 // Ñêîëüêî ðàç ïðîèãðàí çâóê
3296 gTriggers
[i
].SoundPlayCount
:= utils
.readLongInt(st
);
3297 // Ïðîèãðûâàåòñÿ ëè çâóê?
3298 b
:= utils
.readBool(st
);
3301 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà
3302 dw
:= utils
.readLongWord(st
);
3304 //Mem.ReadSingle(vol);
3305 st
.ReadBuffer(vol
, sizeof(vol
)); // sorry
3306 // Ñòåðåî ñìåùåíèå çâóêà
3307 //Mem.ReadSingle(pan);
3308 st
.ReadBuffer(pan
, sizeof(pan
)); // sorry
3309 // Çàïóñêàåì çâóê, åñëè åñòü
3310 if (gTriggers
[i
].Sound
<> nil) then
3312 gTriggers
[i
].Sound
.PlayPanVolume(pan
, vol
);
3313 gTriggers
[i
].Sound
.Pause(True);
3314 gTriggers
[i
].Sound
.SetPosition(dw
);
3318 gTriggers
[i
].userVars
.Free();
3319 gTriggers
[i
].userVars
:= nil;
3320 uvcount
:= utils
.readLongInt(st
);
3321 if (uvcount
< 0) or (uvcount
> 1024*1024) then raise XStreamError
.Create('invalid number of user vars in trigger');
3322 if (uvcount
> 0) then
3324 gTriggers
[i
].userVars
:= THashStrVariant
.Create();
3326 while (uvcount
> 0) do
3329 uvname
:= utils
.readStr(st
);
3330 vt
:= utils
.readLongInt(st
);
3332 varString
: begin ustr
:= utils
.readStr(st
); vv
:= ustr
; end;
3333 varBoolean
: begin ubool
:= utils
.readBool(st
); vv
:= ubool
; end;
3334 varShortInt
: begin uint
:= utils
.readLongInt(st
); vv
:= ShortInt(uint
); end;
3335 varSmallint
: begin uint
:= utils
.readLongInt(st
); vv
:= SmallInt(uint
); end;
3336 varInteger
: begin uint
:= utils
.readLongInt(st
); vv
:= LongInt(uint
); end;
3337 varByte
: begin uint
:= utils
.readLongInt(st
); vv
:= Byte(uint
); end;
3338 varWord
: begin uint
:= utils
.readLongInt(st
); vv
:= Word(uint
); end;
3339 varLongWord
: begin uint
:= utils
.readLongInt(st
); vv
:= LongWord(uint
); end;
3340 else raise Exception
.CreateFmt('cannot load uservar ''%s''', [uvname
]);
3342 gTriggers
[i
].userVars
.put(uvname
, vv
);