Looking for Opinions on Difficulty

iamdanno

Warlord
Joined
Jan 16, 2012
Messages
196
Location
Oklahoma City, OK, USA
I would like to try to make a MOD that would show the list of Air Units in a city color-coded by health, so that selecting which to attack with would be more intuitive. I have never created my own MOD before, although I am familiar with the process. How difficult do you think it would be? I have no knowledge of LUA, or other programming languages, so hopefully could be done with XML only.

Thanks in Advance!
 
It can't be done in XML only, you'll have to do a bit of Lua for that.
 
That's what I suspected, but luckily it is not a big deal. Maybe someday I'll try to learn enough LUA to get it done.

Thanks for the quick reply.
 
You need to make a mod that replaces the UnitFlagManager.lua file (this is different for Vanilla and G&K, so you'll need to pick which one you want to start with)

attachment.php


Add UnitFlagManager.lua to the mod and set VFS=true (as you are replacing an existing file)

There are two changes needed, one for units on a carrier and one for units in a city (fortunately the changes are the same for Vanilla and G&K, unfortunately Firaxis didn't bother putting what is basically identical code for units on a carrier and units in a city in a single utility method!)

Code:
  -- we're carrying
  controlTable = {};
  self.m_CargoControls.PullDown:BuildEntry( "UnitInstance", controlTable );
                    
[COLOR="Magenta"]  local sHealth = ""
  local healthPercent = math.max(math.min(pPlotUnit:GetCurrHitPoints() / pPlotUnit:GetMaxHitPoints(), 1), 0)
  -- Only colour units with moves left and that are currently damaged - missiles, atomic bombs, etc will never be coloured
  if (pPlotUnit:MovesLeft() > 0 and healthPercent < 1) then
    if (healthPercent > 0.66) then
      sHealth = "[COLOR:0:255:0:255]"
    elseif (healthPercent > 0.33) then
      sHealth = "[COLOR:255:255:0:255]"
    else
      sHealth = "[COLOR:255:0:0:255]"
    end
  end
  controlTable.Button:SetText(string.format("%s%s[ENDCOLOR]", sHealth, pPlotUnit:GetName()));[/COLOR]

  controlTable.Button:SetVoids( self.m_playerID, pPlotUnit:GetID() );

Code:
  cityFlagInstance.PullDown:BuildEntry( "UnitInstance", controlTable );
                
  -- 
[COLOR="magenta"]  local sHealth = ""
  local healthPercent = math.max(math.min(pPlotUnit:GetCurrHitPoints() / pPlotUnit:GetMaxHitPoints(), 1), 0)
  -- Only colour units with moves left and that are currently damaged - missiles, atomic bombs, etc will never be coloured
  if (pPlotUnit:MovesLeft() > 0 and healthPercent < 1) then
    if (healthPercent > 0.66) then
      sHealth = "[COLOR:0:255:0:255]"
    elseif (healthPercent > 0.33) then
      sHealth = "[COLOR:255:255:0:255]"
    else
      sHealth = "[COLOR:255:0:0:255]"
    end
  end
  local unitName = string.format("%s%s[ENDCOLOR]", sHealth, pPlotUnit:GetName());[/COLOR]               

  local bw, bh = controlTable.Button:GetSizeVal();

The code you need to add/change is in magenta, the rest is so you can find where to make the two changes
 
Thanks, Whoward! That doesn't seem too complicated. I'll try it out when I get a moment. Hopefully all goes well.

On an unrelated topic, I have used many of your MODs, and have been very happy with them. Thanks for sharing your good work with all of us! :goodjob:
 
Just to follow-up, I tried this out and it worked just as your attachment showed. It works for all players, so now I can see what air units the enemy has, and how (un)healthy they are, which I didn't really think about ahead of time. Thanks again!
 
It works for all players, so now I can see what air units the enemy has, and how (un)healthy they are,

That ability to click on other players "air numbers" and see the list of units in a city/carrier is really a bug that should be removed IMHO.
 
Can't have a spy on an aircraft carrier :mischief: Depending on how you consider the scale, in RL you could probably tell that information just with a good pair of binoculars, so maybe not a bug?
 
Can't have a spy on an aircraft carrier :mischief: Depending on how you consider the scale, in RL you could probably tell that information just with a good pair of binoculars, so maybe not a bug?

True, you can't have a spy in an aircraft carrier. But I was only talking about cities. Seeing aircraft units on carriers makes sense but in a city not so much.
 
It should be possible to see air units in any city at satellites tech, IMO. I also like the satellites allow city targeting without LOS idea, too. I use that mod always.
 
Back
Top Bottom