X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_triggers.pas;h=9ca5756b048cd9409686c8f59496c1a7ed522b67;hb=27b297c1c90cca9fe2b4e52a0af81e70e3ce4d4e;hp=c1516535c11decd0fc4a9dad7c23044479811b23;hpb=3349a0b38bc1fae71b758cb1686d4f6d0bf4f926;p=d2df-sdl.git diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index c151653..9ca5756 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -69,7 +69,7 @@ procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0) function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word; ActivateType: Byte; IgnoreList: DWArray = nil): DWArray; procedure g_Triggers_PressL(X1, Y1, X2, Y2: Integer; UID: DWORD; ActivateType: Byte); -procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte); +procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1); procedure g_Triggers_OpenAll(); procedure g_Triggers_DecreaseSpawner(ID: DWORD); procedure g_Triggers_Free(); @@ -435,6 +435,7 @@ var Anim: TAnimation; begin Result := -1; + TextureID := DWORD(-1); snd := 'SOUND_WEAPON_FIREROCKET'; Projectile := True; case ShotType of @@ -731,8 +732,8 @@ begin if D2D then begin - if m.TeleportTo(TX-(p.Obj.Rect.Width div 2), - TY-p.Obj.Rect.Height, + if m.TeleportTo(TX-(m.Obj.Rect.Width div 2), + TY-m.Obj.Rect.Height, Silent, TDir) then Result := True; @@ -923,6 +924,22 @@ begin 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; @@ -1828,6 +1845,9 @@ begin if ShotSightTime > 0 then Exit; + // put this at the beginning so it doesn't trigger itself + TimeOut := Data.ShotWait + 1; + wx := Data.ShotPos.X; wy := Data.ShotPos.Y; pAngle := -DegToRad(Data.ShotAngle); @@ -1840,7 +1860,7 @@ begin 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; @@ -1852,7 +1872,7 @@ begin 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; @@ -1865,7 +1885,7 @@ begin 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; @@ -1878,7 +1898,7 @@ begin 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; @@ -1891,7 +1911,7 @@ begin 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; @@ -1901,7 +1921,7 @@ begin 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; @@ -1915,7 +1935,7 @@ begin 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; @@ -1925,7 +1945,7 @@ begin 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; @@ -1934,10 +1954,15 @@ begin end; end; - else TargetUID := ActivateUID; + else begin + if (Data.ShotTarget <> TRIGGER_SHOT_TARGET_NONE) or + (Data.ShotType <> TRIGGER_SHOT_REV) then + TargetUID := ActivateUID; + 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 @@ -1956,8 +1981,6 @@ begin end; end; end; - - TimeOut := Data.ShotWait + 1; end; TRIGGER_EFFECT: @@ -2472,7 +2495,7 @@ begin end; end; -procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte); +procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1); var a: Integer; k: Byte; @@ -2498,7 +2521,8 @@ begin rsq := Radius * Radius; for a := 0 to High(gTriggers) do - if (gTriggers[a].TriggerType <> TRIGGER_NONE) and + if (gTriggers[a].ID <> DWORD(IgnoreTrigger)) and + (gTriggers[a].TriggerType <> TRIGGER_NONE) and (gTriggers[a].TimeOut = 0) and ((gTriggers[a].Keys and k) = gTriggers[a].Keys) and ByteBool(gTriggers[a].ActivateType and ActivateType) then