diff --git a/binaries/data/mods/public/maps/scripts/WonderVictory.js b/binaries/data/mods/public/maps/scripts/WonderVictory.js index 1942bdabfd..b10a9f757e 100644 --- a/binaries/data/mods/public/maps/scripts/WonderVictory.js +++ b/binaries/data/mods/public/maps/scripts/WonderVictory.js @@ -23,7 +23,7 @@ Trigger.prototype.WonderVictoryEntityRenamed = function(data) // Make the completed wonder permanently visible TriggerHelper.MakeEntityPermanentlyVisible(data.newentity, 50); - // Send "wonder completed" notifications + // Send "wonder completed" notifications (only for non-Gaia wonders) const cmpOwnership = Engine.QueryInterface(data.newentity, IID_Ownership); if (cmpOwnership) { @@ -215,6 +215,48 @@ Trigger.prototype.WonderStartNotification = function(data) ); }; +Trigger.prototype.RevealGaiaWonders = function() +{ + Engine.ProfileStart("RevealGaiaWonders"); + const cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); + if (!cmpEndGameManager) + return; + + const victoryConditions = cmpEndGameManager.GetVictoryConditions(); + if (!victoryConditions || !victoryConditions.includes("wonder")) + return; + + const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); + if (!cmpRangeManager) + return; + + // Find all Gaia-owned wonders + for (const ent of cmpRangeManager.GetEntitiesByPlayer(0)) + if (Engine.QueryInterface(ent, IID_Wonder)) + TriggerHelper.MakeEntityPermanentlyVisible(ent, 50); + + + // Send notification about Gaia wonders + const numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); + const activePlayers = []; + for (let i = 1; i < numPlayers; ++i) + { + const cmpPlayer = QueryPlayerIDInterface(i); + if (cmpPlayer && cmpPlayer.GetState() != "defeated") + activePlayers.push(i); + } + + if (activePlayers.length > 0) + { + TriggerHelper.SendNotification( + markForTranslation("A Wonder has been revealed on the map!"), + activePlayers, + 20000 + ); + } + Engine.ProfileStop(); +}; + { const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); cmpTrigger.RegisterTrigger("OnEntityRenamed", "WonderVictoryEntityRenamed", { "enabled": true }); @@ -222,5 +264,6 @@ Trigger.prototype.WonderStartNotification = function(data) cmpTrigger.RegisterTrigger("OnDiplomacyChanged", "WonderVictoryDiplomacyChanged", { "enabled": true }); cmpTrigger.RegisterTrigger("OnPlayerWon", "WonderVictoryPlayerWon", { "enabled": true }); cmpTrigger.RegisterTrigger("OnConstructionStarted", "WonderStartNotification", { "enabled": true }); + cmpTrigger.DoAfterDelay(0, "RevealGaiaWonders", {}); cmpTrigger.wonderVictoryMessages = {}; }