Events.SerialEventHexCultureChanged.Add( CheckCultureChange )
Dprint("- Each U.K. unit on french territory get 50% chance to go back to London (or die trying)", bDebug)
for unit in pEngland:Units() do
if unit:GetPlot():GetOwner() == iFrance then
if math.random( 1, 100 ) > 50 or unit:GetDomainType() == DomainTypes.DOMAIN_SEA then
Dprint(" Killed : " .. unit:GetName(), bDebug)
unit:Kill(false, -1)
else
Dprint(" Escape : " .. unit:GetName(), bDebug)
CleanOrdersRED (unit)
unit:SetXY(iEnglandCityX, iEnglandCityY)
end
end
end
Dprint("- Each U.K. unit on french territory get 50% chance to go back to London (or die trying)", bDebug)
for unit in pEngland:Units() do
if unit:GetPlot():GetOwner() == iFrance then
Dprint(" Killed : " .. unit:GetName(), bDebug)
unit:Kill(false, -1)
end
end
for unit in pFrance:Units() do
--local newUnit = ChangeUnitOwner (unit, iVichy)
if (unit:GetUnitType() == CONVOY or unit:GetUnitType() == FORTIFIED_GUN) then
Dprint(" - Killing " .. unit:GetName(), bDebug)
unit:Kill(false, -1)
elseif not unit:IsDead() then
if unit:GetDomainType() == DomainTypes.DOMAIN_AIR then
table.insert(Air, { Unit = unit, XP = unit:GetExperience() })
elseif unit:GetDomainType() == DomainTypes.DOMAIN_SEA then
table.insert(Sea, { Unit = unit, XP = unit:GetExperience() })
else
table.insert(Land, { Unit = unit, XP = unit:GetExperience() })
end
end
end
for unit in pFrance:Units() do
Dprint(" - Killing " .. unit:GetName(), bDebug)
unit:Kill(false, -1)
end
Nop, the file is not loaded at all there, there is one "end" missing somewhere, check if you've not removed too many lines (the indentation should help you)There was no crash. But whatever you had us remove, I'm guessing that just made it so the event wouldn't fire? Because after that nothing happened. I assigned a bit of production after capturing the city, but then left.
I'm afraid I'll have to stop Testing now, however I have one small question for Gedemon:
How would I go about changing the unit supply limit in the lua files (for each civ)
TIA
Dprint("- Change french cities ownership ...", bDebug)
for city in pFrance:Cities() do -- todo : handle french owned cities in colonies
local plot = city:Plot()
local plotKey = GetPlotKey ( plot )
local originalOwner = GetPlotFirstOwner(plotKey)
if originalOwner ~= iFrance then -- liberate cities captured by France
Dprint(" - liberate city captured by France: " .. city:GetName(), bDebug )
local originalPlayer = Players[originalOwner]
EscapeUnitsFromPlot(plot)
coroutine.yield()
originalPlayer:AcquireCity(city, false, true)
--city:SetOccupied(false) -- needed in this case ?
coroutine.yield()
else
local x, y = city:GetX(), city:GetY()
if ((x < 24 and y > 32) or (y > 42 and x < 33)) then -- occupied territory
Dprint(" - " .. city:GetName() .. " in occupied territory at (".. x ..",".. y ..")", bDebug)
if city:GetOwner() ~= newPlayerID then
EscapeUnitsFromPlot(plot)
coroutine.yield()
pAxis:AcquireCity(city, false, true)
coroutine.yield()
city:SetPuppet(false)
city:ChangeResistanceTurns(-city:GetResistanceTurns())
else -- just remove resistance if city was already occupied
city:ChangeResistanceTurns(-city:GetResistanceTurns())
end
elseif (y > 32 and x < 32) then -- Vichy territory
Dprint(" - " .. city:GetName() .. " in Vichy territory at (".. x ..",".. y ..")", bDebug)
EscapeUnitsFromPlot(plot)
coroutine.yield()
pVichy:AcquireCity(city, false, true)
coroutine.yield()
--city:SetOccupied(false)
city:SetPuppet(false)
city:SetNumRealBuilding(COURTHOUSE, 1) -- above won't work, try workaround...
city:ChangeResistanceTurns(-city:GetResistanceTurns())
elseif (y > 26 and x > 32 and y < 35 and x < 34) then -- Nice, Ajaccio to Italy
Dprint(" - " .. city:GetName() .. " in Italy occupied territory at (".. x ..",".. y ..")", bDebug)
if city:GetOwner() ~= iItaly then
EscapeUnitsFromPlot(plot)
coroutine.yield()
pItaly:AcquireCity(city, false, true)
coroutine.yield()
city:SetPuppet(false)
city:ChangeResistanceTurns(-city:GetResistanceTurns())
end
elseif (y > 44 and x > 32 and y < 47 and x < 37) then -- Metz, Strasbourg to Germany
Dprint(" - " .. city:GetName() .. " in Germany occupied territory at (".. x ..",".. y ..")", bDebug)
if city:GetOwner() ~= iGermany then
EscapeUnitsFromPlot(plot)
coroutine.yield()
pGermany:AcquireCity(city, false, true)
coroutine.yield()
city:SetPuppet(false)
city:ChangeResistanceTurns(-city:GetResistanceTurns())
end
end
end
end
Dprint("Finalizing Fall of France ...", bDebug)
-- remove resistance from Paris
pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())
-- french may try to restart...
if Game.GetActivePlayer() ~= iFrance then
Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
end
pFrance:SetGold(pFrance:GetGold() + 5000)
--savedData.SetValue("FranceHasFallen", 1) -- at the begining of the script to prevent duplicate call now that we use coroutine
Dprint("Fall of France event completed...", bDebug)
--pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())
if Game.GetActivePlayer() ~= iFrance then
Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
end
pFrance:SetGold(pFrance:GetGold() + 5000)
okay, so it could be in those lines if it's not a delayed crash :
Code:Dprint("Finalizing Fall of France ...", bDebug) -- remove resistance from Paris pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns()) -- french may try to restart... if Game.GetActivePlayer() ~= iFrance then Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1) end pFrance:SetGold(pFrance:GetGold() + 5000) --savedData.SetValue("FranceHasFallen", 1) -- at the begining of the script to prevent duplicate call now that we use coroutine Dprint("Fall of France event completed...", bDebug)
3 things to try:
1/ remove
Code:--pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())
2/ remove
Code:if Game.GetActivePlayer() ~= iFrance then Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1) end
3/ remove
Code:pFrance:SetGold(pFrance:GetGold() + 5000)
let's hope it's one of those...
On the first one, did you want me to REMOVE the line, or simply type the two dashes infront of it?
--[[
--]]