index 53b023b995235d07dd989df3f91d4d4b311ef25d..fab30ec3324c2627cc4140c93b72a5cabad3b180 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
mapIndex: Integer; // index in fields['trigger'], used in save/load
trigPanelGUID: Integer;
- //TrigData: TTriggerData;
- trigData: TDynRecord; // triggerdata; owned by trigger
+ trigDataRec: TDynRecord; // triggerdata; owned by trigger (cloned)
- public
- function trigCenter (): TDFPoint; inline;
+ {$INCLUDE ../shared/mapdef_tgc_def.inc}
public
- property trigShotPanelGUID: Integer read trigPanelGUID write trigPanelGUID;
+ function trigCenter (): TDFPoint; inline;
end;
function g_Triggers_Create(Trigger: TTrigger; forceInternalIndex: Integer=-1): DWORD;
TRIGGER_SIGNATURE = $58475254; // 'TRGX'
TRAP_DAMAGE = 1000;
+{$INCLUDE ../shared/mapdef_tgc_impl.inc}
function TTrigger.trigCenter (): TDFPoint; inline;
begin
begin
for a := 0 to High(gPlayers) do
begin
- if (gPlayers[a] <> nil) and gPlayers[a].Live and gPlayers[a].Collide(X, Y, Width, Height) then
+ if (gPlayers[a] <> nil) and gPlayers[a].alive and gPlayers[a].Collide(X, Y, Width, Height) then
begin
gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
end;
begin
for a := 0 to High(gPlayers) do
begin
- if (gPlayers[a] <> nil) and gPlayers[a].Live and gPlayers[a].Collide(X, Y, Width, Height) then
+ if (gPlayers[a] <> nil) and gPlayers[a].alive and gPlayers[a].Collide(X, Y, Width, Height) then
begin
gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
end;
(*
if gMonsters <> nil then
for a := 0 to High(gMonsters) do
- if (gMonsters[a] <> nil) and gMonsters[a].Live and
+ if (gMonsters[a] <> nil) and gMonsters[a].alive and
g_Obj_Collide(X, Y, Width, Height, @gMonsters[a].Obj) then
gMonsters[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
*)
@@ -687,28 +686,28 @@ procedure MakeShot (var Trigger: TTrigger; wx, wy, dx, dy: Integer; TargetUID: W
begin
with Trigger do
begin
- if (trigData.trigShotAmmo = 0) or ((trigData.trigShotAmmo > 0) and (ShotAmmoCount > 0)) then
+ if (tgcAmmo = 0) or ((tgcAmmo > 0) and (ShotAmmoCount > 0)) then
begin
- if (trigShotPanelGUID <> -1) and (ShotPanelTime = 0) then
+ if (trigPanelGUID <> -1) and (ShotPanelTime = 0) then
begin
- g_Map_SwitchTextureGUID(ShotPanelType, trigShotPanelGUID);
+ g_Map_SwitchTextureGUID(ShotPanelType, trigPanelGUID);
ShotPanelTime := 4; // òèêîâ íà âñïûøêó âûñòðåëà
end;
- if (trigData.trigShotIntSight > 0) then ShotSightTimeout := 180; // ~= 5 ñåêóíä
+ if (tgcSight > 0) then ShotSightTimeout := 180; // ~= 5 ñåêóíä
if (ShotAmmoCount > 0) then Dec(ShotAmmoCount);
- dx += Random(trigData.trigShotAccuracy)-Random(trigData.trigShotAccuracy);
- dy += Random(trigData.trigShotAccuracy)-Random(trigData.trigShotAccuracy);
+ dx += Random(tgcAccuracy)-Random(tgcAccuracy);
+ dy += Random(tgcAccuracy)-Random(tgcAccuracy);
- tr_SpawnShot(trigData.trigShotType, wx, wy, dx, dy, trigData.trigShotSound, TargetUID);
+ tr_SpawnShot(tgcShotType, wx, wy, dx, dy, not tgcQuiet, TargetUID);
end
else
begin
- if (trigData.trigShotIntReload > 0) and (ShotReloadTime = 0) then
+ if (tgcReload > 0) and (ShotReloadTime = 0) then
begin
- ShotReloadTime := trigData.trigShotIntReload; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
+ ShotReloadTime := tgcReload; // òèêîâ íà ïåðåçàðÿäêó ïóøêè
end;
end;
end;
if (ActivateUID < 0) or (ActivateUID > $FFFF) then Exit;
msg := b_Text_Format(MText);
case MSendTo of
- 0: // activator
+ TRIGGER_MESSAGE_DEST_ME: // activator
begin
if g_GetUIDType(ActivateUID) = UID_PLAYER then
begin
if g_Game_IsWatchedPlayer(ActivateUID) then
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
end
else
begin
p := g_Player_Get(ActivateUID);
if g_Game_IsNet and (p.FClientID >= 0) then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, p.FClientID)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, p.FClientID);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, p.FClientID)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, p.FClientID);
end;
end;
end;
end;
- 1: // activator's team
+ TRIGGER_MESSAGE_DEST_MY_TEAM: // activator's team
begin
if g_GetUIDType(ActivateUID) = UID_PLAYER then
begin
p := g_Player_Get(ActivateUID);
if g_Game_IsWatchedTeam(p.Team) then
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
end;
if g_Game_IsNet then
begin
if (gPlayers[i].Team = p.Team) and (gPlayers[i].FClientID >= 0) then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
end;
end;
end;
end;
end;
- 2: // activator's enemy team
+ TRIGGER_MESSAGE_DEST_ENEMY_TEAM: // activator's enemy team
begin
if g_GetUIDType(ActivateUID) = UID_PLAYER then
begin
p := g_Player_Get(ActivateUID);
if g_Game_IsWatchedTeam(p.Team) then
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
end;
if g_Game_IsNet then
begin
if (gPlayers[i].Team <> p.Team) and (gPlayers[i].FClientID >= 0) then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
end;
end;
end;
end;
end;
- 3: // red team
+ TRIGGER_MESSAGE_DEST_RED_TEAM: // red team
begin
if g_Game_IsWatchedTeam(TEAM_RED) then
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
end;
if g_Game_IsNet then
begin
if (gPlayers[i].Team = TEAM_RED) and (gPlayers[i].FClientID >= 0) then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
end;
end;
end;
end;
- 4: // blue team
+ TRIGGER_MESSAGE_DEST_BLUE_TEAM: // blue team
begin
if g_Game_IsWatchedTeam(TEAM_BLUE) then
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
end;
if g_Game_IsNet then
begin
if (gPlayers[i].Team = TEAM_BLUE) and (gPlayers[i].FClientID >= 0) then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM, gPlayers[i].FClientID)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg, gPlayers[i].FClientID);
end;
end;
end;
end;
- 5: // everyone
+ TRIGGER_MESSAGE_DEST_EVERYONE: // everyone
begin
- if MKind = 0 then g_Console_Add(msg, True)
- else if MKind = 1 then g_Game_Message(msg, MTime);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then g_Console_Add(msg, True)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then g_Game_Message(msg, MTime);
if g_Game_IsNet then
begin
- if MKind = 0 then MH_SEND_Chat(msg, NET_CHAT_SYSTEM)
- else if MKind = 1 then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg);
+ if MKind = TRIGGER_MESSAGE_KIND_CHAT then MH_SEND_Chat(msg, NET_CHAT_SYSTEM)
+ else if MKind = TRIGGER_MESSAGE_KIND_GAME then MH_SEND_GameEvent(NET_EV_BIGTEXT, MTime, msg);
end;
end;
end;
with Trigger do
begin
if TriggerType <> TRIGGER_SHOT then Exit;
- result := (trigData.trigShotAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
+ result := (tgcAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
or g_Obj_Collide(X, Y, Width, Height, Obj);
- if result and (trigData.trigShotAim and TRIGGER_SHOT_AIM_TRACE > 0) then
+ if result and (tgcAim and TRIGGER_SHOT_AIM_TRACE > 0) then
begin
- result := g_TraceVector(trigData.trigShotPos.X, trigData.trigShotPos.Y,
+ result := g_TraceVector(tgcTX, tgcTY,
Obj^.X + Obj^.Rect.X + (Obj^.Rect.Width div 2),
Obj^.Y + Obj^.Rect.Y + (Obj^.Rect.Height div 2));
end;
function monsShotTarget (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.alive and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
function monsShotTargetMonPlr (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.alive and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
function monShotTargetPlrMon (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.alive and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
g_Sound_PlayEx('SOUND_GAME_SWITCH0');
if g_Game_IsNet then MH_SEND_Sound(X, Y, 'SOUND_GAME_SWITCH0');
gExitByTrigger := True;
- g_Game_ExitLevel(trigData.trigMapName);
+ g_Game_ExitLevel(tgcMap);
TimeOut := 18;
Result := True;
TRIGGER_TELEPORT:
begin
Result := tr_Teleport(ActivateUID,
- trigData.trigTargetPoint.X, trigData.trigTargetPoint.Y,
- trigData.trigTlpDir, trigData.trigsilent_teleport,
- trigData.trigd2d_teleport);
+ tgcTarget.X, tgcTarget.Y,
+ tgcDirection, tgcSilent,
+ tgcD2d);
TimeOut := 0;
end;
TRIGGER_OPENDOOR:
begin
- Result := tr_OpenDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ Result := tr_OpenDoor(trigPanelGUID, tgcSilent, tgcD2d);
TimeOut := 0;
end;
TRIGGER_CLOSEDOOR:
begin
- Result := tr_CloseDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ Result := tr_CloseDoor(trigPanelGUID, tgcSilent, tgcD2d);
TimeOut := 0;
end;
begin
if gWalls[{trigPanelID}pan.arrIdx].Enabled then
begin
- result := tr_OpenDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ result := tr_OpenDoor(trigPanelGUID, tgcSilent, tgcD2d);
if (TriggerType = TRIGGER_DOOR5) then DoorTime := 180;
end
else
begin
- result := tr_CloseDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ result := tr_CloseDoor(trigPanelGUID, tgcSilent, tgcD2d);
end;
if result then TimeOut := 18;
TRIGGER_CLOSETRAP, TRIGGER_TRAP:
begin
- tr_CloseTrap(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ tr_CloseTrap(trigPanelGUID, tgcSilent, tgcD2d);
if TriggerType = TRIGGER_TRAP then
begin
TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF:
begin
PressCount += 1;
- if PressTime = -1 then PressTime := trigData.trigWait;
+ if PressTime = -1 then PressTime := tgcWait;
if coolDown then TimeOut := 18 else TimeOut := 0;
Result := True;
end;
TRIGGER_LIFTUP:
begin
- Result := tr_SetLift(trigPanelGUID, 0, trigData.trigNoSound, trigData.trigd2d_doors);
+ Result := tr_SetLift(trigPanelGUID, 0, tgcSilent, tgcD2d);
TimeOut := 0;
- if (not trigData.trigNoSound) and Result then begin
+ if (not tgcSilent) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_LIFTDOWN:
begin
- Result := tr_SetLift(trigPanelGUID, 1, trigData.trigNoSound, trigData.trigd2d_doors);
+ Result := tr_SetLift(trigPanelGUID, 1, tgcSilent, tgcD2d);
TimeOut := 0;
- if (not trigData.trigNoSound) and Result then begin
+ if (not tgcSilent) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_LIFT:
begin
- Result := tr_SetLift(trigPanelGUID, 3, trigData.trigNoSound, trigData.trigd2d_doors);
+ Result := tr_SetLift(trigPanelGUID, 3, tgcSilent, tgcD2d);
if Result then
begin
TimeOut := 18;
- if (not trigData.trigNoSound) and Result then begin
+ if (not tgcSilent) and Result then begin
g_Sound_PlayExAt('SOUND_GAME_SWITCH0',
X + (Width div 2),
Y + (Height div 2));
TRIGGER_TEXTURE:
begin
- if trigData.trigActivateOnce then
+ if tgcActivateOnce then
begin
Enabled := False;
TriggerType := TRIGGER_NONE;
else
TimeOut := 0;
- animonce := trigData.trigAnimOnce;
+ animonce := tgcAnimateOnce;
Result := True;
end;
begin
if Sound <> nil then
begin
- if trigData.trigSoundSwitch and Sound.IsPlaying() then
+ if tgcSoundSwitch and Sound.IsPlaying() then
begin // Íóæíî âûêëþ÷èòü, åñëè èãðàë
Sound.Stop();
SoundPlayCount := 0;
Result := True;
end
else // (not Data.SoundSwitch) or (not Sound.IsPlaying())
- if (trigData.trigPlayCount > 0) or (not Sound.IsPlaying()) then
+ if (tgcPlayCount > 0) or (not Sound.IsPlaying()) then
begin
- if trigData.trigPlayCount > 0 then
- SoundPlayCount := trigData.trigPlayCount
+ if tgcPlayCount > 0 then
+ SoundPlayCount := tgcPlayCount
else // 0 - èãðàåì áåñêîíå÷íî
SoundPlayCount := 1;
Result := True;
end;
TRIGGER_SPAWNMONSTER:
- if (trigData.trigMonType in [MONSTER_DEMON..MONSTER_MAN]) then
+ if (tgcSpawnMonsType in [MONSTER_DEMON..MONSTER_MAN]) then
begin
Result := False;
- if (trigData.trigMonDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
+ if (tgcDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
Result := True;
end;
- if ((trigData.trigMonDelay = 0) and (actType <> ACTIVATE_CUSTOM))
- or ((trigData.trigMonDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
- for k := 1 to trigData.trigMonCount do
+ if ((tgcDelay = 0) and (actType <> ACTIVATE_CUSTOM))
+ or ((tgcDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
+ for k := 1 to tgcMonsCount do
begin
- if (actType = ACTIVATE_CUSTOM) and (trigData.trigMonDelay > 0) then
- SpawnCooldown := trigData.trigMonDelay;
- if (trigData.trigMonMax > 0) and (SpawnedCount >= trigData.trigMonMax) then
+ if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then
+ SpawnCooldown := tgcDelay;
+ if (tgcMax > 0) and (SpawnedCount >= tgcMax) then
Break;
- mon := g_Monsters_Create(trigData.trigMonType,
- trigData.trigMonPos.X, trigData.trigMonPos.Y,
- TDirection(trigData.trigMonDir), True);
+ mon := g_Monsters_Create(tgcSpawnMonsType,
+ tgcTX, tgcTY,
+ TDirection(tgcDirection), True);
Result := True;
// Çäîðîâüå:
- if (trigData.trigMonHealth > 0) then
- mon.SetHealth(trigData.trigMonHealth);
+ if (tgcHealth > 0) then
+ mon.SetHealth(tgcHealth);
// Óñòàíàâëèâàåì ïîâåäåíèå:
- mon.MonsterBehaviour := trigData.trigMonBehav;
+ mon.MonsterBehaviour := tgcBehaviour;
mon.FNoRespawn := True;
if g_Game_IsNet then
MH_SEND_MonsterSpawn(mon.UID);
// Èäåì èñêàòü öåëü, åñëè íàäî:
- if trigData.trigMonActive then
+ if tgcActive then
mon.WakeUp();
- if trigData.trigMonType <> MONSTER_BARREL then Inc(gTotalMonsters);
+ if tgcSpawnMonsType <> MONSTER_BARREL then Inc(gTotalMonsters);
if g_Game_IsNet then
begin
gMonstersSpawned[High(gMonstersSpawned)] := mon.UID;
end;
- if trigData.trigMonMax > 0 then
+ if tgcMax > 0 then
begin
mon.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
- case trigData.trigMonEffect of
+ case tgcEffect of
EFFECT_TELEPORT: begin
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
- g_Sound_PlayExAt('SOUND_GAME_TELEPORT', trigData.trigMonPos.X, trigData.trigMonPos.Y);
+ g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
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);
- g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', trigData.trigMonPos.X, trigData.trigMonPos.Y);
+ g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
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);
- g_Sound_PlayExAt('SOUND_FIRE', trigData.trigMonPos.X, trigData.trigMonPos.Y);
+ g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
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:
- if (trigData.trigItemType in [ITEM_MEDKIT_SMALL..ITEM_MAX]) then
+ if (tgcSpawnItemType in [ITEM_MEDKIT_SMALL..ITEM_MAX]) then
begin
Result := False;
- if (trigData.trigItemDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
+ if (tgcDelay > 0) and (actType <> ACTIVATE_CUSTOM) then
begin
AutoSpawn := not AutoSpawn;
SpawnCooldown := 0;
Result := True;
end;
- if ((trigData.trigItemDelay = 0) and (actType <> ACTIVATE_CUSTOM))
- or ((trigData.trigItemDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
- if (not trigData.trigItemOnlyDM) or
+ if ((tgcDelay = 0) and (actType <> ACTIVATE_CUSTOM))
+ or ((tgcDelay > 0) and (actType = ACTIVATE_CUSTOM)) then
+ if (not tgcDmonly) or
(gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
- for k := 1 to trigData.trigItemCount do
+ for k := 1 to tgcItemCount do
begin
- if (actType = ACTIVATE_CUSTOM) and (trigData.trigItemDelay > 0) then
- SpawnCooldown := trigData.trigItemDelay;
- if (trigData.trigItemMax > 0) and (SpawnedCount >= trigData.trigItemMax) then
+ if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then
+ SpawnCooldown := tgcDelay;
+ if (tgcMax > 0) and (SpawnedCount >= tgcMax) then
Break;
- iid := g_Items_Create(trigData.trigItemPos.X, trigData.trigItemPos.Y,
- trigData.trigItemType, trigData.trigItemFalls, False, True);
+ iid := g_Items_Create(tgcTX, tgcTY,
+ tgcSpawnItemType, tgcGravity, False, True);
Result := True;
- if trigData.trigItemMax > 0 then
+ if tgcMax > 0 then
begin
it := g_Items_ByIdx(iid);
it.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
- case trigData.trigItemEffect of
+ case tgcEffect of
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', trigData.trigItemPos.X, trigData.trigItemPos.Y);
+ g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY);
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);
- g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', trigData.trigItemPos.X, trigData.trigItemPos.Y);
+ g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY);
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);
- g_Sound_PlayExAt('SOUND_FIRE', trigData.trigItemPos.X, trigData.trigItemPos.Y);
+ g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY);
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
// Ìåíÿåì ìóçûêó, åñëè åñòü íà ÷òî:
- if (Trigger.trigData.trigMusicName <> '') then
+ if (Trigger.tgcMusicName <> '') then
begin
- gMusic.SetByName(Trigger.trigData.trigMusicName);
+ gMusic.SetByName(Trigger.tgcMusicName);
gMusic.SpecPause := True;
gMusic.Play();
end;
- if Trigger.trigData.trigMusicAction = 1 then
- begin // Âêëþ÷èòü
+ case Trigger.tgcMusicAction of
+ TRIGGER_MUSIC_ACTION_STOP: // Âûêëþ÷èòü
+ gMusic.SpecPause := True; // Ïàóçà
+ TRIGGER_MUSIC_ACTION_PLAY: // Âêëþ÷èòü
if gMusic.SpecPause then // Áûëà íà ïàóçå => èãðàòü
gMusic.SpecPause := False
else // Èãðàëà => ñíà÷àëà
gMusic.SetPosition(0);
- end
- else // Âûêëþ÷èòü
- begin
- // Ïàóçà:
- gMusic.SpecPause := True;
- end;
+ end;
if coolDown then
TimeOut := 36
TRIGGER_PUSH:
begin
- pAngle := -DegToRad(trigData.trigPushAngle);
+ pAngle := -DegToRad(tgcAngle);
Result := tr_Push(ActivateUID,
- Floor(Cos(pAngle)*trigData.trigPushForce),
- Floor(Sin(pAngle)*trigData.trigPushForce),
- trigData.trigResetVel);
+ Floor(Cos(pAngle)*tgcForce),
+ Floor(Sin(pAngle)*tgcForce),
+ tgcResetVelocity);
TimeOut := 0;
end;
begin
Result := False;
// Ïðèáàâèòü èëè îòíÿòü î÷êî
- if (trigData.trigScoreAction in [0..1]) and (trigData.trigScoreCount > 0) then
+ if (tgcScoreAction in [TRIGGER_SCORE_ACTION_ADD, TRIGGER_SCORE_ACTION_SUB]) and (tgcScoreCount > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäå
- if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (tgcScoreTeam in [TRIGGER_SCORE_TEAM_MINE_RED, TRIGGER_SCORE_TEAM_MINE_BLUE]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
- 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
+ if ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED))
+ or ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
begin
- Inc(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Scores
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+r');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '+r');
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+re');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '+re');
end;
+ end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- 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
+ if ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED))
+ or ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
begin
- Dec(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Fouls
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-r');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '-r');
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_RED]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-re');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '-re');
end;
+ end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- 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
+ if ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE))
+ or ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Scores
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_OWN], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+b');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '+b');
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_ENEMY], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '+be');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '+be');
end;
+ end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- 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
+ if ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE))
+ or ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Fouls
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_OWN], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-b');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '-b');
end else
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, trigData.trigScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_ENEMY], [p.Name, tgcScoreCount, _lc[I_PLAYER_SCORE_TO_BLUE]]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (trigData.trigScoreCount shl 16), '-be');
+ MH_SEND_GameEvent(NET_EV_SCORE, p.UID or (tgcScoreCount shl 16), '-be');
end;
+ end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
// Êàêîé-òî êîíêðåòíîé êîìàíäå
- if trigData.trigScoreTeam in [2..3] then
+ if tgcScoreTeam in [TRIGGER_SCORE_TEAM_FORCE_RED, TRIGGER_SCORE_TEAM_FORCE_BLUE] then
begin
- if (trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 2) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then
begin
- Inc(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Scores
- if trigData.trigScoreCon then
+ if tgcScoreCon then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_RED], trigData.trigScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_RED], tgcScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '+tr');
+ MH_SEND_GameEvent(NET_EV_SCORE, tgcScoreCount shl 16, '+tr');
end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- if (trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 2) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then
begin
- Dec(gTeamStat[TEAM_RED].Goals, trigData.trigScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Fouls
- if trigData.trigScoreCon then
+ if tgcScoreCon then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_RED], trigData.trigScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_RED], tgcScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '-tr');
+ MH_SEND_GameEvent(NET_EV_SCORE, tgcScoreCount shl 16, '-tr');
end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- if (trigData.trigScoreAction = 0) and (trigData.trigScoreTeam = 3) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Scores
- if trigData.trigScoreCon then
+ if tgcScoreCon then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_BLUE], trigData.trigScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_ADD_TEAM], [_lc[I_PLAYER_SCORE_BLUE], tgcScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '+tb');
+ MH_SEND_GameEvent(NET_EV_SCORE, tgcScoreCount shl 16, '+tb');
end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
- if (trigData.trigScoreAction = 1) and (trigData.trigScoreTeam = 3) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, trigData.trigScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Fouls
- if trigData.trigScoreCon then
+ if tgcScoreCon then
begin
- g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_BLUE], trigData.trigScoreCount]), True);
+ g_Console_Add(Format(_lc[I_PLAYER_SCORE_SUB_TEAM], [_lc[I_PLAYER_SCORE_BLUE], tgcScoreCount]), True);
if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_GameEvent(NET_EV_SCORE, trigData.trigScoreCount shl 16, '-tb');
+ MH_SEND_GameEvent(NET_EV_SCORE, tgcScoreCount shl 16, '-tb');
end;
- if trigData.trigScoreMsg then
+ if tgcScoreMsg 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;
// Âûèãðûø
- if (trigData.trigScoreAction = 2) and (gGameSettings.GoalLimit > 0) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_WIN) and (gGameSettings.GoalLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
- if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (tgcScoreTeam in [TRIGGER_SCORE_TEAM_MINE_RED, TRIGGER_SCORE_TEAM_MINE_BLUE]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
- if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED)) // Red Wins
- or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED)) // Red Wins
+ or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
+ begin
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) 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
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wre');
end;
+ end;
Result := True;
end;
- if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Blue Wins
- or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ end;
+ if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE)) // Blue Wins
+ or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
+ begin
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ begin
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) 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
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_GameEvent(NET_EV_SCORE, p.UID, 'wbe');
end;
+ end;
Result := True;
end;
+ end;
end;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
- if trigData.trigScoreTeam in [2..3] then
+ if tgcScoreTeam in [TRIGGER_SCORE_TEAM_FORCE_RED, TRIGGER_SCORE_TEAM_FORCE_BLUE] then
begin
- if trigData.trigScoreTeam = 2 then // Red Wins
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then // Red Wins
+ begin
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
- if trigData.trigScoreTeam = 3 then // Blue Wins
+ end;
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then // Blue Wins
+ begin
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
Result := True;
end;
+ end;
end;
end;
// Ïðîèãðûø
- if (trigData.trigScoreAction = 3) and (gGameSettings.GoalLimit > 0) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_LOOSE) and (gGameSettings.GoalLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
- if (trigData.trigScoreTeam in [0..1]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
+ if (tgcScoreTeam in [TRIGGER_SCORE_TEAM_MINE_RED, TRIGGER_SCORE_TEAM_MINE_BLUE]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
begin
p := g_Player_Get(ActivateUID);
- if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_BLUE)) // Red Wins
- or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_RED)) then
+ if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE)) // Red Wins
+ or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ if tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED 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;
- if ((trigData.trigScoreTeam = 0) and (p.Team = TEAM_RED)) // Blue Wins
- or ((trigData.trigScoreTeam = 1) and (p.Team = TEAM_BLUE)) then
+ if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED)) // Blue Wins
+ or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
- if trigData.trigScoreCon then
- if trigData.trigScoreTeam = 0 then
+ if tgcScoreCon then
+ if tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED 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;
// Êàêîé-òî êîíêðåòíîé êîìàíäû
- if trigData.trigScoreTeam in [2..3] then
+ if tgcScoreTeam in [TRIGGER_SCORE_TEAM_FORCE_BLUE, TRIGGER_SCORE_TEAM_FORCE_RED] then
begin
- if trigData.trigScoreTeam = 3 then // Red Wins
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then // Red Wins
+ begin
if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
Result := True;
end;
- if trigData.trigScoreTeam = 2 then // Blue Wins
+ end;
+ if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then // Blue Wins
+ begin
if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
begin
gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
Result := True;
end;
+ end;
end;
end;
if Result then begin
TRIGGER_MESSAGE:
begin
- Result := tr_Message(trigData.trigMessageKind, trigData.trigMessageText,
- trigData.trigMessageSendTo, trigData.trigMessageTime,
+ Result := tr_Message(tgcKind, tgcText,
+ tgcMsgDest, tgcMsgTime,
ActivateUID);
TimeOut := 18;
end;
end else
begin // Óæå âèäåëè åãî
// Åñëè èíòåðâàë îòêëþ÷¸í, íî îí âñ¸ åù¸ â çîíå ïîðàæåíèÿ, äà¸ì åìó âðåìÿ
- if (trigData.trigDamageInterval = 0) and (Activators[k].TimeOut > 0) then
+ if (tgcInterval = 0) and (Activators[k].TimeOut > 0) then
Activators[k].TimeOut := 65535;
// Òàéìàóò ïðîø¸ë - ðàáîòàåì
Result := Activators[k].TimeOut = 0;
Exit;
// Íàíîñèì óðîí èãðîêó
- if (TriggerType = TRIGGER_DAMAGE) and (trigData.trigDamageValue > 0) then
- p.Damage(trigData.trigDamageValue, 0, 0, 0, HIT_SOME);
+ if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then
+ p.Damage(tgcAmount, 0, 0, 0, HIT_SOME);
// Ëå÷èì èãðîêà
- if (TriggerType = TRIGGER_HEALTH) and (trigData.trigHealValue > 0) then
- if p.Heal(trigData.trigHealValue, not trigData.trigHealMax) and (not trigData.trigHealSilent) then
+ if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then
+ if p.Heal(tgcAmount, not tgcHealMax) and (not tgcSilent) then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', p.Obj.X, p.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
Exit;
// Íàíîñèì óðîí ìîíñòðó
- if (TriggerType = TRIGGER_DAMAGE) and (trigData.trigDamageValue > 0) then
- m.Damage(trigData.trigDamageValue, 0, 0, 0, HIT_SOME);
+ if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then
+ m.Damage(tgcAmount, 0, 0, 0, HIT_SOME);
// Ëå÷èì ìîíñòðà
- if (TriggerType = TRIGGER_HEALTH) and (trigData.trigHealValue > 0) then
- if m.Heal(trigData.trigHealValue) and (not trigData.trigHealSilent) then
+ if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then
+ if m.Heal(tgcAmount) and (not tgcSilent) then
begin
g_Sound_PlayExAt('SOUND_ITEM_GETITEM', m.Obj.X, m.Obj.Y);
if g_Game_IsServer and g_Game_IsNet then
end;
end;
// Íàçíà÷àåì âðåìÿ ñëåäóþùåãî âîçäåéñòâèÿ
- if TriggerType = TRIGGER_DAMAGE then
- idx := trigData.trigDamageInterval
- else
- idx := trigData.trigHealInterval;
+ idx := tgcInterval;
if coolDown then
if idx > 0 then
Activators[k].TimeOut := idx
Exit;
// put this at the beginning so it doesn't trigger itself
- TimeOut := trigData.trigShotWait + 1;
+ TimeOut := tgcWait + 1;
- wx := trigData.trigShotPos.X;
- wy := trigData.trigShotPos.Y;
- pAngle := -DegToRad(trigData.trigShotAngle);
+ wx := tgcTX;
+ wy := tgcTY;
+ pAngle := -DegToRad(tgcAngle);
xd := wx + Round(Cos(pAngle) * 32.0);
yd := wy + Round(Sin(pAngle) * 32.0);
TargetUID := 0;
- case trigData.trigShotTarget of
+ case tgcShotTarget of
TRIGGER_SHOT_TARGET_MON: // monsters
//TODO: accelerate this!
g_Mons_ForEachAlive(monsShotTarget);
TRIGGER_SHOT_TARGET_PLR: // players
if gPlayers <> nil then
for idx := Low(gPlayers) to High(gPlayers) do
- if (gPlayers[idx] <> nil) and gPlayers[idx].Live and
+ if (gPlayers[idx] <> nil) and gPlayers[idx].alive and
tr_ShotAimCheck(Trigger, @(gPlayers[idx].Obj)) then
begin
xd := gPlayers[idx].GameX + PLAYER_RECT_CX;
TRIGGER_SHOT_TARGET_RED: // red team
if gPlayers <> nil then
for idx := Low(gPlayers) to High(gPlayers) do
- if (gPlayers[idx] <> nil) and gPlayers[idx].Live and
+ if (gPlayers[idx] <> nil) and gPlayers[idx].alive and
(gPlayers[idx].Team = TEAM_RED) and
tr_ShotAimCheck(Trigger, @(gPlayers[idx].Obj)) then
begin
TRIGGER_SHOT_TARGET_BLUE: // blue team
if gPlayers <> nil then
for idx := Low(gPlayers) to High(gPlayers) do
- if (gPlayers[idx] <> nil) and gPlayers[idx].Live and
+ if (gPlayers[idx] <> nil) and gPlayers[idx].alive and
(gPlayers[idx].Team = TEAM_BLUE) and
tr_ShotAimCheck(Trigger, @(gPlayers[idx].Obj)) then
begin
if (TargetUID = 0) and (gPlayers <> nil) then
for idx := Low(gPlayers) to High(gPlayers) do
- if (gPlayers[idx] <> nil) and gPlayers[idx].Live and
+ if (gPlayers[idx] <> nil) and gPlayers[idx].alive and
tr_ShotAimCheck(Trigger, @(gPlayers[idx].Obj)) then
begin
xd := gPlayers[idx].GameX + PLAYER_RECT_CX;
begin
if gPlayers <> nil then
for idx := Low(gPlayers) to High(gPlayers) do
- if (gPlayers[idx] <> nil) and gPlayers[idx].Live and
+ if (gPlayers[idx] <> nil) and gPlayers[idx].alive and
tr_ShotAimCheck(Trigger, @(gPlayers[idx].Obj)) then
begin
xd := gPlayers[idx].GameX + PLAYER_RECT_CX;
end;
else begin
- if (trigData.trigShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
- (trigData.trigShotType <> TRIGGER_SHOT_REV) then
+ if (tgcShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
+ (tgcShotType <> TRIGGER_SHOT_REV) then
TargetUID := ActivateUID;
end;
end;
- if (trigData.trigShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
- ((trigData.trigShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
+ if (tgcShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
+ ((tgcShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
begin
Result := True;
- if (trigData.trigShotIntSight = 0) or
- (trigData.trigShotTarget = TRIGGER_SHOT_TARGET_NONE) or
+ if (tgcSight = 0) or
+ (tgcShotTarget = TRIGGER_SHOT_TARGET_NONE) or
(TargetUID = ShotSightTarget) then
MakeShot(Trigger, wx, wy, xd, yd, TargetUID)
else
begin
- ShotSightTime := trigData.trigShotIntSight;
+ ShotSightTime := tgcSight;
ShotSightTargetN := TargetUID;
- if trigData.trigShotType = TRIGGER_SHOT_BFG then
+ if tgcShotType = TRIGGER_SHOT_BFG then
begin
g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', wx, wy);
if g_Game_IsNet and g_Game_IsServer then
TRIGGER_EFFECT:
begin
- idx := trigData.trigFXCount;
+ idx := tgcFXCount;
while idx > 0 do
begin
- case trigData.trigFXPos of
+ case tgcFXPos of
TRIGGER_EFFECT_POS_CENTER:
begin
wx := X + Width div 2;
wy := Y + Height div 2;
end;
end;
- 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);
+ xd := tgcVelX;
+ yd := tgcVelY;
+ if tgcSpreadL > 0 then xd -= Random(tgcSpreadL+1);
+ if tgcSpreadR > 0 then xd += Random(tgcSpreadR+1);
+ if tgcSpreadU > 0 then yd -= Random(tgcSpreadU+1);
+ if tgcSpreadD > 0 then yd += Random(tgcSpreadD+1);
tr_MakeEffect(wx, wy, xd, yd,
- trigData.trigFXType, trigData.trigFXSubType,
- trigData.trigFXColorR, trigData.trigFXColorG, trigData.trigFXColorB, True, False);
+ tgcFXType, tgcFXSubType,
+ tgcFXRed, tgcFXGreen, tgcFXBlue, True, False);
Dec(idx);
end;
- TimeOut := trigData.trigFXWait;
+ TimeOut := tgcWait;
end;
end;
end;
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.trigDataRec := triggers.itemAt[mapidx];
+ if (Trigger.trigDataRec = nil) then raise Exception.Create('LOAD: internal error in trigger loader');
+ Trigger.mapId := Trigger.trigDataRec.id;
Trigger.mapIndex := mapidx;
- if (Trigger.trigData.trigRec <> nil) then
+ if (Trigger.trigDataRec.trigRec <> nil) then
begin
- Trigger.trigData := Trigger.trigData.trigRec.clone();
+ Trigger.trigDataRec := Trigger.trigDataRec.trigRec.clone(nil);
end
else
begin
- Trigger.trigData := nil;
+ Trigger.trigDataRec := nil;
end;
result := g_Triggers_Create(Trigger, arridx);
end;
fn, mapw: AnsiString;
f, olen: Integer;
begin
-// Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà:
+ // Íå ñîçäàâàòü âûõîä, åñëè èãðà áåç âûõîäà
if (Trigger.TriggerType = TRIGGER_EXIT) and
(not LongBool(gGameSettings.Options and GAME_OPTION_ALLOWEXIT)) then
Trigger.TriggerType := TRIGGER_NONE;
-// Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð:
+ // Åñëè ìîíñòðû çàïðåùåíû, îòìåíÿåì òðèããåð
if (Trigger.TriggerType = TRIGGER_SPAWNMONSTER) and
(not LongBool(gGameSettings.Options and GAME_OPTION_MONSTERS)) and
(gGameSettings.GameType <> GT_SINGLE) then
Trigger.TriggerType := TRIGGER_NONE;
-// Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå:
- if Trigger.TriggerType = TRIGGER_SECRET then
- gSecretsCount := gSecretsCount + 1;
+ // Ñ÷èòàåì êîëè÷åñòâî ñåêðåòîâ íà êàðòå
+ if Trigger.TriggerType = TRIGGER_SECRET then gSecretsCount += 1;
if (forceInternalIndex < 0) then
begin
end;
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;
ClientID := gTriggerClientID;
end
else
+ begin
ClientID := 0;
+ end;
TimeOut := 0;
ActivateUID := 0;
PlayerCollide := False;
SpawnedCount := 0;
end;
-// Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê":
- if (Trigger.TriggerType = TRIGGER_SOUND) and
- (Trigger.trigData.trigSoundName <> '') then
+ // update cached trigger variables
+ trigUpdateCacheData(gTriggers[find_id], gTriggers[find_id].trigDataRec);
+
+ // Çàãðóæàåì çâóê, åñëè ýòî òðèããåð "Çâóê"
+ if (Trigger.TriggerType = TRIGGER_SOUND) and (Trigger.tgcSoundName <> '') then
begin
- // Åùå íåò òàêîãî çâóêà:
- if not g_Sound_Exists(Trigger.trigData.trigSoundName) then
+ // Åùå íåò òàêîãî çâóêà
+ if not g_Sound_Exists(Trigger.tgcSoundName) then
begin
- fn := g_ExtractWadName(Trigger.trigData.trigSoundName);
-
+ fn := g_ExtractWadName(Trigger.tgcSoundName);
if fn = '' then
- begin // Çâóê â ôàéëå ñ êàðòîé
- mapw := g_ExtractWadName(gMapInfo.Map);
- fn := mapw+':'+g_ExtractFilePathName(Trigger.trigData.trigSoundName);
- end
+ begin // Çâóê â ôàéëå ñ êàðòîé
+ mapw := g_ExtractWadName(gMapInfo.Map);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.tgcSoundName);
+ end
else // Çâóê â îòäåëüíîì ôàéëå
- fn := GameDir + '/wads/' + Trigger.trigData.trigSoundName;
+ begin
+ fn := GameDir + '/wads/' + Trigger.tgcSoundName;
+ end;
- if not g_Sound_CreateWADEx(Trigger.trigData.trigSoundName, fn) then
- g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.trigData.trigSoundName]));
+ if not g_Sound_CreateWADEx(Trigger.tgcSoundName, fn) then
+ begin
+ g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.tgcSoundName]));
+ end;
end;
- // Ñîçäàåì îáúåêò çâóêà:
+ // Ñîçäàåì îáúåêò çâóêà
with gTriggers[find_id] do
begin
Sound := TPlayableSound.Create();
- if not Sound.SetByName(Trigger.trigData.trigSoundName) then
+ if not Sound.SetByName(Trigger.tgcSoundName) then
begin
Sound.Free();
Sound := nil;
end;
end;
-// Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà":
- if (Trigger.TriggerType = TRIGGER_MUSIC) and
- (Trigger.trigData.trigMusicName <> '') then
+ // Çàãðóæàåì ìóçûêó, åñëè ýòî òðèããåð "Ìóçûêà"
+ if (Trigger.TriggerType = TRIGGER_MUSIC) and (Trigger.tgcMusicName <> '') then
begin
- // Åùå íåò òàêîé ìóçûêè:
- if not g_Sound_Exists(Trigger.trigData.trigMusicName) then
+ // Åùå íåò òàêîé ìóçûêè
+ if not g_Sound_Exists(Trigger.tgcMusicName) then
begin
- fn := g_ExtractWadName(Trigger.trigData.trigMusicName);
+ fn := g_ExtractWadName(Trigger.tgcMusicName);
if fn = '' then
- begin // Ìóçûêà â ôàéëå ñ êàðòîé
- mapw := g_ExtractWadName(gMapInfo.Map);
- fn := mapw+':'+g_ExtractFilePathName(Trigger.trigData.trigMusicName);
- end
+ begin // Ìóçûêà â ôàéëå ñ êàðòîé
+ mapw := g_ExtractWadName(gMapInfo.Map);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.tgcMusicName);
+ end
else // Ìóçûêà â ôàéëå ñ êàðòîé
- fn := GameDir+'/wads/'+Trigger.trigData.trigMusicName;
+ begin
+ fn := GameDir+'/wads/'+Trigger.tgcMusicName;
+ end;
- if not g_Sound_CreateWADEx(Trigger.trigData.trigMusicName, fn, True) then
- g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.trigData.trigMusicName]));
+ if not g_Sound_CreateWADEx(Trigger.tgcMusicName, fn, True) then
+ begin
+ g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, Trigger.tgcMusicName]));
+ end;
end;
end;
-// Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü":
+ // Çàãðóæàåì äàííûå òðèããåðà "Òóðåëü"
if Trigger.TriggerType = TRIGGER_SHOT then
+ begin
with gTriggers[find_id] do
begin
ShotPanelTime := 0;
ShotSightTimeout := 0;
ShotSightTarget := 0;
ShotSightTargetN := 0;
- ShotAmmoCount := Trigger.trigData.trigShotAmmo;
+ ShotAmmoCount := Trigger.tgcAmmo;
ShotReloadTime := 0;
end;
+ end;
Result := find_id;
end;
continue;
end;
// Ñ÷èòàåì, ÷òî îáúåêò ïîêèíóë çîíó äåéñòâèÿ òðèããåðà
- if (trigData.trigDamageInterval = 0) and (Activators[b].TimeOut < 65530) then Activators[b].TimeOut := 0;
+ if (tgcInterval = 0) and (Activators[b].TimeOut < 65530) then Activators[b].TimeOut := 0;
end;
end;
if SpawnCooldown = 0 then
begin
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ìîíñòðà
- if (TriggerType = TRIGGER_SPAWNMONSTER) and (trigData.trigMonDelay > 0) then
+ if (TriggerType = TRIGGER_SPAWNMONSTER) and (tgcDelay > 0) then
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
end;
// Åñëè ïðèøëî âðåìÿ, ñïàâíèì ïðåäìåò
- if (TriggerType = TRIGGER_SPAWNITEM) and (trigData.trigItemDelay > 0) then
+ if (TriggerType = TRIGGER_SPAWNITEM) and (tgcDelay > 0) then
begin
ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_CUSTOM);
if ShotPanelTime > 0 then
begin
Dec(ShotPanelTime);
- if ShotPanelTime = 0 then g_Map_SwitchTextureGUID(ShotPanelType, trigShotPanelGUID);
+ if ShotPanelTime = 0 then g_Map_SwitchTextureGUID(ShotPanelType, trigPanelGUID);
end;
if ShotSightTime > 0 then
begin
if ShotReloadTime > 0 then
begin
Dec(ShotReloadTime);
- if ShotReloadTime = 0 then ShotAmmoCount := trigData.trigShotAmmo;
+ if ShotReloadTime = 0 then ShotAmmoCount := tgcAmmo;
end;
end;
begin
if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then
begin
- if trigData.trigPlayCount > 0 then SoundPlayCount -= 1; // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
- if trigData.trigLocal then
+ if tgcPlayCount > 0 then SoundPlayCount -= 1; // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
+ if tgcLocal then
begin
- Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), trigData.trigVolume/255.0);
+ Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), tgcVolume/255.0);
end
else
begin
- Sound.PlayPanVolume((trigData.trigPan-127.0)/128.0, trigData.trigVolume/255.0);
+ Sound.PlayPanVolume((tgcPan-127.0)/128.0, tgcVolume/255.0);
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 (g_Map_PanelByGUID(trigPanelGUID) <> nil) then
begin
- tr_OpenDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors);
+ tr_OpenDoor(trigPanelGUID, tgcSilent, tgcD2d);
DoorTime := -1;
end;
else
begin
// Ïîêà îòêðûòà - çàêðûâàåì
- if tr_CloseDoor(trigPanelGUID, trigData.trigNoSound, trigData.trigd2d_doors) then DoorTime := -1;
+ if tr_CloseDoor(trigPanelGUID, tgcSilent, tgcD2d) then DoorTime := -1;
end;
end;
end;
// Òðèããåð - ðàñøèðèòåëü èëè ïåðåêëþ÷àòåëü, è ïðîøëà çàäåðæêà, è íàæàëè íóæíîå ÷èñëî ðàç:
if (TriggerType in [TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF]) and
- (PressTime = 0) and (PressCount >= trigData.trigCount) then
+ (PressTime = 0) and (PressCount >= tgcPressCount) then
begin
// Ñáðàñûâàåì çàäåðæêó àêòèâàöèè:
PressTime := -1;
// Ñáðàñûâàåì ñ÷åò÷èê íàæàòèé:
- if trigData.trigCount > 0 then PressCount -= trigData.trigCount else PressCount := 0;
+ if tgcPressCount > 0 then PressCount -= tgcPressCount else PressCount := 0;
// Îïðåäåëÿåì èçìåíÿåìûå èì òðèããåðû:
for b := 0 to High(gTriggers) do
begin
- if g_Collide(trigData.trigtX, trigData.trigtY, trigData.trigtWidth, trigData.trigtHeight, gTriggers[b].X, gTriggers[b].Y,
+ if g_Collide(tgcTX, tgcTY, tgcTWidth, tgcTHeight, gTriggers[b].X, gTriggers[b].Y,
gTriggers[b].Width, gTriggers[b].Height) and
- ((b <> a) or (trigData.trigWait > 0)) then
+ ((b <> a) or (tgcWait > 0)) then
begin // Can be self-activated, if there is Data.Wait
- if (not trigData.trigExtRandom) or gTriggers[b].Enabled then
+ if (not tgcExtRandom) or gTriggers[b].Enabled then
begin
SetLength(Affected, Length(Affected) + 1);
Affected[High(Affected)] := b;
TRIGGER_OFF: pan.movingActive := false;
TRIGGER_ONOFF: pan.movingActive := not pan.movingActive;
end;
+ if not tgcSilent and (Length(tgcSound) > 0) then
+ begin
+ g_Sound_PlayExAt(tgcSound, X, Y);
+ if g_Game_IsServer and g_Game_IsNet then MH_SEND_Sound(X, Y, tgcSound);
+ end;
end;
// Âûáèðàåì îäèí èç òðèããåðîâ äëÿ ðàñøèðèòåëÿ, åñëè âêëþ÷åí ðàíäîì:
- if (TriggerType = TRIGGER_PRESS) and trigData.trigExtRandom then
+ if (TriggerType = TRIGGER_PRESS) and tgcExtRandom then
begin
if (Length(Affected) > 0) then
begin
if gPlayers[b] <> nil then
with gPlayers[b] do
// Æèâ, åñòü íóæíûå êëþ÷è è îí ðÿäîì:
- if Live and ((gTriggers[a].Keys and GetKeys) = gTriggers[a].Keys) and
+ if alive and ((gTriggers[a].Keys and GetKeys) = gTriggers[a].Keys) and
Collide(X, Y, Width, Height) then
begin
gTriggers[a].ActivateUID := UID;
procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0);
begin
+ if (ID >= Length(gTriggers)) then exit;
gTriggers[ID].ActivateUID := ActivateUID;
ActivateTrigger(gTriggers[ID], ActivateType);
end;
(TriggerType = TRIGGER_DOOR5) or
(TriggerType = TRIGGER_DOOR) then
begin
- tr_OpenDoor(trigPanelGUID, True, trigData.trigd2d_doors);
+ tr_OpenDoor(trigPanelGUID, True, tgcD2d);
if TriggerType = TRIGGER_DOOR5 then DoorTime := 180;
b := True;
end;
Dec(gTriggers[ID].SpawnedCount);
end;
-procedure g_Triggers_Free();
+
+procedure g_Triggers_Free ();
var
a: Integer;
begin
begin
if (gTriggers[a].TriggerType = TRIGGER_SOUND) then
begin
- if g_Sound_Exists(gTriggers[a].trigData.trigSoundName) then
+ if g_Sound_Exists(gTriggers[a].tgcSoundName) then
begin
- g_Sound_Delete(gTriggers[a].trigData.trigSoundName);
+ g_Sound_Delete(gTriggers[a].tgcSoundName);
end;
gTriggers[a].Sound.Free();
end;
begin
SetLength(gTriggers[a].Activators, 0);
end;
- gTriggers[a].trigData.Free();
+ gTriggers[a].trigDataRec.Free();
end;
gTriggers := nil;
SetLength(gMonstersSpawned, 0);
end;
+
procedure g_Triggers_SaveState(var Mem: TBinMemoryWriter);
var
- count, act_count, i, j: Integer;
+ count, actCount, i, j: Integer;
dw: DWORD;
sg: Single;
b: Boolean;
begin
// Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðèããåðîâ
count := Length(gTriggers);
+ Mem := TBinMemoryWriter.Create((count+1)*200);
- Mem := TBinMemoryWriter.Create((count+1) * 200);
-
- // Êîëè÷åñòâî òðèããåðîâ:
+ // Êîëè÷åñòâî òðèããåðîâ
Mem.WriteInt(count);
-
- //e_LogWritefln('saving %s triggers (count=%s)', [Length(gTriggers), count]);
-
- if count = 0 then exit;
+ if (count = 0) then exit;
for i := 0 to High(gTriggers) do
begin
- // Ñèãíàòóðà òðèããåðà:
+ // Ñèãíàòóðà òðèããåðà
dw := TRIGGER_SIGNATURE; // 'TRGX'
Mem.WriteDWORD(dw);
- // Òèï òðèããåðà:
+ // Òèï òðèããåðà
Mem.WriteByte(gTriggers[i].TriggerType);
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.WriteWord(gTriggers[i].Width);
Mem.WriteWord(gTriggers[i].Height);
- // Âêëþ÷åí ëè òðèããåð:
+ // Âêëþ÷åí ëè òðèããåð
Mem.WriteBoolean(gTriggers[i].Enabled);
- // Òèï àêòèâàöèè òðèããåðà:
+ // Òèï àêòèâàöèè òðèããåðà
Mem.WriteByte(gTriggers[i].ActivateType);
- // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè:
+ // Êëþ÷è, íåîáõîäèìûå äëÿ àêòèâàöèè
Mem.WriteByte(gTriggers[i].Keys);
- // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ:
+ // ID ïàíåëè, òåêñòóðà êîòîðîé èçìåíèòñÿ
Mem.WriteInt(gTriggers[i].TexturePanelGUID);
- // Òèï ýòîé ïàíåëè:
+ // Òèï ýòîé ïàíåëè
Mem.WriteWord(gTriggers[i].TexturePanelType);
- // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
+ // Âíóòðåííèé íîìåð äðóãîé ïàíåëè (ïî ñ÷àñòëèâîé ñëó÷àéíîñòè îí áóäåò ñîâïàäàòü ñ òåì, ÷òî ñîçäàíî ïðè çàãðóçêå êàðòû)
Mem.WriteInt(gTriggers[i].trigPanelGUID);
- // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè:
+ // Âðåìÿ äî âîçìîæíîñòè àêòèâàöèè
Mem.WriteWord(gTriggers[i].TimeOut);
- // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
+ // UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð
Mem.WriteWord(gTriggers[i].ActivateUID);
- // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
- act_count := Length(gTriggers[i].Activators);
- Mem.WriteInt(act_count);
- for j := 0 to act_count-1 do
+ // Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì
+ actCount := Length(gTriggers[i].Activators);
+ Mem.WriteInt(actCount);
+ for j := 0 to actCount-1 do
begin
// UID îáúåêòà
Mem.WriteWord(gTriggers[i].Activators[j].UID);
// Âðåìÿ îæèäàíèÿ
Mem.WriteWord(gTriggers[i].Activators[j].TimeOut);
end;
- // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà:
+ // Ñòîèò ëè èãðîê â îáëàñòè òðèããåðà
Mem.WriteBoolean(gTriggers[i].PlayerCollide);
- // Âðåìÿ äî çàêðûòèÿ äâåðè:
+ // Âðåìÿ äî çàêðûòèÿ äâåðè
Mem.WriteInt(gTriggers[i].DoorTime);
- // Çàäåðæêà àêòèâàöèè:
+ // Çàäåðæêà àêòèâàöèè
Mem.WriteInt(gTriggers[i].PressTime);
- // Ñ÷åò÷èê íàæàòèé:
+ // Ñ÷åò÷èê íàæàòèé
Mem.WriteInt(gTriggers[i].PressCount);
- // Ñïàâíåð àêòèâåí:
+ // Ñïàâíåð àêòèâåí
Mem.WriteBoolean(gTriggers[i].AutoSpawn);
- // Çàäåðæêà ñïàâíåðà:
+ // Çàäåðæêà ñïàâíåðà
Mem.WriteInt(gTriggers[i].SpawnCooldown);
- // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ:
+ // Ñ÷åò÷èê ñîçäàíèÿ îáúåêòîâ
Mem.WriteInt(gTriggers[i].SpawnedCount);
- // Ñêîëüêî ðàç ïðîèãðàí çâóê:
+ // Ñêîëüêî ðàç ïðîèãðàí çâóê
Mem.WriteInt(gTriggers[i].SoundPlayCount);
- // Ïðîèãðûâàåòñÿ ëè çâóê?
- if gTriggers[i].Sound <> nil then
- b := gTriggers[i].Sound.IsPlaying()
- else
- b := False;
+ // Ïðîèãðûâàåòñÿ ëè çâóê?
+ if (gTriggers[i].Sound <> nil) then b := gTriggers[i].Sound.IsPlaying() else b := false;
Mem.WriteBoolean(b);
if b then
begin
- // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà:
+ // Ïîçèöèÿ ïðîèãðûâàíèÿ çâóêà
dw := gTriggers[i].Sound.GetPosition();
Mem.WriteDWORD(dw);
- // Ãðîìêîñòü çâóêà:
+ // Ãðîìêîñòü çâóêà
sg := gTriggers[i].Sound.GetVolume();
sg := sg / (gSoundLevel/255.0);
Mem.WriteSingle(sg);
- // Ñòåðåî ñìåùåíèå çâóêà:
+ // Ñòåðåî ñìåùåíèå çâóêà
sg := gTriggers[i].Sound.GetPan();
Mem.WriteSingle(sg);
end;
end;
end;
-procedure g_Triggers_LoadState(var Mem: TBinMemoryReader);
+
+procedure g_Triggers_LoadState (var Mem: TBinMemoryReader);
var
- count, act_count, i, j, a: Integer;
+ count, actCount, i, j, a: Integer;
dw: DWORD;
vol, pan: Single;
b: Boolean;
- //p: Pointer;
Trig: TTrigger;
mapIndex: Integer;
- //tw: TStrTextWriter;
begin
- if Mem = nil then
- Exit;
+ if (Mem = nil) then exit;
g_Triggers_Free();
-// Êîëè÷åñòâî òðèããåðîâ:
+ // Êîëè÷åñòâî òðèããåðîâ
Mem.ReadInt(count);
-
if (count = 0) then exit;
for a := 0 to count-1 do
begin
- // Ñèãíàòóðà òðèããåðà:
- Mem.ReadDWORD(dw);
- if (dw <> TRIGGER_SIGNATURE) then // 'TRGX'
- begin
- raise EBinSizeError.Create('g_Triggers_LoadState: Wrong Trigger Signature');
- end;
- // Òèï òðèããåðà:
+ // Ñèãíàòóðà òðèããåðà
+ Mem.ReadDWORD(dw); // 'TRGX'
+ if (dw <> TRIGGER_SIGNATURE) then raise EBinSizeError.Create('g_Triggers_LoadState: Wrong Trigger Signature');
+ // Òèï òðèããåðà
Mem.ReadByte(Trig.TriggerType);
- // Ñïåöèàëüíûå äàííûå òðèããåðà: èíäåêñ â gCurrentMap.field['triggers']
+ // Ñïåöèàëüíûå äàííûå òðèããåðà: èíäåêñ â 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^);
- }
- // Ñîçäàåì òðèããåð:
i := g_Triggers_CreateWithMapIndex(Trig, a, mapIndex);
{
if (gTriggers[i].trigData <> nil) then
// UID òîãî, êòî àêòèâèðîâàë ýòîò òðèããåð:
Mem.ReadWord(gTriggers[i].ActivateUID);
// Ñïèñîê UID-îâ îáúåêòîâ, êîòîðûå íàõîäèëèñü ïîä âîçäåéñòâèåì:
- Mem.ReadInt(act_count);
- if act_count > 0 then
+ Mem.ReadInt(actCount);
+ if actCount > 0 then
begin
- SetLength(gTriggers[i].Activators, act_count);
- for j := 0 to act_count-1 do
+ SetLength(gTriggers[i].Activators, actCount);
+ for j := 0 to actCount-1 do
begin
// UID îáúåêòà
Mem.ReadWord(gTriggers[i].Activators[j].UID);