DEADSOFTWARE

FreeBSD build fixes
[d2df-sdl.git] / src / game / g_triggers.pas
1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$MODE DELPHI}
17 unit g_triggers;
19 interface
21 uses
22 MAPSTRUCT, e_graphics, MAPDEF, g_basic, g_sound,
23 BinEditor;
25 type
26 TActivator = record
27 UID: Word;
28 TimeOut: Word;
29 end;
30 TTrigger = record
31 ID: DWORD;
32 ClientID: DWORD;
33 TriggerType: Byte;
34 X, Y: Integer;
35 Width, Height: Word;
36 Enabled: Boolean;
37 ActivateType: Byte;
38 Keys: Byte;
39 TexturePanel: Integer;
40 TexturePanelType: Word;
42 TimeOut: Word;
43 ActivateUID: Word;
44 Activators: array of TActivator;
45 PlayerCollide: Boolean;
46 DoorTime: Integer;
47 PressTime: Integer;
48 PressCount: Integer;
49 SoundPlayCount: Integer;
50 Sound: TPlayableSound;
51 AutoSpawn: Boolean;
52 SpawnCooldown: Integer;
53 SpawnedCount: Integer;
54 ShotPanelType: Word;
55 ShotPanelTime: Integer;
56 ShotSightTime: Integer;
57 ShotSightTimeout: Integer;
58 ShotSightTarget: Word;
59 ShotSightTargetN: Word;
60 ShotAmmoCount: Word;
61 ShotReloadTime: Integer;
63 Data: TTriggerData;
64 end;
66 function g_Triggers_Create(Trigger: TTrigger): DWORD;
67 procedure g_Triggers_Update();
68 procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0);
69 function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word;
70 ActivateType: Byte; IgnoreList: DWArray = nil): DWArray;
71 procedure g_Triggers_PressL(X1, Y1, X2, Y2: Integer; UID: DWORD; ActivateType: Byte);
72 procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1);
73 procedure g_Triggers_OpenAll();
74 procedure g_Triggers_DecreaseSpawner(ID: DWORD);
75 procedure g_Triggers_Free();
76 procedure g_Triggers_SaveState(var Mem: TBinMemoryWriter);
77 procedure g_Triggers_LoadState(var Mem: TBinMemoryReader);
79 function tr_Message(MKind: Integer; MText: string; MSendTo: Integer; MTime: Integer; ActivateUID: Integer): Boolean;
81 function tr_CloseDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
82 function tr_OpenDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
83 procedure tr_CloseTrap(PanelID: Integer; NoSound: Boolean; d2d: Boolean);
84 function tr_SetLift(PanelID: Integer; d: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
86 function tr_Teleport(ActivateUID: Integer; TX, TY: Integer; TDir: Integer; Silent: Boolean; D2D: Boolean): Boolean;
87 function tr_Push(ActivateUID: Integer; VX, VY: Integer; ResetVel: Boolean): Boolean;
89 procedure tr_MakeEffect(X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean);
90 function tr_SpawnShot(ShotType: Integer; wx, wy, dx, dy: Integer; ShotSound: Boolean; ShotTarget: Word): Integer;
92 var
93 gTriggerClientID: Integer = 0;
94 gTriggers: array of TTrigger;
95 gSecretsCount: Integer = 0;
96 gMonstersSpawned: array of LongInt = nil;
98 implementation
100 uses
101 g_player, g_map, Math, g_gfx, g_game, g_textures,
102 g_console, g_monsters, g_items, g_phys, g_weapons,
103 wadreader, g_main, SysUtils, e_log, g_language,
104 g_options, g_net, g_netmsg, g_scripts;
106 const
107 TRIGGER_SIGNATURE = $52475254; // 'TRGR'
108 TRAP_DAMAGE = 1000;
110 function FindTrigger(): DWORD;
111 var
112 i: Integer;
113 begin
114 if gTriggers <> nil then
115 for i := 0 to High(gTriggers) do
116 if gTriggers[i].TriggerType = TRIGGER_NONE then
117 begin
118 Result := i;
119 Exit;
120 end;
122 if gTriggers = nil then
123 begin
124 SetLength(gTriggers, 8);
125 Result := 0;
126 end
127 else
128 begin
129 Result := High(gTriggers) + 1;
130 SetLength(gTriggers, Length(gTriggers) + 8);
131 end;
132 end;
134 function tr_CloseDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
135 var
136 a, b, c: Integer;
137 begin
138 Result := False;
140 if PanelID = -1 then Exit;
142 if not d2d then
143 begin
144 with gWalls[PanelID] do
145 begin
146 if g_CollidePlayer(X, Y, Width, Height) or
147 g_CollideMonster(X, Y, Width, Height) then Exit;
149 if not Enabled then
150 begin
151 if not NoSound then
152 begin
153 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X, Y);
154 if g_Game_IsServer and g_Game_IsNet then
155 MH_SEND_Sound(X, Y, 'SOUND_GAME_DOORCLOSE');
156 end;
157 g_Map_EnableWall(PanelID);
158 Result := True;
159 end;
160 end;
161 end
162 else
163 begin
164 if gDoorMap = nil then Exit;
166 c := -1;
167 for a := 0 to High(gDoorMap) do
168 begin
169 for b := 0 to High(gDoorMap[a]) do
170 if gDoorMap[a, b] = DWORD(PanelID) then
171 begin
172 c := a;
173 Break;
174 end;
176 if c <> -1 then Break;
177 end;
178 if c = -1 then Exit;
180 for b := 0 to High(gDoorMap[c]) do
181 with gWalls[gDoorMap[c, b]] do
182 begin
183 if g_CollidePlayer(X, Y, Width, Height) or
184 g_CollideMonster(X, Y, Width, Height) then Exit;
185 end;
187 if not NoSound then
188 for b := 0 to High(gDoorMap[c]) do
189 if not gWalls[gDoorMap[c, b]].Enabled then
190 begin
191 with gWalls[PanelID] do
192 begin
193 g_Sound_PlayExAt('SOUND_GAME_DOORCLOSE', X, Y);
194 if g_Game_IsServer and g_Game_IsNet then
195 MH_SEND_Sound(X, Y, 'SOUND_GAME_DOORCLOSE');
196 end;
197 Break;
198 end;
200 for b := 0 to High(gDoorMap[c]) do
201 if not gWalls[gDoorMap[c, b]].Enabled then
202 begin
203 g_Map_EnableWall(gDoorMap[c, b]);
204 Result := True;
205 end;
206 end;
207 end;
209 procedure tr_CloseTrap(PanelID: Integer; NoSound: Boolean; d2d: Boolean);
210 var
211 a, b, c: Integer;
212 begin
213 if PanelID = -1 then Exit;
215 if not d2d then
216 begin
217 with gWalls[PanelID] do
218 if (not NoSound) and (not Enabled) then
219 begin
220 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X, Y);
221 if g_Game_IsServer and g_Game_IsNet then
222 MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH1');
223 end;
225 with gWalls[PanelID] do
226 begin
227 if gPlayers <> nil then
228 for a := 0 to High(gPlayers) do
229 if (gPlayers[a] <> nil) and gPlayers[a].Live and
230 gPlayers[a].Collide(X, Y, Width, Height) then
231 gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
233 if gMonsters <> nil then
234 for a := 0 to High(gMonsters) do
235 if (gMonsters[a] <> nil) and gMonsters[a].Live and
236 g_Obj_Collide(X, Y, Width, Height, @gMonsters[a].Obj) then
237 gMonsters[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
239 if not Enabled then g_Map_EnableWall(PanelID);
240 end;
241 end
242 else
243 begin
244 if gDoorMap = nil then Exit;
246 c := -1;
247 for a := 0 to High(gDoorMap) do
248 begin
249 for b := 0 to High(gDoorMap[a]) do
250 if gDoorMap[a, b] = DWORD(PanelID) then
251 begin
252 c := a;
253 Break;
254 end;
256 if c <> -1 then Break;
257 end;
258 if c = -1 then Exit;
260 if not NoSound then
261 for b := 0 to High(gDoorMap[c]) do
262 if not gWalls[gDoorMap[c, b]].Enabled then
263 begin
264 with gWalls[PanelID] do
265 begin
266 g_Sound_PlayExAt('SOUND_GAME_SWITCH1', X, Y);
267 if g_Game_IsServer and g_Game_IsNet then
268 MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH1');
269 end;
270 Break;
271 end;
273 for b := 0 to High(gDoorMap[c]) do
274 with gWalls[gDoorMap[c, b]] do
275 begin
276 if gPlayers <> nil then
277 for a := 0 to High(gPlayers) do
278 if (gPlayers[a] <> nil) and gPlayers[a].Live and
279 gPlayers[a].Collide(X, Y, Width, Height) then
280 gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
282 if gMonsters <> nil then
283 for a := 0 to High(gMonsters) do
284 if (gMonsters[a] <> nil) and gMonsters[a].Live and
285 g_Obj_Collide(X, Y, Width, Height, @gMonsters[a].Obj) then
286 gMonsters[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
288 if not Enabled then g_Map_EnableWall(gDoorMap[c, b]);
289 end;
290 end;
291 end;
293 function tr_OpenDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
294 var
295 a, b, c: Integer;
296 begin
297 Result := False;
299 if PanelID = -1 then Exit;
301 if not d2d then
302 begin
303 with gWalls[PanelID] do
304 if Enabled then
305 begin
306 if not NoSound then
307 begin
308 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X, Y);
309 if g_Game_IsServer and g_Game_IsNet then
310 MH_SEND_Sound(X, Y, 'SOUND_GAME_DOOROPEN');
311 end;
312 g_Map_DisableWall(PanelID);
313 Result := True;
314 end;
315 end
316 else
317 begin
318 if gDoorMap = nil then Exit;
320 c := -1;
321 for a := 0 to High(gDoorMap) do
322 begin
323 for b := 0 to High(gDoorMap[a]) do
324 if gDoorMap[a, b] = DWORD(PanelID) then
325 begin
326 c := a;
327 Break;
328 end;
330 if c <> -1 then Break;
331 end;
332 if c = -1 then Exit;
334 if not NoSound then
335 for b := 0 to High(gDoorMap[c]) do
336 if gWalls[gDoorMap[c, b]].Enabled then
337 begin
338 with gWalls[PanelID] do
339 begin
340 g_Sound_PlayExAt('SOUND_GAME_DOOROPEN', X, Y);
341 if g_Game_IsServer and g_Game_IsNet then
342 MH_SEND_Sound(X, Y, 'SOUND_GAME_DOOROPEN');
343 end;
344 Break;
345 end;
347 for b := 0 to High(gDoorMap[c]) do
348 if gWalls[gDoorMap[c, b]].Enabled then
349 begin
350 g_Map_DisableWall(gDoorMap[c, b]);
351 Result := True;
352 end;
353 end;
354 end;
356 function tr_SetLift(PanelID: Integer; d: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
357 var
358 a, b, c, t: Integer;
359 begin
360 t := 0;
361 Result := False;
363 if PanelID = -1 then Exit;
365 if (gLifts[PanelID].PanelType = PANEL_LIFTUP) or
366 (gLifts[PanelID].PanelType = PANEL_LIFTDOWN) then
367 case d of
368 0: t := 0;
369 1: t := 1;
370 else t := IfThen(gLifts[PanelID].LiftType = 1, 0, 1);
371 end
372 else if (gLifts[PanelID].PanelType = PANEL_LIFTLEFT) or
373 (gLifts[PanelID].PanelType = PANEL_LIFTRIGHT) then
374 case d of
375 0: t := 2;
376 1: t := 3;
377 else t := IfThen(gLifts[PanelID].LiftType = 2, 3, 2);
378 end;
380 if not d2d then
381 begin
382 with gLifts[PanelID] do
383 if LiftType <> t then
384 begin
385 g_Map_SetLift(PanelID, t);
387 {if not NoSound then
388 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);}
389 Result := True;
390 end;
391 end
392 else // Êàê â D2d
393 begin
394 if gLiftMap = nil then Exit;
396 c := -1;
397 for a := 0 to High(gLiftMap) do
398 begin
399 for b := 0 to High(gLiftMap[a]) do
400 if gLiftMap[a, b] = DWORD(PanelID) then
401 begin
402 c := a;
403 Break;
404 end;
406 if c <> -1 then Break;
407 end;
408 if c = -1 then Exit;
410 {if not NoSound then
411 for b := 0 to High(gLiftMap[c]) do
412 if gLifts[gLiftMap[c, b]].LiftType <> t then
413 begin
414 with gLifts[PanelID] do
415 g_Sound_PlayExAt('SOUND_GAME_SWITCH0', X, Y);
416 Break;
417 end;}
419 for b := 0 to High(gLiftMap[c]) do
420 with gLifts[gLiftMap[c, b]] do
421 if LiftType <> t then
422 begin
423 g_Map_SetLift(gLiftMap[c, b], t);
425 Result := True;
426 end;
427 end;
428 end;
430 function tr_SpawnShot(ShotType: Integer; wx, wy, dx, dy: Integer; ShotSound: Boolean; ShotTarget: Word): Integer;
431 var
432 snd: string;
433 Projectile: Boolean;
434 TextureID: DWORD;
435 Anim: TAnimation;
436 begin
437 Result := -1;
438 TextureID := DWORD(-1);
439 snd := 'SOUND_WEAPON_FIREROCKET';
440 Projectile := True;
441 case ShotType of
442 TRIGGER_SHOT_PISTOL:
443 begin
444 g_Weapon_pistol(wx, wy, dx, dy, 0, True);
445 snd := 'SOUND_WEAPON_FIREPISTOL';
446 Projectile := False;
447 if ShotSound then
448 begin
449 g_Player_CreateShell(wx, wy, 0, -2, SHELL_BULLET);
450 if g_Game_IsNet then
451 MH_SEND_Effect(wx, wy, 0, NET_GFX_SHELL1);
452 end;
453 end;
455 TRIGGER_SHOT_BULLET:
456 begin
457 g_Weapon_mgun(wx, wy, dx, dy, 0, True);
458 if gSoundEffectsDF then snd := 'SOUND_WEAPON_FIRECGUN'
459 else snd := 'SOUND_WEAPON_FIREPISTOL';
460 Projectile := False;
461 if ShotSound then
462 begin
463 g_Player_CreateShell(wx, wy, 0, -2, SHELL_BULLET);
464 if g_Game_IsNet then
465 MH_SEND_Effect(wx, wy, 0, NET_GFX_SHELL1);
466 end;
467 end;
469 TRIGGER_SHOT_SHOTGUN:
470 begin
471 g_Weapon_Shotgun(wx, wy, dx, dy, 0, True);
472 snd := 'SOUND_WEAPON_FIRESHOTGUN';
473 Projectile := False;
474 if ShotSound then
475 begin
476 g_Player_CreateShell(wx, wy, 0, -2, SHELL_SHELL);
477 if g_Game_IsNet then
478 MH_SEND_Effect(wx, wy, 0, NET_GFX_SHELL2);
479 end;
480 end;
482 TRIGGER_SHOT_SSG:
483 begin
484 g_Weapon_DShotgun(wx, wy, dx, dy, 0, True);
485 snd := 'SOUND_WEAPON_FIRESHOTGUN2';
486 Projectile := False;
487 if ShotSound then
488 begin
489 g_Player_CreateShell(wx, wy, 0, -2, SHELL_SHELL);
490 g_Player_CreateShell(wx, wy, 0, -2, SHELL_SHELL);
491 if g_Game_IsNet then
492 MH_SEND_Effect(wx, wy, 0, NET_GFX_SHELL3);
493 end;
494 end;
496 TRIGGER_SHOT_IMP:
497 begin
498 g_Weapon_ball1(wx, wy, dx, dy, 0, -1, True);
499 snd := 'SOUND_WEAPON_FIREBALL';
500 end;
502 TRIGGER_SHOT_PLASMA:
503 begin
504 g_Weapon_Plasma(wx, wy, dx, dy, 0, -1, True);
505 snd := 'SOUND_WEAPON_FIREPLASMA';
506 end;
508 TRIGGER_SHOT_SPIDER:
509 begin
510 g_Weapon_aplasma(wx, wy, dx, dy, 0, -1, True);
511 snd := 'SOUND_WEAPON_FIREPLASMA';
512 end;
514 TRIGGER_SHOT_CACO:
515 begin
516 g_Weapon_ball2(wx, wy, dx, dy, 0, -1, True);
517 snd := 'SOUND_WEAPON_FIREBALL';
518 end;
520 TRIGGER_SHOT_BARON:
521 begin
522 g_Weapon_ball7(wx, wy, dx, dy, 0, -1, True);
523 snd := 'SOUND_WEAPON_FIREBALL';
524 end;
526 TRIGGER_SHOT_MANCUB:
527 begin
528 g_Weapon_manfire(wx, wy, dx, dy, 0, -1, True);
529 snd := 'SOUND_WEAPON_FIREBALL';
530 end;
532 TRIGGER_SHOT_REV:
533 begin
534 g_Weapon_revf(wx, wy, dx, dy, 0, ShotTarget, -1, True);
535 snd := 'SOUND_WEAPON_FIREREV';
536 end;
538 TRIGGER_SHOT_ROCKET:
539 begin
540 g_Weapon_Rocket(wx, wy, dx, dy, 0, -1, True);
541 snd := 'SOUND_WEAPON_FIREROCKET';
542 end;
544 TRIGGER_SHOT_BFG:
545 begin
546 g_Weapon_BFGShot(wx, wy, dx, dy, 0, -1, True);
547 snd := 'SOUND_WEAPON_FIREBFG';
548 end;
550 TRIGGER_SHOT_EXPL:
551 begin
552 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then
553 begin
554 Anim := TAnimation.Create(TextureID, False, 6);
555 Anim.Blending := False;
556 g_GFX_OnceAnim(wx-64, wy-64, Anim);
557 Anim.Free();
558 end;
559 Projectile := False;
560 g_Weapon_Explode(wx, wy, 60, 0);
561 snd := 'SOUND_WEAPON_EXPLODEROCKET';
562 end;
564 TRIGGER_SHOT_BFGEXPL:
565 begin
566 if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then
567 begin
568 Anim := TAnimation.Create(TextureID, False, 6);
569 Anim.Blending := False;
570 g_GFX_OnceAnim(wx-64, wy-64, Anim);
571 Anim.Free();
572 end;
573 Projectile := False;
574 g_Weapon_BFG9000(wx, wy, 0);
575 snd := 'SOUND_WEAPON_EXPLODEBFG';
576 end;
578 else exit;
579 end;
581 if g_Game_IsNet and g_Game_IsServer then
582 case ShotType of
583 TRIGGER_SHOT_EXPL:
584 MH_SEND_Effect(wx, wy, Byte(ShotSound), NET_GFX_EXPLODE);
585 TRIGGER_SHOT_BFGEXPL:
586 MH_SEND_Effect(wx, wy, Byte(ShotSound), NET_GFX_BFGEXPL);
587 else
588 begin
589 if Projectile then
590 MH_SEND_CreateShot(LastShotID);
591 if ShotSound then
592 MH_SEND_Sound(wx, wy, snd);
593 end;
594 end;
596 if ShotSound then
597 g_Sound_PlayExAt(snd, wx, wy);
599 if Projectile then
600 Result := LastShotID;
601 end;
603 procedure MakeShot(var Trigger: TTrigger; wx, wy, dx, dy: Integer; TargetUID: Word);
604 begin
605 with Trigger do
606 if (Data.ShotAmmo = 0) or
607 ((Data.ShotAmmo > 0) and (ShotAmmoCount > 0)) then
608 begin
609 if (Data.ShotPanelID <> -1) and (ShotPanelTime = 0) then
610 begin
611 g_Map_SwitchTexture(ShotPanelType, Data.ShotPanelID);
612 ShotPanelTime := 4; // òèêîâ íà âñïûøêó âûñòðåëà
613 end;
615 if Data.ShotIntSight > 0 then
616 ShotSightTimeout := 180; // ~= 5 ñåêóíä
618 if ShotAmmoCount > 0 then Dec(ShotAmmoCount);
620 dx := dx + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
621 dy := dy + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
623 tr_SpawnShot(Data.ShotType, wx, wy, dx, dy, Data.ShotSound, TargetUID);
624 end
625 else
626 if (Data.ShotIntReload > 0) and (ShotReloadTime = 0) then
627 ShotReloadTime := Data.ShotIntReload; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
628 end;
630 procedure tr_MakeEffect(X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean);
631 var
632 FramesID: DWORD;
633 Anim: TAnimation;
634 begin
635 if T = TRIGGER_EFFECT_PARTICLE then
636 case ST of
637 TRIGGER_EFFECT_SLIQUID:
638 begin
639 if (CR = 255) and (CG = 0) and (CB = 0) then
640 g_GFX_SimpleWater(X, Y, 1, VX, VY, 1, 0, 0, 0)
641 else if (CR = 0) and (CG = 255) and (CB = 0) then
642 g_GFX_SimpleWater(X, Y, 1, VX, VY, 2, 0, 0, 0)
643 else if (CR = 0) and (CG = 0) and (CB = 255) then
644 g_GFX_SimpleWater(X, Y, 1, VX, VY, 3, 0, 0, 0)
645 else
646 g_GFX_SimpleWater(X, Y, 1, VX, VY, 0, 0, 0, 0);
647 end;
648 TRIGGER_EFFECT_LLIQUID:
649 g_GFX_SimpleWater(X, Y, 1, VX, VY, 4, CR, CG, CB);
650 TRIGGER_EFFECT_DLIQUID:
651 g_GFX_SimpleWater(X, Y, 1, VX, VY, 5, CR, CG, CB);
652 TRIGGER_EFFECT_BLOOD:
653 g_GFX_Blood(X, Y, 1, VX, VY, 0, 0, CR, CG, CB);
654 TRIGGER_EFFECT_SPARK:
655 g_GFX_Spark(X, Y, 1, GetAngle2(VX, VY), 0, 0);
656 TRIGGER_EFFECT_BUBBLE:
657 g_GFX_Bubbles(X, Y, 1, 0, 0);
658 end;
659 if T = TRIGGER_EFFECT_ANIMATION then
660 case ST of
661 EFFECT_TELEPORT: begin
662 if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
663 begin
664 Anim := TAnimation.Create(FramesID, False, 3);
665 if not Silent then
666 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
667 g_GFX_OnceAnim(X-32, Y-32, Anim);
668 Anim.Free();
669 end;
670 if Send and g_Game_IsServer and g_Game_IsNet then
671 MH_SEND_Effect(X, Y, Byte(not Silent), NET_GFX_TELE);
672 end;
673 EFFECT_RESPAWN: begin
674 if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
675 begin
676 Anim := TAnimation.Create(FramesID, False, 4);
677 if not Silent then
678 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
679 g_GFX_OnceAnim(X-16, Y-16, Anim);
680 Anim.Free();
681 end;
682 if Send and g_Game_IsServer and g_Game_IsNet then
683 MH_SEND_Effect(X-16, Y-16, Byte(not Silent), NET_GFX_RESPAWN);
684 end;
685 EFFECT_FIRE: begin
686 if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
687 begin
688 Anim := TAnimation.Create(FramesID, False, 4);
689 if not Silent then
690 g_Sound_PlayExAt('SOUND_FIRE', X, Y);
691 g_GFX_OnceAnim(X-32, Y-128, Anim);
692 Anim.Free();
693 end;
694 if Send and g_Game_IsServer and g_Game_IsNet then
695 MH_SEND_Effect(X-32, Y-128, Byte(not Silent), NET_GFX_FIRE);
696 end;
697 end;
698 end;
700 function tr_Teleport(ActivateUID: Integer; TX, TY: Integer; TDir: Integer; Silent: Boolean; D2D: Boolean): Boolean;
701 var
702 p: TPlayer;
703 m: TMonster;
704 begin
705 Result := False;
706 if (ActivateUID < 0) or (ActivateUID > $FFFF) then Exit;
707 case g_GetUIDType(ActivateUID) of
708 UID_PLAYER:
709 begin
710 p := g_Player_Get(ActivateUID);
711 if p = nil then
712 Exit;
714 if D2D then
715 begin
716 if p.TeleportTo(TX-(p.Obj.Rect.Width div 2),
717 TY-p.Obj.Rect.Height,
718 Silent,
719 TDir) then
720 Result := True;
721 end
722 else
723 if p.TeleportTo(TX, TY, Silent, TDir) then
724 Result := True;
725 end;
727 UID_MONSTER:
728 begin
729 m := g_Monsters_Get(ActivateUID);
730 if m = nil then
731 Exit;
733 if D2D then
734 begin
735 if m.TeleportTo(TX-(m.Obj.Rect.Width div 2),
736 TY-m.Obj.Rect.Height,
737 Silent,
738 TDir) then
739 Result := True;
740 end
741 else
742 if m.TeleportTo(TX, TY, Silent, TDir) then
743 Result := True;
744 end;
745 end;
746 end;
748 function tr_Push(ActivateUID: Integer; VX, VY: Integer; ResetVel: Boolean): Boolean;
749 var
750 p: TPlayer;
751 m: TMonster;
752 begin
753 Result := True;
754 if (ActivateUID < 0) or (ActivateUID > $FFFF) then Exit;
755 case g_GetUIDType(ActivateUID) of
756 UID_PLAYER:
757 begin
758 p := g_Player_Get(ActivateUID);
759 if p = nil then
760 Exit;
762 if ResetVel then
763 begin
764 p.GameVelX := 0;
765 p.GameVelY := 0;
766 p.GameAccelX := 0;
767 p.GameAccelY := 0;
768 end;
770 p.Push(VX, VY);
771 end;
773 UID_MONSTER:
774 begin
775 m := g_Monsters_Get(ActivateUID);
776 if m = nil then
777 Exit;
779 if ResetVel then
780 begin
781 m.GameVelX := 0;
782 m.GameVelY := 0;
783 m.GameAccelX := 0;
784 m.GameAccelY := 0;
785 end;
787 m.Push(VX, VY);
788 end;
789 end;
790 end;
792 function tr_Message(MKind: Integer; MText: string; MSendTo: Integer; MTime: Integer; ActivateUID: Integer): Boolean;
793 var
794 msg: string;
795 p: TPlayer;
796 i: Integer;
797 begin
798 Result := True;
799 if (ActivateUID < 0) or (ActivateUID > $FFFF) then Exit;
800 msg := b_Text_Format(MText);
801 case MSendTo of
802 0: // activator
803 begin
804 if g_GetUIDType(ActivateUID) = UID_PLAYER then
805 begin
806 if g_Game_IsWatchedPlayer(ActivateUID) then
807 begin
808 if MKind = 0 then
809 g_Console_Add(msg, True)
810 else if MKind = 1 then
811 g_Game_Message(msg, MTime);
812 end
813 else
814 begin
815 p := g_Player_Get(ActivateUID);
816 if g_Game_IsNet and (p.FClientID >= 0) then
817 if MKind = 0 then
818 MH_SEND_Chat(msg, NET_CHAT_SYSTEM, p.FClientID)
819 else if MKind = 1 then
820 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, p.FClientID);
821 end;
822 end;
823 end;
825 1: // activator's team
826 begin
827 if g_GetUIDType(ActivateUID) = UID_PLAYER then
828 begin
829 p := g_Player_Get(ActivateUID);
830 if g_Game_IsWatchedTeam(p.Team) then
831 if MKind = 0 then
832 g_Console_Add(msg, True)
833 else if MKind = 1 then
834 g_Game_Message(msg, MTime);
836 if g_Game_IsNet then
837 begin
838 for i := Low(gPlayers) to High(gPlayers) do
839 if (gPlayers[i].Team = p.Team) and (gPlayers[i].FClientID >= 0) then
840 if MKind = 0 then
841 MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
842 else if MKind = 1 then
843 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
844 end;
845 end;
846 end;
848 2: // activator's enemy team
849 begin
850 if g_GetUIDType(ActivateUID) = UID_PLAYER then
851 begin
852 p := g_Player_Get(ActivateUID);
853 if g_Game_IsWatchedTeam(p.Team) then
854 if MKind = 0 then
855 g_Console_Add(msg, True)
856 else if MKind = 1 then
857 g_Game_Message(msg, MTime);
859 if g_Game_IsNet then
860 begin
861 for i := Low(gPlayers) to High(gPlayers) do
862 if (gPlayers[i].Team <> p.Team) and (gPlayers[i].FClientID >= 0) then
863 if MKind = 0 then
864 MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
865 else if MKind = 1 then
866 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
867 end;
868 end;
869 end;
871 3: // red team
872 begin
873 if g_Game_IsWatchedTeam(TEAM_RED) then
874 if MKind = 0 then
875 g_Console_Add(msg, True)
876 else if MKind = 1 then
877 g_Game_Message(msg, MTime);
879 if g_Game_IsNet then
880 begin
881 for i := Low(gPlayers) to High(gPlayers) do
882 if (gPlayers[i].Team = TEAM_RED) and (gPlayers[i].FClientID >= 0) then
883 if MKind = 0 then
884 MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
885 else if MKind = 1 then
886 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
887 end;
888 end;
890 4: // blue team
891 begin
892 if g_Game_IsWatchedTeam(TEAM_BLUE) then
893 if MKind = 0 then
894 g_Console_Add(msg, True)
895 else if MKind = 1 then
896 g_Game_Message(msg, MTime);
898 if g_Game_IsNet then
899 begin
900 for i := Low(gPlayers) to High(gPlayers) do
901 if (gPlayers[i].Team = TEAM_BLUE) and (gPlayers[i].FClientID >= 0) then
902 if MKind = 0 then
903 MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
904 else if MKind = 1 then
905 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
906 end;
907 end;
909 5: // everyone
910 begin
911 if MKind = 0 then
912 g_Console_Add(msg, True)
913 else if MKind = 1 then
914 g_Game_Message(msg, MTime);
916 if g_Game_IsNet then
917 begin
918 if MKind = 0 then
919 MH_SEND_Chat(msg, NET_CHAT_SYSTEM)
920 else if MKind = 1 then
921 MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg);
922 end;
923 end;
924 end;
925 end;
927 function tr_ShotAimCheck(var Trigger: TTrigger; Obj: PObj): Boolean;
928 begin
929 with Trigger do
930 begin
931 if TriggerType <> TRIGGER_SHOT then
932 Exit;
933 Result := (Data.ShotAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
934 or g_Obj_Collide(X, Y, Width, Height, Obj);
935 if Result and (Data.ShotAim and TRIGGER_SHOT_AIM_TRACE > 0) then
936 Result := g_TraceVector(Data.ShotPos.X,
937 Data.ShotPos.Y,
938 Obj^.X + Obj^.Rect.X + (Obj^.Rect.Width div 2),
939 Obj^.Y + Obj^.Rect.Y + (Obj^.Rect.Height div 2));
940 end;
941 end;
943 function ActivateTrigger(var Trigger: TTrigger; actType: Byte): Boolean;
944 var
945 animonce: Boolean;
946 p: TPlayer;
947 m: TMonster;
948 i, k, wx, wy, xd, yd: Integer;
949 iid: LongWord;
950 coolDown: Boolean;
951 pAngle: Real;
952 FramesID: DWORD;
953 Anim: TAnimation;
954 UIDType: Byte;
955 TargetUID: Word;
956 begin
957 Result := False;
958 if g_Game_IsClient then
959 Exit;
961 if not Trigger.Enabled then
962 Exit;
963 if (Trigger.TimeOut <> 0) and (actType <> ACTIVATE_CUSTOM) then
964 Exit;
965 if gLMSRespawn = LMS_RESPAWN_WARMUP then
966 Exit;
968 animonce := False;
970 coolDown := (actType <> 0);
972 with Trigger do
973 begin
974 case TriggerType of
975 TRIGGER_EXIT:
976 begin
977 g_Sound_PlayEx('SOUND_GAME_SWITCH0');
978 if g_Game_IsNet then MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH0');
979 gExitByTrigger := True;
980 g_Game_ExitLevel(Data.MapName);
981 TimeOut := 18;
982 Result := True;
984 Exit;
985 end;
987 TRIGGER_TELEPORT:
988 begin
989 Result := tr_Teleport(ActivateUID,
990 Data.TargetPoint.X, Data.TargetPoint.Y,
991 Data.TlpDir, Data.silent_teleport,
992 Data.d2d_teleport);
993 TimeOut := 0;
994 end;
996 TRIGGER_OPENDOOR:
997 begin
998 Result := tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
999 TimeOut := 0;
1000 end;
1002 TRIGGER_CLOSEDOOR:
1003 begin
1004 Result := tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
1005 TimeOut := 0;
1006 end;
1008 TRIGGER_DOOR, TRIGGER_DOOR5:
1009 begin
1010 if Data.PanelID <> -1 then
1011 begin
1012 if gWalls[Data.PanelID].Enabled then
1013 begin
1014 Result := tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
1016 if TriggerType = TRIGGER_DOOR5 then
1017 DoorTime := 180;
1018 end
1019 else
1020 Result := tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
1022 if Result then
1023 TimeOut := 18;
1024 end;
1025 end;
1027 TRIGGER_CLOSETRAP, TRIGGER_TRAP:
1028 begin
1029 tr_CloseTrap(Data.PanelID, Data.NoSound, Data.d2d_doors);
1031 if TriggerType = TRIGGER_TRAP then
1032 begin
1033 DoorTime := 40;
1034 TimeOut := 76;
1035 end
1036 else
1037 begin
1038 DoorTime := -1;
1039 TimeOut := 0;
1040 end;
1042 Result := True;
1043 end;
1045 TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF:
1046 begin
1047 PressCount := PressCount + 1;
1049 if PressTime = -1 then
1050 PressTime := Data.Wait;
1052 if coolDown then
1053 TimeOut := 18
1054 else
1055 TimeOut := 0;
1056 Result := True;
1057 end;
1059 TRIGGER_SECRET:
1060 if g_GetUIDType(ActivateUID) = UID_PLAYER then
1061 begin
1062 Enabled := False;
1063 Result := True;
1064 if gLMSRespawn = LMS_RESPAWN_NONE then
1065 begin
1066 g_Player_Get(ActivateUID).GetSecret();
1067 Inc(gCoopSecretsFound);
1068 if g_Game_IsNet then MH_SEND_GameStats();
1069 end;
1070 end;
1072 TRIGGER_LIFTUP:
1073 begin
1074 Result := tr_SetLift(Data.PanelID, 0, Data.NoSound, Data.d2d_doors);
1075 TimeOut := 0;
1077 if (not Data.NoSound) and Result then begin
1078 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1079 X + (Width div 2),
1080 Y + (Height div 2));
1081 if g_Game_IsServer and g_Game_IsNet then
1082 MH_SEND_Sound(X + (Width div 2),
1083 Y + (Height div 2),
1084 'SOUND_GAME_SWITCH0');
1085 end;
1086 end;
1088 TRIGGER_LIFTDOWN:
1089 begin
1090 Result := tr_SetLift(Data.PanelID, 1, Data.NoSound, Data.d2d_doors);
1091 TimeOut := 0;
1093 if (not Data.NoSound) and Result then begin
1094 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1095 X + (Width div 2),
1096 Y + (Height div 2));
1097 if g_Game_IsServer and g_Game_IsNet then
1098 MH_SEND_Sound(X + (Width div 2),
1099 Y + (Height div 2),
1100 'SOUND_GAME_SWITCH0');
1101 end;
1102 end;
1104 TRIGGER_LIFT:
1105 begin
1106 Result := tr_SetLift(Data.PanelID, 3, Data.NoSound, Data.d2d_doors);
1108 if Result then
1109 begin
1110 TimeOut := 18;
1112 if (not Data.NoSound) and Result then begin
1113 g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
1114 X + (Width div 2),
1115 Y + (Height div 2));
1116 if g_Game_IsServer and g_Game_IsNet then
1117 MH_SEND_Sound(X + (Width div 2),
1118 Y + (Height div 2),
1119 'SOUND_GAME_SWITCH0');
1120 end;
1121 end;
1122 end;
1124 TRIGGER_TEXTURE:
1125 begin
1126 if ByteBool(Data.ActivateOnce) then
1127 begin
1128 Enabled := False;
1129 TriggerType := TRIGGER_NONE;
1130 end
1131 else
1132 if coolDown then
1133 TimeOut := 6
1134 else
1135 TimeOut := 0;
1137 animonce := Data.AnimOnce;
1138 Result := True;
1139 end;
1141 TRIGGER_SOUND:
1142 begin
1143 if Sound <> nil then
1144 begin
1145 if Data.SoundSwitch and Sound.IsPlaying() then
1146 begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
1147 Sound.Stop();
1148 SoundPlayCount := 0;
1149 Result := True;
1150 end
1151 else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
1152 if (Data.PlayCount > 0) or (not Sound.IsPlaying()) then
1153 begin
1154 if Data.PlayCount > 0 then
1155 SoundPlayCount := Data.PlayCount
1156 else // 0 - èãðàåì áåñêîíå÷íî
1157 SoundPlayCount := 1;
1158 Result := True;
1159 end;
1160 if g_Game_IsNet then MH_SEND_TriggerSound(Trigger);
1161 end;
1162 end;
1164 TRIGGER_SPAWNMONSTER:
1165 if (Data.MonType in [MONSTER_DEMON..MONSTER_MAN]) then
1166 begin
1167 Result := False;
1168 if (Data.MonDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
1169 begin
1170 AutoSpawn := not AutoSpawn;
1171 SpawnCooldown := 0;
1172 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1173 Result := True;
1174 end;
1176 if ((Data.MonDelay = 0) and (actType <> ACTIVATE_CUSTOM))
1177 or ((Data.MonDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
1178 for k := 1 to Data.MonCount do
1179 begin
1180 if (actType = ACTIVATE_CUSTOM) and (Data.MonDelay > 0) then
1181 SpawnCooldown := Data.MonDelay;
1182 if (Data.MonMax > 0) and (SpawnedCount >= Data.MonMax) then
1183 Break;
1185 i := g_Monsters_Create(Data.MonType,
1186 Data.MonPos.X, Data.MonPos.Y,
1187 TDirection(Data.MonDir), True);
1189 Result := True;
1191 // Çäîðîâüå:
1192 if (Data.MonHealth > 0) then
1193 gMonsters[i].SetHealth(Data.MonHealth);
1194 // Óñòàíàâëèâàåì ïîâåäåíèå:
1195 gMonsters[i].MonsterBehaviour := Data.MonBehav;
1196 gMonsters[i].FNoRespawn := True;
1197 if g_Game_IsNet then
1198 MH_SEND_MonsterSpawn(gMonsters[i].UID);
1199 // Èäåì èñêàòü öåëü, åñëè íàäî:
1200 if Data.MonActive then
1201 gMonsters[i].WakeUp();
1203 if Data.MonType <> MONSTER_BARREL then Inc(gTotalMonsters);
1205 if g_Game_IsNet then
1206 begin
1207 SetLength(gMonstersSpawned, Length(gMonstersSpawned)+1);
1208 gMonstersSpawned[High(gMonstersSpawned)] := gMonsters[i].UID;
1209 end;
1211 if Data.MonMax > 0 then
1212 begin
1213 gMonsters[i].SpawnTrigger := ID;
1214 Inc(SpawnedCount);
1215 end;
1217 case Data.MonEffect of
1218 EFFECT_TELEPORT: begin
1219 if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
1220 begin
1221 Anim := TAnimation.Create(FramesID, False, 3);
1222 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data.MonPos.X, Data.MonPos.Y);
1223 g_GFX_OnceAnim(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-32,
1224 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+(gMonsters[i].Obj.Rect.Height div 2)-32, Anim);
1225 Anim.Free();
1226 end;
1227 if g_Game_IsServer and g_Game_IsNet then
1228 MH_SEND_Effect(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-32,
1229 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+(gMonsters[i].Obj.Rect.Height div 2)-32, 1,
1230 NET_GFX_TELE);
1231 end;
1232 EFFECT_RESPAWN: begin
1233 if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
1234 begin
1235 Anim := TAnimation.Create(FramesID, False, 4);
1236 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data.MonPos.X, Data.MonPos.Y);
1237 g_GFX_OnceAnim(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-16,
1238 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+(gMonsters[i].Obj.Rect.Height div 2)-16, Anim);
1239 Anim.Free();
1240 end;
1241 if g_Game_IsServer and g_Game_IsNet then
1242 MH_SEND_Effect(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-16,
1243 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+(gMonsters[i].Obj.Rect.Height div 2)-16, 1,
1244 NET_GFX_RESPAWN);
1245 end;
1246 EFFECT_FIRE: begin
1247 if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
1248 begin
1249 Anim := TAnimation.Create(FramesID, False, 4);
1250 g_Sound_PlayExAt('SOUND_FIRE', Data.MonPos.X, Data.MonPos.Y);
1251 g_GFX_OnceAnim(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-32,
1252 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+gMonsters[i].Obj.Rect.Height-128, Anim);
1253 Anim.Free();
1254 end;
1255 if g_Game_IsServer and g_Game_IsNet then
1256 MH_SEND_Effect(gMonsters[i].Obj.X+gMonsters[i].Obj.Rect.X+(gMonsters[i].Obj.Rect.Width div 2)-32,
1257 gMonsters[i].Obj.Y+gMonsters[i].Obj.Rect.Y+gMonsters[i].Obj.Rect.Height-128, 1,
1258 NET_GFX_FIRE);
1259 end;
1260 end;
1261 end;
1262 if g_Game_IsNet then
1263 begin
1264 MH_SEND_GameStats();
1265 MH_SEND_CoopStats();
1266 end;
1268 if coolDown then
1269 TimeOut := 18
1270 else
1271 TimeOut := 0;
1272 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1273 if actType = ACTIVATE_CUSTOM then
1274 Result := False;
1275 end;
1277 TRIGGER_SPAWNITEM:
1278 if (Data.ItemType in [ITEM_MEDKIT_SMALL..ITEM_MAX]) then
1279 begin
1280 Result := False;
1281 if (Data.ItemDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
1282 begin
1283 AutoSpawn := not AutoSpawn;
1284 SpawnCooldown := 0;
1285 // Àâòîñïàâíåð ïåðåêëþ÷åí - ìåíÿåì òåêñòóðó
1286 Result := True;
1287 end;
1289 if ((Data.ItemDelay = 0) and (actType <> ACTIVATE_CUSTOM))
1290 or ((Data.ItemDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
1291 if (not Data.ItemOnlyDM) or
1292 (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1293 for k := 1 to Data.ItemCount do
1294 begin
1295 if (actType = ACTIVATE_CUSTOM) and (Data.ItemDelay > 0) then
1296 SpawnCooldown := Data.ItemDelay;
1297 if (Data.ItemMax > 0) and (SpawnedCount >= Data.ItemMax) then
1298 Break;
1300 iid := g_Items_Create(Data.ItemPos.X, Data.ItemPos.Y,
1301 Data.ItemType, Data.ItemFalls, False, True);
1303 Result := True;
1305 if Data.ItemMax > 0 then
1306 begin
1307 gItems[iid].SpawnTrigger := ID;
1308 Inc(SpawnedCount);
1309 end;
1311 case Data.ItemEffect of
1312 EFFECT_TELEPORT: begin
1313 if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
1314 begin
1315 Anim := TAnimation.Create(FramesID, False, 3);
1316 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data.ItemPos.X, Data.ItemPos.Y);
1317 g_GFX_OnceAnim(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-32,
1318 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+(gItems[iid].Obj.Rect.Height div 2)-32, Anim);
1319 Anim.Free();
1320 end;
1321 if g_Game_IsServer and g_Game_IsNet then
1322 MH_SEND_Effect(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-32,
1323 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+(gItems[iid].Obj.Rect.Height div 2)-32, 1,
1324 NET_GFX_TELE);
1325 end;
1326 EFFECT_RESPAWN: begin
1327 if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
1328 begin
1329 Anim := TAnimation.Create(FramesID, False, 4);
1330 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data.ItemPos.X, Data.ItemPos.Y);
1331 g_GFX_OnceAnim(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-16,
1332 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+(gItems[iid].Obj.Rect.Height div 2)-16, Anim);
1333 Anim.Free();
1334 end;
1335 if g_Game_IsServer and g_Game_IsNet then
1336 MH_SEND_Effect(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-16,
1337 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+(gItems[iid].Obj.Rect.Height div 2)-16, 1,
1338 NET_GFX_RESPAWN);
1339 end;
1340 EFFECT_FIRE: begin
1341 if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
1342 begin
1343 Anim := TAnimation.Create(FramesID, False, 4);
1344 g_Sound_PlayExAt('SOUND_FIRE', Data.ItemPos.X, Data.ItemPos.Y);
1345 g_GFX_OnceAnim(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-32,
1346 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+gItems[iid].Obj.Rect.Height-128, Anim);
1347 Anim.Free();
1348 end;
1349 if g_Game_IsServer and g_Game_IsNet then
1350 MH_SEND_Effect(gItems[iid].Obj.X+gItems[iid].Obj.Rect.X+(gItems[iid].Obj.Rect.Width div 2)-32,
1351 gItems[iid].Obj.Y+gItems[iid].Obj.Rect.Y+gItems[iid].Obj.Rect.Height-128, 1,
1352 NET_GFX_FIRE);
1353 end;
1354 end;
1356 if g_Game_IsNet then
1357 MH_SEND_ItemSpawn(True, iid);
1358 end;
1360 if coolDown then
1361 TimeOut := 18
1362 else
1363 TimeOut := 0;
1364 // Åñëè àêòèâèðîâàí àâòîñïàâíåðîì, íå ìåíÿåì òåêñòóðó
1365 if actType = ACTIVATE_CUSTOM then
1366 Result := False;
1367 end;
1369 TRIGGER_MUSIC:
1370 begin
1371 // Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
1372 if (Trigger.Data.MusicName <> '') then
1373 begin
1374 gMusic.SetByName(Trigger.Data.MusicName);
1375 gMusic.SpecPause := True;
1376 gMusic.Play();
1377 end;
1379 if Trigger.Data.MusicAction = 1 then
1380 begin // Âêëþ÷èòü
1381 if gMusic.SpecPause then // Áûëà íà ïàóçå => èãðàòü
1382 gMusic.SpecPause := False
1383 else // Èãðàëà => ñíà÷àëà
1384 gMusic.SetPosition(0);
1385 end
1386 else // Âûêëþ÷èòü
1387 begin
1388 // Ïàóçà:
1389 gMusic.SpecPause := True;
1390 end;
1392 if coolDown then
1393 TimeOut := 36
1394 else
1395 TimeOut := 0;
1396 Result := True;
1397 if g_Game_IsNet then MH_SEND_TriggerMusic;
1398 end;
1400 TRIGGER_PUSH:
1401 begin
1402 pAngle := -DegToRad(Data.PushAngle);
1403 Result := tr_Push(ActivateUID,
1404 Floor(Cos(pAngle)*Data.PushForce),
1405 Floor(Sin(pAngle)*Data.PushForce),
1406 Data.ResetVel);
1407 TimeOut := 0;
1408 end;
1410 TRIGGER_SCORE:
1411 begin
1412 Result := False;
1413 // Ïðèáàâèòü èëè îòíÿòü î÷êî
1414 if (Data.ScoreAction in [0..1]) and (Data.ScoreCount > 0) then
1415 begin
1416 // Ñâîåé èëè ÷óæîé êîìàíäå
1417 if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
1418 begin
1419 p := g_Player_Get(ActivateUID);
1420 if ((Data.ScoreAction = 0) and (Data.ScoreTeam = 0) and (p.Team = TEAM_RED))
1421 or ((Data.ScoreAction = 0) and (Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
1422 begin
1423 Inc(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Scores
1425 if Data.ScoreCon then
1426 if Data.ScoreTeam = 0 then
1427 begin
1428 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1429 if g_Game_IsServer and g_Game_IsNet then
1430 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+r');
1431 end else
1432 begin
1433 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1434 if g_Game_IsServer and g_Game_IsNet then
1435 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+re');
1436 end;
1438 if Data.ScoreMsg then
1439 begin
1440 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
1441 if g_Game_IsServer and g_Game_IsNet then
1442 MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
1443 end;
1444 end;
1445 if ((Data.ScoreAction = 1) and (Data.ScoreTeam = 0) and (p.Team = TEAM_RED))
1446 or ((Data.ScoreAction = 1) and (Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
1447 begin
1448 Dec(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Fouls
1450 if Data.ScoreCon then
1451 if Data.ScoreTeam = 0 then
1452 begin
1453 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1454 if g_Game_IsServer and g_Game_IsNet then
1455 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-r');
1456 end else
1457 begin
1458 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1459 if g_Game_IsServer and g_Game_IsNet then
1460 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-re');
1461 end;
1463 if Data.ScoreMsg then
1464 begin
1465 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
1466 if g_Game_IsServer and g_Game_IsNet then
1467 MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
1468 end;
1469 end;
1470 if ((Data.ScoreAction = 0) and (Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE))
1471 or ((Data.ScoreAction = 0) and (Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
1472 begin
1473 Inc(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Scores
1475 if Data.ScoreCon then
1476 if Data.ScoreTeam = 0 then
1477 begin
1478 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1479 if g_Game_IsServer and g_Game_IsNet then
1480 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+b');
1481 end else
1482 begin
1483 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1484 if g_Game_IsServer and g_Game_IsNet then
1485 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+be');
1486 end;
1488 if Data.ScoreMsg then
1489 begin
1490 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
1491 if g_Game_IsServer and g_Game_IsNet then
1492 MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
1493 end;
1494 end;
1495 if ((Data.ScoreAction = 1) and (Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE))
1496 or ((Data.ScoreAction = 1) and (Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
1497 begin
1498 Dec(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Fouls
1500 if Data.ScoreCon then
1501 if Data.ScoreTeam = 0 then
1502 begin
1503 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1504 if g_Game_IsServer and g_Game_IsNet then
1505 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-b');
1506 end else
1507 begin
1508 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1509 if g_Game_IsServer and g_Game_IsNet then
1510 MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-be');
1511 end;
1513 if Data.ScoreMsg then
1514 begin
1515 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
1516 if g_Game_IsServer and g_Game_IsNet then
1517 MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_BLUE);
1518 end;
1519 end;
1520 Result := (p.Team = TEAM_RED) or (p.Team = TEAM_BLUE);
1521 end;
1522 // Êàêîé-òî êîíêðåòíîé êîìàíäå
1523 if Data.ScoreTeam in [2..3] then
1524 begin
1525 if (Data.ScoreAction = 0) and (Data.ScoreTeam = 2) then
1526 begin
1527 Inc(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Scores
1529 if Data.ScoreCon then
1530 begin
1531 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_RED], Data.ScoreCount]), True);
1532 if g_Game_IsServer and g_Game_IsNet then
1533 MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '+tr');
1534 end;
1536 if Data.ScoreMsg then
1537 begin
1538 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
1539 if g_Game_IsServer and g_Game_IsNet then
1540 MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
1541 end;
1542 end;
1543 if (Data.ScoreAction = 1) and (Data.ScoreTeam = 2) then
1544 begin
1545 Dec(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Fouls
1547 if Data.ScoreCon then
1548 begin
1549 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_RED], Data.ScoreCount]), True);
1550 if g_Game_IsServer and g_Game_IsNet then
1551 MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '-tr');
1552 end;
1554 if Data.ScoreMsg then
1555 begin
1556 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
1557 if g_Game_IsServer and g_Game_IsNet then
1558 MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
1559 end;
1560 end;
1561 if (Data.ScoreAction = 0) and (Data.ScoreTeam = 3) then
1562 begin
1563 Inc(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Scores
1565 if Data.ScoreCon then
1566 begin
1567 g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_BLUE], Data.ScoreCount]), True);
1568 if g_Game_IsServer and g_Game_IsNet then
1569 MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '+tb');
1570 end;
1572 if Data.ScoreMsg then
1573 begin
1574 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
1575 if g_Game_IsServer and g_Game_IsNet then
1576 MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
1577 end;
1578 end;
1579 if (Data.ScoreAction = 1) and (Data.ScoreTeam = 3) then
1580 begin
1581 Dec(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Fouls
1583 if Data.ScoreCon then
1584 begin
1585 g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_BLUE], Data.ScoreCount]), True);
1586 if g_Game_IsServer and g_Game_IsNet then
1587 MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '-tb');
1588 end;
1590 if Data.ScoreMsg then
1591 begin
1592 g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
1593 if g_Game_IsServer and g_Game_IsNet then
1594 MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_BLUE);
1595 end;
1596 end;
1597 Result := True;
1598 end;
1599 end;
1600 // Âûèãðûø
1601 if (Data.ScoreAction = 2) and (gGameSettings.GoalLimit > 0) then
1602 begin
1603 // Ñâîåé èëè ÷óæîé êîìàíäû
1604 if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
1605 begin
1606 p := g_Player_Get(ActivateUID);
1607 if ((Data.ScoreTeam = 0) and (p.Team = TEAM_RED)) // Red Wins
1608 or ((Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
1609 if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
1610 begin
1611 gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
1613 if Data.ScoreCon then
1614 if Data.ScoreTeam = 0 then
1615 begin
1616 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1617 if g_Game_IsServer and g_Game_IsNet then
1618 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wr');
1619 end else
1620 begin
1621 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1622 if g_Game_IsServer and g_Game_IsNet then
1623 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wre');
1624 end;
1626 Result := True;
1627 end;
1628 if ((Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Blue Wins
1629 or ((Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
1630 if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
1631 begin
1632 gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
1634 if Data.ScoreCon then
1635 if Data.ScoreTeam = 0 then
1636 begin
1637 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1638 if g_Game_IsServer and g_Game_IsNet then
1639 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wb');
1640 end else
1641 begin
1642 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1643 if g_Game_IsServer and g_Game_IsNet then
1644 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wbe');
1645 end;
1647 Result := True;
1648 end;
1649 end;
1650 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1651 if Data.ScoreTeam in [2..3] then
1652 begin
1653 if Data.ScoreTeam = 2 then // Red Wins
1654 if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
1655 begin
1656 gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
1657 Result := True;
1658 end;
1659 if Data.ScoreTeam = 3 then // Blue Wins
1660 if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
1661 begin
1662 gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
1663 Result := True;
1664 end;
1665 end;
1666 end;
1667 // Ïðîèãðûø
1668 if (Data.ScoreAction = 3) and (gGameSettings.GoalLimit > 0) then
1669 begin
1670 // Ñâîåé èëè ÷óæîé êîìàíäû
1671 if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
1672 begin
1673 p := g_Player_Get(ActivateUID);
1674 if ((Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Red Wins
1675 or ((Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
1676 if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
1677 begin
1678 gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
1680 if Data.ScoreCon then
1681 if Data.ScoreTeam = 0 then
1682 begin
1683 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1684 if g_Game_IsServer and g_Game_IsNet then
1685 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wre');
1686 end else
1687 begin
1688 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
1689 if g_Game_IsServer and g_Game_IsNet then
1690 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wr');
1691 end;
1693 Result := True;
1694 end;
1695 if ((Data.ScoreTeam = 0) and (p.Team = TEAM_RED)) // Blue Wins
1696 or ((Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
1697 if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
1698 begin
1699 gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
1701 if Data.ScoreCon then
1702 if Data.ScoreTeam = 0 then
1703 begin
1704 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1705 if g_Game_IsServer and g_Game_IsNet then
1706 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wbe');
1707 end else
1708 begin
1709 g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
1710 if g_Game_IsServer and g_Game_IsNet then
1711 MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wb');
1712 end;
1714 Result := True;
1715 end;
1716 end;
1717 // Êàêîé-òî êîíêðåòíîé êîìàíäû
1718 if Data.ScoreTeam in [2..3] then
1719 begin
1720 if Data.ScoreTeam = 3 then // Red Wins
1721 if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
1722 begin
1723 gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
1724 Result := True;
1725 end;
1726 if Data.ScoreTeam = 2 then // Blue Wins
1727 if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
1728 begin
1729 gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
1730 Result := True;
1731 end;
1732 end;
1733 end;
1734 if Result then begin
1735 if coolDown then
1736 TimeOut := 18
1737 else
1738 TimeOut := 0;
1739 if g_Game_IsServer and g_Game_IsNet then
1740 MH_SEND_GameStats;
1741 end;
1742 end;
1744 TRIGGER_MESSAGE:
1745 begin
1746 Result := tr_Message(Data.MessageKind, Data.MessageText,
1747 Data.MessageSendTo, Data.MessageTime,
1748 ActivateUID);
1749 TimeOut := 18;
1750 end;
1752 TRIGGER_DAMAGE, TRIGGER_HEALTH:
1753 begin
1754 Result := False;
1755 UIDType := g_GetUIDType(ActivateUID);
1756 if (UIDType = UID_PLAYER) or (UIDType = UID_MONSTER) then
1757 begin
1758 Result := True;
1759 k := -1;
1760 if coolDown then
1761 begin
1762 // Âñïîìèíàåì, àêòèâèðîâàë ëè îí ìåíÿ ðàíüøå
1763 for i := 0 to High(Activators) do
1764 if Activators[i].UID = ActivateUID then
1765 begin
1766 k := i;
1767 Break;
1768 end;
1769 if k = -1 then
1770 begin // Âèäèì åãî âïåðâûå
1771 // Çàïîìèíàåì åãî
1772 SetLength(Activators, Length(Activators) + 1);
1773 k := High(Activators);
1774 Activators[k].UID := ActivateUID;
1775 end else
1776 begin // Óæå âèäåëè åãî
1777 // Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
1778 if (Data.DamageInterval = 0) and (Activators[k].TimeOut > 0) then
1779 Activators[k].TimeOut := 65535;
1780 // Òàéìàóò ïðîø¸ë - ðàáîòàåì
1781 Result := Activators[k].TimeOut = 0;
1782 end;
1783 end;
1785 if Result then
1786 begin
1787 case UIDType of
1788 UID_PLAYER:
1789 begin
1790 p := g_Player_Get(ActivateUID);
1791 if p = nil then
1792 Exit;
1794 // Íàíîñèì óðîí èãðîêó
1795 if (TriggerType = TRIGGER_DAMAGE) and (Data.DamageValue > 0) then
1796 p.Damage(Data.DamageValue, 0, 0, 0, HIT_SOME);
1798 // Ëå÷èì èãðîêà
1799 if (TriggerType = TRIGGER_HEALTH) and (Data.HealValue > 0) then
1800 if p.Heal(Data.HealValue, not Data.HealMax) and (not Data.HealSilent) then
1801 begin
1802 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p.Obj.X, p.Obj.Y);
1803 if g_Game_IsServer and g_Game_IsNet then
1804 MH_SEND_Sound(p.Obj.X, p.Obj.Y, 'SOUND_ITEM_GETITEM');
1805 end;
1806 end;
1808 UID_MONSTER:
1809 begin
1810 m := g_Monsters_Get(ActivateUID);
1811 if m = nil then
1812 Exit;
1814 // Íàíîñèì óðîí ìîíñòðó
1815 if (TriggerType = TRIGGER_DAMAGE) and (Data.DamageValue > 0) then
1816 m.Damage(Data.DamageValue, 0, 0, 0, HIT_SOME);
1818 // Ëå÷èì ìîíñòðà
1819 if (TriggerType = TRIGGER_HEALTH) and (Data.HealValue > 0) then
1820 if m.Heal(Data.HealValue) and (not Data.HealSilent) then
1821 begin
1822 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m.Obj.X, m.Obj.Y);
1823 if g_Game_IsServer and g_Game_IsNet then
1824 MH_SEND_Sound(m.Obj.X, m.Obj.Y, 'SOUND_ITEM_GETITEM');
1825 end;
1826 end;
1827 end;
1828 // Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
1829 if TriggerType = TRIGGER_DAMAGE then
1830 i := Data.DamageInterval
1831 else
1832 i := Data.HealInterval;
1833 if coolDown then
1834 if i > 0 then
1835 Activators[k].TimeOut := i
1836 else
1837 Activators[k].TimeOut := 65535;
1838 end;
1839 end;
1840 TimeOut := 0;
1841 end;
1843 TRIGGER_SHOT:
1844 begin
1845 if ShotSightTime > 0 then
1846 Exit;
1848 // put this at the beginning so it doesn't trigger itself
1849 TimeOut := Data.ShotWait + 1;
1851 wx := Data.ShotPos.X;
1852 wy := Data.ShotPos.Y;
1853 pAngle := -DegToRad(Data.ShotAngle);
1854 xd := wx + Round(Cos(pAngle) * 32.0);
1855 yd := wy + Round(Sin(pAngle) * 32.0);
1856 TargetUID := 0;
1858 case Data.ShotTarget of
1859 TRIGGER_SHOT_TARGET_MON: // monsters
1860 if gMonsters <> nil then
1861 for i := Low(gMonsters) to High(gMonsters) do
1862 if (gMonsters[i] <> nil) and gMonsters[i].Live and
1863 tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
1864 begin
1865 xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
1866 yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
1867 TargetUID := gMonsters[i].UID;
1868 break;
1869 end;
1871 TRIGGER_SHOT_TARGET_PLR: // players
1872 if gPlayers <> nil then
1873 for i := Low(gPlayers) to High(gPlayers) do
1874 if (gPlayers[i] <> nil) and gPlayers[i].Live and
1875 tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
1876 begin
1877 xd := gPlayers[i].GameX + PLAYER_RECT_CX;
1878 yd := gPlayers[i].GameY + PLAYER_RECT_CY;
1879 TargetUID := gPlayers[i].UID;
1880 break;
1881 end;
1883 TRIGGER_SHOT_TARGET_RED: // red team
1884 if gPlayers <> nil then
1885 for i := Low(gPlayers) to High(gPlayers) do
1886 if (gPlayers[i] <> nil) and gPlayers[i].Live and
1887 (gPlayers[i].Team = TEAM_RED) and
1888 tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
1889 begin
1890 xd := gPlayers[i].GameX + PLAYER_RECT_CX;
1891 yd := gPlayers[i].GameY + PLAYER_RECT_CY;
1892 TargetUID := gPlayers[i].UID;
1893 break;
1894 end;
1896 TRIGGER_SHOT_TARGET_BLUE: // blue team
1897 if gPlayers <> nil then
1898 for i := Low(gPlayers) to High(gPlayers) do
1899 if (gPlayers[i] <> nil) and gPlayers[i].Live and
1900 (gPlayers[i].Team = TEAM_BLUE) and
1901 tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
1902 begin
1903 xd := gPlayers[i].GameX + PLAYER_RECT_CX;
1904 yd := gPlayers[i].GameY + PLAYER_RECT_CY;
1905 TargetUID := gPlayers[i].UID;
1906 break;
1907 end;
1909 TRIGGER_SHOT_TARGET_MONPLR: // monsters then players
1910 begin
1911 if gMonsters <> nil then
1912 for i := Low(gMonsters) to High(gMonsters) do
1913 if (gMonsters[i] <> nil) and gMonsters[i].Live and
1914 tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
1915 begin
1916 xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
1917 yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
1918 TargetUID := gMonsters[i].UID;
1919 break;
1920 end;
1921 if (TargetUID = 0) and (gPlayers <> nil) then
1922 for i := Low(gPlayers) to High(gPlayers) do
1923 if (gPlayers[i] <> nil) and gPlayers[i].Live and
1924 tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
1925 begin
1926 xd := gPlayers[i].GameX + PLAYER_RECT_CX;
1927 yd := gPlayers[i].GameY + PLAYER_RECT_CY;
1928 TargetUID := gPlayers[i].UID;
1929 break;
1930 end;
1931 end;
1933 TRIGGER_SHOT_TARGET_PLRMON: // players then monsters
1934 begin
1935 if gPlayers <> nil then
1936 for i := Low(gPlayers) to High(gPlayers) do
1937 if (gPlayers[i] <> nil) and gPlayers[i].Live and
1938 tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
1939 begin
1940 xd := gPlayers[i].GameX + PLAYER_RECT_CX;
1941 yd := gPlayers[i].GameY + PLAYER_RECT_CY;
1942 TargetUID := gPlayers[i].UID;
1943 break;
1944 end;
1945 if (TargetUID = 0) and (gMonsters <> nil) then
1946 for i := Low(gMonsters) to High(gMonsters) do
1947 if (gMonsters[i] <> nil) and gMonsters[i].Live and
1948 tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
1949 begin
1950 xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
1951 yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
1952 TargetUID := gMonsters[i].UID;
1953 break;
1954 end;
1955 end;
1957 else begin
1958 if (Data.ShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
1959 (Data.ShotType <> TRIGGER_SHOT_REV) then
1960 TargetUID := ActivateUID;
1961 end;
1962 end;
1964 if (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
1965 ((Data.ShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
1966 begin
1967 Result := True;
1968 if (Data.ShotIntSight = 0) or
1969 (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or
1970 (TargetUID = ShotSightTarget) then
1971 MakeShot(Trigger, wx, wy, xd, yd, TargetUID)
1972 else
1973 begin
1974 ShotSightTime := Data.ShotIntSight;
1975 ShotSightTargetN := TargetUID;
1976 if Data.ShotType = TRIGGER_SHOT_BFG then
1977 begin
1978 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx, wy);
1979 if g_Game_IsNet and g_Game_IsServer then
1980 MH_SEND_Sound(wx, wy, 'SOUND_WEAPON_STARTFIREBFG');
1981 end;
1982 end;
1983 end;
1984 end;
1986 TRIGGER_EFFECT:
1987 begin
1988 i := Data.FXCount;
1990 while i > 0 do
1991 begin
1992 case Data.FXPos of
1993 TRIGGER_EFFECT_POS_CENTER:
1994 begin
1995 wx := X + Width div 2;
1996 wy := Y + Height div 2;
1997 end;
1998 TRIGGER_EFFECT_POS_AREA:
1999 begin
2000 wx := X + Random(Width);
2001 wy := Y + Random(Height);
2002 end;
2003 else begin
2004 wx := X + Width div 2;
2005 wy := Y + Height div 2;
2006 end;
2007 end;
2008 xd := Data.FXVelX;
2009 yd := Data.FXVelY;
2010 if Data.FXSpreadL > 0 then xd := xd - Random(Data.FXSpreadL + 1);
2011 if Data.FXSpreadR > 0 then xd := xd + Random(Data.FXSpreadR + 1);
2012 if Data.FXSpreadU > 0 then yd := yd - Random(Data.FXSpreadU + 1);
2013 if Data.FXSpreadD > 0 then yd := yd + Random(Data.FXSpreadD + 1);
2014 tr_MakeEffect(wx, wy, xd, yd,
2015 Data.FXType, Data.FXSubType,
2016 Data.FXColorR, Data.FXColorG, Data.FXColorB, True, False);
2017 Dec(i);
2018 end;
2019 TimeOut := Data.FXWait;
2020 end;
2022 TRIGGER_SCRIPT:
2023 begin
2024 g_Scripts_ProcExec(Data.SCRProc, [ID, ActivateUID, actType, Data.SCRArg], 'map');
2025 TimeOut := 0;
2026 Result := True;
2027 end;
2028 end;
2029 end;
2031 if Result and (Trigger.TexturePanel <> -1) then
2032 g_Map_SwitchTexture(Trigger.TexturePanelType, Trigger.TexturePanel, IfThen(animonce, 2, 1));
2033 end;
2035 function g_Triggers_Create(Trigger: TTrigger): DWORD;
2036 var
2037 find_id: DWORD;
2038 fn, mapw: String;
2039 begin
2040 // Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà:
2041 if (Trigger.TriggerType = TRIGGER_EXIT) and
2042 (not LongBool(gGameSettings.Options and GAME_OPTION_ALLOWEXIT)) then
2043 Trigger.TriggerType := TRIGGER_NONE;
2045 // Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð:
2046 if (Trigger.TriggerType = TRIGGER_SPAWNMONSTER) and
2047 (not LongBool(gGameSettings.Options and GAME_OPTION_MONSTERS)) and
2048 (gGameSettings.GameType <> GT_SINGLE) then
2049 Trigger.TriggerType := TRIGGER_NONE;
2051 // Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå:
2052 if Trigger.TriggerType = TRIGGER_SECRET then
2053 gSecretsCount := gSecretsCount + 1;
2055 find_id := FindTrigger();
2056 gTriggers[find_id] := Trigger;
2058 with gTriggers[find_id] do
2059 begin
2060 ID := find_id;
2061 // if this type of trigger exists both on the client and on the server
2062 // use an uniform numeration
2063 if Trigger.TriggerType = TRIGGER_SOUND then
2064 begin
2065 Inc(gTriggerClientID);
2066 ClientID := gTriggerClientID;
2067 end
2068 else
2069 ClientID := 0;
2070 TimeOut := 0;
2071 ActivateUID := 0;
2072 PlayerCollide := False;
2073 DoorTime := -1;
2074 PressTime := -1;
2075 PressCount := 0;
2076 SoundPlayCount := 0;
2077 Sound := nil;
2078 AutoSpawn := False;
2079 SpawnCooldown := 0;
2080 SpawnedCount := 0;
2081 end;
2083 // Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê":
2084 if (Trigger.TriggerType = TRIGGER_SOUND) and
2085 (Trigger.Data.SoundName <> '') then
2086 begin
2087 // Åùå íåò òàêîãî çâóêà:
2088 if not g_Sound_Exists(Trigger.Data.SoundName) then
2089 begin
2090 fn := g_ExtractWadName(Trigger.Data.SoundName);
2092 if fn = '' then
2093 begin // Çâóê â ôàéëå ñ êàðòîé
2094 mapw := g_ExtractWadName(gMapInfo.Map);
2095 fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.SoundName);
2096 end
2097 else // Çâóê â îòäåëüíîì ôàéëå
2098 fn := GameDir + '/wads/' + Trigger.Data.SoundName;
2100 if not g_Sound_CreateWADEx(Trigger.Data.SoundName, fn) then
2101 g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.Data.SoundName]));
2102 end;
2104 // Ñîçäàåì îáúåêò çâóêà:
2105 with gTriggers[find_id] do
2106 begin
2107 Sound := TPlayableSound.Create();
2108 if not Sound.SetByName(Trigger.Data.SoundName) then
2109 begin
2110 Sound.Free();
2111 Sound := nil;
2112 end;
2113 end;
2114 end;
2116 // Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà":
2117 if (Trigger.TriggerType = TRIGGER_MUSIC) and
2118 (Trigger.Data.MusicName <> '') then
2119 begin
2120 // Åùå íåò òàêîé ìóçûêè:
2121 if not g_Sound_Exists(Trigger.Data.MusicName) then
2122 begin
2123 fn := g_ExtractWadName(Trigger.Data.MusicName);
2125 if fn = '' then
2126 begin // Ìóçûêà â ôàéëå ñ êàðòîé
2127 mapw := g_ExtractWadName(gMapInfo.Map);
2128 fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.MusicName);
2129 end
2130 else // Ìóçûêà â ôàéëå ñ êàðòîé
2131 fn := GameDir+'/wads/'+Trigger.Data.MusicName;
2133 if not g_Sound_CreateWADEx(Trigger.Data.MusicName, fn, True) then
2134 g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.Data.MusicName]));
2135 end;
2136 end;
2138 // Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü":
2139 if Trigger.TriggerType = TRIGGER_SHOT then
2140 with gTriggers[find_id] do
2141 begin
2142 ShotPanelTime := 0;
2143 ShotSightTime := 0;
2144 ShotSightTimeout := 0;
2145 ShotSightTarget := 0;
2146 ShotSightTargetN := 0;
2147 ShotAmmoCount := Trigger.Data.ShotAmmo;
2148 ShotReloadTime := 0;
2149 end;
2151 Result := find_id;
2152 end;
2154 procedure g_Triggers_Update();
2155 var
2156 a, b, i: Integer;
2157 Affected: array of Integer;
2158 begin
2159 if gTriggers = nil then
2160 Exit;
2161 SetLength(Affected, 0);
2163 for a := 0 to High(gTriggers) do
2164 with gTriggers[a] do
2165 // Åñòü òðèããåð:
2166 if TriggerType <> TRIGGER_NONE then
2167 begin
2168 // Óìåíüøàåì âðåìÿ äî çàêðûòèÿ äâåðè (îòêðûòèÿ ëîâóøêè):
2169 if DoorTime > 0 then
2170 DoorTime := DoorTime - 1;
2171 // Óìåíüøàåì âðåìÿ îæèäàíèÿ ïîñëå íàæàòèÿ:
2172 if PressTime > 0 then
2173 PressTime := PressTime - 1;
2174 // Ïðîâåðÿåì èãðîêîâ è ìîíñòðîâ, êîòîðûõ ðàíåå çàïîìíèëè:
2175 if (TriggerType = TRIGGER_DAMAGE) or (TriggerType = TRIGGER_HEALTH) then
2176 for b := 0 to High(Activators) do
2177 begin
2178 // Óìåíüøàåì âðåìÿ äî ïîâòîðíîãî âîçäåéñòâèÿ:
2179 if Activators[b].TimeOut > 0 then
2180 Dec(Activators[b].TimeOut)
2181 else
2182 Continue;
2183 // Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
2184 if (Data.DamageInterval = 0) and (Activators[b].TimeOut < 65530) then
2185 Activators[b].TimeOut := 0;
2186 end;
2188 // Îáðàáàòûâàåì ñïàâíåðû:
2189 if Enabled and AutoSpawn then
2190 if SpawnCooldown = 0 then
2191 begin
2192 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà:
2193 if (TriggerType = TRIGGER_SPAWNMONSTER) and (Data.MonDelay > 0) then
2194 begin
2195 ActivateUID := 0;
2196 ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
2197 end;
2198 // Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò:
2199 if (TriggerType = TRIGGER_SPAWNITEM) and (Data.ItemDelay > 0) then
2200 begin
2201 ActivateUID := 0;
2202 ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
2203 end;
2204 end else // Óìåíüøàåì âðåìÿ îæèäàíèÿ:
2205 Dec(SpawnCooldown);
2207 // Îáðàáàòûâàåì ñîáûòèÿ òðèããåðà "Òóðåëü":
2208 if TriggerType = TRIGGER_SHOT then
2209 begin
2210 if ShotPanelTime > 0 then
2211 begin
2212 Dec(ShotPanelTime);
2213 if ShotPanelTime = 0 then
2214 g_Map_SwitchTexture(ShotPanelType, Data.ShotPanelID);
2215 end;
2216 if ShotSightTime > 0 then
2217 begin
2218 Dec(ShotSightTime);
2219 if ShotSightTime = 0 then
2220 ShotSightTarget := ShotSightTargetN;
2221 end;
2222 if ShotSightTimeout > 0 then
2223 begin
2224 Dec(ShotSightTimeout);
2225 if ShotSightTimeout = 0 then
2226 ShotSightTarget := 0;
2227 end;
2228 if ShotReloadTime > 0 then
2229 begin
2230 Dec(ShotReloadTime);
2231 if ShotReloadTime = 0 then
2232 ShotAmmoCount := Data.ShotAmmo;
2233 end;
2234 end;
2236 // Òðèããåð "Çâóê" óæå îòûãðàë, åñëè íóæíî åùå - ïåðåçàïóñêàåì:
2237 if Enabled and (TriggerType = TRIGGER_SOUND) and (Sound <> nil) then
2238 if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then
2239 begin
2240 if Data.PlayCount > 0 then // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
2241 SoundPlayCount := SoundPlayCount - 1;
2242 if Data.Local then
2243 Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), Data.Volume/255.0)
2244 else
2245 Sound.PlayPanVolume((Data.Pan-127.0)/128.0, Data.Volume/255.0);
2246 if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then
2247 MH_SEND_TriggerSound(gTriggers[a]);
2248 end;
2250 // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü:
2251 if (TriggerType = TRIGGER_TRAP) and (DoorTime = 0) and (Data.PanelID <> -1) then
2252 begin
2253 tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
2254 DoorTime := -1;
2255 end;
2257 // Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü:
2258 if (TriggerType = TRIGGER_DOOR5) and (DoorTime = 0) and (Data.PanelID <> -1) then
2259 begin
2260 // Óæå çàêðûòà:
2261 if gWalls[Data.PanelID].Enabled then
2262 DoorTime := -1
2263 else // Ïîêà îòêðûòà - çàêðûâàåì
2264 if tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors) then
2265 DoorTime := -1;
2266 end;
2268 // Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
2269 if (TriggerType in [TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF]) and
2270 (PressTime = 0) and (PressCount >= Data.Count) then
2271 begin
2272 // Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
2273 PressTime := -1;
2274 // Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
2275 if Data.Count > 0 then
2276 PressCount := PressCount - Data.Count
2277 else
2278 PressCount := 0;
2280 // Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
2281 for b := 0 to High(gTriggers) do
2282 if g_Collide(Data.tX, Data.tY, Data.tWidth, Data.tHeight, gTriggers[b].X, gTriggers[b].Y,
2283 gTriggers[b].Width, gTriggers[b].Height) and
2284 ((b <> a) or (Data.Wait > 0)) then
2285 begin // Can be self-activated, if there is Data.Wait
2286 if (not Data.ExtRandom) or gTriggers[b].Enabled then
2287 begin
2288 SetLength(Affected, Length(Affected) + 1);
2289 Affected[High(Affected)] := b;
2290 end;
2291 end;
2292 // Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
2293 if (TriggerType = TRIGGER_PRESS) and Data.ExtRandom then
2294 begin
2295 if (Length(Affected) > 0) then
2296 begin
2297 b := Affected[Random(Length(Affected))];
2298 gTriggers[b].ActivateUID := gTriggers[a].ActivateUID;
2299 ActivateTrigger(gTriggers[b], 0);
2300 end;
2301 end
2302 else //  ïðîòèâíîì ñëó÷àå ðàáîòàåì êàê îáû÷íî:
2303 for i := 0 to High(Affected) do
2304 begin
2305 b := Affected[i];
2306 case TriggerType of
2307 TRIGGER_PRESS:
2308 begin
2309 gTriggers[b].ActivateUID := gTriggers[a].ActivateUID;
2310 ActivateTrigger(gTriggers[b], 0);
2311 end;
2312 TRIGGER_ON:
2313 begin
2314 gTriggers[b].Enabled := True;
2315 end;
2316 TRIGGER_OFF:
2317 begin
2318 gTriggers[b].Enabled := False;
2319 gTriggers[b].TimeOut := 0;
2320 if gTriggers[b].AutoSpawn then
2321 begin
2322 gTriggers[b].AutoSpawn := False;
2323 gTriggers[b].SpawnCooldown := 0;
2324 end;
2325 end;
2326 TRIGGER_ONOFF:
2327 begin
2328 gTriggers[b].Enabled := not gTriggers[b].Enabled;
2329 if not gTriggers[b].Enabled then
2330 begin
2331 gTriggers[b].TimeOut := 0;
2332 if gTriggers[b].AutoSpawn then
2333 begin
2334 gTriggers[b].AutoSpawn := False;
2335 gTriggers[b].SpawnCooldown := 0;
2336 end;
2337 end;
2338 end;
2339 end;
2340 end;
2341 SetLength(Affected, 0);
2342 end;
2344 // Óìåíüøàåì âðåìÿ äî âîçìîæíîñòè ïîâòîðíîé àêòèâàöèè:
2345 if TimeOut > 0 then
2346 begin
2347 TimeOut := TimeOut - 1;
2348 Continue; // ×òîáû íå ïîòåðÿòü 1 åäèíèöó çàäåðæêè
2349 end;
2351 // Íèæå èäóò òèïû àêòèâàöèè, åñëè òðèããåð îòêëþ÷¸í - èä¸ì äàëüøå
2352 if not Enabled then
2353 Continue;
2355 // "Èãðîê áëèçêî":
2356 if ByteBool(ActivateType and ACTIVATE_PLAYERCOLLIDE) and
2357 (TimeOut = 0) then
2358 if gPlayers <> nil then
2359 for b := 0 to High(gPlayers) do
2360 if gPlayers[b] <> nil then
2361 with gPlayers[b] do
2362 // Æèâ, åñòü íóæíûå êëþ÷è è îí ðÿäîì:
2363 if Live and ((gTriggers[a].Keys and GetKeys) = gTriggers[a].Keys) and
2364 Collide(X, Y, Width, Height) then
2365 begin
2366 gTriggers[a].ActivateUID := UID;
2368 if (gTriggers[a].TriggerType in [TRIGGER_SOUND, TRIGGER_MUSIC]) and
2369 PlayerCollide then
2370 { Don't activate sound/music again if player is here }
2371 else
2372 ActivateTrigger(gTriggers[a], ACTIVATE_PLAYERCOLLIDE);
2373 end;
2375 { TODO 5 : àêòèâàöèÿ ìîíñòðàìè òðèããåðîâ ñ êëþ÷àìè }
2377 if ByteBool(ActivateType and ACTIVATE_MONSTERCOLLIDE) and
2378 ByteBool(ActivateType and ACTIVATE_NOMONSTER) and
2379 (TimeOut = 0) and (Keys = 0) then
2380 begin
2381 // Åñëè "Ìîíñòð áëèçêî" è "Ìîíñòðîâ íåò",
2382 // çàïóñêàåì òðèããåð íà ñòàðòå êàðòû è ñíèìàåì îáà ôëàãà
2383 ActivateType := ActivateType and not (ACTIVATE_MONSTERCOLLIDE or ACTIVATE_NOMONSTER);
2384 gTriggers[a].ActivateUID := 0;
2385 ActivateTrigger(gTriggers[a], 0);
2386 end else
2387 begin
2388 // "Ìîíñòð áëèçêî":
2389 if ByteBool(ActivateType and ACTIVATE_MONSTERCOLLIDE) and
2390 (TimeOut = 0) and (Keys = 0) then // Åñëè íå íóæíû êëþ÷è
2391 if gMonsters <> nil then
2392 for b := 0 to High(gMonsters) do
2393 if (gMonsters[b] <> nil) then
2394 with gMonsters[b] do
2395 if Collide(X, Y, Width, Height) then
2396 begin
2397 gTriggers[a].ActivateUID := UID;
2398 ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
2399 end;
2401 // "Ìîíñòðîâ íåò":
2402 if ByteBool(ActivateType and ACTIVATE_NOMONSTER) and
2403 (TimeOut = 0) and (Keys = 0) then
2404 if not g_CollideMonster(X, Y, Width, Height) then
2405 begin
2406 gTriggers[a].ActivateUID := 0;
2407 ActivateTrigger(gTriggers[a], ACTIVATE_NOMONSTER);
2408 end;
2409 end;
2411 PlayerCollide := g_CollidePlayer(X, Y, Width, Height);
2412 end;
2413 end;
2415 procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0);
2416 begin
2417 gTriggers[ID].ActivateUID := ActivateUID;
2418 ActivateTrigger(gTriggers[ID], ActivateType);
2419 end;
2421 function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word;
2422 ActivateType: Byte; IgnoreList: DWArray = nil): DWArray;
2423 var
2424 a: Integer;
2425 k: Byte;
2426 p: TPlayer;
2427 begin
2428 Result := nil;
2430 if gTriggers = nil then Exit;
2432 case g_GetUIDType(UID) of
2433 UID_GAME: k := 255;
2434 UID_PLAYER:
2435 begin
2436 p := g_Player_Get(UID);
2437 if p <> nil then
2438 k := p.GetKeys
2439 else
2440 k := 0;
2441 end;
2442 else k := 0;
2443 end;
2445 for a := 0 to High(gTriggers) do
2446 if (gTriggers[a].TriggerType <> TRIGGER_NONE) and
2447 (gTriggers[a].TimeOut = 0) and
2448 (not InDWArray(a, IgnoreList)) and
2449 ((gTriggers[a].Keys and k) = gTriggers[a].Keys) and
2450 ByteBool(gTriggers[a].ActivateType and ActivateType) then
2451 if g_Collide(X, Y, Width, Height,
2452 gTriggers[a].X, gTriggers[a].Y,
2453 gTriggers[a].Width, gTriggers[a].Height) then
2454 begin
2455 gTriggers[a].ActivateUID := UID;
2456 if ActivateTrigger(gTriggers[a], ActivateType) then
2457 begin
2458 SetLength(Result, Length(Result)+1);
2459 Result[High(Result)] := a;
2460 end;
2461 end;
2462 end;
2464 procedure g_Triggers_PressL(X1, Y1, X2, Y2: Integer; UID: DWORD; ActivateType: Byte);
2465 var
2466 a: Integer;
2467 k: Byte;
2468 p: TPlayer;
2469 begin
2470 if gTriggers = nil then Exit;
2472 case g_GetUIDType(UID) of
2473 UID_GAME: k := 255;
2474 UID_PLAYER:
2475 begin
2476 p := g_Player_Get(UID);
2477 if p <> nil then
2478 k := p.GetKeys
2479 else
2480 k := 0;
2481 end;
2482 else k := 0;
2483 end;
2485 for a := 0 to High(gTriggers) do
2486 if (gTriggers[a].TriggerType <> TRIGGER_NONE) and
2487 (gTriggers[a].TimeOut = 0) and
2488 ((gTriggers[a].Keys and k) = gTriggers[a].Keys) and
2489 ByteBool(gTriggers[a].ActivateType and ActivateType) then
2490 if g_CollideLine(x1, y1, x2, y2, gTriggers[a].X, gTriggers[a].Y,
2491 gTriggers[a].Width, gTriggers[a].Height) then
2492 begin
2493 gTriggers[a].ActivateUID := UID;
2494 ActivateTrigger(gTriggers[a], ActivateType);
2495 end;
2496 end;
2498 procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1);
2499 var
2500 a: Integer;
2501 k: Byte;
2502 rsq: Word;
2503 p: TPlayer;
2504 begin
2505 if gTriggers = nil then
2506 Exit;
2508 case g_GetUIDType(UID) of
2509 UID_GAME: k := 255;
2510 UID_PLAYER:
2511 begin
2512 p := g_Player_Get(UID);
2513 if p <> nil then
2514 k := p.GetKeys
2515 else
2516 k := 0;
2517 end;
2518 else k := 0;
2519 end;
2521 rsq := Radius * Radius;
2523 for a := 0 to High(gTriggers) do
2524 if (gTriggers[a].ID <> DWORD(IgnoreTrigger)) and
2525 (gTriggers[a].TriggerType <> TRIGGER_NONE) and
2526 (gTriggers[a].TimeOut = 0) and
2527 ((gTriggers[a].Keys and k) = gTriggers[a].Keys) and
2528 ByteBool(gTriggers[a].ActivateType and ActivateType) then
2529 with gTriggers[a] do
2530 if g_Collide(CX-Radius, CY-Radius, 2*Radius, 2*Radius,
2531 X, Y, Width, Height) then
2532 if ((Sqr(CX-X)+Sqr(CY-Y)) < rsq) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ëåâîìó óãëó
2533 ((Sqr(CX-X-Width)+Sqr(CY-Y)) < rsq) or // Öåíòð êðóãà áëèçîê ê âåðõíåìó ïðàâîìó óãëó
2534 ((Sqr(CX-X-Width)+Sqr(CY-Y-Height)) < rsq) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ïðàâîìó óãëó
2535 ((Sqr(CX-X)+Sqr(CY-Y-Height)) < rsq) or // Öåíòð êðóãà áëèçîê ê íèæíåìó ëåâîìó óãëó
2536 ( (CX > (X-Radius)) and (CX < (X+Width+Radius)) and
2537 (CY > Y) and (CY < (Y+Height)) ) or // Öåíòð êðóãà íåäàëåêî îò âåðòèêàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
2538 ( (CY > (Y-Radius)) and (CY < (Y+Height+Radius)) and
2539 (CX > X) and (CX < (X+Width)) ) then // Öåíòð êðóãà íåäàëåêî îò ãîðèçîíòàëüíûõ ãðàíèö ïðÿìîóãîëüíèêà
2540 begin
2541 ActivateUID := UID;
2542 ActivateTrigger(gTriggers[a], ActivateType);
2543 end;
2544 end;
2546 procedure g_Triggers_OpenAll();
2547 var
2548 a: Integer;
2549 b: Boolean;
2550 begin
2551 if gTriggers = nil then Exit;
2553 b := False;
2554 for a := 0 to High(gTriggers) do
2555 with gTriggers[a] do
2556 if (TriggerType = TRIGGER_OPENDOOR) or
2557 (TriggerType = TRIGGER_DOOR5) or
2558 (TriggerType = TRIGGER_DOOR) then
2559 begin
2560 tr_OpenDoor(Data.PanelID, True, Data.d2d_doors);
2561 if TriggerType = TRIGGER_DOOR5 then DoorTime := 180;
2562 b := True;
2563 end;
2565 if b then g_Sound_PlayEx('SOUND_GAME_DOOROPEN');
2566 end;
2568 procedure g_Triggers_DecreaseSpawner(ID: DWORD);
2569 begin
2570 if (gTriggers <> nil) then
2571 if gTriggers[ID].SpawnedCount > 0 then
2572 Dec(gTriggers[ID].SpawnedCount);
2573 end;
2575 procedure g_Triggers_Free();
2576 var
2577 a: Integer;
2578 begin
2579 if gTriggers <> nil then
2580 for a := 0 to High(gTriggers) do
2581 begin
2582 if gTriggers[a].TriggerType = TRIGGER_SOUND then
2583 begin
2584 if g_Sound_Exists(gTriggers[a].Data.SoundName) then
2585 g_Sound_Delete(gTriggers[a].Data.SoundName);
2587 gTriggers[a].Sound.Free();
2588 end;
2589 if gTriggers[a].Activators <> nil then
2590 SetLength(gTriggers[a].Activators, 0);
2591 end;
2593 gTriggers := nil;
2594 gSecretsCount := 0;
2595 SetLength(gMonstersSpawned, 0);
2596 end;
2598 procedure g_Triggers_SaveState(var Mem: TBinMemoryWriter);
2599 var
2600 count, act_count, i, j: Integer;
2601 dw: DWORD;
2602 sg: Single;
2603 b: Boolean;
2604 p: Pointer;
2605 begin
2606 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ:
2607 count := 0;
2608 if gTriggers <> nil then
2609 for i := 0 to High(gTriggers) do
2610 count := count + 1;
2612 Mem := TBinMemoryWriter.Create((count+1) * 200);
2614 // Êîëè÷åñòâî òðèããåðîâ:
2615 Mem.WriteInt(count);
2617 if count = 0 then
2618 Exit;
2620 for i := 0 to High(gTriggers) do
2621 begin
2622 // Ñèãíàòóðà òðèããåðà:
2623 dw := TRIGGER_SIGNATURE; // 'TRGR'
2624 Mem.WriteDWORD(dw);
2625 // Òèï òðèããåðà:
2626 Mem.WriteByte(gTriggers[i].TriggerType);
2627 // Ñïåöèàëüíûå äàííûå òðèããåðà:
2628 p := @gTriggers[i].Data;
2629 Mem.WriteMemory(p, SizeOf(TTriggerData));
2630 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
2631 Mem.WriteInt(gTriggers[i].X);
2632 Mem.WriteInt(gTriggers[i].Y);
2633 // Ðàçìåðû:
2634 Mem.WriteWord(gTriggers[i].Width);
2635 Mem.WriteWord(gTriggers[i].Height);
2636 // Âêëþ÷åí ëè òðèããåð:
2637 Mem.WriteBoolean(gTriggers[i].Enabled);
2638 // Òèï àêòèâàöèè òðèããåðà:
2639 Mem.WriteByte(gTriggers[i].ActivateType);
2640 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè:
2641 Mem.WriteByte(gTriggers[i].Keys);
2642 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ:
2643 Mem.WriteInt(gTriggers[i].TexturePanel);
2644 // Òèï ýòîé ïàíåëè:
2645 Mem.WriteWord(gTriggers[i].TexturePanelType);
2646 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
2647 Mem.WriteWord(gTriggers[i].TimeOut);
2648 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
2649 Mem.WriteWord(gTriggers[i].ActivateUID);
2650 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
2651 act_count := Length(gTriggers[i].Activators);
2652 Mem.WriteInt(act_count);
2653 for j := 0 to act_count-1 do
2654 begin
2655 // UID îáúåêòà
2656 Mem.WriteWord(gTriggers[i].Activators[j].UID);
2657 // Âðåìÿ îæèäàíèÿ
2658 Mem.WriteWord(gTriggers[i].Activators[j].TimeOut);
2659 end;
2660 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà:
2661 Mem.WriteBoolean(gTriggers[i].PlayerCollide);
2662 // Âðåìÿ äî çàêðûòèÿ äâåðè:
2663 Mem.WriteInt(gTriggers[i].DoorTime);
2664 // Çàäåðæêà àêòèâàöèè:
2665 Mem.WriteInt(gTriggers[i].PressTime);
2666 // Ñ÷åò÷èê íàæàòèé:
2667 Mem.WriteInt(gTriggers[i].PressCount);
2668 // Ñïàâíåð àêòèâåí:
2669 Mem.WriteBoolean(gTriggers[i].AutoSpawn);
2670 // Çàäåðæêà ñïàâíåðà:
2671 Mem.WriteInt(gTriggers[i].SpawnCooldown);
2672 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ:
2673 Mem.WriteInt(gTriggers[i].SpawnedCount);
2674 // Ñêîëüêî ðàç ïðîèãðàí çâóê:
2675 Mem.WriteInt(gTriggers[i].SoundPlayCount);
2676 // Ïðîèãðûâàåòñÿ ëè çâóê?
2677 if gTriggers[i].Sound <> nil then
2678 b := gTriggers[i].Sound.IsPlaying()
2679 else
2680 b := False;
2681 Mem.WriteBoolean(b);
2682 if b then
2683 begin
2684 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà:
2685 dw := gTriggers[i].Sound.GetPosition();
2686 Mem.WriteDWORD(dw);
2687 // Ãðîìêîñòü çâóêà:
2688 sg := gTriggers[i].Sound.GetVolume();
2689 sg := sg / (gSoundLevel/255.0);
2690 Mem.WriteSingle(sg);
2691 // Ñòåðåî ñìåùåíèå çâóêà:
2692 sg := gTriggers[i].Sound.GetPan();
2693 Mem.WriteSingle(sg);
2694 end;
2695 end;
2696 end;
2698 procedure g_Triggers_LoadState(var Mem: TBinMemoryReader);
2699 var
2700 count, act_count, i, j, a: Integer;
2701 dw: DWORD;
2702 vol, pan: Single;
2703 b: Boolean;
2704 p: Pointer;
2705 Trig: TTrigger;
2706 begin
2707 if Mem = nil then
2708 Exit;
2710 g_Triggers_Free();
2712 // Êîëè÷åñòâî òðèããåðîâ:
2713 Mem.ReadInt(count);
2715 if count = 0 then
2716 Exit;
2718 for a := 0 to count-1 do
2719 begin
2720 // Ñèãíàòóðà òðèããåðà:
2721 Mem.ReadDWORD(dw);
2722 if dw <> TRIGGER_SIGNATURE then // 'TRGR'
2723 begin
2724 raise EBinSizeError.Create('g_Triggers_LoadState: Wrong Trigger Signature');
2725 end;
2726 // Òèï òðèããåðà:
2727 Mem.ReadByte(Trig.TriggerType);
2728 // Ñïåöèàëüíûå äàííûå òðèããåðà:
2729 Mem.ReadMemory(p, dw);
2730 if dw <> SizeOf(TTriggerData) then
2731 begin
2732 raise EBinSizeError.Create('g_Triggers_LoadState: Wrong TriggerData Size');
2733 end;
2734 Trig.Data := TTriggerData(p^);
2735 // Ñîçäàåì òðèããåð:
2736 i := g_Triggers_Create(Trig);
2737 // Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
2738 Mem.ReadInt(gTriggers[i].X);
2739 Mem.ReadInt(gTriggers[i].Y);
2740 // Ðàçìåðû:
2741 Mem.ReadWord(gTriggers[i].Width);
2742 Mem.ReadWord(gTriggers[i].Height);
2743 // Âêëþ÷åí ëè òðèããåð:
2744 Mem.ReadBoolean(gTriggers[i].Enabled);
2745 // Òèï àêòèâàöèè òðèããåðà:
2746 Mem.ReadByte(gTriggers[i].ActivateType);
2747 // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè:
2748 Mem.ReadByte(gTriggers[i].Keys);
2749 // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ:
2750 Mem.ReadInt(gTriggers[i].TexturePanel);
2751 // Òèï ýòîé ïàíåëè:
2752 Mem.ReadWord(gTriggers[i].TexturePanelType);
2753 // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
2754 Mem.ReadWord(gTriggers[i].TimeOut);
2755 // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
2756 Mem.ReadWord(gTriggers[i].ActivateUID);
2757 // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
2758 Mem.ReadInt(act_count);
2759 if act_count > 0 then
2760 begin
2761 SetLength(gTriggers[i].Activators, act_count);
2762 for j := 0 to act_count-1 do
2763 begin
2764 // UID îáúåêòà
2765 Mem.ReadWord(gTriggers[i].Activators[j].UID);
2766 // Âðåìÿ îæèäàíèÿ
2767 Mem.ReadWord(gTriggers[i].Activators[j].TimeOut);
2768 end;
2769 end;
2770 // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà:
2771 Mem.ReadBoolean(gTriggers[i].PlayerCollide);
2772 // Âðåìÿ äî çàêðûòèÿ äâåðè:
2773 Mem.ReadInt(gTriggers[i].DoorTime);
2774 // Çàäåðæêà àêòèâàöèè:
2775 Mem.ReadInt(gTriggers[i].PressTime);
2776 // Ñ÷åò÷èê íàæàòèé:
2777 Mem.ReadInt(gTriggers[i].PressCount);
2778 // Ñïàâíåð àêòèâåí:
2779 Mem.ReadBoolean(gTriggers[i].AutoSpawn);
2780 // Çàäåðæêà ñïàâíåðà:
2781 Mem.ReadInt(gTriggers[i].SpawnCooldown);
2782 // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ:
2783 Mem.ReadInt(gTriggers[i].SpawnedCount);
2784 // Ñêîëüêî ðàç ïðîèãðàí çâóê:
2785 Mem.ReadInt(gTriggers[i].SoundPlayCount);
2786 // Ïðîèãðûâàåòñÿ ëè çâóê?
2787 Mem.ReadBoolean(b);
2788 if b then
2789 begin
2790 // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà:
2791 Mem.ReadDWORD(dw);
2792 // Ãðîìêîñòü çâóêà:
2793 Mem.ReadSingle(vol);
2794 // Ñòåðåî ñìåùåíèå çâóêà:
2795 Mem.ReadSingle(pan);
2796 // Çàïóñêàåì çâóê, åñëè åñòü:
2797 if gTriggers[i].Sound <> nil then
2798 begin
2799 gTriggers[i].Sound.PlayPanVolume(pan, vol);
2800 gTriggers[i].Sound.Pause(True);
2801 gTriggers[i].Sound.SetPosition(dw);
2802 end
2803 end;
2804 end;
2805 end;
2807 end.