Quick Modding Questions Thread

Trying to create a Pantheon and its not working. Here is the code:
Code:
    <Types>
        <Row Type="BELIEF_SM_ORAL_TRADITION" Kind="KIND_BELIEF"/>
    </Types>
    <Beliefs>
        <Row BeliefType="BELIEF_SM_ORAL_TRADITION" Name="LOC_BELIEF_SM_ORAL_TRADITION_NAME" Description="LOC_BELIEF_SM_ORAL_TRADITION_DESCRIPTION" BeliefClassType="BELIEF_CLASS_PANTHEON"/>
    </Beliefs>
    <BeliefModifiers>
        <Row BeliefType="BELIEF_SM_ORAL_TRADITION" ModifierId="SM_ORAL_TRADITION_RICE"/>
        <Row BeliefType="BELIEF_SM_ORAL_TRADITION" ModifierId="SM_ORAL_TRADITION_WHEAT"/>
    </BeliefModifiers>
    <Modifiers>
        <Row ModifierId="SM_ORAL_TRADITION_RICE" ModifierType="MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER" SubjectRequirementSetId="PLAYER_HAS_PANTHEON_REQUIREMENTS"/>
        <Row ModifierId="SM_ORAL_TRADITION_RICE_MODIFIER" ModifierType="MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD" SubjectRequirementSetId="SM_PLOT_HAS_RICE_REQUIREMENTS"/>
        <Row ModifierId="SM_ORAL_TRADITION_WHEAT" ModifierType="MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER" SubjectRequirementSetId="PLAYER_HAS_PANTHEON_REQUIREMENTS"/>
        <Row ModifierId="SM_ORAL_TRADITION_WHEAT_MODIFIER" ModifierType="MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD" SubjectRequirementSetId="SM_PLOT_HAS_WHEAT_REQUIREMENTS"/>
    </Modifiers>
    <ModifierArguments>
        <Row ModifierId="SM_ORAL_TRADITION_RICE" Name="ModifierId" Value="SM_ORAL_TRADITION_RICE_MODIFIER"/>
        <Row ModifierId="SM_ORAL_TRADITION_WHEAT" Name="ModifierId" Value="SM_ORAL_TRADITION_WHEAT_MODIFIER"/>
        <Row ModifierId="SM_ORAL_TRADITION_RICE_MODIFIER" Name="YieldType" Value="YIELD_SCIENCE"/>
        <Row ModifierId="SM_ORAL_TRADITION_RICE_MODIFIER" Name="Amount" Value="1"/>
        <Row ModifierId="SM_ORAL_TRADITION_WHEAT_MODIFIER" Name="YieldType" Value="YIELD_SCIENCE"/>
        <Row ModifierId="SM_ORAL_TRADITION_WHEAT_MODIFIER" Name="Amount" Value="1"/>
    </ModifierArguments>
    <RequirementSets>
        <Row RequirementSetId="SM_PLOT_HAS_RICE_REQUIREMENTS" RequirementSetType="REQUIREMENTSET_TEST_ANY"/>
        <Row RequirementSetId="SM_PLOT_HAS_WHEAT_REQUIREMENTS" RequirementSetType="REQUIREMENTSET_TEST_ANY"/>
    </RequirementSets>
    <RequirementSetRequirements>
        <Row RequirementSetId="SM_PLOT_HAS_RICE_REQUIREMENTS" RequirementId="SM_REQUIRES_PLOT_HAS_RICE"/>
        <Row RequirementSetId="SM_PLOT_HAS_WHEAT_REQUIREMENTS" RequirementId="SM_REQUIRES_PLOT_HAS_WHEAT"/>
    </RequirementSetRequirements>
    <Requirements>
        <Row RequirementId="SM_REQUIRES_PLOT_HAS_RICE" RequirementType="REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES"/>
        <Row RequirementId="SM_REQUIRES_PLOT_HAS_WHEAT" RequirementType="REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES"/>
    </Requirements>
    <RequirementArguments>
        <Row RequirementId="SM_REQUIRES_PLOT_HAS_RICE" Name="ResourceType" Value="RESOURCE_RICE"/>
        <Row RequirementId="SM_REQUIRES_PLOT_HAS_WHEAT" Name="ResourceType" Value="RESOURCE_WHEAT"/>
    </RequirementArguments>
The Pantheon shows up and is selectable but the Science bonus isn't being applied.
What am I doing wrong?

EDIT: I have the text and icons working also (just in case that's applicable)
 
Last edited:
Trying to create a Pantheon and its not working.
I'm guessing that it's because the modifier you're using only applies to a specific city but the modifier is attached to all players. I.e. different levels.

So you could try to replace:
Code:
MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD
With:
Code:
MODIFIER_PLAYER_ADJUST_PLOT_YIELD
Otherwise you could try and attach the initial modifier to all cities instead of all players. Meaning that you could try and replace:
Code:
MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER
With:
Code:
MODIFIER_ALL_CITIES_ATTACH_MODIFIER
 
Last edited:
Hello, I was wondering if there was any way to get human players civilizations and leaders in a SQL game play script? Looking through the schema there does not seem to be anything, but am I missing something?
 
Hello, I was wondering if there was any way to get human players civilizations and leaders in a SQL game play script? Looking through the schema there does not seem to be anything, but am I missing something?
What are you trying to do?
 
What are you trying to do?
Code:
 SELECT TraitType FROM CivilizationTraits WHERE TraitType != 'TRAIT_CIVILIZATION_FOUNDING_FATHERS'

Currently hardcoding a TraitType into a select query, would like to select the traits of human players only into the where clause.
 
Sorry, I still don't understand, what do you want to do in game (or on the setup screen) ?
 
Is it possible to create a resource which requires other resources and/or buildings?
 
Problems with faulty mod coding (?Maybe) .
This mod once used to work fine. but now I can't upgrade ANY units despite that previous versions of my mod works fine on unit upgradings.
(My mod is Vanilla mod)

This time i've made it step by step. adding new units one era and test (and fix) and then add the next. previous versions works fine. but this time there's problems upgrading units as upgrade button doesn't show up AT ALL
Error1.jpg
 

Attachments

Last edited:
So, I would basically like to use the city models from the Industrial era in the Modern era instead of them going to skyscrapers right away at that time. Would it suffice to change the relevant bits within Cities.artdef or would something like this require editing a lot more files?
 
Trying to set up a civ with a UB that provides diplomatic favor per turn equal to the adjacency bonus of the district the UB is part of (Campus, in this case). As near as I can tell, though, Diplomatic Favor isn't a yield (so setting YieldType="YIELD_FAVOR" won't do it for me; I've been struggling to find whatever the internal value for Favor is and failing); on top of that, I'm not sure how to go about setting the building to give Favor per turn = district adjacency bonus since that isn't a fixed value. Any ideas?
 
Anyone know where the fallout mechanic is coded? I'm trying to make a polar themed mod where ice and snow deal environmental damage (similar to the fallout mechanic), thought I would start by looking at how fallout works but I cant find it...
 
In Lua, how do I get the current loyalty value (between 0 - 100) of a city? I am making my first Lua mod (already done some SQL/XML mods) I was searching the "Lua Objects" tab of this reference and the only function that mentions loyalty is "ChangeLoyalty".

Is GetCulturalIdentity() the function to use? Basically I am thinking of attaching my code to the "CityLoyaltyChanged" event and if loyalty is above/below a certain amount then the rest of my code is triggered.
 
Code:
	local pCulturalIdentity = pCity:GetCulturalIdentity();
	local currentLoyalty = pCulturalIdentity:GetLoyalty();
	local maxLoyalty = pCulturalIdentity:GetMaxLoyalty();
	local loyaltyLevel = pCulturalIdentity:GetLoyaltyLevel();
	local loyaltyLevelName = GameInfo.LoyaltyLevels[loyaltyLevel].Name;
	local loyaltyPerTurn:number = pCulturalIdentity:GetLoyaltyPerTurn();
From a quick skim of one of the game's lua User Interface files. So far as we know at the moment City:GetCulturalIdentity() is only valid in a User Interface context, so you cannot use it in a GameplayScript.

The City:ChangeLoyalty(iChgangeAmount) method is indeed what would be needed to alter a city's current Loyalty value. Firaxis uses this in the Black Death Scenario. But it can only be used in a GamePlayScript.
 
Hello, I was wondering if there was any way to get human players civilizations and leaders in a SQL game play script? Looking through the schema there does not seem to be anything, but am I missing something?
Sorry for the delay in responding. This is simply not possible. SQL cannot "read" which civs or leaders are being used as human players. The database is not dynamic to what is chosen in the game setup screens in this way.

Modifiers can be created (via a requirement) that require a given player be a human or an AI in order for the modifier to be implemented, but in this case the code within the SQL does not alter in any way based on whether Trajan for example is being used as a human or an AI or not at all. The game's controlling software looks to see if the player is being used as a player and as a human and implements the required instructions from within the SQL database when this is the case, and does not do so when this is not the case. But the data in the SQL database does not change in any way based on whether or not the player is in the game, not in the game, is a human, or is an AI.

Lua GameplayScripts can "read" who (leader or civ) is playing as a human, but SQL cannot. And what lua can do with this information is another issue entirely.
 
  • Like
Reactions: cvb
Is it possible to have a tree logic of AND and OR in requirements? I think not because I only saw TEST_ALL (AND for all requirements) or TEST_ANY (OR for all requirements) but maybe I missed something.
The use would be for a modifier to be applied if the district is a holy site or a lavra and if the district is adjacent to a pasture. That way I wouldn't have to have a modifier for the holy site and a different one for the lavra.
 
From a quick skim of one of the game's lua User Interface files. So far as we know at the moment City:GetCulturalIdentity() is only valid in a User Interface context, so you cannot use it in a GameplayScript.

The City:ChangeLoyalty(iChgangeAmount) method is indeed what would be needed to alter a city's current Loyalty value. Firaxis uses this in the Black Death Scenario. But it can only be used in a GamePlayScript.

Thanks for the reply LeeS and for your modding guide which I was reading a few days ago to learn how Lua modding works! I have seen mentioned that data can be sent between the UI and GamePlayScript contexts. In this case, is that the sort of thing I should look into?

Let me describe my end goal and if anyone knows a better way to go about it I would appreciate being pointed in the right direction. My end goal is to change the maximum loyalty for cities under certain conditions. For example, if you are not the original owner of a city then loyalty might max out at 85% instead of 100% no matter how much loyalty the city is gaining per turn. Since there does not seem to be any way to change the maximum loyalty directly, what I was thinking of doing was adding code triggered by the CityLoyaltyChanged event that would decrement the loyalty back down to my maximum any time the city loyalty changes. This is why I figured I need to be able to check what the current loyalty is so I can check if it has exceeded the new maximum loyalty and how much to subtract to set it back to the maximum.
 
Is it possible to have a tree logic of AND and OR in requirements? I think not because I only saw TEST_ALL (AND for all requirements) or TEST_ANY (OR for all requirements) but maybe I missed something.
The use would be for a modifier to be applied if the district is a holy site or a lavra and if the district is adjacent to a pasture. That way I wouldn't have to have a modifier for the holy site and a different one for the lavra.
You can string differing Requirement "logics" together. A RequirementType for a RequirementId can be REQUIREMENT_REQUIREMENTSET_IS_MET. The RequirementArguments table then specifies the name of the second RequirementSetId whose conditions have to be met. This second RequirementSetId can have a different "TEST" method than the original RequirementSetId.

Code:
	<RequirementSets>
		<Row>
			<RequirementSetId>UNIT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
			<RequirementSetType>REQUIREMENTSET_TEST_ANY</RequirementSetType>
		</Row>
	</RequirementSets>
	<RequirementSetRequirements>
		<Row>
			<RequirementSetId>UNIT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
			<RequirementId>UNIT_IS_LIGHT_CAVALRY</RequirementId>
		</Row>
		<Row>
			<RequirementSetId>UNIT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
			<RequirementId>UNIT_IS_HEAVY_CAVALRY</RequirementId>
		</Row>
	</RequirementSetRequirements>
	<Requirements>
		<Row>
			<RequirementId>REQUIREMENTS_MET_UNIT_IS_CAVALRY_REQUIREMENTS</RequirementId>
			<RequirementType>REQUIREMENT_REQUIREMENTSET_IS_MET</RequirementType>
		</Row>
	</Requirements>
	<RequirementArguments>
		<Row>
			<RequirementId>REQUIREMENTS_MET_UNIT_IS_CAVALRY_REQUIREMENTS</RequirementId>
			<Name>RequirementSetId</Name>
			<Value>UNIT_IS_CAVALRY_REQUIREMENTS</Value>
		</Row>
	</RequirementArguments>

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

Code:
<RequirementId>REQUIREMENTS_MET_UNIT_IS_CAVALRY_REQUIREMENTS</RequirementId>
Would be a RequirementId within a "higher-level" (ie, first) RequirementSetId. The specific example of how to specify another RequirementSetId is from Vanilla and I think may have been superceded by other code in one of the patches, but the basic notion on how to string different "TEST" types together to obtain This AND (That OR Those) is still valid regardless.
 
  • Like
Reactions: cvb
xnsy6cp2px941.png

I have a question about custom civ leaders. I'm working on a 3D model for my own leader. It's my first attempt at both 3D sculpting and game modding. I'm learning as i go so i have no idea how importing 3D models and setting up civilization looks like. Mostly because i thought i might check if im able to model a leader that is at least bearable to look at. Now i want to progress further and have couple of questions.
  1. If i create a whole model in blender with textures, animations etc. can i then import it into CIV and all my textures etc. would be same as i arranged them in blender?
  2. I want to create idle standing animation since it's my first civ but i'm wondering: are leaders a one animated object? Or maybe some of their props are different models, separate from each other? My leader is going to hold a glass of wine, should i do this as a separate model?
  3. Is hair something i should model also in blender?
I hope it's the correct thread to post this!
 
Modifiers can be created (via a requirement) that require a given player be a human or an AI in order for the modifier to be implemented [...]
You can string differing Requirement "logics" together. [...] to obtain This AND (That OR Those) is still valid regardless.
Thank you for this info and the impetus!

I have created (copy&paste) my first SQL modification and would like to ask whether there are obvious mistakes contained:
Spoiler :

INSERT INTO TraitModifiers (TraitType, ModifierId) VALUES
('TRAIT_LEADER_MAJOR_CIV', 'IMPROVEMENT_MINE_MODIFIER_JJ');

INSERT INTO Modifiers (ModifierId, ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId) VALUES
('IMPROVEMENT_MINE_MODIFIER_JJ', 'MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 0, 1, 'PLAYER_IS_HUMAN', 'QUALIFIED_REQUIREMENTS_JJ');

INSERT INTO ModifierArguments (ModifierId, Name, Type, Value, Extra, SecondExtra) VALUES
('IMPROVEMENT_MINE_MODIFIER_JJ', 'Amount', 'YIELD_FOOD', '-1', NULL, NULL);


INSERT INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('QUALIFIED_REQUIREMENTS_JJ', 'REQUIREMENTSET_TEST_ANY');

INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('QUALIFIED_REQUIREMENTS_JJ', 'REQUIRES_IMPROVEMENT_MINE_JJ');


INSERT INTO Requirements (RequirementId, RequirementType) VALUES
('REQUIRES_IMPROVEMENT_MINE_JJ', 'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES');

INSERT INTO RequirementArguments (RequirementId, Name, Type, Value, Extra, SecondExtra) VALUES
('REQUIRES_IMPROVEMENT_MINE_JJ', 'UnitType', 'ARGTYPE_IDENTITY', 'IMPROVEMENT_MINE', NULL, NULL);

It reduces the Food yield of mined plots by 1 for the (single) human player.

The purpose are more interesting decisions / better balance between hills & flat land, mines & farms and chopping vs. lumber mills as well as somewhat increased difficulty while the AI isn't disturbed.

.
 
Back
Top Bottom