index e39b8c66a3dfdd7b6a2491f85087cae51e119ddb..6698288c33cda673ec4fe9129256171494b1fc1c 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
interface
uses
interface
uses
- MAPSTRUCT, e_graphics, MAPDEF, g_basic, g_sound,
- BinEditor;
+ MAPDEF, e_graphics, g_basic, g_sound,
+ BinEditor, xdynrec;
type
TActivator = record
UID: Word;
TimeOut: Word;
end;
type
TActivator = record
UID: Word;
TimeOut: Word;
end;
+ PTrigger = ^TTrigger;
TTrigger = record
TTrigger = record
+ public
ID: DWORD;
ClientID: DWORD;
TriggerType: Byte;
ID: DWORD;
ClientID: DWORD;
TriggerType: Byte;
ShotAmmoCount: Word;
ShotReloadTime: Integer;
ShotAmmoCount: Word;
ShotReloadTime: Integer;
- Data: TTriggerData;
+ mapId: AnsiString; // trigger id, from map
+ mapIndex: Integer; // index in fields['trigger'], used in save/load
+ //trigShotPanelId: Integer;
+ trigPanelId: Integer;
+
+ //TrigData: TTriggerData;
+ trigData: TDynRecord; // triggerdata; owned by trigger
+
+ public
+ function trigCenter (): TDFPoint; inline;
+
+ public
+ property trigShotPanelId: Integer read trigPanelId write trigPanelId;
end;
end;
-function g_Triggers_Create(Trigger: TTrigger): DWORD;
+function g_Triggers_Create(Trigger: TTrigger; forceInternalIndex: Integer=-1): DWORD;
procedure g_Triggers_Update();
procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0);
function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word;
procedure g_Triggers_Update();
procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0);
function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word;
g_player, g_map, Math, g_gfx, g_game, g_textures,
g_console, g_monsters, g_items, g_phys, g_weapons,
wadreader, g_main, SysUtils, e_log, g_language,
g_player, g_map, Math, g_gfx, g_game, g_textures,
g_console, g_monsters, g_items, g_phys, g_weapons,
wadreader, g_main, SysUtils, e_log, g_language,
- g_options, g_net, g_netmsg;
+ g_options, g_net, g_netmsg, utils, xparser;
const
const
- TRIGGER_SIGNATURE = $52475254; // 'TRGR'
+ TRIGGER_SIGNATURE = $58475254; // 'TRGX'
TRAP_DAMAGE = 1000;
TRAP_DAMAGE = 1000;
+
+function TTrigger.trigCenter (): TDFPoint; inline;
+begin
+ result := TDFPoint.Create(x+width div 2, y+height div 2);
+end;
+
+
function FindTrigger(): DWORD;
var
i: Integer;
begin
function FindTrigger(): DWORD;
var
i: Integer;
begin
- if gTriggers <> nil then
- for i := 0 to High(gTriggers) do
- if gTriggers[i].TriggerType = TRIGGER_NONE then
- begin
- Result := i;
- Exit;
- end;
+ for i := 0 to High(gTriggers) do
+ begin
+ if gTriggers[i].TriggerType = TRIGGER_NONE then begin result := i; exit; end;
+ end;
- if gTriggers = nil then
+ if (gTriggers = nil) then
begin
SetLength(gTriggers, 8);
begin
SetLength(gTriggers, 8);
- Result := 0;
+ result := 0;
end
else
begin
end
else
begin
- Result := High(gTriggers) + 1;
- SetLength(gTriggers, Length(gTriggers) + 8);
+ result := Length(gTriggers);
+ SetLength(gTriggers, result+8);
+ for i := result to High(gTriggers) do gTriggers[i].TriggerType := TRIGGER_NONE;
end;
end;
end;
end;
+
function tr_CloseDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
var
a, b, c: Integer;
function tr_CloseDoor(PanelID: Integer; NoSound: Boolean; d2d: Boolean): Boolean;
var
a, b, c: Integer;
procedure MakeShot(var Trigger: TTrigger; wx, wy, dx, dy: Integer; TargetUID: Word);
begin
with Trigger do
procedure MakeShot(var Trigger: TTrigger; wx, wy, dx, dy: Integer; TargetUID: Word);
begin
with Trigger do
- if (Data.ShotAmmo = 0) or
- ((Data.ShotAmmo > 0) and (ShotAmmoCount > 0)) then
+ if (trigData.trigShotAmmo = 0) or
+ ((trigData.trigShotAmmo > 0) and (ShotAmmoCount > 0)) then
begin
begin
- if (Data.ShotPanelID <> -1) and (ShotPanelTime = 0) then
+ if (trigShotPanelID <> -1) and (ShotPanelTime = 0) then
begin
begin
- g_Map_SwitchTexture(ShotPanelType, Data.ShotPanelID);
+ g_Map_SwitchTexture(ShotPanelType, trigShotPanelID);
ShotPanelTime := 4; // òèêîâ íà âñïûøêó âûñòðåëà
end;
ShotPanelTime := 4; // òèêîâ íà âñïûøêó âûñòðåëà
end;
- if Data.ShotIntSight > 0 then
+ if trigData.trigShotIntSight > 0 then
ShotSightTimeout := 180; // ~= 5 ñåêóíä
if ShotAmmoCount > 0 then Dec(ShotAmmoCount);
ShotSightTimeout := 180; // ~= 5 ñåêóíä
if ShotAmmoCount > 0 then Dec(ShotAmmoCount);
- dx := dx + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
- dy := dy + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
+ dx := dx + Random(trigData.trigShotAccuracy) - Random(trigData.trigShotAccuracy);
+ dy := dy + Random(trigData.trigShotAccuracy) - Random(trigData.trigShotAccuracy);
- tr_SpawnShot(Data.ShotType, wx, wy, dx, dy, Data.ShotSound, TargetUID);
+ tr_SpawnShot(trigData.trigShotType, wx, wy, dx, dy, trigData.trigShotSound, TargetUID);
end
else
end
else
- if (Data.ShotIntReload > 0) and (ShotReloadTime = 0) then
- ShotReloadTime := Data.ShotIntReload; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
+ if (trigData.trigShotIntReload > 0) and (ShotReloadTime = 0) then
+ ShotReloadTime := trigData.trigShotIntReload; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
end;
procedure tr_MakeEffect(X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean);
end;
procedure tr_MakeEffect(X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean);
begin
if TriggerType <> TRIGGER_SHOT then
Exit;
begin
if TriggerType <> TRIGGER_SHOT then
Exit;
- Result := (Data.ShotAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
+ Result := (trigData.trigShotAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
or g_Obj_Collide(X, Y, Width, Height, Obj);
or g_Obj_Collide(X, Y, Width, Height, Obj);
- if Result and (Data.ShotAim and TRIGGER_SHOT_AIM_TRACE > 0) then
- Result := g_TraceVector(Data.ShotPos.X,
- Data.ShotPos.Y,
+ if Result and (trigData.trigShotAim and TRIGGER_SHOT_AIM_TRACE > 0) then
+ Result := g_TraceVector(trigData.trigShotPos.X,
+ trigData.trigShotPos.Y,
Obj^.X + Obj^.Rect.X + (Obj^.Rect.Width div 2),
Obj^.Y + Obj^.Rect.Y + (Obj^.Rect.Height div 2));
end;
Obj^.X + Obj^.Rect.X + (Obj^.Rect.Width div 2),
Obj^.Y + Obj^.Rect.Y + (Obj^.Rect.Height div 2));
end;
g_Sound_PlayEx('SOUND_GAME_SWITCH0');
if g_Game_IsNet then MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH0');
gExitByTrigger := True;
g_Sound_PlayEx('SOUND_GAME_SWITCH0');
if g_Game_IsNet then MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH0');
gExitByTrigger := True;
- g_Game_ExitLevel(Data.MapName);
+ g_Game_ExitLevel(trigData.trigMapName);
TimeOut := 18;
Result := True;
TimeOut := 18;
Result := True;
TRIGGER_TELEPORT:
begin
Result := tr_Teleport(ActivateUID,
TRIGGER_TELEPORT:
begin
Result := tr_Teleport(ActivateUID,
- Data.TargetPoint.X, Data.TargetPoint.Y,
- Data.TlpDir, Data.silent_teleport,
- Data.d2d_teleport);
+ trigData.trigTargetPoint.X, trigData.trigTargetPoint.Y,
+ trigData.trigTlpDir, trigData.trigsilent_teleport,
+ trigData.trigd2d_teleport);
TimeOut := 0;
end;
TRIGGER_OPENDOOR:
begin
TimeOut := 0;
end;
TRIGGER_OPENDOOR:
begin
- Result := tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ Result := tr_OpenDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
TimeOut := 0;
end;
TRIGGER_CLOSEDOOR:
begin
TimeOut := 0;
end;
TRIGGER_CLOSEDOOR:
begin
- Result := tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ Result := tr_CloseDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
TimeOut := 0;
end;
TRIGGER_DOOR, TRIGGER_DOOR5:
begin
TimeOut := 0;
end;
TRIGGER_DOOR, TRIGGER_DOOR5:
begin
- if Data.PanelID <> -1 then
+ if trigPanelID <> -1 then
begin
begin
- if gWalls[Data.PanelID].Enabled then
+ if gWalls[trigPanelID].Enabled then
begin
begin
- Result := tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ Result := tr_OpenDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
if TriggerType = TRIGGER_DOOR5 then
DoorTime := 180;
end
else
if TriggerType = TRIGGER_DOOR5 then
DoorTime := 180;
end
else
- Result := tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ Result := tr_CloseDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
if Result then
TimeOut := 18;
if Result then
TimeOut := 18;
TRIGGER_CLOSETRAP, TRIGGER_TRAP:
begin
TRIGGER_CLOSETRAP, TRIGGER_TRAP:
begin
- tr_CloseTrap(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ tr_CloseTrap(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
if TriggerType = TRIGGER_TRAP then
begin
if TriggerType = TRIGGER_TRAP then
begin
PressCount := PressCount + 1;
if PressTime = -1 then
PressCount := PressCount + 1;
if PressTime = -1 then
- PressTime := Data.Wait;
+ PressTime := trigData.trigWait;
if coolDown then
TimeOut := 18
if coolDown then
TimeOut := 18
TRIGGER_LIFTUP:
begin
TRIGGER_LIFTUP:
begin
- Result := tr_SetLift(Data.PanelID, 0, Data.NoSound, Data.d2d_doors);
+ Result := tr_SetLift(trigPanelID, 0, trigData.trigNoSound, trigData.trigd2d_doors);
TimeOut := 0;
TimeOut := 0;
- if (not Data.NoSound) and Result then begin
+ if (not trigData.trigNoSound) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_LIFTDOWN:
begin
TRIGGER_LIFTDOWN:
begin
- Result := tr_SetLift(Data.PanelID, 1, Data.NoSound, Data.d2d_doors);
+ Result := tr_SetLift(trigPanelID, 1, trigData.trigNoSound, trigData.trigd2d_doors);
TimeOut := 0;
TimeOut := 0;
- if (not Data.NoSound) and Result then begin
+ if (not trigData.trigNoSound) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_LIFT:
begin
TRIGGER_LIFT:
begin
- Result := tr_SetLift(Data.PanelID, 3, Data.NoSound, Data.d2d_doors);
+ Result := tr_SetLift(trigPanelID, 3, trigData.trigNoSound, trigData.trigd2d_doors);
if Result then
begin
TimeOut := 18;
if Result then
begin
TimeOut := 18;
- if (not Data.NoSound) and Result then begin
+ if (not trigData.trigNoSound) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_TEXTURE:
begin
TRIGGER_TEXTURE:
begin
- if ByteBool(Data.ActivateOnce) then
+ if trigData.trigActivateOnce then
begin
Enabled := False;
TriggerType := TRIGGER_NONE;
begin
Enabled := False;
TriggerType := TRIGGER_NONE;
else
TimeOut := 0;
else
TimeOut := 0;
- animonce := Data.AnimOnce;
+ animonce := trigData.trigAnimOnce;
Result := True;
end;
Result := True;
end;
begin
if Sound <> nil then
begin
begin
if Sound <> nil then
begin
- if Data.SoundSwitch and Sound.IsPlaying() then
+ if trigData.trigSoundSwitch and Sound.IsPlaying() then
begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
Sound.Stop();
SoundPlayCount := 0;
Result := True;
end
else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
Sound.Stop();
SoundPlayCount := 0;
Result := True;
end
else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
- if (Data.PlayCount > 0) or (not Sound.IsPlaying()) then
+ if (trigData.trigPlayCount > 0) or (not Sound.IsPlaying()) then
begin
begin
- if Data.PlayCount > 0 then
- SoundPlayCount := Data.PlayCount
+ if trigData.trigPlayCount > 0 then
+ SoundPlayCount := trigData.trigPlayCount
else // 0 - èãðàåì áåñêîíå÷íî
SoundPlayCount := 1;
Result := True;
else // 0 - èãðàåì áåñêîíå÷íî
SoundPlayCount := 1;
Result := True;
end;
TRIGGER_SPAWNMONSTER:
end;
TRIGGER_SPAWNMONSTER:
- if (Data.MonType in [MONSTER_DEMON..MONSTER_MAN]) then
+ if (trigData.trigMonType in [MONSTER_DEMON..MONSTER_MAN]) then
begin
Result := False;
begin
Result := False;
- if (Data.MonDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
+ if (trigData.trigMonDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
Result := True;
end;
Result := True;
end;
- if ((Data.MonDelay = 0) and (actType <> ACTIVATE_CUSTOM))
- or ((Data.MonDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
- for k := 1 to Data.MonCount do
+ if ((trigData.trigMonDelay = 0) and (actType <> ACTIVATE_CUSTOM))
+ or ((trigData.trigMonDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
+ for k := 1 to trigData.trigMonCount do
begin
begin
- if (actType = ACTIVATE_CUSTOM) and (Data.MonDelay > 0) then
- SpawnCooldown := Data.MonDelay;
- if (Data.MonMax > 0) and (SpawnedCount >= Data.MonMax) then
+ if (actType = ACTIVATE_CUSTOM) and (trigData.trigMonDelay > 0) then
+ SpawnCooldown := trigData.trigMonDelay;
+ if (trigData.trigMonMax > 0) and (SpawnedCount >= trigData.trigMonMax) then
Break;
Break;
- mon := g_Monsters_Create(Data.MonType,
- Data.MonPos.X, Data.MonPos.Y,
- TDirection(Data.MonDir), True);
+ mon := g_Monsters_Create(trigData.trigMonType,
+ trigData.trigMonPos.X, trigData.trigMonPos.Y,
+ TDirection(trigData.trigMonDir), True);
Result := True;
// Çäîðîâüå:
Result := True;
// Çäîðîâüå:
- if (Data.MonHealth > 0) then
- mon.SetHealth(Data.MonHealth);
+ if (trigData.trigMonHealth > 0) then
+ mon.SetHealth(trigData.trigMonHealth);
// Óñòàíàâëèâàåì ïîâåäåíèå:
// Óñòàíàâëèâàåì ïîâåäåíèå:
- mon.MonsterBehaviour := Data.MonBehav;
+ mon.MonsterBehaviour := trigData.trigMonBehav;
mon.FNoRespawn := True;
if g_Game_IsNet then
MH_SEND_MonsterSpawn(mon.UID);
// Èäåì èñêàòü öåëü, åñëè íàäî:
mon.FNoRespawn := True;
if g_Game_IsNet then
MH_SEND_MonsterSpawn(mon.UID);
// Èäåì èñêàòü öåëü, åñëè íàäî:
- if Data.MonActive then
+ if trigData.trigMonActive then
mon.WakeUp();
mon.WakeUp();
- if Data.MonType <> MONSTER_BARREL then Inc(gTotalMonsters);
+ if trigData.trigMonType <> MONSTER_BARREL then Inc(gTotalMonsters);
if g_Game_IsNet then
begin
if g_Game_IsNet then
begin
gMonstersSpawned[High(gMonstersSpawned)] := mon.UID;
end;
gMonstersSpawned[High(gMonstersSpawned)] := mon.UID;
end;
- if Data.MonMax > 0 then
+ if trigData.trigMonMax > 0 then
begin
mon.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
begin
mon.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
- case Data.MonEffect of
+ case trigData.trigMonEffect of
EFFECT_TELEPORT: begin
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
EFFECT_TELEPORT: begin
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
- g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data.MonPos.X, Data.MonPos.Y);
+ g_Sound_PlayExAt('SOUND_GAME_TELEPORT', trigData.trigMonPos.X, trigData.trigMonPos.Y);
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, Anim);
Anim.Free();
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, Anim);
Anim.Free();
if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
- g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data.MonPos.X, Data.MonPos.Y);
+ g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', trigData.trigMonPos.X, trigData.trigMonPos.Y);
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16,
mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, Anim);
Anim.Free();
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16,
mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, Anim);
Anim.Free();
if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
- g_Sound_PlayExAt('SOUND_FIRE', Data.MonPos.X, Data.MonPos.Y);
+ g_Sound_PlayExAt('SOUND_FIRE', trigData.trigMonPos.X, trigData.trigMonPos.Y);
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, Anim);
Anim.Free();
g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32,
mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, Anim);
Anim.Free();
end;
TRIGGER_SPAWNITEM:
end;
TRIGGER_SPAWNITEM:
- if (Data.ItemType in [ITEM_MEDKIT_SMALL..ITEM_MAX]) then
+ if (trigData.trigItemType in [ITEM_MEDKIT_SMALL..ITEM_MAX]) then
begin
Result := False;
begin
Result := False;
- if (Data.ItemDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
+ if (trigData.trigItemDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
Result := True;
end;
Result := True;
end;
- if ((Data.ItemDelay = 0) and (actType <> ACTIVATE_CUSTOM))
- or ((Data.ItemDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
- if (not Data.ItemOnlyDM) or
+ if ((trigData.trigItemDelay = 0) and (actType <> ACTIVATE_CUSTOM))
+ or ((trigData.trigItemDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
+ if (not trigData.trigItemOnlyDM) or
(gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
(gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
- for k := 1 to Data.ItemCount do
+ for k := 1 to trigData.trigItemCount do
begin
begin
- if (actType = ACTIVATE_CUSTOM) and (Data.ItemDelay > 0) then
- SpawnCooldown := Data.ItemDelay;
- if (Data.ItemMax > 0) and (SpawnedCount >= Data.ItemMax) then
+ if (actType = ACTIVATE_CUSTOM) and (trigData.trigItemDelay > 0) then
+ SpawnCooldown := trigData.trigItemDelay;
+ if (trigData.trigItemMax > 0) and (SpawnedCount >= trigData.trigItemMax) then
Break;
Break;
- iid := g_Items_Create(Data.ItemPos.X, Data.ItemPos.Y,
- Data.ItemType, Data.ItemFalls, False, True);
+ iid := g_Items_Create(trigData.trigItemPos.X, trigData.trigItemPos.Y,
+ trigData.trigItemType, trigData.trigItemFalls, False, True);
Result := True;
Result := True;
- if Data.ItemMax > 0 then
+ if trigData.trigItemMax > 0 then
begin
it := g_Items_ByIdx(iid);
it.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
begin
it := g_Items_ByIdx(iid);
it.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
- case Data.ItemEffect of
+ case trigData.trigItemEffect of
EFFECT_TELEPORT: begin
it := g_Items_ByIdx(iid);
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
EFFECT_TELEPORT: begin
it := g_Items_ByIdx(iid);
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
- g_Sound_PlayExAt('SOUND_GAME_TELEPORT', Data.ItemPos.X, Data.ItemPos.Y);
+ g_Sound_PlayExAt('SOUND_GAME_TELEPORT', trigData.trigItemPos.X, trigData.trigItemPos.Y);
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, Anim);
Anim.Free();
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, Anim);
Anim.Free();
if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
- g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', Data.ItemPos.X, Data.ItemPos.Y);
+ g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', trigData.trigItemPos.X, trigData.trigItemPos.Y);
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16,
it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, Anim);
Anim.Free();
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16,
it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, Anim);
Anim.Free();
if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
- g_Sound_PlayExAt('SOUND_FIRE', Data.ItemPos.X, Data.ItemPos.Y);
+ g_Sound_PlayExAt('SOUND_FIRE', trigData.trigItemPos.X, trigData.trigItemPos.Y);
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, Anim);
Anim.Free();
g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32,
it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, Anim);
Anim.Free();
TRIGGER_MUSIC:
begin
// Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
TRIGGER_MUSIC:
begin
// Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
- if (Trigger.Data.MusicName <> '') then
+ if (Trigger.trigData.trigMusicName <> '') then
begin
begin
- gMusic.SetByName(Trigger.Data.MusicName);
+ gMusic.SetByName(Trigger.trigData.trigMusicName);
gMusic.SpecPause := True;
gMusic.Play();
end;
gMusic.SpecPause := True;
gMusic.Play();
end;
- if Trigger.Data.MusicAction = 1 then
+ if Trigger.trigData.trigMusicAction = 1 then
begin // Âêëþ÷èòü
if gMusic.SpecPause then // Áûëà íà ïàóçå => èãðàòü
gMusic.SpecPause := False
begin // Âêëþ÷èòü
if gMusic.SpecPause then // Áûëà íà ïàóçå => èãðàòü
gMusic.SpecPause := False
TRIGGER_PUSH:
begin
TRIGGER_PUSH:
begin
- pAngle := -DegToRad(Data.PushAngle);
+ pAngle := -DegToRad(trigData.trigPushAngle);
Result := tr_Push(ActivateUID,
Result := tr_Push(ActivateUID,
- Floor(Cos(pAngle)*Data.PushForce),
- Floor(Sin(pAngle)*Data.PushForce),
- Data.ResetVel);
+ Floor(Cos(pAngle)*trigData.trigPushForce),
+ Floor(Sin(pAngle)*trigData.trigPushForce),
+ trigData.trigResetVel);
TimeOut := 0;
end;
TimeOut := 0;
end;
begin
Result := False;
// Ïðèáàâèòü èëè îòíÿòü î÷êî
begin
Result := False;
// Ïðèáàâèòü èëè îòíÿòü î÷êî
- if (Data.ScoreAction in [0..1]) and (Data.ScoreCount > 0) then
+ if (trigData.trigScoreAction in [0..1]) and (trigData.trigScoreCount > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäå
begin
// Ñâîåé èëè ÷óæîé êîìàíäå
- if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
begin
p := g_Player_Get(ActivateUID);
- if ((Data.ScoreAction = 0) and (Data.ScoreTeam = 0) and (p.Team = TEAM_RED))
- or ((Data.ScoreAction = 0) and (Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED))
+ or ((trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
begin
begin
- Inc(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Scores
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+r');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+r');
end else
begin
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+re');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+re');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
end;
end;
- if ((Data.ScoreAction = 1) and (Data.ScoreTeam = 0) and (p.Team = TEAM_RED))
- or ((Data.ScoreAction = 1) and (Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED))
+ or ((trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
begin
begin
- Dec(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Fouls
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-r');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-r');
end else
begin
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-re');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-re');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
end;
end;
- if ((Data.ScoreAction = 0) and (Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE))
- or ((Data.ScoreAction = 0) and (Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ if ((trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE))
+ or ((trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
begin
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Scores
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+b');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+b');
end else
begin
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '+be');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+be');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
end;
end;
- if ((Data.ScoreAction = 1) and (Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE))
- or ((Data.ScoreAction = 1) and (Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ if ((trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE))
+ or ((trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
begin
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Fouls
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-b');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-b');
end else
begin
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, Data.ScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (Data.ScoreCount shl 16), '-be');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-be');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
Result := (p.Team = TEAM_RED) or (p.Team = TEAM_BLUE);
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäå
Result := (p.Team = TEAM_RED) or (p.Team = TEAM_BLUE);
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäå
- if Data.ScoreTeam in [2..3] then
+ if trigData.trigScoreTeam in [2..3] then
begin
begin
- if (Data.ScoreAction = 0) and (Data.ScoreTeam = 2) then
+ if (trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 2) then
begin
begin
- Inc(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Scores
- if Data.ScoreCon then
+ if trigData.trigScoreCon then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_RED], Data.ScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_RED], trigData.trigScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '+tr');
+ MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '+tr');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_RED);
end;
end;
- if (Data.ScoreAction = 1) and (Data.ScoreTeam = 2) then
+ if (trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 2) then
begin
begin
- Dec(gTeamStat[TEAM_RED].Goals, Data.ScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Fouls
- if Data.ScoreCon then
+ if trigData.trigScoreCon then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_RED], Data.ScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_RED], trigData.trigScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '-tr');
+ MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '-tr');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, -TEAM_RED);
end;
end;
- if (Data.ScoreAction = 0) and (Data.ScoreTeam = 3) then
+ if (trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 3) then
begin
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Scores
- if Data.ScoreCon then
+ if trigData.trigScoreCon then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_BLUE], Data.ScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_BLUE], trigData.trigScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '+tb');
+ MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '+tb');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
end;
end;
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_ADD], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE_MSG, TEAM_BLUE);
end;
end;
- if (Data.ScoreAction = 1) and (Data.ScoreTeam = 3) then
+ if (trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 3) then
begin
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, Data.ScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Fouls
- if Data.ScoreCon then
+ if trigData.trigScoreCon then
begin
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_BLUE], Data.ScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_BLUE], trigData.trigScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, Data.ScoreCount shl 16, '-tb');
+ MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '-tb');
end;
end;
- if Data.ScoreMsg then
+ if trigData.trigScoreMsg then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Game_Message(Format(_lc[I_MESSAGE_SCORE_SUB], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 108);
if g_Game_IsServer and g_Game_IsNet then
end;
end;
// Âûèãðûø
end;
end;
// Âûèãðûø
- if (Data.ScoreAction = 2) and (gGameSettings.GoalLimit > 0) then
+ if (trigData.trigScoreAction = 2) and (gGameSettings.GoalLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
- if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
begin
p := g_Player_Get(ActivateUID);
- if ((Data.ScoreTeam = 0) and (p.Team = TEAM_RED)) // Red Wins
- or ((Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED)) // Red Wins
+ or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
Result := True;
end;
Result := True;
end;
- if ((Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Blue Wins
- or ((Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Blue Wins
+ or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_OWN], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
end;
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
end;
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
- if Data.ScoreTeam in [2..3] then
+ if trigData.trigScoreTeam in [2..3] then
begin
begin
- if Data.ScoreTeam = 2 then // Red Wins
+ if trigData.trigScoreTeam = 2 then // Red Wins
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
- if Data.ScoreTeam = 3 then // Blue Wins
+ if trigData.trigScoreTeam = 3 then // Blue Wins
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
end;
end;
// Ïðîèãðûø
end;
end;
// Ïðîèãðûø
- if (Data.ScoreAction = 3) and (gGameSettings.GoalLimit > 0) then
+ if (trigData.trigScoreAction = 3) and (gGameSettings.GoalLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
- if (Data.ScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
begin
p := g_Player_Get(ActivateUID);
- if ((Data.ScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Red Wins
- or ((Data.ScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Red Wins
+ or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
Result := True;
end;
Result := True;
end;
- if ((Data.ScoreTeam = 0) and (p.Team = TEAM_RED)) // Blue Wins
- or ((Data.ScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED)) // Blue Wins
+ or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
- if Data.ScoreCon then
- if Data.ScoreTeam = 0 then
+ if trigData.trigScoreCon then
+ if trigData.trigScoreTeam = 0 then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Console_Add(Format(_lc[I_PLAYER_SCORE_WIN_ENEMY], [p.Name, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
end;
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
end;
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
- if Data.ScoreTeam in [2..3] then
+ if trigData.trigScoreTeam in [2..3] then
begin
begin
- if Data.ScoreTeam = 3 then // Red Wins
+ if trigData.trigScoreTeam = 3 then // Red Wins
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
- if Data.ScoreTeam = 2 then // Blue Wins
+ if trigData.trigScoreTeam = 2 then // Blue Wins
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
TRIGGER_MESSAGE:
begin
TRIGGER_MESSAGE:
begin
- Result := tr_Message(Data.MessageKind, Data.MessageText,
- Data.MessageSendTo, Data.MessageTime,
+ Result := tr_Message(trigData.trigMessageKind, trigData.trigMessageText,
+ trigData.trigMessageSendTo, trigData.trigMessageTime,
ActivateUID);
TimeOut := 18;
end;
ActivateUID);
TimeOut := 18;
end;
end else
begin // Óæå âèäåëè åãî
// Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
end else
begin // Óæå âèäåëè åãî
// Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
- if (Data.DamageInterval = 0) and (Activators[k].TimeOut > 0) then
+ if (trigData.trigDamageInterval = 0) and (Activators[k].TimeOut > 0) then
Activators[k].TimeOut := 65535;
// Òàéìàóò ïðîø¸ë - ðàáîòàåì
Result := Activators[k].TimeOut = 0;
Activators[k].TimeOut := 65535;
// Òàéìàóò ïðîø¸ë - ðàáîòàåì
Result := Activators[k].TimeOut = 0;
Exit;
// Íàíîñèì óðîí èãðîêó
Exit;
// Íàíîñèì óðîí èãðîêó
- if (TriggerType = TRIGGER_DAMAGE) and (Data.DamageValue > 0) then
- p.Damage(Data.DamageValue, 0, 0, 0, HIT_SOME);
+ if (TriggerType = TRIGGER_DAMAGE) and (trigData.trigDamageValue > 0) then
+ p.Damage(trigData.trigDamageValue, 0, 0, 0, HIT_SOME);
// Ëå÷èì èãðîêà
// Ëå÷èì èãðîêà
- if (TriggerType = TRIGGER_HEALTH) and (Data.HealValue > 0) then
- if p.Heal(Data.HealValue, not Data.HealMax) and (not Data.HealSilent) then
+ if (TriggerType = TRIGGER_HEALTH) and (trigData.trigHealValue > 0) then
+ if p.Heal(trigData.trigHealValue, not trigData.trigHealMax) and (not trigData.trigHealSilent) then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p.Obj.X, p.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p.Obj.X, p.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
Exit;
// Íàíîñèì óðîí ìîíñòðó
Exit;
// Íàíîñèì óðîí ìîíñòðó
- if (TriggerType = TRIGGER_DAMAGE) and (Data.DamageValue > 0) then
- m.Damage(Data.DamageValue, 0, 0, 0, HIT_SOME);
+ if (TriggerType = TRIGGER_DAMAGE) and (trigData.trigDamageValue > 0) then
+ m.Damage(trigData.trigDamageValue, 0, 0, 0, HIT_SOME);
// Ëå÷èì ìîíñòðà
// Ëå÷èì ìîíñòðà
- if (TriggerType = TRIGGER_HEALTH) and (Data.HealValue > 0) then
- if m.Heal(Data.HealValue) and (not Data.HealSilent) then
+ if (TriggerType = TRIGGER_HEALTH) and (trigData.trigHealValue > 0) then
+ if m.Heal(trigData.trigHealValue) and (not trigData.trigHealSilent) then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m.Obj.X, m.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m.Obj.X, m.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
end;
// Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
if TriggerType = TRIGGER_DAMAGE then
end;
// Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
if TriggerType = TRIGGER_DAMAGE then
- idx := Data.DamageInterval
+ idx := trigData.trigDamageInterval
else
else
- idx := Data.HealInterval;
+ idx := trigData.trigHealInterval;
if coolDown then
if idx > 0 then
Activators[k].TimeOut := idx
if coolDown then
if idx > 0 then
Activators[k].TimeOut := idx
Exit;
// put this at the beginning so it doesn't trigger itself
Exit;
// put this at the beginning so it doesn't trigger itself
- TimeOut := Data.ShotWait + 1;
+ TimeOut := trigData.trigShotWait + 1;
- wx := Data.ShotPos.X;
- wy := Data.ShotPos.Y;
- pAngle := -DegToRad(Data.ShotAngle);
+ wx := trigData.trigShotPos.X;
+ wy := trigData.trigShotPos.Y;
+ pAngle := -DegToRad(trigData.trigShotAngle);
xd := wx + Round(Cos(pAngle) * 32.0);
yd := wy + Round(Sin(pAngle) * 32.0);
TargetUID := 0;
xd := wx + Round(Cos(pAngle) * 32.0);
yd := wy + Round(Sin(pAngle) * 32.0);
TargetUID := 0;
- case Data.ShotTarget of
+ case trigData.trigShotTarget of
TRIGGER_SHOT_TARGET_MON: // monsters
//TODO: accelerate this!
g_Mons_ForEachAlive(monsShotTarget);
TRIGGER_SHOT_TARGET_MON: // monsters
//TODO: accelerate this!
g_Mons_ForEachAlive(monsShotTarget);
end;
else begin
end;
else begin
- if (Data.ShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
- (Data.ShotType <> TRIGGER_SHOT_REV) then
+ if (trigData.trigShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
+ (trigData.trigShotType <> TRIGGER_SHOT_REV) then
TargetUID := ActivateUID;
end;
end;
TargetUID := ActivateUID;
end;
end;
- if (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
- ((Data.ShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
+ if (trigData.trigShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
+ ((trigData.trigShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
begin
Result := True;
begin
Result := True;
- if (Data.ShotIntSight = 0) or
- (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or
+ if (trigData.trigShotIntSight = 0) or
+ (trigData.trigShotTarget = TRIGGER_SHOT_TARGET_NONE) or
(TargetUID = ShotSightTarget) then
MakeShot(Trigger, wx, wy, xd, yd, TargetUID)
else
begin
(TargetUID = ShotSightTarget) then
MakeShot(Trigger, wx, wy, xd, yd, TargetUID)
else
begin
- ShotSightTime := Data.ShotIntSight;
+ ShotSightTime := trigData.trigShotIntSight;
ShotSightTargetN := TargetUID;
ShotSightTargetN := TargetUID;
- if Data.ShotType = TRIGGER_SHOT_BFG then
+ if trigData.trigShotType = TRIGGER_SHOT_BFG then
begin
g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx, wy);
if g_Game_IsNet and g_Game_IsServer then
begin
g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx, wy);
if g_Game_IsNet and g_Game_IsServer then
TRIGGER_EFFECT:
begin
TRIGGER_EFFECT:
begin
- idx := Data.FXCount;
+ idx := trigData.trigFXCount;
while idx > 0 do
begin
while idx > 0 do
begin
- case Data.FXPos of
+ case trigData.trigFXPos of
TRIGGER_EFFECT_POS_CENTER:
begin
wx := X + Width div 2;
TRIGGER_EFFECT_POS_CENTER:
begin
wx := X + Width div 2;
wy := Y + Height div 2;
end;
end;
wy := Y + Height div 2;
end;
end;
- xd := Data.FXVelX;
- yd := Data.FXVelY;
- if Data.FXSpreadL > 0 then xd := xd - Random(Data.FXSpreadL + 1);
- if Data.FXSpreadR > 0 then xd := xd + Random(Data.FXSpreadR + 1);
- if Data.FXSpreadU > 0 then yd := yd - Random(Data.FXSpreadU + 1);
- if Data.FXSpreadD > 0 then yd := yd + Random(Data.FXSpreadD + 1);
+ xd := trigData.trigFXVelX;
+ yd := trigData.trigFXVelY;
+ if trigData.trigFXSpreadL > 0 then xd := xd - Random(trigData.trigFXSpreadL + 1);
+ if trigData.trigFXSpreadR > 0 then xd := xd + Random(trigData.trigFXSpreadR + 1);
+ if trigData.trigFXSpreadU > 0 then yd := yd - Random(trigData.trigFXSpreadU + 1);
+ if trigData.trigFXSpreadD > 0 then yd := yd + Random(trigData.trigFXSpreadD + 1);
tr_MakeEffect(wx, wy, xd, yd,
tr_MakeEffect(wx, wy, xd, yd,
- Data.FXType, Data.FXSubType,
- Data.FXColorR, Data.FXColorG, Data.FXColorB, True, False);
+ trigData.trigFXType, trigData.trigFXSubType,
+ trigData.trigFXColorR, trigData.trigFXColorG, trigData.trigFXColorB, True, False);
Dec(idx);
end;
Dec(idx);
end;
- TimeOut := Data.FXWait;
+ TimeOut := trigData.trigFXWait;
end;
end;
end;
end;
end;
end;
g_Map_SwitchTexture(Trigger.TexturePanelType, Trigger.TexturePanel, IfThen(animonce, 2, 1));
end;
g_Map_SwitchTexture(Trigger.TexturePanelType, Trigger.TexturePanel, IfThen(animonce, 2, 1));
end;
-function g_Triggers_Create(Trigger: TTrigger): DWORD;
+
+function g_Triggers_CreateWithMapIndex (Trigger: TTrigger; arridx, mapidx: Integer): DWORD;
+var
+ triggers: TDynField;
+begin
+ triggers := gCurrentMap['trigger'];
+ if (triggers = nil) then raise Exception.Create('LOAD: map has no triggers');
+ if (mapidx < 0) or (mapidx >= triggers.count) then raise Exception.Create('LOAD: invalid map trigger index');
+ Trigger.trigData := triggers.item[mapidx];
+ if (Trigger.trigData = nil) then raise Exception.Create('LOAD: internal error in trigger loader');
+ Trigger.mapId := Trigger.trigData.id;
+ Trigger.mapIndex := mapidx;
+ if (Trigger.trigData.trigRec <> nil) then
+ begin
+ Trigger.trigData := Trigger.trigData.trigRec.clone();
+ end
+ else
+ begin
+ Trigger.trigData := nil;
+ end;
+ result := g_Triggers_Create(Trigger, arridx);
+end;
+
+
+function g_Triggers_Create(Trigger: TTrigger; forceInternalIndex: Integer=-1): DWORD;
var
find_id: DWORD;
var
find_id: DWORD;
- fn, mapw: String;
+ fn, mapw: AnsiString;
+ f, olen: Integer;
begin
// Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà:
if (Trigger.TriggerType = TRIGGER_EXIT) and
begin
// Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà:
if (Trigger.TriggerType = TRIGGER_EXIT) and
if Trigger.TriggerType = TRIGGER_SECRET then
gSecretsCount := gSecretsCount + 1;
if Trigger.TriggerType = TRIGGER_SECRET then
gSecretsCount := gSecretsCount + 1;
- find_id := FindTrigger();
+ if (forceInternalIndex < 0) then
+ begin
+ find_id := FindTrigger();
+ end
+ else
+ begin
+ olen := Length(gTriggers);
+ if (forceInternalIndex >= olen) then
+ begin
+ SetLength(gTriggers, forceInternalIndex+1);
+ for f := olen to High(gTriggers) do gTriggers[f].TriggerType := TRIGGER_NONE;
+ end;
+ find_id := DWORD(forceInternalIndex);
+ end;
gTriggers[find_id] := Trigger;
gTriggers[find_id] := Trigger;
+ //e_LogWritefln('created trigger with map index %s, findid=%s (%s)', [Trigger.mapIndex, find_id, Trigger.mapId]);
+
+ {
+ writeln('trigger #', find_id, ': pos=(', Trigger.x, ',', Trigger.y, ')-(', Trigger.width, 'x', Trigger.height, ')',
+ '; TexturePanel=', Trigger.TexturePanel,
+ '; TexturePanelType=', Trigger.TexturePanelType,
+ '; ShotPanelType=', Trigger.ShotPanelType,
+ '; TriggerType=', Trigger.TriggerType,
+ '; ActivateType=', Trigger.ActivateType,
+ '; Keys=', Trigger.Keys,
+ '; trigPanelId=', Trigger.trigPanelId,
+ '; trigShotPanelId=', Trigger.trigShotPanelId
+ );
+ }
+
with gTriggers[find_id] do
begin
ID := find_id;
with gTriggers[find_id] do
begin
ID := find_id;
// Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê":
if (Trigger.TriggerType = TRIGGER_SOUND) and
// Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê":
if (Trigger.TriggerType = TRIGGER_SOUND) and
- (Trigger.Data.SoundName <> '') then
+ (Trigger.trigData.trigSoundName <> '') then
begin
// Åùå íåò òàêîãî çâóêà:
begin
// Åùå íåò òàêîãî çâóêà:
- if not g_Sound_Exists(Trigger.Data.SoundName) then
+ if not g_Sound_Exists(Trigger.trigData.trigSoundName) then
begin
begin
- fn := g_ExtractWadName(Trigger.Data.SoundName);
+ fn := g_ExtractWadName(Trigger.trigData.trigSoundName);
if fn = '' then
begin // Çâóê â ôàéëå ñ êàðòîé
mapw := g_ExtractWadName(gMapInfo.Map);
if fn = '' then
begin // Çâóê â ôàéëå ñ êàðòîé
mapw := g_ExtractWadName(gMapInfo.Map);
- fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.SoundName);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.trigData.trigSoundName);
end
else // Çâóê â îòäåëüíîì ôàéëå
end
else // Çâóê â îòäåëüíîì ôàéëå
- fn := GameDir + '/wads/' + Trigger.Data.SoundName;
+ fn := GameDir + '/wads/' + Trigger.trigData.trigSoundName;
- if not g_Sound_CreateWADEx(Trigger.Data.SoundName, fn) then
- g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.Data.SoundName]));
+ if not g_Sound_CreateWADEx(Trigger.trigData.trigSoundName, fn) then
+ g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.trigData.trigSoundName]));
end;
// Ñîçäàåì îáúåêò çâóêà:
with gTriggers[find_id] do
begin
Sound := TPlayableSound.Create();
end;
// Ñîçäàåì îáúåêò çâóêà:
with gTriggers[find_id] do
begin
Sound := TPlayableSound.Create();
- if not Sound.SetByName(Trigger.Data.SoundName) then
+ if not Sound.SetByName(Trigger.trigData.trigSoundName) then
begin
Sound.Free();
Sound := nil;
begin
Sound.Free();
Sound := nil;
// Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà":
if (Trigger.TriggerType = TRIGGER_MUSIC) and
// Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà":
if (Trigger.TriggerType = TRIGGER_MUSIC) and
- (Trigger.Data.MusicName <> '') then
+ (Trigger.trigData.trigMusicName <> '') then
begin
// Åùå íåò òàêîé ìóçûêè:
begin
// Åùå íåò òàêîé ìóçûêè:
- if not g_Sound_Exists(Trigger.Data.MusicName) then
+ if not g_Sound_Exists(Trigger.trigData.trigMusicName) then
begin
begin
- fn := g_ExtractWadName(Trigger.Data.MusicName);
+ fn := g_ExtractWadName(Trigger.trigData.trigMusicName);
if fn = '' then
begin // Ìóçûêà â ôàéëå ñ êàðòîé
mapw := g_ExtractWadName(gMapInfo.Map);
if fn = '' then
begin // Ìóçûêà â ôàéëå ñ êàðòîé
mapw := g_ExtractWadName(gMapInfo.Map);
- fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.MusicName);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.trigData.trigMusicName);
end
else // Ìóçûêà â ôàéëå ñ êàðòîé
end
else // Ìóçûêà â ôàéëå ñ êàðòîé
- fn := GameDir+'/wads/'+Trigger.Data.MusicName;
+ fn := GameDir+'/wads/'+Trigger.trigData.trigMusicName;
- if not g_Sound_CreateWADEx(Trigger.Data.MusicName, fn, True) then
- g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.Data.MusicName]));
+ if not g_Sound_CreateWADEx(Trigger.trigData.trigMusicName, fn, True) then
+ g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.trigData.trigMusicName]));
end;
end;
end;
end;
ShotSightTimeout := 0;
ShotSightTarget := 0;
ShotSightTargetN := 0;
ShotSightTimeout := 0;
ShotSightTarget := 0;
ShotSightTargetN := 0;
- ShotAmmoCount := Trigger.Data.ShotAmmo;
+ ShotAmmoCount := Trigger.trigData.trigShotAmmo;
ShotReloadTime := 0;
end;
Result := find_id;
end;
ShotReloadTime := 0;
end;
Result := find_id;
end;
+
+// sorry; grid doesn't support recursive queries, so we have to do this
+type
+ TSimpleMonsterList = specialize TSimpleList<TMonster>;
+
+var
+ tgMonsList: TSimpleMonsterList = nil;
+
procedure g_Triggers_Update();
var
a, b, i: Integer;
Affected: array of Integer;
procedure g_Triggers_Update();
var
a, b, i: Integer;
Affected: array of Integer;
- {function monsNear (mon: TMonster): Boolean;
- begin
- result := false; // don't stop
- if mon.Collide(gTriggers[a].X, gTriggers[a].Y, gTriggers[a].Width, gTriggers[a].Height) then
- begin
- gTriggers[a].ActivateUID := mon.UID;
- ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
- end;
- end;}
-
function monsNear (mon: TMonster): Boolean;
begin
result := false; // don't stop
function monsNear (mon: TMonster): Boolean;
begin
result := false; // don't stop
+ {
gTriggers[a].ActivateUID := mon.UID;
ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
gTriggers[a].ActivateUID := mon.UID;
ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
+ }
+ tgMonsList.append(mon);
end;
end;
+var
+ mon: TMonster;
begin
begin
+ if (tgMonsList = nil) then tgMonsList := TSimpleMonsterList.Create();
+
if gTriggers = nil then
Exit;
SetLength(Affected, 0);
if gTriggers = nil then
Exit;
SetLength(Affected, 0);
else
Continue;
// Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
else
Continue;
// Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
- if (Data.DamageInterval = 0) and (Activators[b].TimeOut < 65530) then
+ if (trigData.trigDamageInterval = 0) and (Activators[b].TimeOut < 65530) then
Activators[b].TimeOut := 0;
end;
Activators[b].TimeOut := 0;
end;
if SpawnCooldown = 0 then
begin
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà:
if SpawnCooldown = 0 then
begin
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà:
- if (TriggerType = TRIGGER_SPAWNMONSTER) and (Data.MonDelay > 0) then
+ if (TriggerType = TRIGGER_SPAWNMONSTER) and (trigData.trigMonDelay > 0) then
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
end;
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò:
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
end;
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò:
- if (TriggerType = TRIGGER_SPAWNITEM) and (Data.ItemDelay > 0) then
+ if (TriggerType = TRIGGER_SPAWNITEM) and (trigData.trigItemDelay > 0) then
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
begin
Dec(ShotPanelTime);
if ShotPanelTime = 0 then
begin
Dec(ShotPanelTime);
if ShotPanelTime = 0 then
- g_Map_SwitchTexture(ShotPanelType, Data.ShotPanelID);
+ g_Map_SwitchTexture(ShotPanelType, trigShotPanelID);
end;
if ShotSightTime > 0 then
begin
end;
if ShotSightTime > 0 then
begin
begin
Dec(ShotReloadTime);
if ShotReloadTime = 0 then
begin
Dec(ShotReloadTime);
if ShotReloadTime = 0 then
- ShotAmmoCount := Data.ShotAmmo;
+ ShotAmmoCount := trigData.trigShotAmmo;
end;
end;
end;
end;
if Enabled and (TriggerType = TRIGGER_SOUND) and (Sound <> nil) then
if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then
begin
if Enabled and (TriggerType = TRIGGER_SOUND) and (Sound <> nil) then
if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then
begin
- if Data.PlayCount > 0 then // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
+ if trigData.trigPlayCount > 0 then // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
SoundPlayCount := SoundPlayCount - 1;
SoundPlayCount := SoundPlayCount - 1;
- if Data.Local then
- Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), Data.Volume/255.0)
+ if trigData.trigLocal then
+ Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), trigData.trigVolume/255.0)
else
else
- Sound.PlayPanVolume((Data.Pan-127.0)/128.0, Data.Volume/255.0);
+ Sound.PlayPanVolume((trigData.trigPan-127.0)/128.0, trigData.trigVolume/255.0);
if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then
MH_SEND_TriggerSound(gTriggers[a]);
end;
// Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü:
if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then
MH_SEND_TriggerSound(gTriggers[a]);
end;
// Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü:
- if (TriggerType = TRIGGER_TRAP) and (DoorTime = 0) and (Data.PanelID <> -1) then
+ if (TriggerType = TRIGGER_TRAP) and (DoorTime = 0) and (trigPanelID <> -1) then
begin
begin
- tr_OpenDoor(Data.PanelID, Data.NoSound, Data.d2d_doors);
+ tr_OpenDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors);
DoorTime := -1;
end;
// Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü:
DoorTime := -1;
end;
// Òðèããåð "Äâåðü 5 ñåê" - ïîðà çàêðûâàòü:
- if (TriggerType = TRIGGER_DOOR5) and (DoorTime = 0) and (Data.PanelID <> -1) then
+ if (TriggerType = TRIGGER_DOOR5) and (DoorTime = 0) and (trigPanelID <> -1) then
begin
// Óæå çàêðûòà:
begin
// Óæå çàêðûòà:
- if gWalls[Data.PanelID].Enabled then
+ if gWalls[trigPanelID].Enabled then
DoorTime := -1
else // Ïîêà îòêðûòà - çàêðûâàåì
DoorTime := -1
else // Ïîêà îòêðûòà - çàêðûâàåì
- if tr_CloseDoor(Data.PanelID, Data.NoSound, Data.d2d_doors) then
+ if tr_CloseDoor(trigPanelID, trigData.trigNoSound, trigData.trigd2d_doors) then
DoorTime := -1;
end;
// Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
if (TriggerType in [TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF]) and
DoorTime := -1;
end;
// Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
if (TriggerType in [TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF]) and
- (PressTime = 0) and (PressCount >= Data.Count) then
+ (PressTime = 0) and (PressCount >= trigData.trigCount) then
begin
// Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
PressTime := -1;
// Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
begin
// Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
PressTime := -1;
// Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
- if Data.Count > 0 then
- PressCount := PressCount - Data.Count
+ if trigData.trigCount > 0 then
+ PressCount := PressCount - trigData.trigCount
else
PressCount := 0;
// Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
for b := 0 to High(gTriggers) do
else
PressCount := 0;
// Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
for b := 0 to High(gTriggers) do
- if g_Collide(Data.tX, Data.tY, Data.tWidth, Data.tHeight, gTriggers[b].X, gTriggers[b].Y,
+ if g_Collide(trigData.trigtX, trigData.trigtY, trigData.trigtWidth, trigData.trigtHeight, gTriggers[b].X, gTriggers[b].Y,
gTriggers[b].Width, gTriggers[b].Height) and
gTriggers[b].Width, gTriggers[b].Height) and
- ((b <> a) or (Data.Wait > 0)) then
+ ((b <> a) or (trigData.trigWait > 0)) then
begin // Can be self-activated, if there is Data.Wait
begin // Can be self-activated, if there is Data.Wait
- if (not Data.ExtRandom) or gTriggers[b].Enabled then
+ if (not trigData.trigExtRandom) or gTriggers[b].Enabled then
begin
SetLength(Affected, Length(Affected) + 1);
Affected[High(Affected)] := b;
end;
end;
// Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
begin
SetLength(Affected, Length(Affected) + 1);
Affected[High(Affected)] := b;
end;
end;
// Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
- if (TriggerType = TRIGGER_PRESS) and Data.ExtRandom then
+ if (TriggerType = TRIGGER_PRESS) and trigData.trigExtRandom then
begin
if (Length(Affected) > 0) then
begin
begin
if (Length(Affected) > 0) then
begin
begin
//g_Mons_ForEach(monsNear);
//Alive?!
begin
//g_Mons_ForEach(monsNear);
//Alive?!
+ tgMonsList.reset();
g_Mons_ForEachAt(gTriggers[a].X, gTriggers[a].Y, gTriggers[a].Width, gTriggers[a].Height, monsNear);
g_Mons_ForEachAt(gTriggers[a].X, gTriggers[a].Y, gTriggers[a].Width, gTriggers[a].Height, monsNear);
+ for mon in tgMonsList do
+ begin
+ gTriggers[a].ActivateUID := mon.UID;
+ ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
+ end;
+ tgMonsList.reset(); // just in case
end;
// "Ìîíñòðîâ íåò"
end;
// "Ìîíñòðîâ íåò"
(TriggerType = TRIGGER_DOOR5) or
(TriggerType = TRIGGER_DOOR) then
begin
(TriggerType = TRIGGER_DOOR5) or
(TriggerType = TRIGGER_DOOR) then
begin
- tr_OpenDoor(Data.PanelID, True, Data.d2d_doors);
+ tr_OpenDoor(trigPanelID, True, trigData.trigd2d_doors);
if TriggerType = TRIGGER_DOOR5 then DoorTime := 180;
b := True;
end;
if TriggerType = TRIGGER_DOOR5 then DoorTime := 180;
b := True;
end;
var
a: Integer;
begin
var
a: Integer;
begin
- if gTriggers <> nil then
- for a := 0 to High(gTriggers) do
+ for a := 0 to High(gTriggers) do
+ begin
+ if (gTriggers[a].TriggerType = TRIGGER_SOUND) then
begin
begin
- if gTriggers[a].TriggerType = TRIGGER_SOUND then
+ if g_Sound_Exists(gTriggers[a].trigData.trigSoundName) then
begin
begin
- if g_Sound_Exists(gTriggers[a].Data.SoundName) then
- g_Sound_Delete(gTriggers[a].Data.SoundName);
-
- gTriggers[a].Sound.Free();
+ g_Sound_Delete(gTriggers[a].trigData.trigSoundName);
end;
end;
- if gTriggers[a].Activators <> nil then
- SetLength(gTriggers[a].Activators, 0);
+ gTriggers[a].Sound.Free();
+ end;
+ if (gTriggers[a].Activators <> nil) then
+ begin
+ SetLength(gTriggers[a].Activators, 0);
end;
end;
+ gTriggers[a].trigData.Free();
+ end;
gTriggers := nil;
gSecretsCount := 0;
gTriggers := nil;
gSecretsCount := 0;
dw: DWORD;
sg: Single;
b: Boolean;
dw: DWORD;
sg: Single;
b: Boolean;
- p: Pointer;
begin
begin
-// Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ:
- count := 0;
- if gTriggers <> nil then
- for i := 0 to High(gTriggers) do
- count := count + 1;
+ // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ
+ count := Length(gTriggers);
Mem := TBinMemoryWriter.Create((count+1) * 200);
Mem := TBinMemoryWriter.Create((count+1) * 200);
-// Êîëè÷åñòâî òðèããåðîâ:
+ // Êîëè÷åñòâî òðèããåðîâ:
Mem.WriteInt(count);
Mem.WriteInt(count);
- if count = 0 then
- Exit;
+ //e_LogWritefln('saving %s triggers (count=%s)', [Length(gTriggers), count]);
+
+ if count = 0 then exit;
for i := 0 to High(gTriggers) do
begin
// Ñèãíàòóðà òðèããåðà:
for i := 0 to High(gTriggers) do
begin
// Ñèãíàòóðà òðèããåðà:
- dw := TRIGGER_SIGNATURE; // 'TRGR'
+ dw := TRIGGER_SIGNATURE; // 'TRGX'
Mem.WriteDWORD(dw);
// Òèï òðèããåðà:
Mem.WriteByte(gTriggers[i].TriggerType);
Mem.WriteDWORD(dw);
// Òèï òðèããåðà:
Mem.WriteByte(gTriggers[i].TriggerType);
- // Ñïåöèàëüíûå äàííûå òðèããåðà:
- p := @gTriggers[i].Data;
- Mem.WriteMemory(p, SizeOf(TTriggerData));
+ if (gTriggers[i].TriggerType = TRIGGER_NONE) then continue; // empty one
+ // Ñïåöèàëüíûå äàííûå òðèããåðà: äà â æîïó, ïîòîì èç êàðòû îïÿòü âûòàùèì; ñîõðàíèì òîëüêî èíäåêñ
+ //e_LogWritefln('=== trigger #%s saved ===', [gTriggers[i].mapIndex]);
+ Mem.WriteInt(gTriggers[i].mapIndex);
+ //p := @gTriggers[i].Data;
+ //Mem.WriteMemory(p, SizeOf(TTriggerData));
// Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
Mem.WriteInt(gTriggers[i].X);
Mem.WriteInt(gTriggers[i].Y);
// Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
Mem.WriteInt(gTriggers[i].X);
Mem.WriteInt(gTriggers[i].Y);
Mem.WriteInt(gTriggers[i].TexturePanel);
// Òèï ýòîé ïàíåëè:
Mem.WriteWord(gTriggers[i].TexturePanelType);
Mem.WriteInt(gTriggers[i].TexturePanel);
// Òèï ýòîé ïàíåëè:
Mem.WriteWord(gTriggers[i].TexturePanelType);
+ // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
+ Mem.WriteInt(gTriggers[i].trigPanelId);
// Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
Mem.WriteWord(gTriggers[i].TimeOut);
// UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
// Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
Mem.WriteWord(gTriggers[i].TimeOut);
// UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
dw: DWORD;
vol, pan: Single;
b: Boolean;
dw: DWORD;
vol, pan: Single;
b: Boolean;
- p: Pointer;
+ //p: Pointer;
Trig: TTrigger;
Trig: TTrigger;
+ mapIndex: Integer;
+ //tw: TStrTextWriter;
begin
if Mem = nil then
Exit;
begin
if Mem = nil then
Exit;
// Êîëè÷åñòâî òðèããåðîâ:
Mem.ReadInt(count);
// Êîëè÷åñòâî òðèããåðîâ:
Mem.ReadInt(count);
- if count = 0 then
- Exit;
+ if (count = 0) then exit;
for a := 0 to count-1 do
begin
// Ñèãíàòóðà òðèããåðà:
Mem.ReadDWORD(dw);
for a := 0 to count-1 do
begin
// Ñèãíàòóðà òðèããåðà:
Mem.ReadDWORD(dw);
- if dw <> TRIGGER_SIGNATURE then // 'TRGR'
+ if (dw <> TRIGGER_SIGNATURE) then // 'TRGX'
begin
raise EBinSizeError.Create('g_Triggers_LoadState: Wrong Trigger Signature');
end;
// Òèï òðèããåðà:
Mem.ReadByte(Trig.TriggerType);
begin
raise EBinSizeError.Create('g_Triggers_LoadState: Wrong Trigger Signature');
end;
// Òèï òðèããåðà:
Mem.ReadByte(Trig.TriggerType);
- // Ñïåöèàëüíûå äàííûå òðèããåðà:
+ // Ñïåöèàëüíûå äàííûå òðèããåðà: èíäåêñ â gCurrentMap.field['triggers']
+ if (Trig.TriggerType = TRIGGER_NONE) then continue; // empty one
+ Mem.ReadInt(mapIndex);
+ //!!!FIXME!!!
+ {
Mem.ReadMemory(p, dw);
if dw <> SizeOf(TTriggerData) then
begin
raise EBinSizeError.Create('g_Triggers_LoadState: Wrong TriggerData Size');
end;
Trig.Data := TTriggerData(p^);
Mem.ReadMemory(p, dw);
if dw <> SizeOf(TTriggerData) then
begin
raise EBinSizeError.Create('g_Triggers_LoadState: Wrong TriggerData Size');
end;
Trig.Data := TTriggerData(p^);
+ }
// Ñîçäàåì òðèããåð:
// Ñîçäàåì òðèããåð:
- i := g_Triggers_Create(Trig);
+ i := g_Triggers_CreateWithMapIndex(Trig, a, mapIndex);
+ {
+ if (gTriggers[i].trigData <> nil) then
+ begin
+ tw := TStrTextWriter.Create();
+ try
+ gTriggers[i].trigData.writeTo(tw);
+ e_LogWritefln('=== trigger #%s loaded ==='#10'%s'#10'---', [mapIndex, tw.str]);
+ finally
+ tw.Free();
+ end;
+ end;
+ }
// Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
Mem.ReadInt(gTriggers[i].X);
Mem.ReadInt(gTriggers[i].Y);
// Êîîðäèíàòû ëåâîãî âåðõíåãî óãëà:
Mem.ReadInt(gTriggers[i].X);
Mem.ReadInt(gTriggers[i].Y);
Mem.ReadInt(gTriggers[i].TexturePanel);
// Òèï ýòîé ïàíåëè:
Mem.ReadWord(gTriggers[i].TexturePanelType);
Mem.ReadInt(gTriggers[i].TexturePanel);
// Òèï ýòîé ïàíåëè:
Mem.ReadWord(gTriggers[i].TexturePanelType);
+ // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
+ Mem.ReadInt(gTriggers[i].trigPanelId);
// Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
Mem.ReadWord(gTriggers[i].TimeOut);
// UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
// Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
Mem.ReadWord(gTriggers[i].TimeOut);
// UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð: