1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Promotions Displayed with Unit Icon

Discussion in 'Civ5 - Mod Components' started by xienwolf, Oct 7, 2010.

  1. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Not sure what the standard style will be for mod distribution, since Modbuddy lets us put them out in the world unannounced and undiscussed, but I figure a thread for feedback is always better :)

    In User Interface-Other you will find my Mod "FlagPromotions"

    This is a fairly simple little modcomp which lets the promotions on a unit be seen along with the unit model on the map itself. I personally found it annoying in a large battle to have to remember which units were my veterans and which were the cannon fodder, or which Archer could shoot over a mountain and which had to walk around. Seeing the promotions on enemies was even MORE annoying since I had to mouse over them and then remember what the promotion on that unit actually DOES.


    Since I referred to Kael's guide to set this up in Modbuddy (originally I just modified the base files directly, fortunately that happened to be basically needed anyway) and I saw he had an example which is nearly EXACTLY what I was doing (code point of view, not game effect), I have included his little modcomp to disable the unit icons along with this. Note that disabling the icons also disables the promotions though.

    In addition to using Kael's mod to disable the icons completely, you also have an option to disable only the added promotion display piece (might be nice if things start to get cluttered). You can select the unit by clicking on any of their promotions, and you can do a mouseover of the promotions to see a description if you desire.

    Limitations:

    Only 9 promotions are displayed per unit. So the first 8 by SQL table order, and then the last one after that (if more than 9 on the unit) will show up. Eventually I'll look at changing that (make it variable on-the-fly, or at least make it so the user can easily select the max number themselves), and also allowing an XML tag to define a promotion as "not worth showing" since there are many which you honestly don't care about seeing (like "Can Embark").

    The Promotions won't "move" with the Unit Icon for special cases like stacking a Military and Civilian unit on a tile, or setting up Garrison in a city. This is also something I can clean up, but I am going to try and make the mod into a completely new file so it isn't prone to conflicting with other people's work (like Kael's small mod) so setting up adjustments will come after that sometime.
     

    Attached Files:

  2. Zuul

    Zuul Mod lister!

    Joined:
    Nov 13, 2005
    Messages:
    1,117
    Location:
    Sweden
    Nice, but maybe they could be displayed in half size if possible?
     
  3. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
  4. MisterBenn

    MisterBenn Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    126
    It's a great concept but I agree it probably needs shrinking. Perhaps only user-selected promotions should be displayed?

    A variation might be to have a tiny rank symbol to indicate a unit's level as it gains experience.
     
  5. nebnotrub

    nebnotrub Chieftain

    Joined:
    May 26, 2010
    Messages:
    11
    Nice mod. Would it be possible to make it so you could turn it on/off with a hotkey rather than having to open and click the panel?
     
  6. gruven

    gruven Chieftain

    Joined:
    May 12, 2010
    Messages:
    75
    Very nice.
    Would it be possible to hide the "demotions" or are they indistinguishable from promotions to the games's code? It would save space if the game wasn't reminding us that archers can not melee attack, horsemen don't get defensive terrain bonuses, etc.
     
  7. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    They are all handled with the same code. I actually dislike how they used the same icons for all of them anyways, it means you can't tell what's what at a glance anymore.
     
  8. BomberEscort

    BomberEscort Don't be alarmed; this is a kindness

    Joined:
    Jul 28, 2003
    Messages:
    1,102
    Gender:
    Male
    Location:
    Kansas City
    I was hoping there would be mods that changed the graphics of the promotion icon from the triangles to something that could be visually recognized. This game smacks of "I ran out of budget". Some promotion icons are complete, some are triangles; some battles you can see the odds, some battles you can't...
     
  9. Erendir

    Erendir Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    59
    This is easily done, You have to modify the UnitFlagManager.lua:
    add this code after line 49:

    Code:
    [COLOR="Grey"]--[[ End Modify ]][/COLOR]
    
    --[[ Modified by Erendir ]]
    --[[ Filter Promotions by Type ]]
    local ignoredPromotionType = {
        PROMOTION_OCEAN_IMPASSABLE = true,
        PROMOTION_GREAT_GENERAL = true,
        -- feel free to adjust this list
    }
    --[[ End Modify ]]
    
    [COLOR="Grey"]local g_UnitFlagClass = [/COLOR]
    
    (i greyed out what should be just before and after the new code).

    Now find the code (line 329)
    Code:
    if (unit:IsHasPromotion(unitPromotionID)) then
    and change it to
    Code:
    if [B]not ignoredPromotionType[unitPromotion.Type] and[/B] (unit:IsHasPromotion(unitPromotionID)) then --[[ Modified by Erendir ]]
    that's all. Now You can easily modify the ignoredPromotionType table, by simply adding lines like
    Code:
    PROMOTION_EMBARKATION = true[B],[/B]
    
    (don't forget the comma!)

    The list of all promotion types here:
    Spoiler :
    PROMOTION_INSTA_HEAL Heal Instantly
    PROMOTION_SHOCK_1 Shock I
    PROMOTION_SHOCK_2 Shock II
    PROMOTION_SHOCK_3 Shock III
    PROMOTION_DRILL_1 Drill I
    PROMOTION_DRILL_2 Drill II
    PROMOTION_DRILL_3 Drill III
    PROMOTION_ACCURACY_1 Accuracy I
    PROMOTION_ACCURACY_2 Accuracy II
    PROMOTION_ACCURACY_3 Accuracy III
    PROMOTION_BARRAGE_1 Barrage I
    PROMOTION_BARRAGE_2 Barrage II
    PROMOTION_BARRAGE_3 Barrage III
    PROMOTION_TARGETING_1 Targeting I
    PROMOTION_TARGETING_2 Targeting II
    PROMOTION_TARGETING_3 Targeting III
    PROMOTION_SENTRY Sentry
    PROMOTION_SIEGE Siege
    PROMOTION_VOLLEY Volley
    PROMOTION_MEDIC Medic
    PROMOTION_AMPHIBIOUS Amphibious
    PROMOTION_COVER_1 Cover I
    PROMOTION_COVER_2 Cover II
    PROMOTION_INDIRECT_FIRE Indirect Fire
    PROMOTION_CHARGE Charge
    PROMOTION_FORMATION_1 Formation I
    PROMOTION_FORMATION_2 Formation II
    PROMOTION_AMBUSH_1 Ambush I
    PROMOTION_AMBUSH_2 Ambush II
    PROMOTION_SUPPLY Supply
    PROMOTION_MARCH March
    PROMOTION_BLITZ Blitz
    PROMOTION_WOODSMAN Woodsman
    PROMOTION_LOGISTICS Logistics
    PROMOTION_RANGE Range
    PROMOTION_MOBILITY Mobility
    PROMOTION_INTERCEPTION_1 Interception I
    PROMOTION_INTERCEPTION_2 Interception II
    PROMOTION_INTERCEPTION_3 Interception III
    PROMOTION_DOGFIGHTING_1 Dogfighting I
    PROMOTION_DOGFIGHTING_2 Dogfighting II
    PROMOTION_DOGFIGHTING_3 Dogfighting III
    PROMOTION_AIR_SIEGE_1 Siege I
    PROMOTION_AIR_SIEGE_2 Siege II
    PROMOTION_AIR_SIEGE_3 Siege III
    PROMOTION_BOMBARDMENT_1 Bombardment I
    PROMOTION_BOMBARDMENT_2 Bombardment II
    PROMOTION_BOMBARDMENT_3 Bombardment III
    PROMOTION_AIR_TARGETING_1 Targeting I
    PROMOTION_AIR_TARGETING_2 Targeting II
    PROMOTION_AIR_AMBUSH_1 Ambush I
    PROMOTION_AIR_AMBUSH_2 Ambush II
    PROMOTION_AIR_RANGE Range
    PROMOTION_SORTIE Sortie
    PROMOTION_REPAIR Repair
    PROMOTION_AIR_REPAIR Air Repair
    PROMOTION_AIR_LOGISTICS Logistics
    PROMOTION_EVASION Evasion
    PROMOTION_SCOUTING_1 Scouting I
    PROMOTION_SCOUTING_2 Scouting II
    PROMOTION_SCOUTING_3 Scouting III
    PROMOTION_SURVIVALISM_1 Survivalism I
    PROMOTION_SURVIVALISM_2 Survivalism II
    PROMOTION_SURVIVALISM_3 Survivalism III
    PROMOTION_HELI_AMBUSH_1 Ambush I
    PROMOTION_HELI_AMBUSH_2 Ambush II
    PROMOTION_HELI_MOBILITY_1 Mobility I
    PROMOTION_HELI_MOBILITY_2 Mobility II
    PROMOTION_HELI_REPAIR Repair
    PROMOTION_MORALE Morale
    PROMOTION_ADJACENT_BONUS Discipline
    PROMOTION_OLIGARCHY Oligarchy
    PROMOTION_HIMEJI_CASTLE Himeji Castle
    PROMOTION_NAVAL_TRADITION Naval Tradition
    PROMOTION_GREAT_LIGHTHOUSE Great Lighthouse
    PROMOTION_NATIONALISM Nationalism
    PROMOTION_EMBARKATION Embarkation
    PROMOTION_DEFENSIVE_EMBARKATION Embarkation with Defense
    PROMOTION_EXTRA_MOVES_I 1 Extra Movement
    PROMOTION_EXTRA_SIGHT_I Extra Sight (1)
    PROMOTION_EXTRA_SIGHT_II Extra Sight (2)
    PROMOTION_EXTRA_SIGHT_III Extra Sight (3)
    PROMOTION_EXTRA_SIGHT_IV Extra Sight (4)
    PROMOTION_SIGHT_PENALTY Limited Visibility
    PROMOTION_AIR_RECON Air Recon
    PROMOTION_ANTI_MOUNTED_I Bonus vs Mounted (50)
    PROMOTION_ANTI_MOUNTED_II Bonus vs Mounted (100)
    PROMOTION_CITY_SIEGE Demolish
    PROMOTION_CITY_ASSAULT Bonus vs Cities (30)
    PROMOTION_DEFENSE_PENALTY Penalty on Defense (50)
    PROMOTION_MOUNTED_PENALTY Penalty vs Mounted (50)
    PROMOTION_CITY_PENALTY Penalty Attacking Cities (33)
    PROMOTION_SMALL_CITY_PENALTY Penalty Attacking Cities (25)
    PROMOTION_INTERCEPTION_I Interception (20)
    PROMOTION_INTERCEPTION_II Interception (40)
    PROMOTION_INTERCEPTION_III Interception (50)
    PROMOTION_INTERCEPTION_IV Interception (100)
    PROMOTION_AIR_SWEEP Air Sweep
    PROMOTION_WEAK_RANGED Ground Attack Penalty (75)
    PROMOTION_ANTI_AIR Bonus vs Aircraft (100)
    PROMOTION_ANTI_HELICOPTER Bonus vs Helicopters (100)
    PROMOTION_ANTI_FIGHTER Bonus vs Fighters (50)
    PROMOTION_ANTI_SUBMARINE_I Bonus vs Submarines (50)
    PROMOTION_ANTI_SUBMARINE_II Bonus vs Submarines (100)
    PROMOTION_ANTI_TANK Bonus vs Tanks (100)
    PROMOTION_EVASION_I Evasion (50)
    PROMOTION_EVASION_II Evasion (100)
    PROMOTION_NAVAL_PENALTY Penalty vs Naval (50)
    PROMOTION_RIVAL_TERRITORY Can Enter Rival Territory
    PROMOTION_CARGO_I Can Carry 1 Cargo
    PROMOTION_CARGO_II Can Carry 2 Cargo
    PROMOTION_CARGO_III Can Carry 3 Cargo
    PROMOTION_CARGO_IV Can Carry 4 Cargo
    PROMOTION_FOLIAGE_IMPASSABLE Cannot Enter Forest or Jungle
    PROMOTION_ROUGH_TERRAIN_ENDS_TURN Rough Terrain Penalty
    PROMOTION_OCEAN_IMPASSABLE_UNTIL_ASTRONOMY Astronomy Needed
    PROMOTION_OCEAN_IMPASSABLE Cannot Enter Deep Ocean
    PROMOTION_INVISIBLE_SUBMARINE Is Invisible (Submarine)
    PROMOTION_SEE_INVISIBLE_SUBMARINE Can See Submarines
    PROMOTION_IGNORE_TERRAIN_COST Ignores Terrain Cost
    PROMOTION_HOVERING_UNIT Hovering Unit
    PROMOTION_FLAT_MOVEMENT_COST All Tiles Cost 1 Move
    PROMOTION_CAN_MOVE_IMPASSABLE May Enter Ice Tiles
    PROMOTION_NO_CAPTURE Unable to Capture Cities
    PROMOTION_ONLY_DEFENSIVE May Not Melee Attack
    PROMOTION_NO_DEFENSIVE_BONUSES No Defensive Terrain Bonuses
    PROMOTION_PARADROP May Paradrop
    PROMOTION_MUST_SET_UP Must Set Up to Ranged Attack
    PROMOTION_RANGED_SUPPORT_FIRE Ranged Support Fire
    PROMOTION_CAN_MOVE_AFTER_ATTACKING Can Move After Attacking
    PROMOTION_OPEN_TERRAIN Combat Bonus in Open Terrain
    PROMOTION_SECOND_ATTACK May Attack Twice
    PROMOTION_OCEAN_MOVEMENT Naval Movement
    PROMOTION_GREAT_GENERAL Leadership
    PROMOTION_SPAWN_GENERALS_I Great Generals I
    PROMOTION_SPAWN_GENERALS_II Great Generals II
    PROMOTION_FREE_PILLAGE_MOVES No Movement Cost to Pillage
    PROMOTION_HEAL_IF_DESTROY_ENEMY Heal if Destroy an Enemy
    PROMOTION_PARTIAL_HEAL_IF_DESTROY_ENEMY Heals 2 Damage If Kills a Unit
    PROMOTION_ATTACK_BONUS Combat Bonus When Attacking (25)
    PROMOTION_MOHAWK Combat Bonus in Forest/Jungle (50)
    PROMOTION_JAGUAR Combat Bonus in Jungle only (50)
    PROMOTION_FOREIGN_LANDS Foreign Lands Bonus (20)
    PROMOTION_FASTER_HEAL Heals at Double Rate
    PROMOTION_STRONGER_VS_DAMAGED Damaged Enemy Bonus
    PROMOTION_WITHDRAW_BEFORE_MELEE Withdraw Before Melee
    PROMOTION_MEDIC_GENERAL Enhanced Medic
    PROMOTION_GAIN_EXPERIENCE Quick Study
    PROMOTION_ANTI_CAVALRY Bonus vs Cavalry (100)
    PROMOTION_ANTI_MOUNTED_III Bonus vs Mounted (100)
    PROMOTION_COVER_PENALTY Penalty vs Ranged (10)
    PROMOTION_HOPLITE Bonus vs Mounted (50)
    PROMOTION_POPULISM Populism
     
  10. xienwolf

    xienwolf Chieftain

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Quite possible, and fairly simple. I recently put in a new harddrive though, so right now don't even have Steam, let alone Civ 5 and all of the modding framework >< But since the system is already set up to be toggled, you just have to add a second way in which to toggle it. So find ANY example of adding a hotkey to the game and you should be able to set things up in moments.

    Erendir has quite a nice solution for you. I just wanted to pipe in that personally I would hide any promotion which you don't acquire via spending XP when you level up. Some aren't "demotions" but are still quite useless to see since ALL of those units have it. And others (embarkation comes to mind) are absolutely nothing but annoying clutter.
     
  11. Erendir

    Erendir Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    59
    I made a new improved version of this mod.
    Player-view features:

    • in-game options menu, with options stored between sessions -- no need to edit any lua file to amend visible promotions.
    • promotions like shock I,II,III are shown only once (the highest level)
    Screenshots (big size!):
    Spoiler :













    Modder-view features:

    • the are as few changes on core files, as was possible: MiniMapPanel.xml is unchanged, in UnitFlagManager.lua are changed 3 lines (remover local keyword), and only 2 uncommented lines added (1 of them can be removed). Look at diff
      Spoiler :
      Code:
      9,10c9
      < g_MasterList = {}; --@was: local -- Modified by Erendir
      < local g_MasterList = g_MasterList; -- local link to the global table -- Added by Erendir
      ---
      > local g_MasterList = {};
      14c13
      < g_GarrisonedUnitFlagsInStrategicView = true; --@was: local -- Modified by Erendir
      ---
      > local g_GarrisonedUnitFlagsInStrategicView = true;
      36,37c35
      < -- Modified by Erendir
      < g_UnitFlagClass =  --@was: local -- Modified by Erendir
      ---
      > local g_UnitFlagClass =
      1507,1510d1504
      <
      < -- Added by Erendir
      < include"UnitFlagManager_addin"
      < -- End Add
    • unfortunally, i found no possibility to leave UnitFlagManager.xml untouched.
    I hope, it's easily integrated in any other mod.

    This is alpha, because it's was not enough tested.
    To install, simply place the FlagPromotions__v_2_.civ5mod file in your \My Games\Sid Meier's Civilization 5\MODS\ directory.
    This version of the mod is currently NOT available anywhere else.
     

    Attached Files:

  12. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    Where is the options menu opened from?
     
  13. Mentos

    Mentos Prince

    Joined:
    Sep 29, 2010
    Messages:
    377
    I also think that showing only the additionally earned combat-relevant promotions is enough.
    This easier distinguishes between new built units and experienced ones.

    I guess it would be too much to ask if the tooltip info of e.g. Shock III icon would also include the cumulative bonus of I and II too.
    Doesn't matter, saving some icons is already nice enough!

    PS: Ehm, call me a newb but I can't install Erendir's civ5mod file somehow.
     
  14. Erendir

    Erendir Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    59
    oh, i indeed forget to mention this: right click on "Unit Promotions", the last item in minimaps sidemenu.

    just disable all the others. (It's possibly to catch your promotion-choices at level up, and so let the game know, what promotions a unit earned for xp, but not for ai-players - or i don't know the way. So just disable what You don't need...)
    look at the last screenshot in my prev post. Or do you mean to show the sum of bonus damage, like in "All Promotions description tooltip" ? This isn't so simple, but possible (or just copy that part of code)

    You can always simply unpack the file -- it's a 7z-archive -- to the MODS folder.
     
  15. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    Instead of the Right Click options menu, which is hardly intuitive, I suggest adding a button to the DiploCorner using alpaca's diplocorner addin tool. It will still be 100% workable with other mods this way.
     
  16. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    I really like this!

    It's worthwhile to make accessing the options more clear, though I'm not sure compatibility would be improved much - it still wouldn't work with other mods altering unit flags.

    I've attached an updated ModUserData.lua with a loop that automatically default-hides any promotion that is unit attribute and not a special UU attribute. Attributes are things like ranged units "cannot attack in melee" that are obvious by looking at the unit, and there's dozens of them so it takes a while to disable them all with manual clicks.

    I also added a "resetToDefaults" parameter to the updateIgnoredPromotions() function, and cleaned up the code a bit in this file (it's possible to use "for promotion in GameInfo.UnitPromotions()" to loop them instead of a sql query).
     

    Attached Files:

  17. Erendir

    Erendir Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    59
    Nice someone finds it useful :)

    there're some typos, like PROMOTION_ForEIGN_LANDS and TXT_KEY_PROMOTION_GAIN_EXPERIENCE
    Here's corrected version:
    Spoiler :
    Code:
    -- ModUserData
    -- Author: Erendir
    -- DateCreated: 1/23/2011 12:36:56 PM
    --------------------------------------------------------------
    local _VERBOSE = false
    local print
    if not _VERBOSE then print = function() end end
    
    ModID        = "44311931-9c7a-4f55-b465-7dc8d814e24d";
    ModVersion    = Modding.GetActivatedModVersion(ModID) or 2;
    ModUserData = Modding.OpenUserData(ModID, ModVersion);
    
    default_ignoredPromotion = {}
    for promotionType in GameInfo.UnitPromotions() do
        if promotionType.PediaType == "PEDIA_ATTRIBUTES" then
            default_ignoredPromotion[promotionType.Type] = true
        end
    end
    default_ignoredPromotion["PROMOTION_JAGUAR"]                             = false --jaguar
    default_ignoredPromotion["PROMOTION_PARTIAL_HEAL_IF_DESTROY_ENEMY"]     = false --jaguar
    default_ignoredPromotion["PROMOTION_FASTER_HEAL"]                         = false --immortal
    default_ignoredPromotion["PROMOTION_MOHAWK"]                             = false --mohawk
    default_ignoredPromotion["PROMOTION_SPAWN_GENERALS_I"]                     = false --companion cavalry
    default_ignoredPromotion["PROMOTION_ANTI_MOUNTED_I"]                     = false --siamese elephant
    default_ignoredPromotion["PROMOTION_CITY_ASSAULT"]                         = false --songhai cavalry
    default_ignoredPromotion["PROMOTION_SECOND_ATTACK"]                     = false --chu-ko-nu
    default_ignoredPromotion["PROMOTION_SPAWN_GENERALS_II"]                 = false --samurai
    default_ignoredPromotion["PROMOTION_IGNORE_TERRAIN_COST"]                 = false --minuteman
    default_ignoredPromotion["PROMOTION_HEAL_IF_DESTROY_ENEMY"]             = false --janissary
    default_ignoredPromotion["PROMOTION_FREE_PILLAGE_MOVES"]                 = false --sipahi
    default_ignoredPromotion["PROMOTION_EXTRA_SIGHT_I"]                     = false --sipahi
    default_ignoredPromotion["PROMOTION_STRONGER_VS_DAMAGED"]                 = false --cossak
    default_ignoredPromotion["PROMOTION_FOREIGN_LANDS"]                     = false --foreign legion
    default_ignoredPromotion["PROMOTION_ANTI_FIGHTER"]                         = false --zero
    default_ignoredPromotion["PROMOTION_EXTRA_SIGHT_I"]                     = false --ship of the line
    default_ignoredPromotion["PROMOTION_IGNORE_TERRAIN_COST"]                 = false --scout
    default_ignoredPromotion["PROMOTION_GAIN_EXPERIENCE"]                     = false --keshik
        
    ignorePromotion = {}
    
    function updateIgnoredPromotions(resetToDefaults)
        print'updateIgnoredPromotions'
        -- get list of ignored promotion from ModUserData
        for promotion in GameInfo.UnitPromotions() do
            local id = promotion.ID
            local ignore = ModUserData.GetValue(id)
            if ignore == nil or resetToDefaults then
                ignore = default_ignoredPromotion[promotion.Type];
                ModUserData.SetValue(id, ignore and 0 or 1)
            else
                ignore = (ignore == 0) and true or false
            end
            ignorePromotion[id]=ignore
            --if ignore~=nil then print(string.format('ignorePromotion[%d]=%s', id, tostring(ignore))) end
        end
    end
    updateIgnoredPromotions ()
    --updateIgnoredPromotions (true) -- resets to defaults


    i know, i just thought a SQL-query is better for performance: i'm pretty sure the GameInfo.UnitPromotions is defined like this:
    Code:
    GameInfo.UnitPromotions = function ()
        return DB.Query"select * from UnitPromotions"
    end
    
    and using it directly may save some memory and CPU-time. Of cause this needs benchmarking, but i'm sure this loop:
    Code:
    for promotionType in GameInfo.UnitPromotions() do
        if promotionType.PediaType == "PEDIA_ATTRIBUTES" then
            default_ignoredPromotion[promotionType.Type] = true
        end
    end
    is slower than this one:
    Code:
    for promotionType in DB.Query"select * from UnitPromotions where PediaType='PEDIA_ATTRIBUTES'" do
            default_ignoredPromotion[promotionType.Type] = true
    end
    (and replacing * with Type will save another bit of memory used)

    request If someone makes icons for PROMOTION_MEDIC and PROMOTION_FASTER_HEAL (enchanced medic), i'll (try to) add them to the game.

    !!! there's a bug in UnitFlagManager_addin: line 232 is now
    Code:
            if unit 
    but should be
    Code:
            if [B]not[/B] unit 
     
  18. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    While possible, it might reading from a Lua table already imported from the database, which would only be memory access time. It's all hypothetical since we can't see the game's core code though. Either way the main thing is there's always the tradeoff in programming between performance and code readability. Most lua scripts have execution time in milliseconds (unless writing data to disk), and in today's world paying programmers cost more than performance, so I typically go for easily readable code. :thumbsup:

    I really like the concept of this mod so I put a few hours of work in to get it to match the unit panel. I think it only refreshed the icons when the option was toggled? Now there's just the matter of icon size... working on it.

    • Keeps up to date when a unit receives promotions.
    • Displays promotions when units become visible by leaving fog of war.
    • Defaults 'shared' category promotions to hidden in addition to non-UU attributes, though one exception that might be desired is Morale. In most of my games only a portion of my army has that promotion.
    • Fixed a few bugs here and there.
    Would it be acceptable if I include this mod in a package I'm putting together? If yall want to keep it independent I would understand. The only reason I ask is merging lua files can be a little tricky for CiV players unfamiliar with programming. :)
     
  19. Erendir

    Erendir Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    59
    I would really like to see this mod as part of Your package, as i'm using it :)

    Your improvements/fixes are good, also if i disagree with disabling my performance tweaks...
    As of shared promotions: i find it useful to see if an enemy has something like Oligarchy. I would say a checkbox is needed to turn shared promotions on/off at once. Another improvement i'm thinking of is to show "ignores terrain cost" promotion on all units except scout -- just to know, this archer/crossbowman/... is really fast.
     
  20. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    I think creating a new UI element for each mod when it's a simple on/off map display toggle like this one could quickly clutter the screen. Adding it the built-in minimap panel makes sense for something like this. I adjusted the tooltip slightly so the right-click option is prominently featured in green, capitalized text.

    Since there's a small number of 'shared' promotions they could be default-hidden or default-shown, either way would be alright for those. I'm not disagreeing with the performance adjustments either, they're a good idea. A good place to do so would probably be the UpdatePromotions main loop since it's run often, accessing the options screen and storing retrieving user data is more rare. :)

    FlagPromotions (v 3)


    I've created a new 16px size for the icons. It's a choice of 32px or 16px because texture processing in games usually goes in powers of 2, I suspect CiV has the same restriction. One challenge is Civ4's 0-1-2 icon style scaled better than CiV's 1-2-3 style. It's hard to distinguish CiV's ranks at smaller sizes. There's still a few icons using Civ4's method like Interception, but most don't. These are the 256px (civilopedia) and 16px (unit flags) below.

    For me at least, on the 16px size top row I can tell one rank from the next , but the bottom row icons all look the same.








    I've done some editing today on the graphics side of things to improve the presentation of the icons. My goal is to make them visually unobtrusive, yet clear to recognize when looking at. They're sharper ingame than the screenshot below because vBulletin automatically compresses images when viewed.

    I also found and fixed a minor bug opening the options menu, where it added everything to the list each time it's opened. RefreshFlagPromotionsOptions() only needed to be called once. :)

     

    Attached Files:

Share This Page