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

How to Prevent Cargo Promotion Stacking?

Discussion in 'Civ5 - Creation & Customization' started by sman1975, Jul 10, 2017.

  1. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    Hello,

    The mod I'm working on has a group of units - in this case heavy capital ships. I'd like to allow the Battleship to carry 1 "missile" - which doesn't help much until Advanced Ballistics, so it shouldn't break the game. The Battleship will upgrade to the Missile Cruiser which can carry 3 missiles.

    To set this up, I would give the Battleship the PROMOTION_CARGO_I promotion, and the Missile Cruiser already has the PROMOTION_CARGO_III promotion from the normal game.

    The problem is the Battleship carries the Cargo 1 promotion when upgraded, so Missile Cruisers upgraded from Battleships can carry 4 missiles, but newly built Missile Cruisers will only carry 3.

    I'm thinking about changing the "LostWithUpgrade" on the Cargo promotions to TRUE so each unit would start with the same carrying capacity.

    Can anyone think of any circumstance where that breaks anything with other units? Or is there a better (preferably non-LUA) method to prevent these cargo promotions stacking?

    Thanks!
     
  2. Troller0001

    Troller0001 Not an actual Troll

    Joined:
    Mar 9, 2016
    Messages:
    730
    Gender:
    Male
    Location:
    The Netherlands
    That could work, though the Carrier and Nuclear sub seem to be using those same promotions (but have different SPECIALCARGO defined in the XML, where that special cargo are either nukes or planes).
    What you could do is add a new promotion, which functions exactly the same as PROMOTION_CARGO_I but does have the the LostWithUpgrade tag set to true. This prevents any issues with other units, even those that might be added by other modders.
     
  3. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    Thanks, @Troller0001. I hadn't considered that approach - creating a new series of cargo promotions for "my" units, and leaving the game's original set of cargo promotions alone. This would maximize compatibility in case someone wants to add more mods (that might rely on original cargo promotion behavior) while mine is active. You always seem to have such good suggestions!

    Now, it's on to figuring out how to get factories to use either coal or oil.... :crazyeye:
     
    Troller0001 likes this.
  4. Enginseer

    Enginseer Salientia of the Community Patch Supporter

    Joined:
    Nov 7, 2012
    Messages:
    3,215
    Gender:
    Male
    Location:
    Somewhere in California
    Two same de facto building with coal/oil requirement. Then having a MutuallyExclusiveGroup attached to those buildings.
     
  5. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    You really only want one factory, due to the XBuiltTriggersIdeologyChoice element in the factory's definition. I don't even want to think about how to use two buildings contributing to that...

    So, I was thinking of creating a "Oil Generator Station" and a "Coal Generator Station" - either of which would be a prereq for the factory. These buildings would be the ones that required resources to build - would be cheap to build so as not to slow things down too much.

    The problem is with the Building_ClassesNeededInCity table - if there are two BuildingClassType entries for the same BuildingType, the game sees those as an AND relationship, requiring both Generator Stations as a prereq.

    I thought about putting both Generator Stations into a single class that has no default building, but it's hard to structure the overrides if someone decides to add non-standard civs. I'm sure there's a SQL statement with the correct wildcards that would do this (assuming my mod loads last), but I haven't had time to research this enough. I'm really not even sure if the game allows two buildings in the same class available to all players.

    I've seen a thread discussing this, but the solution seemed to require LUA:

    https://forums.civfanatics.com/threads/or-requirements-for-buildings.543711/

    The problem is, it sounds like using LUA would require replacing the city build UI - which other mods like to do as well - which limits compatibility of my mod with others. Avoiding this is preferable, I think.

    I wonder if I can add the Factory to the city if I use the "FreeBuildingThisCity" element? Allow a player to build either Generator Station, and that will "give" the Factory to the city? Of course, I'd have to make the Generator Stations cost more than the factory - and make them mutually exclusive. Hmmm... Will have to do some testing on this...

    Was hoping someone out there had already solved this so I wouldn't have to - especially one that doesn't require CityCanConstruct.

    Guess I'll need to open a different thread on this - it's turning into a bit of a headache.... :wallbash:
     
    Last edited: Jul 11, 2017
  6. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    Actually, after more research (but not testing), it seems the Generator Stations would have to be the buildings that add all the production. The factory would need to become an almost dummy building. Prevents a player from building the Generator Station, then getting the factory and then selling the Generator Station and reclaiming the coal/oil. Would also need to change both generator buildings and factory to "never capture" and "nuke immune" so there wouldn't be a situation where the factory survives city capture/nuking while the Generator Stations did not - i.e. no free factories...

    Will test later today and post results.....
     
    Last edited: Jul 11, 2017
  7. Chrisy15

    Chrisy15 Flower, Beautiful

    Joined:
    Jul 9, 2015
    Messages:
    2,070
    There's code in Enlightenment Era that allows for OR building prereqs; it reduces the matter down to just making insertions into a table.
     
  8. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    I checked the code and you're right: enlightenment era does allow this, and fortunately without involving the production pop up. Will test it tomorrow.

    Thanks for the suggestion!
     
  9. sman1975

    sman1975 King

    Joined:
    Aug 27, 2016
    Messages:
    899
    Location:
    Dallas, TX
    On further review, I still have the same basic problem with the EE code - the relationship between the Factory and it's supporting (either oil or coal) Generator Station. If I use the EE building prereq OR code, I would still be able to sell the generator and reclaim the resource and still keep the factory. I'm still wanting to keep only 1 Factory type, so as to prevent the complicated issue of XBuiltTriggersIdeologyChoice (3 factories trigger Ideology - with more than 1 factory type, this gets tricky).

    So, after a bit of thinking... (no laughs please!) I think my plan is:
    - keep the normal factory (and it alone will be used with XBuiltTriggersIdeologyChoice)
    - Introduce a new Oil Factory (prereq tech Replaceable Parts) - but it has nothing to do with Ideology. It also has similar costs/production bumps as the normal Factory. It would also be buildable in a city without a factory.
    - Use the EE code to allow either the Factory or Oil Factory to be the prereq for the Solar Plant, Nuclear Plant, and Spaceship Factories

    The last bullet may be not needed. The mod I'm working on introduces 75 new buildings. I could probably find new prereq candidates for those 3 buildings so the OR function wouldn't be needed.

    Ugh. So much discussion. "A long climb for a short slide" we used to call it.... :lol:

    Thanks everyone for the suggestions!
     
    Last edited: Jul 12, 2017
    Troller0001 likes this.
  10. Chrisy15

    Chrisy15 Flower, Beautiful

    Joined:
    Jul 9, 2015
    Messages:
    2,070
    Alt ofc you could just remove the maintenance costs from the prereq buildings so that they can't be sold...
     
    sman1975 likes this.

Share This Page