[GS] Stuck on checking requirements for modifying improvement yield

Yllnath

Chieftain
Joined
Jul 13, 2012
Messages
4
I want to add a modifier with SQL. I'm checking whether the plot is adjacent to the city center (or a village district I'm working on) and if it has either a farm, pasture, camp or fishingboat. In that case I want to give the tile another +1 food. (In the case of a mine or quarry, +1 prod and all other +1 gold) I'm stuck because of not being sure how to check whether the improvement is one of these 4 for food or one of the two for prod. There's a requirement that checks for PLOT_HAS_FARM or PLOT_HAS_ANY_IMPROVEMENT, etc. But the one I threw in the code below does not exist, of course.
Since I need to check for multiple requirements; adjacent to city center/village (and later on, if a building is present in the village) AND available improvement, I need to set the RequirementSetType to TEST_ALL.

Can a modifier in the modifier table have multiple requirementSetId's? One where there's a TEST_ALL for checking adjacency and another RequirementSetId for a TEST_ANY to check if any of the Farm/Pasture/Etc is true? Or is there another way of going about this?


Code:
INSERT INTO Modifiers
            (ModifierId,                                                        ModifierType,                                            SubjectRequirementSetId)
VALUES        ('IMPROVED_TILE_ADJACENCY_CITY_CENTER_BONUS_FOOD',                    'MODIFIER_SINGLE_PLOT_ADJUST_PLOT_YIELDS',                'REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER');


INSERT INTO ModifierArguments
            (ModifierId,                                                        Name,                    Value)
VALUES        ('IMPROVED_TILE_ADJACENCY_CITY_CENTER_BONUS_FOOD',                    'YieldType',            'YIELD_FOOD'),
            ('IMPROVED_TILE_ADJACENCY_CITY_CENTER_BONUS_FOOD',                    'Amount',                1);



INSERT INTO RequirementSets
            (RequirementSetId,                                                    RequirementSetType)
VALUES        ('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',                    'REQUIREMENTSET_TEST_ALL');

INSERT INTO RequirementSetRequirements  
            (RequirementSetId,                                                    RequirementId)
VALUES        ('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',                    'IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER'),
???
            ('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',                    'REQ_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT'),
???

INSERT INTO Requirements
            (RequirementId,                                                        RequirementType,                                        Inverse)
VALUES        ('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',                                'REQUIREMENT_PLOT_ADJACENT_DISTRICT_TYPE_MATCHES',        0);

INSERT INTO RequirementArguments
            (RequirementId,                                                        Name,                                                    Value)
VALUES        ('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',                                'DistrictType',                                            'DISTRICT_CITY_CENTER'),
            ('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',                                'MaxRange',                                                1);
 
So, I've had a thought an on alternative way to do this.

What about giving an Adjacency Yield of Food to the city center for farms and fishing boats? Same bonus, but given in the opposite direction.
 
Code:
INSERT INTO RequirementSets
	(RequirementSetId,						RequirementSetType)
VALUES	('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',		'REQUIREMENTSET_TEST_ALL')
	('REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT',	'REQUIREMENTSET_TEST_ANY');

INSERT INTO RequirementSetRequirements  
	(RequirementSetId,						RequirementId)
VALUES	('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',		'IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER'),
	('REQ_IMPROVED_TILE_IS_ADJACENT_TO_CITY_CENTER',		'REQUIRES_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT_SET'),
	('REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT',	'REQUIRES_IMPROVED_TILE_HAS_FARM'),
	('REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT',	'REQUIRES_IMPROVED_TILE_HAS_PASTURE'),
	('REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT',	'REQUIRES_IMPROVED_TILE_HAS_CAMP'),
	('REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT',	'REQUIRES_IMPROVED_TILE_HAS_FISHINGBOAT');

INSERT INTO Requirements
	(RequirementId,								RequirementType)
VALUES	('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',					'REQUIREMENT_PLOT_ADJACENT_DISTRICT_TYPE_MATCHES'),
	('REQUIRES_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT_SET',	'REQUIREMENT_REQUIREMENTSET_IS_MET'),
	('REQUIRES_IMPROVED_TILE_HAS_FARM',					'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES'),
	('REQUIRES_IMPROVED_TILE_HAS_PASTURE',					'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES'),
	('REQUIRES_IMPROVED_TILE_HAS_CAMP',					'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES'),
	('REQUIRES_IMPROVED_TILE_HAS_FISHINGBOAT',				'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES');


INSERT INTO RequirementArguments
	(RequirementId,								Name,			Value)
VALUES	('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',					'DistrictType',		'DISTRICT_CITY_CENTER'),
	('IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER',					'MaxRange',		1),
	('REQUIRES_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT_SET',	'RequirementSetId',	'REQSET_IMPROVED_TILE_HAS_FARM_PASTURE_CAMP_FISHINGBOAT'),
	('REQUIRES_IMPROVED_TILE_HAS_FARM',					'ImprovementType',	'IMPROVEMENT_FARM'),
	('REQUIRES_IMPROVED_TILE_HAS_PASTURE',					'ImprovementType',	'IMPROVEMENT_PASTURE'),
	('REQUIRES_IMPROVED_TILE_HAS_CAMP',					'ImprovementType',	'IMPROVEMENT_CAMP'),
	('REQUIRES_IMPROVED_TILE_HAS_FISHINGBOAT',				'ImprovementType',	'IMPROVEMENT_FISHING_BOATS');
You might need to give a MinRange of "1" in addition to the MaxRange for 'IMPROVED_TILE_IS_ADJ_TO_CITY_CENTER'.

And double-check that I've not missed any needed commas or semi-colons. I don't see any but usually you don't spot those mistakes within your own code for a while.
 
But the code given really depends entirely on how you are going to hook up the Modifier. If you are hooking it up via table ImprovementModifiers then the additional requirements are not needed because the Improvement Itself is its own Plot Improvement Match check.

If you are hooking up the Modifier by giving it to all of a player's plots, then the structure presented should work I would think. But you would need a different ModifierType since the one you are using is a single-plot modifier.
 
So, I've had a thought an on alternative way to do this.

What about giving an Adjacency Yield of Food to the city center for farms and fishing boats? Same bonus, but given in the opposite direction.

Im pretty new to civ 6 modding and barely know the DB structure aside from a few hours of tinkering yesterday. The way I chose to go about this was because of another mod I saw doing something somewhat similar with applying plot bonuses. But assigning adjacency yields sounds far more logical way to go about what I want. Is this supported in the game? Do you know of an example in the game or in mods that have set adjacency yields like that?

But the code given really depends entirely on how you are going to hook up the Modifier. If you are hooking it up via table ImprovementModifiers then the additional requirements are not needed because the Improvement Itself is its own Plot Improvement Match check.

I haven't looked at the ImprovementModifiers table yet. Perhaps there's a simpler way of going about giving bonus yields to adjacent city center plots. I'll look at it.

If you are hooking up the Modifier by giving it to all of a player's plots, then the structure presented should work I would think. But you would need a different ModifierType since the one you are using is a single-plot modifier.

I understand the two seperate requirementsets, that's where I was working towards as well. But I was stuck with the table Modifiers where I could only like a single modifier to a single requirementSet.
But you've already given me some food for thought. I'll play around with it some more. Cheers so far.
 
Back
Top Bottom