• Civilization 7 has been announced. For more info please check the forum here .

Recon and Naval Raiders ignore borders - and war?

lachumproyale

Chieftain
Joined
Apr 22, 2020
Messages
35
I'm trying to get recon and naval raider units to pass through borders. There are old mods that do this but aren't functioning. Seems like a simple ability grant, but I think there's something else to do with the type of unit we're dealing, and that they have combat abilities? Basically you can get the unit to go into enemy borders sometimes by one tile, and if you have enough moves you can pass through to the other side, but the "declare war" popup gets triggered if you try anything else. I am totally unaware of where that code is, and whether it's located in the "war" side of things or it's some tag on the units themselves. Any info would be appreciated. This is a total wall for me as I'm not sure where to start - where to even find code to start altering/inserting into.

The code - some very old code from TCS, modified by me to add recon units too:
Code:
<?xml version="1.0"?>

<GameInfo>


<Types>

<Row Kind="KIND_ABILITY" Type="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS"/>

<Row Kind="KIND_ABILITY" Type="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS"/>

</Types>


-<TypeTags>

<Row Type="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS" Tag="CLASS_NAVAL_RAIDER"/>

<Row Type="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS" Tag="CLASS_RECON"/>

</TypeTags>


<UnitAbilities>

<Row Description="Even without Open Borders, this unit can enter foreign territory." Name="Ignores Borders" UnitAbilityType="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS"/>

<Row Description="Even without Open Borders, this unit can enter foreign territory." Name="Ignores Borders" UnitAbilityType="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS"/>

</UnitAbilities>


<UnitAbilityModifiers>


<Row>

<UnitAbilityType>ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS</UnitAbilityType>

<ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>

</Row>


<Row>

<UnitAbilityType>ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS</UnitAbilityType>

<ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>

</Row>

</UnitAbilityModifiers>

</GameInfo>
 
I moved on from this as I was pretty lost with how to fix it, and I was in ARS's Improved movement mod and was digging around in one of the .lua files to see if I could find where the swapping unit tiles ability was and I came across "bWillStartWar" in Civ6Common.lua. Obviously there's a change that can be made in here to prevent a unit from triggering war but I haven't the slightest clue what it is. Searching for the stuff that I feel like I'd need to change comes up blank (UnitComponentID, CombatManager, IsAttackChangeWarState). Am I at the point where I'm hitting unmoddable stuff? This is the section of code :

Code:
function MoveUnitToPlot( kUnit:table, plotX:number, plotY:number )
    if kUnit ~= nil then
        local tParameters:table = {};
        tParameters[UnitOperationTypes.PARAM_X] = plotX;
        tParameters[UnitOperationTypes.PARAM_Y] = plotY;       
        
        -- Will this start a war?  Note, we are ignoring destinations in the for that will start a war, the unit will be allowed to move until they are adjacent.
        -- We may want to also skip the war check if the move will take more than one turn to get to the destination.
        local eAttackingPlayer:number = kUnit:GetOwner();
        local eUnitComponentID:table = kUnit:GetComponentID();
        local bWillStartWar = PlayersVisibility[eAttackingPlayer]:IsVisible(plotX, plotY) and CombatManager.IsAttackChangeWarState(eUnitComponentID, plotX, plotY);
        if (bWillStartWar) then
            local eDefendingPlayer = CombatManager.GetBestDefender(eUnitComponentID, plotX, plotY );
            if (eDefendingPlayer == nil) then
                local pPlot = Map.GetPlot(plotX, plotY);
                eDefendingPlayer = pPlot:GetOwner();
            end
            -- Create the action specific parameters
            if (eDefendingPlayer ~= nil and eDefendingPlayer ~= -1) then
                LuaEvents.Civ6Common_ConfirmWarDialog(eAttackingPlayer, eDefendingPlayer, WarTypes.SURPRISE_WAR);
            end
        else
            RequestMoveOperation(kUnit, tParameters, plotX, plotY);
        end
    end           
end
 
I'm trying to get recon and naval raider units to pass through borders. There are old mods that do this but aren't functioning. Seems like a simple ability grant, but I think there's something else to do with the type of unit we're dealing, and that they have combat abilities? Basically you can get the unit to go into enemy borders sometimes by one tile, and if you have enough moves you can pass through to the other side, but the "declare war" popup gets triggered if you try anything else. I am totally unaware of where that code is, and whether it's located in the "war" side of things or it's some tag on the units themselves. Any info would be appreciated. This is a total wall for me as I'm not sure where to start - where to even find code to start altering/inserting into.

The code - some very old code from TCS, modified by me to add recon units too:
Code:
<?xml version="1.0"?>

<GameInfo>


<Types>

<Row Kind="KIND_ABILITY" Type="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS"/>

<Row Kind="KIND_ABILITY" Type="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS"/>

</Types>


-<TypeTags>

<Row Type="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS" Tag="CLASS_NAVAL_RAIDER"/>

<Row Type="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS" Tag="CLASS_RECON"/>

</TypeTags>


<UnitAbilities>

<Row Description="Even without Open Borders, this unit can enter foreign territory." Name="Ignores Borders" UnitAbilityType="ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS"/>

<Row Description="Even without Open Borders, this unit can enter foreign territory." Name="Ignores Borders" UnitAbilityType="ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS"/>

</UnitAbilities>


<UnitAbilityModifiers>


<Row>

<UnitAbilityType>ABILITY_TCS_NAVAL_RAIDER_ENTER_FOREIGN_LANDS</UnitAbilityType>

<ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>

</Row>


<Row>

<UnitAbilityType>ABILITY_TCS_RECON_ENTER_FOREIGN_LANDS</UnitAbilityType>

<ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>

</Row>

</UnitAbilityModifiers>

</GameInfo>
Im also interested in this, also used that, what that mod do is that you can pass by but not anchor
 
I moved on from this as I was pretty lost with how to fix it, and I was in ARS's Improved movement mod and was digging around in one of the .lua files to see if I could find where the swapping unit tiles ability was and I came across "bWillStartWar" in Civ6Common.lua. Obviously there's a change that can be made in here to prevent a unit from triggering war but I haven't the slightest clue what it is. Searching for the stuff that I feel like I'd need to change comes up blank (UnitComponentID, CombatManager, IsAttackChangeWarState). Am I at the point where I'm hitting unmoddable stuff? This is the section of code :

Code:
function MoveUnitToPlot( kUnit:table, plotX:number, plotY:number )
    if kUnit ~= nil then
        local tParameters:table = {};
        tParameters[UnitOperationTypes.PARAM_X] = plotX;
        tParameters[UnitOperationTypes.PARAM_Y] = plotY;      
       
        -- Will this start a war?  Note, we are ignoring destinations in the for that will start a war, the unit will be allowed to move until they are adjacent.
        -- We may want to also skip the war check if the move will take more than one turn to get to the destination.
        local eAttackingPlayer:number = kUnit:GetOwner();
        local eUnitComponentID:table = kUnit:GetComponentID();
        local bWillStartWar = PlayersVisibility[eAttackingPlayer]:IsVisible(plotX, plotY) and CombatManager.IsAttackChangeWarState(eUnitComponentID, plotX, plotY);
        if (bWillStartWar) then
            local eDefendingPlayer = CombatManager.GetBestDefender(eUnitComponentID, plotX, plotY );
            if (eDefendingPlayer == nil) then
                local pPlot = Map.GetPlot(plotX, plotY);
                eDefendingPlayer = pPlot:GetOwner();
            end
            -- Create the action specific parameters
            if (eDefendingPlayer ~= nil and eDefendingPlayer ~= -1) then
                LuaEvents.Civ6Common_ConfirmWarDialog(eAttackingPlayer, eDefendingPlayer, WarTypes.SURPRISE_WAR);
            end
        else
            RequestMoveOperation(kUnit, tParameters, plotX, plotY);
        end
    end          
end
Never tought of this, let me analyse and come back to you
 
Im also interested in this, also used that, what that mod do is that you can pass by but not anchor
It's weird - you can always pass through, but sometimes it'll let you stay within the borders, ending the unit's movement there. In one test it seemed to be working completely, but I had changed nothing. Very bizarre. Good luck, I'll let you know if I find anything out as well.
 
Top Bottom