DEADSOFTWARE

always set max volume in sound trigger bounds
[d2df-sdl.git] / src / game / g_triggers.pas
index 9f6df9f5ded1502c244836da3a402ad20c3c76b9..a2ae402536bdea9b3d431e192bf5cda847e9945a 100644 (file)
@@ -809,7 +809,7 @@ begin
     TRIGGER_SHOT_FLAME:
       begin
         g_Weapon_flame(wx, wy, dx, dy, 0, -1, True);
-        //snd := 'SOUND_WEAPON_FIREPLASMA';
+        snd := 'SOUND_GAME_BURNING';
       end;
 
     else exit;
@@ -853,7 +853,7 @@ begin
       dx += Random(tgcAccuracy)-Random(tgcAccuracy);
       dy += Random(tgcAccuracy)-Random(tgcAccuracy);
 
-      tr_SpawnShot(tgcShotType, wx, wy, dx, dy, not tgcQuiet, TargetUID);
+      tr_SpawnShot(tgcShotType, wx, wy, dx, dy, tgcShotSound, TargetUID);
     end
     else
     begin
@@ -1352,9 +1352,15 @@ begin
           Result := True;
           if gLMSRespawn = LMS_RESPAWN_NONE then
           begin
-            g_Player_Get(ActivateUID).GetSecret();
+            p := g_Player_Get(ActivateUID);
+            p.GetSecret();
             Inc(gCoopSecretsFound);
-            if g_Game_IsNet then MH_SEND_GameStats();
+            if g_Game_IsNet then
+            begin
+              MH_SEND_GameStats();
+              if p.FClientID >= 0 then
+                MH_SEND_GameEvent(NET_EV_SECRET, p.UID, '');
+            end;
           end;
         end;
 
@@ -1467,7 +1473,7 @@ begin
             for k := 1 to tgcMonsCount do
             begin
               if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then
-                SpawnCooldown := tgcDelay;
+                SpawnCooldown := -1; // Çàäåðæêà âûñòàâèòñÿ ìîíñòðîì ïðè óíè÷òîæåíèè
               if (tgcMax > 0) and (SpawnedCount >= tgcMax) then
                 Break;
 
@@ -1497,11 +1503,8 @@ begin
                 gMonstersSpawned[High(gMonstersSpawned)] := mon.UID;
               end;
 
-              if tgcMax > 0 then
-              begin
-                mon.SpawnTrigger := ID;
-                Inc(SpawnedCount);
-              end;
+              mon.SpawnTrigger := ID;
+              if tgcMax > 0 then Inc(SpawnedCount);
 
               case tgcEffect of
                 EFFECT_TELEPORT: begin
@@ -1582,7 +1585,7 @@ begin
               for k := 1 to tgcItemCount do
               begin
                 if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then
-                  SpawnCooldown := tgcDelay;
+                  SpawnCooldown := -1; // Çàäåðæêà âûñòàâèòñÿ èòåìîì ïðè óíè÷òîæåíèè
                 if (tgcMax > 0) and (SpawnedCount >= tgcMax) then
                   Break;
 
@@ -1591,12 +1594,9 @@ begin
 
                 Result := True;
 
-                if tgcMax > 0 then
-                begin
-                  it := g_Items_ByIdx(iid);
-                  it.SpawnTrigger := ID;
-                  Inc(SpawnedCount);
-                end;
+                it := g_Items_ByIdx(iid);
+                it.SpawnTrigger := ID;
+                if tgcMax > 0 then Inc(SpawnedCount);
 
                 case tgcEffect of
                   EFFECT_TELEPORT: begin
@@ -2107,7 +2107,14 @@ begin
 
                     // Íàíîñèì óðîí èãðîêó
                     if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then
-                      p.Damage(tgcAmount, 0, 0, 0, HIT_SOME);
+                    begin
+                      // Êèñëîòíûé óðîí íå íàíîñèòñÿ êîãäà åñòü êîñòþì
+                      // "Âîäÿíîé" óðîí íå íàíîñèòñÿ êîãäà åñòü êèñëîðîä
+                      if not (((tgcKind = HIT_ACID) and (p.FMegaRulez[MR_SUIT] > gTime)) or
+                              ((tgcKind = HIT_WATER) and (p.Air > 0))) then
+                        p.Damage(tgcAmount, 0, 0, 0, tgcKind);
+                      if (tgcKind = HIT_FLAME) then p.CatchFire(0);
+                    end;
 
                     // Ëå÷èì èãðîêà
                     if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then
@@ -2127,7 +2134,10 @@ begin
 
                     // Íàíîñèì óðîí ìîíñòðó
                     if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then
-                      m.Damage(tgcAmount, 0, 0, 0, HIT_SOME);
+                    begin
+                      p.Damage(tgcAmount, 0, 0, 0, tgcKind);
+                      if (tgcKind = HIT_FLAME) then m.CatchFire(0);
+                    end;
 
                     // Ëå÷èì ìîíñòðà
                     if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then
@@ -2698,17 +2708,14 @@ begin
         begin
           if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then
           begin
-            if tgcPlayCount > 0 then SoundPlayCount -= 1; // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî
+            if tgcPlayCount > 0 then Dec(SoundPlayCount); (* looped sound if zero *)
             if tgcLocal then
-            begin
-              Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), tgcVolume/255.0);
-            end
+              Sound.PlayVolumeAtRect(X, Y, Width, Height, tgcVolume / 255.0)
             else
-            begin
-              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;
+              Sound.PlayPanVolume((tgcPan - 127.0) / 128.0, tgcVolume / 255.0);
+            if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then
+              MH_SEND_TriggerSound(gTriggers[a])
+          end
         end;
 
         // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü
@@ -3068,11 +3075,20 @@ end;
 procedure g_Triggers_DecreaseSpawner(ID: DWORD);
 begin
   if (gTriggers <> nil) then
-    if gTriggers[ID].SpawnedCount > 0 then
-      Dec(gTriggers[ID].SpawnedCount);
+  begin
+    if gTriggers[ID].tgcMax > 0 then
+    begin
+      if gTriggers[ID].SpawnedCount > 0 then
+        Dec(gTriggers[ID].SpawnedCount);
+    end;
+    if gTriggers[ID].tgcDelay > 0 then
+    begin
+      if gTriggers[ID].SpawnCooldown < 0 then
+        gTriggers[ID].SpawnCooldown := gTriggers[ID].tgcDelay;
+    end;
+  end;
 end;
 
-
 procedure g_Triggers_Free ();
 var
   a: Integer;