Forged Alliance Forever Forged Alliance Forever Forums 2018-04-30T21:00:59+02:00 /feed.php?f=53&t=16141 2018-04-30T21:00:59+02:00 2018-04-30T21:00:59+02:00 /viewtopic.php?t=16141&p=163016#p163016 <![CDATA[Re: How to get the color of an army?]]>
Thank both of you! I wrote some code with the commands you offered. It does work.
Because the values of colors in ScenarioInfo.ArmySetup are just numbers from 1 to 10 according to the rank in the drop down list of 'color' in 'skirmish setup', I have to correlate the numbers with RGB Color Codes.


Code:
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')

function OnPopulate()
    ScenarioUtils.InitializeArmies()   
    ForkThread(DrawBoundaryLine)
end

function DrawBoundaryLine(self)
    local location
    local entities
    local units
    local Color0 = 'FFCEA984'    -- CIVILIAN Color
    local Color1 = 'FFe80a0a'    -- Cybran red
    local Color2 = 'ff2e8b57'    -- new green
    local Color3 = 'FF2929e1'    -- UEF blue
    local Color4 = 'ffa79602'    -- Sera golden
    local Color5 = 'ffffffff'    -- white
    local Color6 = 'FF2F4F4F'    -- dark green
    local Color7 = 'ff000000'    -- black
    local Color8 = 'ff901427'    -- dark red
    local Color9 = 'ff40bf40'    -- mid green
    local Color10 = 'FF5F01A7'   -- dark purple

    while true do
        for k = 1, 3 do
            location = ScenarioUtils.MarkerToPosition('BuffArea_' .. k)
            entities = GetUnitsInRect( Rect(location[1]-11, location[3]-11, location[1]+11, location[3]+11) )
            if entities then
                units = EntityCategoryFilterDown(categories.HYDROCARBON + categories.MASSEXTRACTION, entities)
            end
            if units then
                -- check first if the trigger unit is still present
                if units[1] and not units[1].Dead and not units[1]:BeenDestroyed() and units[1]:GetFractionComplete() == 1 then
                   for _,instigator in units do
                         local tblArmy = ListArmies()
                         local army = instigator:GetArmy()
                       if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyName) ~= '"ARMY_9"' then   
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '1' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color1 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '2' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color2 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '3' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color3 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '4' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color4 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '5' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color5 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '6' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color6 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '7' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color7 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '8' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color8 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '9' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color9 )
                         end
                         if repr(ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor) == '10' then
                                DrawLine({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color10 )
                         end
                      else
                                DrawLinePop({2684.5, 63.96, 489.5}, {2682.5, 63.96, 514.5}, Color0 )
                                DrawLinePop({2682.5, 63.96, 514.5}, {2684.5, 63.96, 489.5}, Color0 )
                      end
                   end
                end   
            end
        end
        WaitSeconds(0) -- waits 5 second. Can be reduced to 1 tick if needed
   end
end

Statistics: Posted by Ghoustaq — 30 Apr 2018, 21:00


]]>
2018-04-30T17:57:52+02:00 2018-04-30T17:57:52+02:00 /viewtopic.php?t=16141&p=163015#p163015 <![CDATA[Re: How to get the color of an army?]]>
Anihilnine wrote:
what are you making ghost?


In brief, it's a map based on the wars between the ancient states in history

In my design, the boundary of a state should adjust to its expansion or contraction just like what happens in the game "Total War".

Statistics: Posted by Ghoustaq — 30 Apr 2018, 17:57


]]>
2018-04-30T16:09:07+02:00 2018-04-30T16:09:07+02:00 /viewtopic.php?t=16141&p=163014#p163014 <![CDATA[Re: How to get the color of an army?]]>
CookieNoob wrote:
In case the hint from speed wasnt sufficient:

Code:
determineArmyColor = function (self)
    local tblArmy = ListArmies()
    local army = self:GetArmy()      -- or whatever way is needed in your case
    return ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor
end


I was lazy to code/test, but I dont think this will work, the format in the ArmySetup table is "ARMY_1" etc, while ListArmies() gives a table of armies' indexes (numbers).

But I guess that's up to OP to test and learn anyway :D

Statistics: Posted by speed2 — 30 Apr 2018, 16:09


]]>
2018-04-30T13:07:30+02:00 2018-04-30T13:07:30+02:00 /viewtopic.php?t=16141&p=163009#p163009 <![CDATA[Re: How to get the color of an army?]]>
Code:
determineArmyColor = function (self)
    local tblArmy = ListArmies()
    local army = self:GetArmy()      -- or whatever way is needed in your case
    return ScenarioInfo.ArmySetup[tblArmy[army]].ArmyColor
end

Statistics: Posted by CookieNoob — 30 Apr 2018, 13:07


]]>
2018-04-29T08:26:35+02:00 2018-04-29T08:26:35+02:00 /viewtopic.php?t=16141&p=162978#p162978 <![CDATA[Re: How to get the color of an army?]]> Statistics: Posted by nine2 — 29 Apr 2018, 08:26


]]>
2018-04-29T07:14:58+02:00 2018-04-29T07:14:58+02:00 /viewtopic.php?t=16141&p=162977#p162977 <![CDATA[Re: How to get the color of an army?]]> Statistics: Posted by speed2 — 29 Apr 2018, 07:14


]]>
2018-04-28T20:37:46+02:00 2018-04-28T20:37:46+02:00 /viewtopic.php?t=16141&p=162973#p162973 <![CDATA[How to get the color of an army?]]>
Only "SetArmyColor" exists. I tried to search on the github, but there's no answer to this.

I want to draw some lines around an area to form a boundary with the color of one player's army and the color should change if another army takes control of this area. But I don't know how to get ARMY's color. :roll:

That's all.

Statistics: Posted by Ghoustaq — 28 Apr 2018, 20:37


]]>