Advanced Pillaging

Atlas627

Deity
Joined
Aug 25, 2011
Messages
2,930
I am trying to make Recon units cost only 1 to Pillage, similar to how the Barbary Corsair only costs 1 to Coastal Raid. The code is already all in the files to enable "Advanced Pillaging", and it looks identical to the implementation of "Advanced Raiding", which is what the Corsair uses. However, when I implement it, nothing happens!

Does anyone know what unit in Vanilla uses Advanced Pillaging, so that I can find it as a reference and make sure Firaxis' code works in the first place? I have some doubts that their code was fully implemented, as this has happened with other modifiers of theirs I have tried to use in the past.

I'll try and copy all 3 codes below (Vanilla Advanced Pillaging, Vanilla Advanced Raiding, and my Advanced Pillaging) if anyone wants to take a look.

Vanilla Advanced Pillaging (I see no unit nor trait that actually gains this ability anywhere)
Code:
In UnitAbilities.xml of Base game:

<Modifiers>
<Row>
            <ModifierId>UNIT_REDUCED_PILLAGE_COST</ModifierId>
            <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_ADVANCED_PILLAGING</ModifierType>
        </Row>
</Modifiers>

<ModifierArguments>
<Row>
            <ModifierId>UNIT_REDUCED_PILLAGE_COST</ModifierId>
            <Name>UseAdvancedPillaging</Name>
            <Value>true</Value>
        </Row>
</ModifierArguments>

Vanilla Advanced Raiding (including the Corsair gaining this ability)
Code:
In Expansion2_UnitAbilities_Major of DLC2:
<Types>
<Row Type="ABILITY_CORSAIR" Kind="KIND_ABILITY"/>
</Types>
<TypeTags>
<Row Type="ABILITY_CORSAIR" Tag="CLASS_CORSAIR"/>
</TypeTags>
<UnitAbilities>
<Row UnitAbilityType="ABILITY_CORSAIR" Name="LOC_ABILITY_CORSAIR_NAME" Description="LOC_ABILITY_CORSAIR_DESCRIPTION"/>
</UnitAbilities>

<UnitAbilityModifiers>
<Row>
            <UnitAbilityType>ABILITY_CORSAIR</UnitAbilityType>
            <ModifierId>CORSAIR_LESS_MOVEMENT_RAID</ModifierId>
        </Row>
</UnitAbilityModifiers>
<Modifiers>
<Row>
            <ModifierId>CORSAIR_LESS_MOVEMENT_RAID</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_ADVANCED_COASTAL_RAID</ModifierType>
        </Row>
</Modifiers>
<ModifierArguments>
<Row>
            <ModifierId>CORSAIR_LESS_MOVEMENT_RAID</ModifierId>
            <Name>UseAdvancedCoastalRaid</Name>
            <Value>true</Value>
        </Row>
</ModifierArguments>

My Advanced Pillaging
Code:
<UnitAbilities>
        <Row UnitAbilityType="AtlasBuilds_Ability_Recon_Quick_Pillaging" Inactive="true" Name="Raider" Description="Pillaging costs only 1 [ICON_Movement] Movement point."/>
    </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>AtlasBuilds_Ability_Recon_Quick_Pillaging</UnitAbilityType>
            <ModifierId>AtlasBuilds_Recon_Quick_Pillaging</ModifierId>
        </Row>
    </UnitAbilityModifiers>
    <Modifiers>
        <Row>
            <ModifierId>AtlasBuilds_Recon_Quick_Pillaging</ModifierId>
            <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_ADVANCED_PILLAGING</ModifierType>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>AtlasBuilds_Recon_Quick_Pillaging</ModifierId>
            <Name>UseAdvancedPillaging</Name>
            <Value>true</Value>
        </Row>
    </ModifierArguments>
    <Types>
        <Row Type="AtlasBuilds_Ability_Recon_Quick_Pillaging" Kind="KIND_ABILITY"/>
    </Types>
    <Tags>
        <Row Tag="AtlasBuilds_Class_Recon_Pillager" Vocabulary="ABILITY_CLASS"/>
    </Tags>
    <TypeTags>
        <Row Type="UNIT_SPEC_OPS" Tag="AtlasBuilds_Class_Recon_Pillager"/>
        <Row Type="UNIT_SKIRMISHER" Tag="AtlasBuilds_Class_Recon_Pillager"/>
        <Row Type="UNIT_INCA_WARAKAQ" Tag="AtlasBuilds_Class_Recon_Pillager"/>
        <Row Type="UNIT_RANGER" Tag="AtlasBuilds_Class_Recon_Pillager"/>
        <Row Type="UNIT_SCOTTISH_HIGHLANDER" Tag="AtlasBuilds_Class_Recon_Pillager"/>
        <Row Type="AtlasBuilds_Ability_Recon_Quick_Pillaging" Tag="AtlasBuilds_Class_Recon_Pillager"/>
    </TypeTags>
 
The ModifierType and its EffectType seem valid in table DynamicModifiers
Code:
ModifierType					CollectionType		EffectType
MODIFIER_PLAYER_UNIT_ADJUST_ADVANCED_PILLAGING	COLLECTION_OWNER		EFFECT_ADJUST_UNIT_ADVANCED_PILLAGING
But the ModifierId is never used in table UnitAbilityModifiers so it is possible that even though it all shows in the Database it is not actually enacted in the game's DLL code.

But the thing that stands out to me is that you have the Ability set as Inactive="true". Boolean true for the "Inactive" column is only used when the UnitAbility is not to be applied by default, but rather is only applied as an effect of a Belief, a Civ or Leader Unique Ability, a Policy Card effect, a World Wonder effect, a Great Person effect, etc.
 
The ModifierType and its EffectType seem valid in table DynamicModifiers
Code:
ModifierType                    CollectionType        EffectType
MODIFIER_PLAYER_UNIT_ADJUST_ADVANCED_PILLAGING    COLLECTION_OWNER        EFFECT_ADJUST_UNIT_ADVANCED_PILLAGING
But the ModifierId is never used in table UnitAbilityModifiers so it is possible that even though it all shows in the Database it is not actually enacted in the game's DLL code.

But the thing that stands out to me is that you have the Ability set as Inactive="true". Boolean true for the "Inactive" column is only used when the UnitAbility is not to be applied by default, but rather is only applied as an effect of a Belief, a Civ or Leader Unique Ability, a Policy Card effect, a World Wonder effect, a Great Person effect, etc.

You are the most helpful person on these boards, I swear. That makes a lot of sense, and was something I just included because every Firaxis example I saw had it, but I never saw one that set it to False! Of course, it must be false by default. I'll give this a try and see if it works, thanks!
 
@LeeS Ok this is quite outdated at this point, but this is a very similar problem so this seems the appropriate place to post it, and you figured out the solution that time so I'm tagging you though anyone else is free to answer and I won't expect anything.


I'm trying to give Gorgo the ability to give all land units produced in the Capital will forevermore generate Great Writer points when they kill something. If I get rid of "Inactive=true", then the ability applies to all land units even though I don't want that to happen! But for some reason when I have Inactive=true, none of the units ever get the ability, or even the modifier.

Here's what I've got in XML:

Code:
<!-- Gorgo -->
    <TraitModifiers>
        <Row TraitType="CULTURE_KILLS_TRAIT" ModifierId="AtlasUniques_Gorgo_Capital_Built_Writer_Kills"/>
        <Row TraitType="CULTURE_KILLS_TRAIT" ModifierId="AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier"/>
    </TraitModifiers>
    <Modifiers>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Capital_Trained_Unit_Ability</ModifierType>
            <Permanent>true</Permanent>
        </Row>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Player_Units_GPP_On_Kill</ModifierType>
            <SubjectRequirementSetId>AtlasUniques_Unit_has_Epic_Deeds_Ability</SubjectRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills</ModifierId>
            <Name>AbilityType</Name>
            <Value>AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill</Value>
        </Row>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
            <Name>Amount</Name>
            <Value>5</Value>
        </Row>
    </ModifierArguments>


    <Types>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_RECON"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_MELEE"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_RANGED"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_SIEGE"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_HEAVY_CAVALRY"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_LIGHT_CAVALRY"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_RANGED_CAVALRY"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_ANTI_CAVALRY"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_HEAVY_CHARIOT"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_LIGHT_CHARIOT"/>
        <Row Type="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Tag="CLASS_WARRIOR_MONK"/>
    </TypeTags>
    <UnitAbilities>
        <Row UnitAbilityType="AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill" Name="Epic Deeds" Description="+5 [ICON_GreatWriter] Great Writer points when defeating a unit." Inactive="true"/>
    </UnitAbilities>
    <!--<UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>AtlasUniques_Ability_Gorgo_Writer_Points_On_Kill</UnitAbilityType>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
        </Row>
    </UnitAbilityModifiers>-->
 
Code:
   <Modifiers>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Capital_Trained_Unit_Ability</ModifierType>
            <Permanent>true</Permanent>
        </Row>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Player_Units_GPP_On_Kill</ModifierType>
            <SubjectRequirementSetId>AtlasUniques_Unit_has_Epic_Deeds_Ability</SubjectRequirementSetId>
        </Row>
    </Modifiers>
Unless you have defined these new ModifierTypes in table DynamicModifiers, they don't exist as valid data for ModifierType.

Beyond that however, you would need to attach the modifier as part of a CITY_TRAINED_UNITS collection and you would need to attach the original modifier to the player's capital city or to all the player's cities with a requirement that the modifier can only take effect in the capital city.

Essentially what you are doing is mimic-ing the way modifiers from Barracks and the like are attached to units created in the city, so I would think you would need to use that sort of approach for attaching the modifier to the units.
 
Something like this ought to work
Code:
	<Types>
		<Row Type="MODIFIER_GRANT_ABILITY_SINGLE_CITY_UNITS_LRS" Kind="KIND_MODIFIER"/>
	</Types>
	<DynamicModifiers>
		<Row ModifierType="MODIFIER_GRANT_ABILITY_SINGLE_CITY_UNITS_LRS" CollectionType="COLLECTION_CITY_TRAINED_UNITS" EffectType="EFFECT_GRANT_ABILITY" />
	</DynamicModifiers>
	<TypeTags>
		<Row Type="ABILITY_ALPINE_ACADEMY" Tag="CLASS_MELEE"/>
		<Row Type="ABILITY_ALPINE_ACADEMY" Tag="CLASS_RANGED"/>
		<Row Type="ABILITY_ALPINE_ACADEMY" Tag="CLASS_ANTI_CAVALRY"/>
	</TypeTags>
	<UnitAbilities>
		<Row UnitAbilityType="ABILITY_ALPINE_ACADEMY" Name="LOC_ABILITY_ALTITUDE_TRAINING_NAME" Description="LOC_ABILITY_ALTITUDE_TRAINING_DESCRIPTION" Inactive="true"/>
	</UnitAbilities>
	<UnitAbilityModifiers>
		<Row>
			<UnitAbilityType>ABILITY_ALPINE_ACADEMY</UnitAbilityType>
			<ModifierId>ALTITUDE_TRAINING_IGNORE_HILLS</ModifierId>
		</Row>
	</UnitAbilityModifiers>
	<Modifiers>
		<Row ModifierId="NATIONAL_ALPINE_ACADEMY_LRS_GRANT_ALPINE_LRS" ModifierType="MODIFIER_GRANT_ABILITY_SINGLE_CITY_UNITS_LRS" Permanent="true" />
	</Modifiers>
	<ModifierArguments>
		<Row ModifierId="NATIONAL_ALPINE_ACADEMY_LRS_GRANT_ALPINE_LRS" Name="AbilityType" Value="ABILITY_ALPINE_ACADEMY" />
	</ModifierArguments>
In the code snippet above you'd need to get the example ModifierId NATIONAL_ALPINE_ACADEMY_LRS_GRANT_ALPINE_LRS attached to the player's capital or else attached to all the player's cities but with a requirementset that only enacts the modifier for the player's capital.

The game already has a built-in effect for attaching a modifier to all of a player's cities but I don't remember the ModifierType used offhand.
 
Code:
ModifierType	CollectionType	EffectType
MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER	COLLECTION_PLAYER_CITIES	EFFECT_ATTACH_MODIFIER

There is also a COLLECTION_PLAYER_CAPITAL_CITY as well as a REQUIREMENT_CITY_IS_ORIGINAL_CAPITAL (which is not actually as useful as one might think), but also a REQUIREMENT_CITY_HAS_BUILDING which could be paired with BUILDING_PALACE when using the MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER ModifierType.
 
Code:
   <Modifiers>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Capital_Trained_Unit_Ability</ModifierType>
            <Permanent>true</Permanent>
        </Row>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Player_Units_GPP_On_Kill</ModifierType>
            <SubjectRequirementSetId>AtlasUniques_Unit_has_Epic_Deeds_Ability</SubjectRequirementSetId>
        </Row>
    </Modifiers>
Unless you have defined these new ModifierTypes in table DynamicModifiers, they don't exist as valid data for ModifierType.

Beyond that however, you would need to attach the modifier as part of a CITY_TRAINED_UNITS collection and you would need to attach the original modifier to the player's capital city or to all the player's cities with a requirement that the modifier can only take effect in the capital city.

Essentially what you are doing is mimic-ing the way modifiers from Barracks and the like are attached to units created in the city, so I would think you would need to use that sort of approach for attaching the modifier to the units.

Yes, I already defined those Modifier Types elsewhere. That part should be working correctly, since I copy-pasted it from a part that was working correctly before. The part that I suspect isn't working is the Ability itself, and something to do with the Inactive=true portion. If I make Inactive=false, all the units have the ability all the time. If I make it true, they never gain the ability...so I suppose I must be doing the Trained Unit Ability portion wrong...hmm.

Code:
ModifierType    CollectionType    EffectType
MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER    COLLECTION_PLAYER_CITIES    EFFECT_ATTACH_MODIFIER

There is also a COLLECTION_PLAYER_CAPITAL_CITY as well as a REQUIREMENT_CITY_IS_ORIGINAL_CAPITAL (which is not actually as useful as one might think), but also a REQUIREMENT_CITY_HAS_BUILDING which could be paired with BUILDING_PALACE when using the MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER ModifierType.

Yes, that's what I used.
 
You need to zip and post the mod. There all kind of missing stuff in your original code, and references to RequirementSets and the like which are not shown.

I know the Inactive=true method works properly, so there has to be something in your code not being done correctly, but without all of it to look at there's no method to sleuth what you have wrong or are missing.
 
Code:
   <Modifiers>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Capital_Trained_Unit_Ability</ModifierType>
            <Permanent>true</Permanent>
        </Row>
        <Row>
            <ModifierId>AtlasUniques_Gorgo_Capital_Built_Writer_Kills_Modifier</ModifierId>
            <ModifierType>AtlasUniques_Modifier_Player_Units_GPP_On_Kill</ModifierType>
            <SubjectRequirementSetId>AtlasUniques_Unit_has_Epic_Deeds_Ability</SubjectRequirementSetId>
        </Row>
    </Modifiers>
Unless you have defined these new ModifierTypes in table DynamicModifiers, they don't exist as valid data for ModifierType.

Beyond that however, you would need to attach the modifier as part of a CITY_TRAINED_UNITS collection and you would need to attach the original modifier to the player's capital city or to all the player's cities with a requirement that the modifier can only take effect in the capital city.

Essentially what you are doing is mimic-ing the way modifiers from Barracks and the like are attached to units created in the city, so I would think you would need to use that sort of approach for attaching the modifier to the units.

This is what I thought I did, but I had an idiot moment and combined the steps of "Assign to the Capital" and "The city assigns abilities to its trained units" into one big invalid step.

Yeesh, and I was so sure I did it right too. Thank you so much for making me second guess myself!
 
Top Bottom