DEADSOFTWARE

spawners now count delay after their first spawn dies
[d2df-sdl.git] / src / game / g_triggers.pas
index 1673cefedadeab37f1f565cd3b100a7a6684119c..174b47e6594ca44e0a0429705ebb039b4394af67 100644 (file)
@@ -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
@@ -3068,11 +3068,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;