Index: binaries/data/mods/public/maps/scenarios/combat_demo.xml =================================================================== --- binaries/data/mods/public/maps/scenarios/combat_demo.xml +++ binaries/data/mods/public/maps/scenarios/combat_demo.xml @@ -3,462 +3,68 @@ cirrus - + + + 0 + 0.5 + + lake + 34.623 - 3.0 + 3 0.898438 - + 0 + + 0 + 1 + 0.99 + 0.1999 + default + - - - + + + - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - - - - 2 - - - @@ -1284,6 +890,139 @@ + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + + + + 2 + + + + Index: binaries/data/mods/public/simulation/components/Visibility.js =================================================================== --- binaries/data/mods/public/simulation/components/Visibility.js +++ binaries/data/mods/public/simulation/components/Visibility.js @@ -27,6 +27,8 @@ this.activated = false; + this.temporaryReveal = {}; + if (this.preview || this.corpse) this.SetActivated(true); }; @@ -60,6 +62,9 @@ */ Visibility.prototype.GetVisibility = function(player, isVisible, isExplored) { + if (player in this.temporaryReveal) + return VIS_VISIBLE; + if (this.preview) { // For the owner only, mock the "RetainInFog" behavior @@ -81,7 +86,25 @@ return isVisible ? VIS_VISIBLE : VIS_HIDDEN; } - return VIS_VISIBLE; + return isVisible ? VIS_VISIBLE : (isExplored ? VIS_FOGGED : VIS_HIDDEN); +}; + +Visibility.prototype.RevealForPlayer = function(player, time) +{ + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + if (player in this.temporaryReveal) + cmpTimer.CancelTimer(this.temporaryReveal[player]); + + cmpTimer.SetTimeout(this.entity, IID_Visibility, "StopTemporaryReveal", time, { "player": player }); + this.SetActivated(true); +}; + +Visibility.prototype.StopTemporaryReveal = function(data) +{ + if (!(data.player in this.temporaryReveal)) + return; + delete this.temporaryReveal[data.player]; + this.SetActivated(false); }; Visibility.prototype.GetRetainInFog = function() @@ -94,4 +117,24 @@ return this.alwaysVisible; }; +Visibility.prototype.OnAttacked = function(msg) +{ + if (!msg.attacker) + return; + + let cmpAttackerVisibility = Engine.QueryInterface(msg.attacker, IID_Visibility); + if (!cmpAttackerVisibility) + return; + + let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + if (!cmpOwnership) + return; + + let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); + if (cmpRangeManager.GetLosVisibility(msg.attacker, cmpOwnership.GetOwner()) === "visible") + return; + + cmpAttackerVisibility.RevealForPlayer(cmpOwnership.GetOwner(), 3000); +}; + Engine.RegisterComponentType(IID_Visibility, "Visibility", Visibility);