index 9ce8c0affc12cd9b8884fa381e40bd8c103ae392..9ca5756b048cd9409686c8f59496c1a7ed522b67 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
end;
end;
+function tr_ShotAimCheck(var Trigger: TTrigger; Obj: PObj): Boolean;
+begin
+ with Trigger do
+ begin
+ if TriggerType <> TRIGGER_SHOT then
+ Exit;
+ Result := (Data.ShotAim and TRIGGER_SHOT_AIM_ALLMAP > 0)
+ 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,
+ Obj^.X + Obj^.Rect.X + (Obj^.Rect.Width div 2),
+ Obj^.Y + Obj^.Rect.Y + (Obj^.Rect.Height div 2));
+ end;
+end;
+
function ActivateTrigger(var Trigger: TTrigger; actType: Byte): Boolean;
var
animonce: Boolean;
if gMonsters <> nil then
for i := Low(gMonsters) to High(gMonsters) do
if (gMonsters[i] <> nil) and gMonsters[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gMonsters[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
begin
xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
if gPlayers <> nil then
for i := Low(gPlayers) to High(gPlayers) do
if (gPlayers[i] <> nil) and gPlayers[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gPlayers[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
begin
xd := gPlayers[i].GameX + PLAYER_RECT_CX;
yd := gPlayers[i].GameY + PLAYER_RECT_CY;
for i := Low(gPlayers) to High(gPlayers) do
if (gPlayers[i] <> nil) and gPlayers[i].Live and
(gPlayers[i].Team = TEAM_RED) and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gPlayers[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
begin
xd := gPlayers[i].GameX + PLAYER_RECT_CX;
yd := gPlayers[i].GameY + PLAYER_RECT_CY;
for i := Low(gPlayers) to High(gPlayers) do
if (gPlayers[i] <> nil) and gPlayers[i].Live and
(gPlayers[i].Team = TEAM_BLUE) and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gPlayers[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
begin
xd := gPlayers[i].GameX + PLAYER_RECT_CX;
yd := gPlayers[i].GameY + PLAYER_RECT_CY;
if gMonsters <> nil then
for i := Low(gMonsters) to High(gMonsters) do
if (gMonsters[i] <> nil) and gMonsters[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gMonsters[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
begin
xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
if (TargetUID = 0) and (gPlayers <> nil) then
for i := Low(gPlayers) to High(gPlayers) do
if (gPlayers[i] <> nil) and gPlayers[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gPlayers[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
begin
xd := gPlayers[i].GameX + PLAYER_RECT_CX;
yd := gPlayers[i].GameY + PLAYER_RECT_CY;
if gPlayers <> nil then
for i := Low(gPlayers) to High(gPlayers) do
if (gPlayers[i] <> nil) and gPlayers[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gPlayers[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gPlayers[i].Obj)) then
begin
xd := gPlayers[i].GameX + PLAYER_RECT_CX;
yd := gPlayers[i].GameY + PLAYER_RECT_CY;
if (TargetUID = 0) and (gMonsters <> nil) then
for i := Low(gMonsters) to High(gMonsters) do
if (gMonsters[i] <> nil) and gMonsters[i].Live and
- (Data.ShotAllMap or g_Obj_Collide(X, Y, Width, Height, @(gMonsters[i].Obj))) then
+ tr_ShotAimCheck(Trigger, @(gMonsters[i].Obj)) then
begin
xd := gMonsters[i].GameX + gMonsters[i].Obj.Rect.Width div 2;
yd := gMonsters[i].GameY + gMonsters[i].Obj.Rect.Height div 2;
end;
end;
- if (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) then
+ if (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) or
+ ((Data.ShotTarget > TRIGGER_SHOT_TARGET_NONE) and (TargetUID = 0)) then
begin
Result := True;
if (Data.ShotIntSight = 0) or