[GS] Building near resource

Riker13

King
Joined
Nov 9, 2001
Messages
859
Location
UK
Hi All,
I want to build a Stonemasons but only if Stone is in the city limits, is there a Modifier for that?
Any help or clues would be great.

*Edit: Just found AdjacentResource="RESOURCE_CATTLE" from Great Zimbabwe wonder, going to try that.
This will do as a temp measure but was after the whole city radius, any ideas?

Regards
Riker13:crazyeye:
 
Last edited:
lua cannot directly enable a building, but it can directly add a building to a city.

I have in fact written a mod for this very sort of thing, but I am still in the process of updating it to make sure it works correctly both with the latest patches and with the two expacs. RaF killed the mod and I had to re-work and re-draft.

What the mod does is adds a dummy building which the code of the mod hides from the player's view, and this dummy building then acts as the prerequisite for the "real" building. The lua code I have written for this is a bit complex but does allow for direct linkage between a building and a resource that is within the working tiles of a city.

--------------------------------------------------------------

All of the columns in the <Buldings> table that have to do with Adjacent Resources are for the placement rules of world wonders and need the "RequiresPlacement" Boolean to be set to true, which does not apply to buildings that are placed within a district (ie, have a PrereqDistrict setting).

These columns in table "Buildings" are only meant for use with World Wonders:

Code:
"AdjacentDistrict"
"RequiresPlacement"
"RequiresRiver"
"AdjacentResource"
"Coast"
"IsWonder"
"MustBeLake"
"MustNotBeLake"
"AdjacentToMountain"
"RequiresReligion"
"MustBeAdjacentLand"
"AdjacentCapital"
"AdjacentImprovement"

I cannot remember now whether column "CityAdjacentTerrain" is only meant for World Wonders since it is only used by Firaxis in one of the Scenarios and I can't remember which one at the moment.
 
Actually, it is possible to check if a city has stone within its borders with a clever use of 'REQUIREMENT_COLLECTION_COUNT_ATLEAST'. Here is an example that will create a requirement that tests if the owner's city has stone:
Code:
INSERT OR REPLACE INTO Requirements (RequirementId, RequirementType) VALUES
    ('REQUIRES_CITY_HAS_STONE', 'REQUIREMENT_COLLECTION_COUNT_ATLEAST');
INSERT OR REPLACE INTO RequirementArguments (RequirementId, Name, Value) VALUES
    ('REQUIRES_CITY_HAS_STONE', 'CollectionType', 'COLLECTION_CITY_PLOT_YIELDS'),
    ('REQUIRES_CITY_HAS_STONE', 'Count', '1'),
    ('REQUIRES_CITY_HAS_STONE', 'RequirementSetId', 'REQSET_PLOT_HAS_STONE');

INSERT OR REPLACE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
    ('REQSET_PLOT_HAS_STONE', 'REQUIREMENTSET_TEST_ALL');
INSERT OR REPLACE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
    ('REQSET_PLOT_HAS_STONE', 'REQUIRES_PLOT_HAS_STONE');
INSERT INTO Requirements (RequirementId, RequirementType) VALUES
    ('REQUIRES_PLOT_HAS_STONE', 'REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES');
INSERT OR REPLACE INTO RequirementArguments (RequirementId, Name, Value) VALUES
    ('REQUIRES_PLOT_HAS_STONE', 'ResourceType', 'RESOURCE_STONE');

The first part of the code checks all of the plots that belong to the city, and the requirement will be met if at least one of those plots meets the 'REQSET_PLOT_HAS_STONE' requirement set. The second part of the code just creates the 'REQSET_PLOT_HAS_STONE'. I haven't tested this specific code, but I use something similar for some of my mods and it's impressive how versatile the 'REQUIREMENT_COLLECTION_COUNT_ATLEAST' requirement type can be. I give credit to the folks behind Terra Miribalis for showing my how it can be used.
 
The issue has never been "Does the city have X resource on at least one of its plots?" It has always been how to allow construction of X building in that specific city because the city has Resource X and to disallow construction of the same building in any city that does not have Resource X.

Unless something has fundamentally changed with the release of GS or Rise and Fall, or as a result of one of the patches, there's no way via modifiers to directly allow or disallow the construction of the building via database modifier methods.

If you know of a new EffectType or CollectionType (or combination thereof) that will allow this I'd appreciate knowing which it is so I can investigate it and streamline the system I use to eliminate the need for lua and the incompatibility issues surrounding use of lua vis-à-vis other mods that re-write base UI lua files (such as the current version of CQUI).
 
Thanks for your input ReggieB it is interesting what people can do with manipulating the code but as LesS has said it looks like it won't get what I need.
Thanks anyway.
 
Back
Top Bottom