Creating a unit only available by upgrading

nrnwood

Chieftain
Joined
Dec 26, 2005
Messages
6
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
 
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
 
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
 
oops - POSTED THIS IN THE CIV 6 FORUM, can a Moderator please move this to the equivalent CIV 5 one?

Regards

Nigel
 
Moderator Action: thread moved
 
Red Key

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

Regards

Nigel
 
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)
 
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
 
Top Bottom