AOE Housing from Factory

acluewithout

Deity
Joined
Dec 1, 2017
Messages
3,496
Hello

I'm working on a mod for mid / late game buildings.

I'd like to give Cities +1 Housing if they're within 6 Tiles of a Factory. I've written something with .sql, but my games crash when I run them. Does anyone know where I'm going wrong?

Code:
--MORE HOUSING

INSERT INTO DynamicModifiers (ModifierType, CollectionType, EffectType)
VALUES ("QNC_MODIFIER_ADJUST_CITY_POPULATION", "COLLECTION_PLAYER_CITIES", "EFFECT_ADJUST_CITY_HOUSING_FROM_GREAT_PEOPLE");

INSERT INTO Types (Type, Kind)
VALUES ("QNC_MODIFIER_ADJUST_CITY_POPULATION", "KIND_MODIFIER");

INSERT INTO BuildingModifiers (BuildingType, ModifierId) VALUES ("BUILDING_FACTORY", "QNC_FACTORY_AOE_HOUSINGBOOST");

INSERT INTO Modifiers (ModifierId, ModifierType, RunOnce, NewOnly, Permanent, OwnerRequirementSetId, SubjectRequirementSetId, OwnerStackLimit, SubjectStackLimit)
VALUES ("QNC_FACTORY_AOE_HOUSINGBOOST", "QNC_MODIFIER_ADJUST_CITY_POPULATION", 0, 0, 0, null, "QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", null, null);

INSERT INTO ModifierArguments (ModifierId, Name, Type, Value, Extra, SecondExtra) VALUES ("QNC_FACTORY_AOE_HOUSINGBOOST", "Amount", "ARGTYPE_IDENTITY", 100, null, null);

INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ("QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", "QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY");
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ("QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", "REQUIREMENTSET_TEST_ANY");

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "BuildingType", "ARGTYPE_IDENTITY", "BUILDING_FACTORY", null, null);

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "MaxRange", "ARGTYPE_IDENTITY", "6", null, null);

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "MinRange", "ARGTYPE_IDENTITY", "0", null, null);

--INSERT INTO Requirements (RequirementId, RequirementType, Likeliness, Impact, Inverse, Reverse, Persistent, ProgressWeight, Triggered)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "REQUIREMENT_PLOT_ADJACENT_BUILDING_TYPE_MATCHES", 0, 0, 0, 0, 0, 1, 0);

Note (0): I'm trying to using the effect "EFFECT_ADJUST_CITY_HOUSING_FROM_GREAT_PEOPLE" to boost housing, as I couldn't find anything else that would boost a City's housing (rather than boosting a Building's housing).

Note (1): I've set housing to 100, just so it's easier to see whether the code is working.

Note (2): @FearSunn I used your IZ mod as a starting point. If you have any comments, it would be very welcome.
 
Last edited:
I've also tried the following code, following the format for Colosseum (for AOE) and for Angkor Wat (for Housing). Again, it just keeps crashing.

Code:
--MORE HOUSING

INSERT INTO BuildingModifiers (BuildingType, ModifierId) VALUES ("BUILDING_FACTORY", "QNC_FACTORY_AOE_HOUSINGBOOST");

INSERT INTO Modifiers (ModifierId, ModifierType, RunOnce, NewOnly, Permanent, OwnerRequirementSetId, SubjectRequirementSetId, OwnerStackLimit, SubjectStackLimit)
VALUES ("QNC_FACTORY_AOE_HOUSINGBOOST", "MODIFIER_PLAYER_CITIES_ADJUST_BUILDING_HOUSING", 0, 0, 0, null, "QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", null, null);

INSERT INTO ModifierArguments (ModifierId, Name, Type, Value, Extra, SecondExtra) VALUES ("QNC_FACTORY_AOE_HOUSINGBOOST", "Amount", "ARGTYPE_IDENTITY", "100", null, null);

INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ("QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", "QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY");
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ("QNC_CITY_HAS_NEARBY_FACTORY_REQUIREMENTS", "REQUIREMENTSET_TEST_ANY");

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "BuildingType", "ARGTYPE_IDENTITY", "BUILDING_FACTORY", null, null);

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "MaxRange", "ARGTYPE_IDENTITY", "6", null, null);

--INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "MinRange", "ARGTYPE_IDENTITY", "0", null, null);

--INSERT INTO Requirements (RequirementId, RequirementType, Likeliness, Impact, Inverse, Reverse, Persistent, ProgressWeight, Triggered)
--VALUES ("QNC_REQUIRES_CITY_HAS_NEARBY_FACTORY", "REQUIREMENT_PLOT_ADJACENT_BUILDING_TYPE_MATCHES", 0, 0, 0, 0, 0, 1, 0);
 
I’m wondering if maybe REQUIREMENT_PLOT_ADJACENT_BUILDINGS_TYPE only works for buildings with a single instance, eg Colosseum and ToA. Does this seem right to anyone?

If that’s right, then I guess my only option is Lua...
 
The first thing you need to do is cure your errors in the database. Both your quoted chunks of code have your insert into the Requirements table commented-out. This results in an invalid reference error and a return to the main menu. Your RequirementArguments are also all commented out, so the game will not be able to "test" anything against anything to satisfy your entry in the RequirementSets table.

When you get the pop-up about disabling mods or are otherwise shoved back to the game's main menu when attempting to run a mod, it is because your database code is not correct. It either has syntax errors or is missing needed data in one or more tables. The very first thing to do is to look in file Database.log to see what errors are being reported.

You have to fix database issues 1st before you can do anything else. Whether or not the game will implement a Great Person Area of Effect effect for a Building or a District is an entirely different issue to not having problems in your database code. You can have a 100% perfect set of database code and the game may still not implement a desired effect simply because the designers at Firaxis never coded the game's executing DLL to apply a given effect-type for a Building.
 
The first thing you need to do is cure your errors in the database. Both your quoted chunks of code have your insert into the Requirements table commented-out. This results in an invalid reference error and a return to the main menu. Your RequirementArguments are also all commented out, so the game will not be able to "test" anything against anything to satisfy your entry in the RequirementSets table.

When you get the pop-up about disabling mods or are otherwise shoved back to the game's main menu when attempting to run a mod, it is because your database code is not correct. It either has syntax errors or is missing needed data in one or more tables. The very first thing to do is to look in file Database.log to see what errors are being reported.

You have to fix database issues 1st before you can do anything else. Whether or not the game will implement a Great Person Area of Effect effect for a Building or a District is an entirely different issue to not having problems in your database code. You can have a 100% perfect set of database code and the game may still not implement a desired effect simply because the designers at Firaxis never coded the game's executing DLL to apply a given effect-type for a Building.

Thanks for taking the time to help. Really appreciate it - I had no idea I’d made such a hash of it!
 
Back
Top Bottom