1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Creating a unit only available by upgrading

Discussion in 'Civ5 - Creation & Customization' started by nrnwood, Feb 17, 2021.

  1. nrnwood

    nrnwood Chieftain

    Joined:
    Dec 26, 2005
    Messages:
    6
    Gender:
    Male
    Location:
    UK
    Please excuse me if this is a red herring.

    I am thinking about creating a new unit "Old Contemptibles" and WWi era British Infantry unit that can only be created by upgrading the Redcoat from
    3UC - Extra Components 2016-10-05

    The aim is to represent the very small pre 1914 British regular army.

    All new units raised in this era would then be the standard WW1 Infantry.

    I can see how to create the the unit and make the upgrade path, but I am not sure how to stop production and purchase of it.

    Any thoughts?

    Thank you
     
  2. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    I have experimented with a few ways of disabling unit build. Currently I am just using #1, and I think that would be best for your case also but I don't think I ever checked if you can still upgrade to the unit with that method. I remember still being allowed to upgrade to the unit with #2 or #3, so they could be backups.

    1. SQL - Create a trait but don't give that trait to any civs/leaders (or reuse TRAIT_CIVILIZATION_NO_PLAYER which is used on fisheries and city parks) and set the unit's TraitType to that trait.
    UPDATE Units SET TraitType = 'TRAIT_CIVILIZATION_NO_PLAYER' WHERE UnitType='UNIT_OLD_CONTEMPTIBLE';
    2. SQL - Use MODIFIER_PLAYER_UNIT_BUILD_DISABLED. Will probably not work with base game.
    3. LUA - SetBuildDisabled(). For more info see Objects tab of ChimpanG's Modding Companion: https://docs.google.com/spreadsheet...lkDACezu5-igfQkVcOxeE_KG0/edit#gid=1494828281
     
  3. nrnwood

    nrnwood Chieftain

    Joined:
    Dec 26, 2005
    Messages:
    6
    Gender:
    Male
    Location:
    UK
    Thank you, I didn't expect such a quick response.

    I am using Civ5 BNW so maybe option 2 will work, but i will experiment with all of them whilst I am build the 'UNIT_OLD_CONTEMPTIBLE' up from the concept to reality (and learn to make the graphics:lol:)

    I will keep you updated on the progress.

    Regards

    Nigel
     
  4. nrnwood

    nrnwood Chieftain

    Joined:
    Dec 26, 2005
    Messages:
    6
    Gender:
    Male
    Location:
    UK
    oops - POSTED THIS IN THE CIV 6 FORUM, can a Moderator please move this to the equivalent CIV 5 one?

    Regards

    Nigel
     
  5. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,683
    Location:
    France
    Moderator Action: thread moved
     
  6. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    My response was based on Civ6. Don't know for Civ5.
     
  7. nrnwood

    nrnwood Chieftain

    Joined:
    Dec 26, 2005
    Messages:
    6
    Gender:
    Male
    Location:
    UK
    Red Key

    I guessed that, but I will still explore your suggestions and let you know.

    Regards

    Nigel
     
  8. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    There are several ways with SQL / XML but all have their limitations.

    The Lua GameEvent PlayerCanTrain is your best bet

    Code:
    local iUnitRanger = GameInfoTypes.UNIT_RANGER
    
    GameEvents.PlayerCanTrain.Add(function(iPlayer, iUnit) 
      if (iUnit == iUnitRanger) then
        return false;
      end
    
      return true
    end)
    
     
    yepzer likes this.
  9. nrnwood

    nrnwood Chieftain

    Joined:
    Dec 26, 2005
    Messages:
    6
    Gender:
    Male
    Location:
    UK
    Thank you. Currently working on the project in this order:
    1 - Create OLD_CONTEMPTIBLE and make sure it does not overwrite WW1 GREAT WAR INFANTRY for England
    2 - Adapt Redcoat to upgrade to OLD_CONTEMPTIBLE
    3 - Shut down any possible creation route other than upgrade
    4 - Make new graphics for OLD_CONTEMPTIBLE
    Looking forward to this as it s my first mod :lol: all the others I have done are compilations to save time loading.

    Regards

    Nigel
     

Share This Page