Quick Modding Questions Thread

If you have Gaul and Byzantum Pack, yo may try to look how their buff is handled, as they recieve CS per adjacent unit. It's possible there will be somewhere where whether it's enemy or not can be changed.
 
Code:
<GameData>
	<Building_YieldChanges>
		<Update>
			<Where BuildingType="BUILDING_STABLE" YieldType="YIELD_CULTURE" />
			<Set YieldType="YIELD_PRODUCTION" />
		</Update>
	</Building_YieldChanges>
</GameData>
But you have to be careful with this sort of update to ensure you do not create rows with duplicated info. Table Building_YieldChanges for example will not allow two rows that both have BuildingType="BUILDING_STABLE" and YieldType="YIELD_PRODUCTION". I did not check whether or not the Stable building already has a row with "YIELD_CULTURE", but it does already have a row with YieldType="YIELD_PRODUCTION" so if the update were to otherwise succeed (ie, find a row in the table where the BuildingType is BUILDING_STABLE and the YieldType is YIELD_CULTURE), attempting to alter this row to use YIELD_PRODUCTION instead would cause a unique constraint error and the Update would not be accepted by the game and anything further within the same XML file would be ignored as well.

You can also do a "global" update to a table like this
Code:
<GameData>
	<Building_YieldChanges>
		<Update>
			<Where  YieldType="YIELD_CULTURE" />
			<Set YieldType="YIELD_PRODUCTION" />
		</Update>
	</Building_YieldChanges>
</GameData>
But this will certainly fail in this particular example and no changes would be made because the entire update (whether done in XML or SQL) must succeed and pass the unique constraint and all other "syntax" requirements before any part of it is implemented. And in this particular example of how global updates can be made, the game would reject the entire thing because there would almost certainly be rows in the table that already have YIELD_PRODUCTION and YIELD_CULTURE for a given building: BUILDING_PALACE for instance.

Using SQL will not get around these issues unless a more complex UPDATE is coded wherein the update first checks for Distinct rows and the like before asking the game to update a given row within the table to use new data.
 
If you have Gaul and Byzantum Pack, yo may try to look how their buff is handled, as they recieve CS per adjacent unit. It's possible there will be somewhere where whether it's enemy or not can be changed.
i don't, but I wonder if the modifer would work in updated vanilla if there is one?

Search database for VARU_NEGATIVE_COMBAT.
As I said, that modifies units adjacent to the subject unit, rather than modifying the subject unit itself when it is adjacent to other units, so wouldn't work unless I gave it to every other unit and set it to only buff a specific player's units, which I do not know how to do.


I'm also interested in knowing if there is any way to nerf enemy players. For instance, "civs at war with x civ recieve-5% science production in their cities"
 
Oathkeeper Oblivion said:
Is there a way to apply a modifier to a unit if they are adjacent to an enemy unit?

I think this should be possible, yes. You're on the right lines regarding the REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR - but we'll need to pair it with an appropriate Modifier that impacts the unit in question. I don't think there's an existing base-game ability that has the exact pair of Modifier and Requirements we want.

i don't, but I wonder if the modifer would work in updated vanilla if there is one?

As I said, that modifies units adjacent to the subject unit, rather than modifying the subject unit itself when it is adjacent to other units, so wouldn't work unless I gave it to every other unit and set it to only buff a specific player's units, which I do not know how to do.

I am going to have a proper scan later this morning - time permitting - to try and give you a fuller reply. But I would expect that the ModifierType we'll want to use may be MODIFIER_PLAYER_UNIT_ADJUST_MOVEMENT. This, along with a variation of the AOE_ENEMY_REQUIREMENTS SubjectRequirementSetId from the Gran Colombia/Maya DLC should work. Even though they are in DLCs, the RequirementType that they use is from the base-game (Vanilla), which is REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR.

Again, don't quote me on this 100% - but I am pretty sure it should be possible to configure.
 
I think this should be possible, yes. You're on the right lines regarding the REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR - but we'll need to pair it with an appropriate Modifier that impacts the unit in question. I don't think there's an existing base-game ability that has the exact pair of Modifier and Requirements we want.



I am going to have a proper scan later this morning - time permitting - to try and give you a fuller reply. But I would expect that the ModifierType we'll want to use may be MODIFIER_PLAYER_UNIT_ADJUST_MOVEMENT. This, along with a variation of the AOE_ENEMY_REQUIREMENTS SubjectRequirementSetId from the Gran Colombia/Maya DLC should work. Even though they are in DLCs, the RequirementType that they use is from the base-game (Vanilla), which is REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR.

Again, don't quote me on this 100% - but I am pretty sure it should be possible to configure.
well that's exciting. Let me know if any of it proves true, I'll be testing it myself.
Although the increased movement was actually just an example. What I'm actually trying to do is a bit more complicated. I'm currently making a civ with the ability for all of their units to heal and move in the same turn. I'm using the same ability that the Arabian Mamluk unit has to do this, however the Mamluk also heals after combat. To counteract this I'm trying to reduce the healing of a unit to 0 if it is within 2 tiles of a unit belonging to a civ at war. Which brings me to figuring out how to apply a modifier to a unit if it is near an enemy unit. Just to reiterate the problem, REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR ends up applying the modifer to the adjacent units (used for the Varu ability). It doesn't apply to a unit given it is adjacent to other units, so the decreased healing would end up going to the units adjacent to my unit, not my unit itself.
 
Code:
<GameData>
    <Building_YieldChanges>
        <Update>
            <Where BuildingType="BUILDING_STABLE" YieldType="YIELD_CULTURE" />
            <Set YieldType="YIELD_PRODUCTION" />
        </Update>
    </Building_YieldChanges>
</GameData>
But you have to be careful with this sort of update to ensure you do not create rows with duplicated info. Table Building_YieldChanges for example will not allow two rows that both have BuildingType="BUILDING_STABLE" and YieldType="YIELD_PRODUCTION". I did not check whether or not the Stable building already has a row with "YIELD_CULTURE", but it does already have a row with YieldType="YIELD_PRODUCTION" so if the update were to otherwise succeed (ie, find a row in the table where the BuildingType is BUILDING_STABLE and the YieldType is YIELD_CULTURE), attempting to alter this row to use YIELD_PRODUCTION instead would cause a unique constraint error and the Update would not be accepted by the game and anything further within the same XML file would be ignored as well.

You can also do a "global" update to a table like this
Code:
<GameData>
    <Building_YieldChanges>
        <Update>
            <Where  YieldType="YIELD_CULTURE" />
            <Set YieldType="YIELD_PRODUCTION" />
        </Update>
    </Building_YieldChanges>
</GameData>
But this will certainly fail in this particular example and no changes would be made because the entire update (whether done in XML or SQL) must succeed and pass the unique constraint and all other "syntax" requirements before any part of it is implemented. And in this particular example of how global updates can be made, the game would reject the entire thing because there would almost certainly be rows in the table that already have YIELD_PRODUCTION and YIELD_CULTURE for a given building: BUILDING_PALACE for instance.

Using SQL will not get around these issues unless a more complex UPDATE is coded wherein the update first checks for Distinct rows and the like before asking the game to update a given row within the table to use new data.
Oh, so it is supposed to work this way. I tried to do this to change one unit prereqtech to another, so that every unit unlocking on one tech would move to the other. That should not give any such non-unique row problems, and actually it didn't. It just didn't work.
 
What is your LoadOrder setting for your UpdateDatabase action? If you are running either of the expansions, and you have no LoadOrder setting or a LoadOrder of 0 (which is the same thing) Updates tend to fail because (a) there's nothing in the database as yet related to Expac code, and (b) the expacs are loading after the Updates made in the mod and are wiping the effect of the update from the Database,
 
I think this should be possible, yes. You're on the right lines regarding the REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR - but we'll need to pair it with an appropriate Modifier that impacts the unit in question. I don't think there's an existing base-game ability that has the exact pair of Modifier and Requirements we want.



I am going to have a proper scan later this morning - time permitting - to try and give you a fuller reply. But I would expect that the ModifierType we'll want to use may be MODIFIER_PLAYER_UNIT_ADJUST_MOVEMENT. This, along with a variation of the AOE_ENEMY_REQUIREMENTS SubjectRequirementSetId from the Gran Colombia/Maya DLC should work. Even though they are in DLCs, the RequirementType that they use is from the base-game (Vanilla), which is REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR.

Again, don't quote me on this 100% - but I am pretty sure it should be possible to configure.
I looked into it, and that modifier presents the same problem. The Mamluk and the Great Person José Félix Ribas both use the modifier REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR to affect enemy units adjacent to them.
What I am trying to do is affect a unit given the requirement that enemy units are are adjacent to them. I haven't found a way to establish that requirement.
 
I looked into it, and that modifier presents the same problem. The Mamluk and the Great Person José Félix Ribas both use the modifier REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR to affect enemy units adjacent to them.
What I am trying to do is affect a unit given the requirement that enemy units are are adjacent to them. I haven't found a way to establish that requirement.

I understand where you are coming from - however, I think you may be mixing up the Requirements and the Modifier functions.

The Requirement is about establishing the conditions under which the Modifier will apply (and therefore apply some game-changing effect). I am not suggesting the existing in-game Modifiers do what we want. They use the same Requirement we want, but we need to code them alongside a different Modifier in order to achieve our goal. The Requirement is just establishing when the use of the Modifier will be 'true'. The Modifier itself is responsible for affecting the entities we want - as long as we use the right one, that has the right contextual Collection/Effect, it should be fine.

Apologies - I have had a really busy week at work so haven't had a chance to look at this specifically for you. I will return to this thread and provide some sample code as soon as I have a chance to do so.
 
I understand where you are coming from - however, I think you may be mixing up the Requirements and the Modifier functions.

The Requirement is about establishing the conditions under which the Modifier will apply (and therefore apply some game-changing effect). I am not suggesting the existing in-game Modifiers do what we want. They use the same Requirement we want, but we need to code them alongside a different Modifier in order to achieve our goal. The Requirement is just establishing when the use of the Modifier will be 'true'. The Modifier itself is responsible for affecting the entities we want - as long as we use the right one, that has the right contextual Collection/Effect, it should be fine.

Apologies - I have had a really busy week at work so haven't had a chance to look at this specifically for you. I will return to this thread and provide some sample code as soon as I have a chance to do so.
I appreciate it. I've tried for an embarrassing amount of hours to get it to work at this point
 
I appreciate it. I've tried for an embarrassing amount of hours to get it to work at this point

I hear your pain. When I was trying to get my first custom civilization to work, I couldn't even put a number on the amount of time I spent trying to figure out one specific UnitAbility. I would say I comfortably iterated around 250 times before then, eventually, spotting what can only be described as a really fundamental typo.

Will try my best to put together some code for you in the next 24 hours or so.
 
Hey guys. How much effort would it take for a beginner to make a modded Sweden with combined bonuses of Norway and its leader.

Thanks
 
Hey guys. How much effort would it take for a beginner to make a modded Sweden with combined bonuses of Norway and its leader.

Thanks
Code:
INSERT INTO CivilizationTraits
        (CivilizationType,      TraitType)
VALUES  ('CIVILIZATION_SWEDEN',    'TRAIT_CIVILIZATION_EARLY_OCEAN_NAVIGATION');

INSERT INTO LeaderTraits
        (LeaderType,      TraitType)
VALUES  ('LEADER_KRISTINA',    'TRAIT_LEADER_MELEE_COASTAL_RAIDS');

Something like this should work?
 
What is your LoadOrder setting for your UpdateDatabase action? If you are running either of the expansions, and you have no LoadOrder setting or a LoadOrder of 0 (which is the same thing) Updates tend to fail because (a) there's nothing in the database as yet related to Expac code, and (b) the expacs are loading after the Updates made in the mod and are wiping the effect of the update from the Database,
Hey, the load order was 1000. I just manually moved every unit instead with individual updates, works ok as long as other people don't add other units in their mods.
 
Hello. How do I mod Lady Six Sky's leader ability to change the range of the Ix Mutal Ajaw? Thanks in advance!!!
 
Hello. How do I mod Lady Six Sky's leader ability to change the range of the Ix Mutal Ajaw? Thanks in advance!!!

The requirement is called REQUIRES_OBJECT_6_TILES_FROM_CAPITAL_NOT_CAPITAL, that's all I can say. I've not worked with these much, so I don't know details, but safest would be to try to create new requirement based on this and change MaxDistance attribute. REQUIREMENT_PLOT_NEAR_CAPITAL seems to be the base requirement from which you can create requirement with adjusted value. Then just change which requirement is attached to OBJECT_IS_6_TILES_FROM_CAPITAL_NOT_CAPITAL_REQUIREMENTS. It's confusing but there's basically two values with similar name attached like so.
 
The requirement is called REQUIRES_OBJECT_6_TILES_FROM_CAPITAL_NOT_CAPITAL, that's all I can say. I've not worked with these much, so I don't know details, but safest would be to try to create new requirement based on this and change MaxDistance attribute. REQUIREMENT_PLOT_NEAR_CAPITAL seems to be the base requirement from which you can create requirement with adjusted value. Then just change which requirement is attached to OBJECT_IS_6_TILES_FROM_CAPITAL_NOT_CAPITAL_REQUIREMENTS. It's confusing but there's basically two values with similar name attached like so.

Thanks for this. I still don't know how to do it. LOL
 
Can someone give me an overview of "LuaEvents"?

I understand how lua "Events" and "GameEvents" work, which are all listed here. And I understand how to pass operations back and forth between UI and Gameplay scripts. But I haven't found a concise explanation for what LuaEvents are and when they should be used. Nor a comprehensive list of LuaEvents comparable to Events/GameEvents.

For example, the base file for Options.lua at line 2056 it has:

Code:
Events.OptionChangeRequiresResolutionAck.Add(OnOptionChangeRequiresResolutionAck);

LuaEvents.PBCNotifyRemind_ShowOptions.Add(OnPBCNotifyRemind_ShowOptions);

A use of Events followed by LuaEvents... what's the difference?

Kind regards,
DB
 
Top Bottom