Is there a command that can remove parts of War Fog?

Interesting mapping tools and mapping help.

Moderator: Morax

Is there a command that can remove parts of War Fog?

Postby Ghoustaq » 22 Apr 2018, 05:54

For example, if my army enter the central area of an island, the whole lands on this island will be visible. How to make it real? :?:
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: Is there a command that can remove parts of War Fog?

Postby speed2 » 22 Apr 2018, 07:25

User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Is there a command that can remove parts of War Fog?

Postby Ghoustaq » 24 Apr 2018, 18:12

speed2 wrote:The only way to do this would be to set area triggers that will create visible areas (those are circles)

https://github.com/FAForever/fa/blob/develop/lua/ScenarioFramework.lua#L84-L91
https://github.com/FAForever/fa/blob/develop/lua/ScenarioFramework.lua#L1116-L1133


Thank you! Here's my code, I am not sure if it is necessary to forkthread this funciton.

local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local TriggerFile = import('scenariotriggers.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local UnitUpgradeTemplates = import('/lua/upgradeTemplates.lua').UnitUpgradeTemplates
local ScenarioPlatoonAI = import('/lua/ScenarioPlatoonAI.lua')
local VizMarker = import('/lua/sim/VizMarker.lua').VizMarker
local SimCamera = import('/lua/SimCamera.lua').SimCamera
local Cinematics = import('/lua/cinematics.lua')
local SimUIVars = import('/lua/sim/SimUIState.lua')

function OnPopulate()
ScenarioUtils.InitializeArmies()
ForkThread(CreateVisibleAreaLocation)
end
local vizLocation
local vizArmy
local vizRadius
local vizLifetime
local X
local Z
local Radius
local LifeTime
local Army
function CreateVisibleAreaLocation(vizRadius, vizLocation, vizLifetime, vizArmy)
if type(vizLocation) == 'string' then
vizLocation = ScenarioUtils.MarkerToPosition(vizLocation)
vizArmy = GetUnitsInRect( Rect(vizLocation[1]-5, vizLocation[3]-5, vizLocation[1]+5, vizLocation[3]+5) )
vizRadius = 20
vizLifetime = 0
end
local spec = {
X = vizLocation[1],
Z = vizLocation[3],
Radius = vizRadius,
LifeTime = vizLifetime,
Army = vizArmy:GetArmyIndex(),
}
local vizEntity = VizMarker(spec)

return vizEntity
end
function OnStart(self)
end



if I forkthread it, an error will occur

WARNING: Error running lua script: ...me commander - forged alliance\maps\11\11_script.lua(36): attempt to call method `GetArmyIndex' (a nil value)
stack traceback:
...me commander - forged alliance\maps\11\11_script.lua(36): in function <...me commander - forged alliance\maps\11\11_script.lua:24>


Can you fix it?
Attachments
BUFFAREA_TEST1.rar
(293.1 KiB) Downloaded 88 times
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: Is there a command that can remove parts of War Fog?

Postby Sprouto » 24 Apr 2018, 18:49

The forkthread is not causing the error.

The error occurs because you're calling GetArmyIndex with a nil;

This means that vizArmy is nil, which means your code is not finding any units in the area you specified. Even worse, if it did find multiple units in the area, you would likely get a similar error, since GetArmyIndex will only function on a single entity.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Is there a command that can remove parts of War Fog?

Postby Ghoustaq » 24 Apr 2018, 19:25

Sprouto wrote:The forkthread is not causing the error.

The error occurs because you're calling GetArmyIndex with a nil;

This means that vizArmy is nil, which means your code is not finding any units in the area you specified. Even worse, if it did find multiple units in the area, you would likely get a similar error, since GetArmyIndex will only function on a single entity.


Yes, you are right. there's no unit in this area at the begginning of the game. So I sent some mobile units to get there later, but the visible area wasn't activated still.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: Is there a command that can remove parts of War Fog?

Postby Sprouto » 24 Apr 2018, 19:56

Well...this code will only run once - right at the start of the game. If the units are there to begin with, it might work, but otherwise you need to find the right place in the main code to insert it. Running it during OnPopulate() will not work beyond the very beginning of a map.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Is there a command that can remove parts of War Fog?

Postby Ghoustaq » 25 Apr 2018, 19:01

Sprouto wrote:Well...this code will only run once - right at the start of the game. If the units are there to begin with, it might work, but otherwise you need to find the right place in the main code to insert it. Running it during OnPopulate() will not work beyond the very beginning of a map.



Hello sprouto

do you know what it means?

WARNING: Error running lua script: attempt to use as integer a table value
stack traceback:
[C]: in function `_c_CreateEntity'
...ed alliance\gamedata\mohodata.scd\lua\sim\entity.lua(11): in function `__init'
...alliance\gamedata\mohodata.scd\lua\sim\vizmarker.lua(15): in function `initfn'
... alliance\gamedata\mohodata.scd\lua\system\class.lua(258): in function <... alliance\gamedata\mohodata.scd\lua\system\class.lua:246>
...me commander - forged alliance\maps\11\11_script.lua(41): in function <...me commander - forged alliance\maps\11\11_script.lua:24>



here's the code has been modified

Code: Select all
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local TriggerFile = import('scenariotriggers.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local UnitUpgradeTemplates = import('/lua/upgradeTemplates.lua').UnitUpgradeTemplates
local ScenarioPlatoonAI = import('/lua/ScenarioPlatoonAI.lua')
local VizMarker = import('/lua/sim/VizMarker.lua').VizMarker
local SimCamera = import('/lua/SimCamera.lua').SimCamera
local Cinematics = import('/lua/cinematics.lua')
local SimUIVars = import('/lua/sim/SimUIState.lua')

function OnPopulate()
   ScenarioUtils.InitializeArmies()
        ForkThread(CreateVisibleAreaLocation)   
end
    local vizLocation
    local vizArmy
    local vizRadius
    local vizLifetime
    local X
    local Z
    local Radius
    local LifeTime
    local Army   
function CreateVisibleAreaLocation(vizRadius, vizLocation, vizLifetime, vizArmy)
    while true do
        for k = 1, 1 do
            vizLocation = ScenarioUtils.MarkerToPosition('vizLocation_' .. k)
            vizArmy = GetUnitsInRect( Rect(vizLocation[1]-5, vizLocation[3]-5, vizLocation[1]+5, vizLocation[3]+5) )
            if vizArmy then
               for _, instigator in vizArmy do
                   if VDist3(instigator:GetPosition(), vizLocation) <= 5 then
                      vizRadius = 20
                      vizLifetime = 0
                      local spec = {
                          X = vizLocation[1],
                          Z = vizLocation[3],
                          Radius = vizRadius,
                          LifeTime = vizLifetime,
                          Army = vizArmy[1]:GetAIBrain(),
                          }
                          local vizEntity = VizMarker(spec)

                          return vizEntity
                   end
               end   
            end
        end
        WaitSeconds(5)
    end
end     
function OnStart(self)
end
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: Is there a command that can remove parts of War Fog?

Postby Sprouto » 25 Apr 2018, 21:57

The error is coming from your attempt to create a vision entity;

local vizEntity = VizMarker(spec)

Look carefully at what your putting into spec;

local spec = {
X = vizLocation[1],
Z = vizLocation[3],
Radius = vizRadius,
LifeTime = vizLifetime,
Army = vizArmy[1]:GetAIBrain(),
}

The error is telling you that some piece of data here is a table - look carefully at what your trying to pass along as Army...
You're not passing it's army index - but the entire brain that it belongs to. Try vizArmy[1]:GetAIBrain():GetArmyIndex()
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Is there a command that can remove parts of War Fog?

Postby Ghoustaq » 26 Apr 2018, 18:59

Sprouto wrote:The error is coming from your attempt to create a vision entity;

local vizEntity = VizMarker(spec)

Look carefully at what your putting into spec;

local spec = {
X = vizLocation[1],
Z = vizLocation[3],
Radius = vizRadius,
LifeTime = vizLifetime,
Army = vizArmy[1]:GetAIBrain(),
}

The error is telling you that some piece of data here is a table - look carefully at what your trying to pass along as Army...
You're not passing it's army index - but the entire brain that it belongs to. Try vizArmy[1]:GetAIBrain():GetArmyIndex()


Thanks, sprouto. Then anonther error occurs. I can't understand it

WARNING: Invalid args to yield(); expected tick count
stack traceback:
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: Is there a command that can remove parts of War Fog?

Postby Sprouto » 26 Apr 2018, 21:40

That will be coming from your WaitSeconds command.

The OnPopulate function has terminated before the Forked function did, leaving the forked thread in limbo with no place to return to when it's done.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Next

Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest