Doing this will I think violate the uniqueness requirements and would thus be rejected:
Code:
<UnitCaptures>
<Row CapturedUnitType="UNIT_SETTLER" BecomesUnitType="UNIT_BUILDER"/>
</UnitCaptures>
The game already has a designation within the table of what to do for "UNIT_SETTLER" when it is captured and cannot have a second row in the table telling it to do something else with the same UnitType. You would need to do as
Code:
<UnitCaptures>
<Update>
<Where CapturedUnitType="UNIT_SETTLER" />
<Set BecomesUnitType="UNIT_BUILDER"/>
</Update>
</UnitCaptures>
But this would still not get you what you are after since it would apply to all players.
------------------------------------
Try the following lua script. You need to place it into an lua file and the lua file needs to be activated as a GamePlayScript under the "In-Game Actions" tab in modbuddy, or under <Components>/<InGameActions> if you create your mods manually:
Code:
local sRequiredCivilization = "CIVILIZATION_ROME"
local iSettler = GameInfo.Units["UNIT_SETTLER"].Index
local iBuilder = GameInfo.Units["UNIT_BUILDER"].Index
function OnSettlerCaptured(iOwner, iUnitId, iUnsure1, iUnsure2)
if (PlayerConfigurations[iOwner]:GetCivilizationTypeName() == sRequiredCivilization) then
local pPlayer = Players[iOwner]
local pPlayerUnits = pPlayer:GetUnits()
local pUnit = pPlayerUnits:FindID(iUnitId)
if (pUnit ~= nil) and (pUnit:GetType() == iSettler) then
local iUnitX, iUnitY = pUnit:GetX(), pUnit:GetY()
pPlayerUnits:Destroy(pUnit)
pPlayerUnits:Create(iBuilder, iUnitX, iUnitY)
end
end
end
Events.UnitCaptured.Add(OnSettlerCaptured)
I'm not 100% sure what the final two arguments are for what the game engine passes to event-type "UnitCaptured", but I believe the 1st two are for the new owner's Player ID# and the unit's ID #, and the code is written accordingly.
You will have to edit "CIVILIZATION_ROME" to the correct name of the civilization you are using.
Here is what my modinfo file looks like for activating two "GamePlayScript" lua-files in a testing mod I use, just for reference on what the modinfo file ought to look like for an lua file of this sort when using modbuddy:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="808bc088-d136-4e70-a657-a3ad50756e66" version="1">
<Properties>
<Name>LUA Testing</Name>
<Description>Testing LUA codes and concepts</Description>
<Teaser>Testing LUA codes and concepts</Teaser>
<Authors>Lee</Authors>
</Properties>
<InGameActions>
<AddGameplayScripts id="Civ6LUA_Testing_File2">
<File>LUA/Civ6LUA_Testing_File2.lua</File>
</AddGameplayScripts>
<AddGameplayScripts id="Civ6LUA_Testing_Gameplay">
<File>LUA/Civ6LUA_Testing_Gameplay.lua</File>
</AddGameplayScripts>
</InGameActions>
<Files>
<File>LUA/Civ6LUA_Testing_File2.lua</File>
<File>LUA/Civ6LUA_Testing_Gameplay.lua</File>
</Files>
</Mod>