Removeable City Center Buildings

Remember the Mod you and Gedemon helped me with some Time ago, that disables Units from being able to be built if there are not enough of a second strategic resource (not maintenance resource)? I've got it to work without touching the ProductionPanel.lua. and it's a GameplayScript, so it affects also the AI. I still haven't finished it (the Concept/Design) but it works. You can have a look on this Thread, but it's not the finale code. So It should be possible to re-use it for Projects (using: pCity:GetBuildings():HasBuilding()...etc).
The reason it works as I recall is that you are using Player:GetUnits():SetBuildDisabled(eUnitIndex, Boolean) which is a direct command to the GameCore. I can't off the top of my head think of any equivalent for Projects. Nor by looking at both my and other people's accumulated documentation do I see a direct equivalent for Projects.

You can use City:GetBuildings():HasBuilding(iBuildingIndex) for all kinds of stuff but how are you going to use it to disable a project from showing on the UI without re-writing the UI file ? The Ai player in this case will not be bothered by "clutter" in the Production Panel list because the AI don't use it. The Gamecore just looks at whether they can do X at the moment in a given city and then it decides on whether or not to make that individual AI city actually do X.
 
The reason it works as I recall is that you are using Player:GetUnits():SetBuildDisabled(eUnitIndex, Boolean) which is a direct command to the GameCore. I can't off the top of my head think of any equivalent for Projects. Nor by looking at both my and other people's accumulated documentation do I see a direct equivalent for Projects.
Didn't know that it's stricted to Units. Good to know!
 
Last edited:
No luck so far finding an EffectType that is related to making a project valid, but currently I was last running vanilla only.

Re-enabling Rise and Storm expacs and then looking through the resulting GameEffects table doesn't show any EffectType related to making a project valid or invalid either, unfortunately. So straightforward direct database methods with a requirement of City Has Building won't do, either, to declutter the city Production Panel.

This game is both freaky scary and annoying: freaky scary it what it will allow by database methods and annoying in what it won't allow full-stop-period-do-not-pass-go.
 
Last edited:
No luck so far finding an EffectType that is related to making a project valid, but currently I was last running vanilla only.
Found this one "EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY". But the Projects that get available by it doesn't seem to have Traits or a column for being Inactive, where they then should be availablle from the start. (EX: PROJECT_COURT_FESTIVAL of Catherine the Magnificence, PROJECT_SEND_AID granted by aid requests)
 
Didn't know that it's stricted to Units. Good to know!
Whenever doing lua you have to bear in mind that the application of what is available is specific and in many cases limited to what Firaxis needed to accomplish an effect for a scenario or whatever.

So because there's a
Code:
Player:DoUnitThing()
available this does not mean there is a
Code:
Player:DoBuildingThing()
or
Code:
City:DoBuildingThing()
or whatever. You have to look up what is specifically available in the references people have made.

Those extra :D were not in the original text and were not intended -- thank you forum parser code.
 
Last edited:
Found this one "EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY". But the Projects that get available by it doesn't seem to have Traits or a column for being Inactive, where they then should be availablle from the start. (EX: PROJECT_COURT_FESTIVAL of Catherine the Magnificence, PROJECT_SEND_AID granted by aid requests)
Aha! I was fixating on the _ADJUST_ EffectTypes.

Of course the problem will be that it is a player-level rather than city-level EffectType, but the ModifierId that makes use of this EffectType can have a RequirementSetId that the player has to have the Tech or Civic that unlocks the building, which will make for a rather complicated SQL code. But it ought to be doable to at least reduce the city clutter of projects that are irrelevant until the player can first make the building.
 
Of course the problem will be that it is a player-level rather than city-level EffectType, but the ModifierId that makes use of this EffectType can have a RequirementSetId that the player has to have the Tech or Civic that unlocks the building, which will make for a rather complicated SQL code. But it ought to be doable to at least reduce the city clutter of projects that are irrelevant until the player can first make the building.
Why not making the Projects getting unlucked by their Buildings (The Buildings they will remove - using BuildingModifiers, with COLLECTION_OWNER_CITY)? That would do the Trick, or not?
 
A rough approximation with direct coding methods rather than SELECT FROM methods
Code:
-- these only need to be added once
INSERT OR REPLACE INTO Types (Type, Kind)
	VALUES	('MODIFIER_PLAYER_ALLOW_PROJECT_BUILDING_REMOVAL_LRS', 'KIND_MODIFIER');

INSERT OR REPLACE INTO DynamicModifiers (ModifierType, CollectionType, EffectType)
	VALUES	('MODIFIER_PLAYER_ALLOW_PROJECT_BUILDING_REMOVAL_LRS', 'COLLECTION_OWNER', 'EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY');

-- one each of these is needed for each Building Removal Project, re-using ModifierType 'MODIFIER_PLAYER_ALLOW_PROJECT_BUILDING_REMOVAL_LRS'
-- each of these individual setups needs its own ModifierId & SubjectSetRequirementId
-- the code does NOT include the method to attach these modifiers to all players, which will need an additional set of table inserts
-- it may also be necessary to use an OwnerRequirementSetId instead of 'Subject' -- the game is a bit strange sometimes as to when it wants Owner and when it wants Subject
INSERT OR REPLACE INTO Modifiers (ModifierType, ModifierId, SubjectSetRequirementId)
	VALUES	('MODIFIER_PLAYER_ALLOW_PROJECT_BUILDING_REMOVAL_LRS', 'MODIFIER_ALLOW_PROJECT_REMOVE_GRANARY_LRS', 'PLAYER_HAS_GRANARY_TECH_LRS');

INSERT OR REPLACE INTO ModifierArguments (ModifierId, Name, Value)
	VALUES	('MODIFIER_ALLOW_PROJECT_REMOVE_GRANARY_LRS', 'ProjectType', 'PROJECT_REMOVE_GRANARY_LRS');

INSERT OR REPLACE INTO Requirements (RequirementId, RequirementType)
	VALUES	('REQUIRES_PLAYER_HAS_POTTERY_LRS', 'REQUIREMENT_PLAYER_HAS_TECHNOLOGY');

INSERT OR REPLACE INTO RequirementArguments (RequirementId, Name, Value)
	VALUES	('REQUIRES_PLAYER_HAS_POTTERY_LRS', 'TechnologyType', 'TECH_POTTERY');

INSERT OR REPLACE INTO RequirementSets (RequirementSetId, RequirementSetType)
	VALUES	('PLAYER_HAS_GRANARY_TECH_LRS', 'REQUIREMENTSET_TEST_ALL')

INSERT OR REPLACE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
	VALUES	('PLAYER_HAS_GRANARY_TECH_LRS', 'REQUIRES_PLAYER_HAS_POTTERY_LRS')
Note the note about this example approach doesn't include the needed activation method of getting these modifiers attached to all players by a GameModifiers or by attaching them to all Major Players via for example the Default Leader trait.
 
Last edited:
Why not making the Projects getting unlucked by their Buildings (The Buildings they will remove - using BuildingModifiers, with COLLECTION_OWNER_CITY)? That would do the Trick, or not?
This might also work as compared to the possible method I just posted. Assuming the game don't have a circular logic meltdown. I think tho it would probably accept it.

Actually, no, I don't think so. EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY so I don't think the game would accept a collection for this EffectType other than COLLECTION_OWNER. But I've been wrong before and I'll be wrong again so it is at least worth a try assuming @DonCan94 wants to go through the effort of making the code and then the tests needed to see if it works for purposes of de-clutter of the interface that has no actual gameplay effect.
 
Actually, no, I don't think so. EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY so I don't think the game would accept a collection for this EffectType other than COLLECTION_OWNER. But I've been wrong before and I'll be wrong again so it is at least worth a try assuming @DonCan94 wants to go through the effort of making the code and then the tests needed to see if it works for purposes of de-clutter of the interface that has no actual gameplay effect.
I guess only a Test can give us the answer. If it works, then it's the handier Methode, If not then your Methode is still the optimal Solution.

BTW, could you take a look at this?
 
Have you thought about my suggestion of the Project Icons with faded colors? just a suggestion :D.

I thought about that after your suggestion, but for me I kinda prefer it the way it looks now.
But If you want I can provide you the files and you can adjust the icons in your taste :)
 
Actually, no, I don't think so. EFFECT_ADD_PLAYER_PROJECT_AVAILABILITY so I don't think the game would accept a collection for this EffectType other than COLLECTION_OWNER. But I've been wrong before and I'll be wrong again so it is at least worth a try assuming @DonCan94 wants to go through the effort of making the code and then the tests needed to see if it works for purposes of de-clutter of the interface that has no actual gameplay effect.


That's the thing. I'm pretty happy it works at all, given the limited time I had to create it. My holidays are over tomorrow and I have to go back to work, so I won't have much time from now on except on the weekends, and I prefer playing civ then ^^
 
I thought about that after your suggestion, but for me I kinda prefer it the way it looks now.
But If you want I can provide you the files and you can adjust the icons in your taste :)
Yeah, the Icons are clear. You don't have to change them.

Great Job with the Mod!
 
Top Bottom