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 @@ -94,4 +94,49 @@ return this.alwaysVisible; }; +Visibility.prototype.RevealForPlayer = function(player, time) +{ + // This is only called for attackers that aren't visible, + // so this is probably efficient enough. + let cmpPos = Engine.QueryInterface(this.entity, IID_Position); + if (!cmpPos || !cmpPos.IsInWorld()) + return; + let beacon = Engine.AddEntity("los_beacons/los_reveal_10"); + let cmpBeaconPos = Engine.QueryInterface(beacon, IID_Position); + let pos = cmpPos.GetPosition2D(); + cmpBeaconPos.JumpTo(pos.x, pos.y); + let cmpBeaconOwner = Engine.QueryInterface(beacon, IID_Ownership); + cmpBeaconOwner.SetOwner(player); + + let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + cmpTimer.SetTimeout(this.entity, IID_Visibility, "DestroyBeacon", time, { "beacon": beacon }); +}; + +Visibility.prototype.DestroyBeacon = function(data) +{ + if (data.beacon) + Engine.DestroyEntity(data.beacon); +}; + +// TODO: this should be in Vision, but that requires moving Vision to JS. +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); Index: binaries/data/mods/public/simulation/templates/los_beacons/los_reveal_10.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/simulation/templates/los_beacons/los_reveal_10.xml @@ -0,0 +1,6 @@ + + + + 10 + + Index: binaries/data/mods/public/simulation/templates/template_los_beacon.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/simulation/templates/template_los_beacon.xml @@ -0,0 +1,33 @@ + + + + + 0 + upright + false + 0 + 6 + + + + + + 128x128/octagram.png + 128x128/octagram_mask.png + + + + + true + false + false + false + + + + false + true + props/special/common/waypoint_flag.xml + true + +